'use strict';
/**
*
*
* @author Mai
* @date 2019/2/27
* @version
*/
$(document).ready(function () {
let timer = null;
let oldSearchVal = null;
// 获取审核相关url
function getUrlPre () {
const path = window.location.pathname.split('/');
return _.take(path, 6).join('/');
}
$('#gr-search').bind('input propertychange', function(e) {
oldSearchVal = e.target.value;
timer && clearTimeout(timer);
timer = setTimeout(() => {
const newVal = $('#gr-search').val();
let html = '';
if (newVal && newVal === oldSearchVal) {
accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
html += `
`;
group.groupList.forEach(item => {
// if (item.id !== changesUid) {
html += `
${item.name}${item.mobile || ''}
${item.role || ''}
`;
// }
});
html += '
';
});
$('.book-list').empty();
$('.book-list').append(html);
}
}
}, 400);
});
// 添加审批流程按钮逻辑
$('.book-list').on('click', 'dt', function () {
const idx = $(this).find('.acc-btn').attr('data-groupid');
const type = $(this).find('.acc-btn').attr('data-type');
if (type === 'hide') {
$(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
$(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
$(this).find('.acc-btn').attr('data-type', 'show')
})
} else {
$(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
$(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
$(this).find('.acc-btn').attr('data-type', 'hide')
})
}
return false
});
$('#hideSp').click(function () {
$('#sub-sp2').modal('hide');
});
// 添加到审批流程中
$('dl').on('click', 'dd', function () {
const id = parseInt($(this).data('id'));
if (id) {
const auditListIdData = [];
$('#auditList li').each(function () {
const aid = $(this).data('auditid');
auditListIdData.push(aid);
});
if (!in_array(auditListIdData, id)) {
postData(getUrlPre() + '/audit/add', { auditorId: id }, (datas) => {
if (shenpi_status === shenpiConst.sp_status.gdzs) {
auditListIdData.splice(-1,0,id);
} else {
auditListIdData.push(id);
}
const html = [];
const auditorshtml = [];
auditListIdData.unshift(changesUid);
for (const [index,ids] of auditListIdData.entries()) {
const accountInfo = _.find(accountList, { 'id': ids });
if (index !== 0) {
const user = accountInfo.id + '/%/' + accountInfo.name + '/%/' + accountInfo.role + '/%/' + accountInfo.company;
html.push('