'use strict'; /** * * * @author Mai * @date 2019/2/27 * @version */ $(document).ready(function () { 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 && cur_uid !== 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 !== cur_uid) { 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 }); function remakeShenpiHtml(datas) { const html = []; // 如果是重新上报,添加到重新上报列表中 const auditorshtml = []; for (const [index,data] of datas.entries()) { if (index !== 0) { html.push('
  • '); if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) { html.push('移除'); } html.push(''); html.push(data.order + ' '); html.push(data.name + ' '); html.push(''); if (_.findIndex(rptAuditList, { uid: data.aid }) !== -1) { html.push(' (' + _.find(rptAuditList, { uid: data.aid }).signature_name + ')'); } html.push(''); html.push(data.role); html.push('
  • '); } // 添加新审批人流程修改 auditorshtml.push('
  • '); auditorshtml.push(' '); auditorshtml.push(data.name + ' ' + data.role + ''); if (index === 0) { auditorshtml.push('原报'); } else if (index+1 === datas.length) { auditorshtml.push('终审'); } else { auditorshtml.push(''+ transFormToChinese(index) +'审'); } auditorshtml.push('
  • '); } $('#auditors').html(html.join('')); $('#auditors-list').html(auditorshtml.join('')); } // 添加到审批流程中 $('dl').on('click', 'dd', function () { const id = parseInt($(this).data('id')); if (id) { postData('/sp/' + spid + '/payment/' + tenderId + '/detail/' + detailId + '/save', { type: 'add_audit', auditorId: id }, (datas) => { remakeShenpiHtml(datas); }); } }); // 删除审批人 $('body').on('click', '#auditors li>a', function () { const li = $(this).parent(); postData('/sp/' + spid + '/payment/' + tenderId + '/detail/' + detailId + '/save', { type: 'del_audit', auditorId: parseInt(li.attr('auditorId')) }, (result) => { li.remove(); for (const rst of result) { const aLi = $('li[auditorId=' + rst.aid + ']'); $('span', aLi).text(rst.order + ' ' + rst.name + ' '); } // 如果是重新上报 // 令最后一个图标转换 $('#auditors-list li[data-auditorid="' + parseInt(li.attr('auditorId')) + '"]').remove(); if ($('#auditors-list li').length !== 0 && !$('#auditors-list li i').hasClass('fa-stop-circle')) { $('#auditors-list li').eq($('#auditors-list li').length-1).children('i') .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle'); } // $('#auditors-list2 li[data-auditid="' + data.auditorId + '"]').remove(); // if ($('#auditors-list2 li').length !== 0 && !$('#auditors-list2 li i').hasClass('fa-stop-circle')) { // $('#auditors-list2 li').eq($('#auditors-list2 li').length-1).children('i') // .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle'); // } for (let i = 0; i < $('#auditors-list li').length; i++) { $('#auditors-list li').eq(i).find('.pull-right').text(i === 0 ? '原报' : (i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i)) + '审'); // $('#auditors-list2').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2').length ? '终' : transFormToChinese(i+1)) + '审'); } }); }); // 退回选择修改审批人流程 $('#hideSp').click(function () { $('#sp-list').modal('hide'); }); $('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'); }); // 重新审批获取手机验证码 // 获取验证码 let isPosting = false; $("#get-code").click(function() { if (isPosting) { return false; } const btn = $(this); $.ajax({ url: '/profile/code?_csrf_j=' + csrf, type: 'post', data: { mobile: authMobile, type: 'shenpi' }, dataTye: 'json', error: function() { isPosting = false; }, beforeSend: function() { isPosting = true; }, success: function(response) { isPosting = false; if (response.err === 0) { codeSuccess(btn); $("input[name='code']").removeAttr('readonly'); $("#re-shenpi-btn").removeAttr('disabled'); } else { toastr.error(response.msg); } } }); }); // 同步报表角色 $('#follow_rpt_audit_btn').click(function () { postData('/sp/' + spid + '/payment/' + tenderId + '/detail/' + detailId + '/save', { type: 'follow_rpt_audit' }, (datas) => { toastr.success('同步成功'); remakeShenpiHtml(datas); }); }); }); // 检查上报情况 function checkAuditorFrom () { if ($('#auditors li').length === 0) { if(shenpi_status === shenpiConst.sp_status.gdspl) { toastr.error('请联系管理员添加审批人'); } else { toastr.error('请先选择审批人,再上报数据'); } return false; } $('#hide-all').show(); } // 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; } /** * 获取成功后的操作 * * @param {Object} btn - 点击的按钮 * @return {void} */ function codeSuccess(btn) { let counter = 60; btn.addClass('disabled').text('重新获取 ' + counter + 'S'); btn.parent().siblings('input').removeAttr('readonly').attr('placeholder', '输入短信中的6位验证码'); const bindBtn = $("#bind-btn"); bindBtn.removeClass('btn-secondary disabled').addClass('btn-primary'); const countDown = setInterval(function() { const countString = counter - 1 <= 0 ? '' : ' ' + (counter - 1) + 'S'; // 倒数结束后 if (countString === '') { clearInterval(countDown); btn.removeClass('disabled'); } const text = '重新获取' + countString; btn.text(text); counter -= 1; }, 1000); }