'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 += `

${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 !== 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('
  • '); if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== auditListIdData.length)) { html.push('移除'); } html.push(''); html.push(index + ' '); html.push(' '); html.push(accountInfo.name + ' '); html.push(''); html.push(accountInfo.role); html.push(''); html.push('

    ' + accountInfo.company + '

    '); html.push('
  • '); } // 添加新审批人流程修改 auditorshtml.push('
  • '); auditorshtml.push(' '); auditorshtml.push(accountInfo.name + ' ' + accountInfo.role + ''); if (index === 0) { auditorshtml.push('原报'); } else if (index+1 === auditListIdData.length) { auditorshtml.push('终审'); } else { auditorshtml.push(''+ transFormToChinese(index) +'审'); } auditorshtml.push('
  • '); } $('#auditList').html(html.join('')); $('#shenpi-audit-list').html(auditorshtml.join('')); }); } else { toastr.error('审批流程中已存在该用户!'); } } }); // 移除审批流程的审批人 $('body').on('click', '.remove_audit_btn', function () { const uid = $(this).parents('li').attr('data-auditid'); const li = $(this).parent(); const data = { auditorId: uid, }; postData(getUrlPre() + '/audit/delete', data, (result) => { li.remove(); let index = 1; $('#auditList li').each(function () { $(this).children('span').text(index); index++; }); if (index === 1) { $('#account_list').val(0); } // 重新上报时。移除审批流程 // 令最后一个图标转换 $('#shenpi-audit-list li[data-auditid="' + uid + '"]').remove(); if ($('#shenpi-audit-list li').length !== 0 && !$('#shenpi-audit-list li i').hasClass('fa-stop-circle')) { $('#shenpi-audit-list li').eq($('#shenpi-audit-list li').length-1).children('i') .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle'); } for (let i = 0; i < $('#shenpi-audit-list li').length; i++) { $('#shenpi-audit-list li').eq(i).find('.pull-right').text(i === 0 ? '原报' : (i+1 === $('#shenpi-audit-list li').length ? '终' : transFormToChinese(i)) + '审'); } $('#shenpi-audit-list li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle'); }); }); $('a[f-target]').click(function () { $($(this).attr('f-target')).modal('show'); }); // 多层modal关闭后的滚动bug修复 $('#sp-list').on('hidden.bs.modal', function (e) { $(document.body).addClass('modal-open'); }); }); // texterea换行 function auditCheck(i) { const inlineRadio1 = $('#inlineRadio1:checked').val() const inlineRadio2 = $('#inlineRadio2:checked').val() const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '
    ').replace(/\n/g, '
    ').replace(/\s/g, ' '); $('textarea[name="opinion"]').eq(i).val(opinion); if (i === 1) { if (!inlineRadio1 && !inlineRadio2) { if (!$('#warning-text').length) { $('#reject-process').prepend('

    请选择退回流程

    '); } return false; } if ($('#warning-text').length) $('#warning-text').remove() } return true; }