'use strict'; $(document).ready(() => { const auditFlow = { getAuditTypeText: function (type) { if (type === auditType.key.common) return ''; return `${auditType.info[type].long}`; }, getSimpleAuditFlow: function(groups) { const html = []; for (const group of groups) { html.push(`
  • `); html.push(``); html.push(`${group[0].name} ${group[0].role}`); html.push('${group[0].flow_name}'); html.push('
  • '); } return html.join(''); }, getStartAuditFlow: function(groups) { const html = []; for (const group of groups) { if (group[0].audit_order === 0) continue; html.push('
  • '); html.push(`
    ${group[0].audit_order}
    `); html.push('
    '); for (const auditor of group) { html.push(`
    ${auditor.name} ${auditor.role}
    `); } html.push('
    '); html.push('
    '); if (group[0].audit_type !== auditType.key.common) { html.push(`${auditType.info[group[0].audit_type].long}`); } if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) { html.push('移除'); } html.push('
    '); html.push('
  • '); } return html.join(''); }, saveAudit: function(data, callback) { postData('audit/save', data, (result) => { callback(result); }); } }; // 搜索 let timer = null; let oldSearchVal = null; $('#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 && userID !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => { html += `

    ${item.name}${item.mobile || ''}

    ${item.role || ''}
    ` }); $('.book-list').empty(); $('.book-list').append(html); } else { if (!$('.acc-btn').length) { accountGroup.forEach((group, idx) => { if (!group) return; html += `
    ${group.groupName}
    `; group.groupList.forEach(item => { if (item.id !== userID) { html += `

    ${item.name}${item.mobile || ''}

    ${item.role || ''}
    ` } }); html += '
    '; }); $('.book-list').empty(); $('.book-list').append(html); } } }, 400); }); // 展开收起角色/公司 $('body').on('click', '.book-list 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; }); // 添加审批人 $('#book-list').on('click', 'dd', function () { const id = parseInt($(this).data('id')); if (!id) return; auditFlow.saveAudit({ operate: 'add', audit_id: id }, (result) => { $('#auditors').html(auditFlow.getStartAuditFlow(result)); $('#auditors-list').html(auditFlow.getSimpleAuditFlow(result)); }); }); // 移除审批人 $('body').on('click', '#auditors li a', function () { const li = $(this).parents('li'); const data = { operate: 'del', audit_id: parseInt(li.attr('auditorId')), }; auditFlow.saveAudit(data, (result) => { $('#auditors').html(auditFlow.getStartAuditFlow(result)); }); }); $('body').on('click', '.remove-audit', function () { const id = parseInt($(this).attr('data-id')); postData('audit/save', { operate: 'del', audit_id: id }, (datas) => { $('#admin-edit-shenpi-list').html(auditFlow.getStartAuditFlow(datas)); auditFlow.getStartAuditFlow(datas); }); }); });