$(function () { autoFlashHeight(); let timer = null; let oldSearchVal = null; $('body').on('input propertychange', '.gr-search', function(e) { oldSearchVal = e.target.value; timer && clearTimeout(timer); timer = setTimeout(() => { const newVal = $(this).val(); const code = $(this).attr('data-code'); 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 || ''}
` }); $('#' + code + '_dropdownMenu .book-list').empty(); $('#' + code + '_dropdownMenu .book-list').append(html); } else { if (!$('#' + code + '_dropdownMenu .acc-btn').length) { accountGroup.forEach((group, idx) => { if (!group) return; html += `
${group.groupName}
`; group.groupList.forEach(item => { html += `

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

${item.role || ''}
`; }); html += '
'; }); $('#' + code + '_dropdownMenu .book-list').empty(); $('#' + code + '_dropdownMenu .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; }); // 选中审批人 $('body').on('click', 'dl dd', function () { const id = parseInt($(this).attr('data-id')); if (!id) return; const this_code = $(this).parents('.dropdown').data('code'); if (_.findIndex(rpt_audit, { uid: id }) !== -1) { toastr.error('该表单角色已存在,请勿重复添加'); return; } const user = _.find(accountList, function (item) { return item.id === id; }); $('#' + this_code + '_user').html(`${user.name}`); $(this).parents('.select-audit').hide(); $('#' + this_code + '_user').show(); rpt_audit[this_code].uid = id; rpt_audit[this_code].name = user.name; console.log(rpt_audit); }); // 移除审批人 $('body').on('click', '.remove-audit', function () { const this_code = parseInt($(this).attr('data-code')); $('#' + this_code + '_user').html(``); $('#' + this_code + '_user').hide(); $('#' + this_code + '_user').siblings('.select-audit').show(); rpt_audit[this_code].uid = null; delete rpt_audit[this_code].name; console.log(rpt_audit); }); // 重新加载角色数据 $('#set-bdjs').on('show.bs.modal', function () { if (old_rpt_audit) { for (const [i, r] of old_rpt_audit.entries()) { if (r.uid) { $('#' + i + '_user').html(`${r.name}`); $('#' + i + '_user').show(); $('#' + i + '_user').siblings('.select-audit').hide(); } else { $('#' + i + '_user').html(``); $('#' + i + '_user').hide(); $('#' + i + '_user').siblings('.select-audit').show(); } } } rpt_audit = _.cloneDeep(old_rpt_audit); }); // 绑定表单角色 $('#bind_rpt_audit_btn').click(function () { if (!is_first) { if (_.findIndex(rpt_audit, { uid: null }) !== -1) { toastr.error('请绑定所有表单角色再提交'); return; } } postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'rpt_audit', rpt_audit }, function (result) { toastr.success('设置成功'); old_rpt_audit = _.cloneDeep(rpt_audit); if (result.is_first) { $('#first_msg').show(); } else { $('#first_msg').hide(); } $('#set-bdjs').modal('hide'); }); }); $('#show-add-btn').click(function () { if (_.findIndex(old_rpt_audit, { uid: null }) !== -1) { toastr.error('未配置好表单角色无法新建表单'); $('#set-bdjs').modal('show'); } else { $('#add-catalogue').modal('show'); } }); $('#add-detail-btn').click(function () { if (_.trim($('#add-detail-code').val()) === '') { toastr.error('请输入编号'); return false; } if ($('#add-detail-time').val() === '') { toastr.error('请输入日期'); return false; } console.log($('#add-detail-time').val()); postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'add-detail', code: _.trim($('#add-detail-code').val()), s_time: $('#add-detail-time').val() }, function (result) { window.location.href = '/payment/' + tenderId + '/detail/' + result.id; }); }); // 获取审批流程 $('a[data-target="#sp-list" ]').on('click', function () { const data = { order: $(this).attr('m-order'), }; postData('/payment/' + tenderId + '/list/'+ trId + '/auditors', data, function (result) { const { auditHistory, auditors, user } = result let auditorsHTML = '' let historyHTML = '' auditors.forEach((auditor, idx) => { if (idx === 0) { auditorsHTML += `
  • ${auditor.name} ${auditor.role} 原报
  • ` } else if(idx === auditors.length -1 && idx !== 0) { auditorsHTML += `
  • ${auditor.name} ${auditor.role} 终审
  • ` } else { auditorsHTML += `
  • ${auditor.name} ${auditor.role} ${transFormToChinese(idx)}审
  • ` } }) $('#auditor-list').empty() $('#auditor-list').append(auditorsHTML) const leftAuditors = auditors; auditHistory.forEach((auditors, idx) => { if(idx === auditHistory.length - 1 && auditHistory.length !== 1) { historyHTML += `
    展开历史审批流程
    ` } historyHTML += `
    ${idx + 1}#
    ' }) $('#audit-list').empty() $('#audit-list').append(historyHTML) }); }); // 展开/收起历史审核记录 $('#audit-list').on('click', 'a', function() { const type = $(this).data('target') const auditCard = $(this).parent().parent() console.log('auditCard', auditCard) if (type === 'show') { $(this).data('target', 'hide') auditCard.find('.fold-card').slideDown('swing', () => { auditCard.find('#end-target').text($(this).data('idx') + '#') auditCard.find('#fold-btn').text('收起历史审核记录') }) } else { $(this).data('target', 'show') auditCard.find('.fold-card').slideUp('swing', () => { auditCard.find('#end-target').text('1#') auditCard.find('#fold-btn').text('展开历史审核记录') }) } }); function formatDate(date) { if (!date) return ''; date = new Date(date) const year = date.getFullYear(); let mon = date.getMonth() + 1; let day = date.getDate(); let hour = date.getHours(); let minute = date.getMinutes(); let scond = date.getSeconds(); if (mon < 10) { mon = '0' + mon.toString(); } if (day < 10) { day = '0' + day.toString(); } if (hour < 10) { hour = '0' + hour.toString(); } if (minute < 10) { minute = '0' + minute.toString(); } if (scond < 10) { scond = '0' + scond.toString(); } return `${year}${mon}-${day}${hour}:${minute}:${scond}`; }; });