$(function () { autoFlashHeight(); // 全选报表 $('#select_all_rpt_checkbox').click(function () { $('#rpt_table input[name="rptId[]"]').prop('checked', true); $(this).prop('checked', false); }); $('#add_rpt_btn').click(function () { const checkArray = []; $('#rpt_table input[name="rptId[]"]:checked').each(function() { checkArray.push({ id: parseInt($(this).val()), name: $(this).attr('data-name'), }); //向数组中添加元素 }); postData('/payment/' + tenderId + '/process/save', { type: 'add-rpt', rpt_list: checkArray }, function (result) { const html = []; for (const data of result) { html.push(`\n`); html.push(`${data.rpt_name}\n`); html.push(`${data.user_name}\n`); html.push('\n'); } tenderRptList = result; $('#tender_rpt_table').html(html.join('')); if (result.length === 0) { $('#process_set').hide(); } else { fisrtSetProcess(); } $('#add-rpt').modal('hide'); }) }); 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-trid'); let html = ''; if (newVal && newVal === oldSearchVal) { accountList.filter(item => item && item.id !== cur_uid && (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 => { if (item.id !== cur_uid) { html += `

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

${item.role || ''}
`; } }); html += '
'; }); $('#' + code + '_dropdownMenu .book-list').empty(); $('#' + code + '_dropdownMenu .book-list').append(html); } } }, 400); }); function setLcShowHtml(this_status, this_tr_id, data) { if (this_status === sp_status.sqspr) { $('#process_set').find('.lc-show').html(''); } else if (this_status === sp_status.gdspl) { let addhtml = '\n'; $('#process_set').find('.lc-show').html(addhtml); } else if (this_status === sp_status.gdzs) { let addhtml = '\n'; $('#process_set').find('.lc-show').html(addhtml); } } function fisrtSetProcess() { $('#tender_rpt_table tr').eq(0).addClass('table-warning'); const tr_id = parseInt($('#tender_rpt_table tr').eq(0).attr('data-id')); $('#process_set').show(); makeProcess(tr_id); } // 初始化选中table if ($('#tender_rpt_table tr').length > 0) { fisrtSetProcess(); } // 选中切换table $('body').on('click', '#tender_rpt_table tr', function () { if (!$(this).hasClass('table-warning')) { $('#tender_rpt_table tr').removeClass('table-warning'); $(this).addClass('table-warning'); const tr_id = parseInt($(this).attr('data-id')); makeProcess(tr_id); } }); // 初始化审批流程 function makeProcess(tr_id) { const trInfo = _.find(tenderRptList, { id: tr_id }); $('#process_set').find('.card-title').text(trInfo.rpt_name); $('#process_set input[name="tender_process"][value="'+ trInfo.sp_status +'"]').prop('checked', true); const spt = sp_status_list[trInfo.sp_status]; $('#process_set').find('.alert-warning').text(spt.name + ':' + spt.msg); const prop = { type: 'get-audits', tr_id: trInfo.id, status: trInfo.sp_status, }; postData('/payment/' + tenderId + '/process/save', prop, function (data) { setLcShowHtml(trInfo.sp_status, trInfo.id, data); }); } // 添加审批流程按钮逻辑 $('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; }); // 更改审批流程状态 $('#process_set .form-check input').on('change', function () { // 获取所有审批的checked值并更新 const this_status = parseInt($(this).val()); const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id')); const spt = sp_status_list[this_status]; $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg); // 拼接post json const prop = { type: 'change-status', tr_id: this_tr_id, status: this_status }; postData('/payment/' + tenderId + '/process/save', prop, function (data) { const trInfo = _.find(tenderRptList, { id: this_tr_id }); trInfo.sp_status = this_status; setLcShowHtml(this_status, this_tr_id, data); }); }); // 选中审批人 $('body').on('click', 'dl dd', function () { const id = parseInt($(this).data('id')); if (!id) return; let this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id')); if (!this_tr_id) this_tr_id = $(this).parents('.dropdown').attr('data-trid'); const user = _.find(accountList, function (item) { return item.id === id; }); const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val()); if (this_status === sp_status.gdspl) { // 判断是否已存在审批人 const aid_num = $(this).parents('ul').find('.remove-audit').length; for (let i = 0; i < aid_num; i++) { const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id')); if (aid === id) { toastr.warning('该审核人已存在,请勿重复添加'); return; } } } const prop = { status: this_status, tr_id: this_tr_id, audit_id: id, type: 'add-audit', }; const _self = $(this); postData('/payment/' + tenderId + '/process/save', prop, function (data) { if (this_status === sp_status.gdspl) { _self.parents('ul').append('
  • 添加流程
  • '); } _self.parents('.spr-span').html('\n' + ''+ user.name +' \n' + ' \n' + ' \n' + ' ' + ' \n'); // '); }); }); // 移除审批人 $('body').on('click', '.remove-audit', function () { const id = parseInt($(this).data('id')); const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val()); const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id')); const prop = { status: this_status, tr_id: this_tr_id, audit_id: id, type: 'del-audit', }; const _self = $(this); postData('/payment/' + tenderId + '/process/save', prop, function (data) { if (this_status === sp_status.gdspl) { const _selflc = _self.parents('.lc-show'); _self.parents('li').remove(); const aid_num = parseInt(_selflc.children('ul').find('li.d-flex').length); if (aid_num === 0) { let addhtml = '\n'; _selflc.html(addhtml); } else { for (let i = 0; i < aid_num; i++) { _selflc.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审'); } } } else if (this_status === sp_status.gdzs) { let addhtml = '\n'; _self.parents('.lc-show').html(addhtml); } }) }); // 固定审批流-添加流程 $('body').on('click', '.add-audit', function () { const num = $(this).parents('ul').children('li').length; const this_tr_id = parseInt($('#tender_rpt_table').find('.table-warning').attr('data-id')); const addhtml = makeSelectAudit(this_tr_id, transFormToChinese(num)); $(this).parents('ul').append(addhtml); $(this).parents('li').remove(); }); // 审批流程-审批人html 生成 function makeAudit(audit, i = '终') { return '
  • \n' + ' '+ i +'审\n' + ' \n' + ' \n' + ' '+ audit.name +' \n' + ' \n' + ' \n' + ' ' + // ' \n' + ' \n' + '
  • '; } // 审批流程-选择审批人html 生成 function makeSelectAudit(tr_id, i = '终') { let divhtml = ''; accountGroup.forEach((group, idx) => { let didivhtml = ''; if(group) { group.groupList.forEach(item => { didivhtml += item.id !== cur_uid ? '
    \n' + '

    ' + item.name + '' + item.mobile + '

    \n' + ' ' + item.role + '\n' + '
    \n' : ''; }); divhtml += '
    ' + group.groupName + '
    \n' + '
    \n' + didivhtml + '
    \n'; } }); let html = '
  • \n' + ' ' + i + '审\n' + ' \n' + ' \n' + ' \n' + ' \n' + ' \n' + '
  • '; return html; } });