123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804 |
- $(function () {
- autoFlashHeight();
- // 全选报表
- $('#select_all_rpt_checkbox').click(function () {
- $(this).prop('checked', false);
- $('#rpt_table input[name="rptId[]"]').each(function () {
- if (parseInt($(this).val()) !== -1) {
- $(this).prop('checked', true);
- }
- });
- });
- $('#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('/sp/' + spid + '/payment/' + tenderId + '/process/save', { type: 'add-rpt', rpt_list: checkArray }, function (result) {
- const html = [];
- for (const data of result) {
- html.push(`<tr data-id="${data.id}">\n`);
- html.push(`<td>${data.rpt_name}</td>\n`);
- html.push(`<td>${data.user_name}</td>\n`);
- html.push(`<td>${data.uid ? _.find(accountList, { id: data.uid }).name : ''}</td>\n`);
- html.push('</tr>\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;
- $('#process_set').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 && (!cur_uid || item.id !== cur_uid) && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
- class="ml-auto">${item.mobile || ''}</span></p>
- <span class="text-muted">${item.role || ''}</span>
- </dd>`
- });
- $(this).parents('.dropdown-menu').children('.book-list').empty();
- $(this).parents('.dropdown-menu').children('.book-list').append(html);
- // $('#' + 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 += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
- </a> ${group.groupName}</dt>
- <div class="dd-content" data-toggleid="${idx}">`;
- group.groupList.forEach(item => {
- if (!cur_uid || item.id !== cur_uid) {
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
- class="ml-auto">${item.mobile || ''}</span></p>
- <span class="text-muted">${item.role || ''}</span>
- </dd>`;
- }
- });
- html += '</div>';
- });
- // $('#' + code + '_dropdownMenu .book-list').empty();
- // $('#' + code + '_dropdownMenu .book-list').append(html);
- $(this).parents('.dropdown-menu').children('.book-list').empty();
- $(this).parents('.dropdown-menu').children('.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 = '<ul class="list-unstyled">\n';
- if (data.length !== 0) {
- for(const [i, audit] of data.entries()) {
- addhtml += makeAudit(audit, transFormToChinese(i+1));
- }
- addhtml += '<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>';
- } else {
- addhtml += makeSelectAudit(this_tr_id, '一');
- }
- addhtml += '</ul>\n';
- $('#process_set').find('.lc-show').html(addhtml);
- } else if (this_status === sp_status.gdzs) {
- let addhtml = '<ul class="list-unstyled">\n' +
- ' <li class="d-flex justify-content-start mb-3">\n' +
- ' <span class="col-auto">授权审批人</span>\n' +
- ' <span class="col-7">\n' +
- ' <span class="d-inline-block"></span>\n' +
- ' </span>\n' +
- ' </li>\n';
- addhtml += data ? makeAudit(data) : makeSelectAudit(this_tr_id);
- addhtml += '</ul>\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);
- cur_uid = trInfo.uid;
- let html = '<div class="mr-2">上报人<b class="text-danger">*</b></div>';
- let divhtml = '';
- accountGroup.forEach((group, idx) => {
- let didivhtml = '';
- if(group) {
- group.groupList.forEach(item => {
- didivhtml += item.id !== cur_uid ? '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
- '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
- ' class="ml-auto">' + item.mobile + '</span></p>\n' +
- ' <span class="text-muted">' + item.role + '</span>\n' +
- ' </dd>\n' : '';
- });
- divhtml += '<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="' + idx + '" data-type="hide"><i class="fa fa-plus-square"></i></a> ' + group.groupName + '</dt>\n' +
- ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
- ' </div>\n';
- }
- });
- if (trInfo.uid) {
- const userInfo = _.find(accountList, { id: trInfo.uid });
- html += '<div class="mr-2">'+ userInfo.name +'</div>\n' +
- '<div><span class="d-inline-block">\n' +
- ' <div class="dropdown text-right">\n' +
- ' <button class="btn btn-sm btn-primary dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
- ' 替换\n' +
- ' </button>\n' +
- ' <div class="dropdown-menu dropdown-menu-right" id="' + tr_id + '_dropdownMenu1" aria-labelledby="' + tr_id + '_dropdownMenuButton1" style="width:220px">\n' +
- ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
- ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
- ' <dl class="list-unstyled book-list">\n' + divhtml +
- ' </dl>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span>\n' +
- '</div>';;
- } else {
- html +='<div><span class="d-inline-block">\n' +
- ' <div class="dropdown text-right">\n' +
- ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
- ' 选择上报人\n' +
- ' </button>\n' +
- ' <div class="dropdown-menu dropdown-menu-right" id="' + tr_id + '_dropdownMenu2" aria-labelledby="' + tr_id + '_dropdownMenuButton2" style="width:220px">\n' +
- ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
- ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
- ' <dl class="list-unstyled book-list">\n' + divhtml +
- ' </dl>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span>\n' +
- '</div>';
- }
- $('#rpt_user').html(html);
- $('input[name="tender_process"][value="'+ trInfo.sp_status +'"]', '#process_set').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('/sp/' + spid + '/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').on('change', `.form-check input`, 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('/sp/' + spid + '/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', '#process_set .lc-show 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('/sp/' + spid + '/payment/' + tenderId + '/process/save', prop, function (data) {
- if (this_status === sp_status.gdspl) {
- _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
- }
- _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
- '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
- ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
- ' <div class="dropdown-menu">\n' +
- ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
- ' <div class="dropdown-divider"></div>\n' +
- ' <div class="px-2 py-1 text-center">\n' +
- ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
- ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span> ' +
- ' </span></span></span>\n');
- // <a href="javascript:void(0);" class="remove-audit btn-sm text-danger px-1" title="移除" data-id="'+ user.id +'"><i class="fa fa-remove"></i></a></span> </span>');
- });
- });
- // 选中上报人
- $('body').on('click', '#rpt_user dl dd', function () {
- const id = parseInt($(this).data('id'));
- if (!id) return;
- console.log(id);
- 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;
- });
- if (!user) toastr.error('用户列表不存在此人');
- const prop = {
- tr_id: this_tr_id,
- uid: id,
- type: 'update-report',
- };
- postData('/sp/' + spid + '/payment/' + tenderId + '/process/save', prop, function (result) {
- tenderRptList = result.list;
- if (result.updateRows) {
- toastr.warning('上报人不能同时作为审批人,审批流已移除 ' + user.name);
- }
- $('#tender_rpt_table tr[data-id="'+ this_tr_id +'"]').children('td').eq(2).html(user.name);
- makeProcess(this_tr_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('/sp/' + spid + '/payment/' + tenderId + '/process/save', prop, function (data) {
- // if (this_status === sp_status.gdspl) {
- // _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
- // }
- // _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
- // '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
- // ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
- // ' <div class="dropdown-menu">\n' +
- // ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
- // ' <div class="dropdown-divider"></div>\n' +
- // ' <div class="px-2 py-1 text-center">\n' +
- // ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
- // ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
- // ' </div>\n' +
- // ' </div>\n' +
- // ' </span> ' +
- // ' </span></span></span>\n');
- // // <a href="javascript:void(0);" class="remove-audit btn-sm text-danger px-1" title="移除" data-id="'+ user.id +'"><i class="fa fa-remove"></i></a></span> </span>');
- // });
- });
- // 移除审批人
- $('body').on('click', '#process_set .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('/sp/' + spid + '/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 = '<ul class="list-unstyled">\n';
- addhtml += makeSelectAudit(this_tr_id, '一');
- addhtml += '</ul>\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 = '<ul class="list-unstyled">\n' +
- ' <li class="d-flex justify-content-start mb-3">\n' +
- ' <span class="col-auto">授权审批人</span>\n' +
- ' <span class="col-7">\n' +
- ' <span class="d-inline-block"></span>\n' +
- ' </span>\n' +
- ' </li>\n';
- addhtml += makeSelectAudit(this_tr_id);
- addhtml += '</ul>\n';
- _self.parents('.lc-show').html(addhtml);
- }
- })
- });
- // 固定审批流-添加流程
- $('body').on('click', '#process_set .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 '<li class="d-flex justify-content-start mb-3">\n' +
- ' <span class="col-auto">'+ i +'审</span>\n' +
- ' <span class="col-7 spr-span">\n' +
- ' <span class="d-inline-block"></span>\n' +
- ' <span class="d-inline-block"><span class="badge badge-light">'+ audit.name +' <span class="dropdown">\n' +
- ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
- ' <div class="dropdown-menu">\n' +
- ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
- ' <div class="dropdown-divider"></div>\n' +
- ' <div class="px-2 py-1 text-center">\n' +
- ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + audit.audit_id + '">移除</button>\n' +
- ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span> ' +
- // '<a href="javascript:void(0);" class="remove-audit btn-sm text-danger px-1" title="移除" data-id="'+ audit.audit_id +'"><i class="fa fa-remove"></i></a></span> </span>\n' +
- ' </span></span></span>\n' +
- ' </li>';
- }
- // 审批流程-选择审批人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 ? '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
- '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
- ' class="ml-auto">' + item.mobile + '</span></p>\n' +
- ' <span class="text-muted">' + item.role + '</span>\n' +
- ' </dd>\n' : '';
- });
- divhtml += '<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="' + idx + '" data-type="hide"><i class="fa fa-plus-square"></i></a> ' + group.groupName + '</dt>\n' +
- ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
- ' </div>\n';
- }
- });
- let html = '<li class="d-flex justify-content-start mb-3">\n' +
- ' <span class="col-auto">' + i + '审</span>\n' +
- ' <span class="col-7 spr-span">\n' +
- ' <span class="d-inline-block">\n' +
- ' <div class="dropdown text-right" >\n' +
- ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
- ' 选择审批人\n' +
- ' </button>\n' +
- ' <div class="dropdown-menu dropdown-menu-right" id="' + tr_id + '_dropdownMenu" aria-labelledby="' + tr_id + '_dropdownMenuButton" style="width:220px">\n' +
- ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
- ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
- ' <dl class="list-unstyled book-list">\n' + divhtml +
- ' </dl>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span>\n' +
- ' </span>\n' +
- ' </li>';
- return html;
- };
- $('#add-rpt').on('show.bs.modal', function () {
- $('#rpt_table').find('input:checked:not(:disabled)').prop('checked', false);
- $('#rpt_table').find('input:not(:disabled)').each(function () {
- if (_.findIndex(tenderRptList, { rpt_id: parseInt($(this).val()) }) !== -1) {
- $(this).prop('checked', true);
- }
- });
- });
- $('#rpt_table input').on('click', function () {
- if ($(this).is(':checked') && parseInt($(this).val()) === -1) {
- $(this).prop('checked', false);
- const index = $("#rpt_table input").index(this);
- // 循环选中当前子项值
- checkedRptProjectList(rptProjectList[index].items);
- }
- });
- function checkedRptProjectList(items) {
- if (items && items.length > 0) {
- for (const item of items) {
- if (item.ID !== -1 && item.items === null) {
- console.log(item);
- $('#rpt_table input').eq(item.index).prop('checked', true);
- } else {
- checkedRptProjectList(item.items);
- }
- }
- }
- };
- // 安全生产费 流程设置相关
- class ProgressMaker {
- constructor (setting) {
- const self = this;
- this.domId = setting.domId;
- this.obj = $(setting.domId);
- if (setting.rptInfo) this.loadRptInfo(setting.rptInfo);
- // 选中上报人
- $(setting.domId).on('click', '[name=user] dl dd', function () {
- const uid = parseInt($(this).data('id'));
- if (!uid) return;
- let tr_id = self.rptInfo.id;
- const user = _.find(accountList, function (item) { return item.id === uid; });
- if (!user) {
- toastr.error('用户列表不存在此人');
- return;
- }
- const data = { tr_id, uid, type: 'update-report' };
- postData('process/save', data, function (result) {
- for (const prop in result.updateData) {
- self.rptInfo[prop] = result.updateData[prop];
- }
- self.refreshUserHtml();
- if (result.updateRows) {
- toastr.warning('上报人不能同时作为审批人,审批流已移除 ' + user.name);
- self.loadAuditList();
- }
- });
- });
- // 更改审批流程状态
- $(setting.domId).on('change', '[name=detail_process]', function () {
- // 获取所有审批的checked值并更新
- const status = parseInt($(this).val());
- let tr_id = self.rptInfo.id;
- const spt = sp_status_list[status];
- $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
- // 拼接post json
- const prop = { type: 'change-status', tr_id, status };
- postData('/sp/' + spid + '/payment/' + tenderId + '/process/save', prop, function (data) {
- self.rptInfo.sp_status = status;
- self.rptInfo.auditData = data;
- self.setLcShowHtml();
- });
- });
- // 选中审批流里的审批人
- $(setting.domId).on('click', '.lc-show dl dd', function () {
- const tr_id = self.rptInfo.id;
- const id = parseInt($(this).data('id'));
- if (!id) return;
- const user = _.find(accountList, function (item) {
- return item.id === id;
- });
- const status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
- if (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, tr_id, audit_id: id, type: 'add-audit' };
- const _self = $(this);
- postData('/sp/' + spid + '/payment/' + tenderId + '/process/save', prop, function (data) {
- if (status === sp_status.gdspl) {
- _self.parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
- }
- _self.parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
- '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <span class="dropdown">\n' +
- ' <a href="javascript:void(0);" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
- ' <div class="dropdown-menu">\n' +
- ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
- ' <div class="dropdown-divider"></div>\n' +
- ' <div class="px-2 py-1 text-center">\n' +
- ' <button class="remove-audit btn btn-sm btn-danger" data-id="' + user.id + '">移除</button>\n' +
- ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span> ' +
- ' </span></span></span>\n');
- });
- });
- // 移除审批人
- $(setting.domId).on('click', '.remove-audit', function () {
- const id = parseInt($(this).data('id'));
- const status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
- const tr_id = self.rptInfo.id;
- const prop = { status, tr_id, audit_id: id, type: 'del-audit' };
- const _self = $(this);
- postData('process/save', prop, function (data) {
- if (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 = '<ul class="list-unstyled">\n';
- addhtml += makeSelectAudit(tr_id, '一');
- addhtml += '</ul>\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 (status === sp_status.gdzs) {
- let addhtml = '<ul class="list-unstyled">\n' +
- ' <li class="d-flex justify-content-start mb-3">\n' +
- ' <span class="col-auto">授权审批人</span>\n' +
- ' <span class="col-7">\n' +
- ' <span class="d-inline-block"></span>\n' +
- ' </span>\n' +
- ' </li>\n';
- addhtml += self.getAuditSelectHtml();
- addhtml += '</ul>\n';
- _self.parents('.lc-show').html(addhtml);
- }
- })
- });
- // 固定审批流-添加流程
- $(setting.domId).on('click', '.add-audit', function () {
- const num = $(this).parents('ul').children('li').length;
- const addhtml = self.getAuditSelectHtml(transFormToChinese(num));
- $(this).parents('ul').append(addhtml);
- $(this).parents('li').remove();
- });
- $(setting.domId).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 && (!self.rptInfo.uid || item.id !== self.rptInfo.uid) && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1)))
- .forEach(item => {
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
- class="ml-auto">${item.mobile || ''}</span></p>
- <span class="text-muted">${item.role || ''}</span>
- </dd>`
- });
- } else {
- if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
- accountGroup.forEach((group, idx) => {
- if (!group) return;
- html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
- </a> ${group.groupName}</dt>
- <div class="dd-content" data-toggleid="${idx}">`;
- group.groupList.forEach(item => {
- if (!self.rptInfo.uid || item.id !== self.rptInfo.uid) {
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
- class="ml-auto">${item.mobile || ''}</span></p>
- <span class="text-muted">${item.role || ''}</span>
- </dd>`;
- }
- });
- html += '</div>';
- });
- }
- }
- $(this).parents('.dropdown-menu').children('.book-list').empty();
- $(this).parents('.dropdown-menu').children('.book-list').append(html);
- }, 400);
- });
- }
- getAccountHtml(uid) {
- const html = [];
- accountGroup.forEach((group, idx) => {
- if (!group) return;
- const groupHtml = [];
- group.groupList.forEach(item => {
- if (item.id === uid) return;
- groupHtml.push('<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
- '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
- ' class="ml-auto">' + item.mobile + '</span></p>\n' +
- ' <span class="text-muted">' + item.role + '</span>\n' +
- ' </dd>\n');
- });
- html.push(`<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i></a>${group.groupName}</dt>`,
- `<div class="dd-content" data-toggleid="${idx}">${groupHtml.join('')}</div>`);
- });
- return html.join('');
- }
- getSelectHtml(name) {
- const tr_id = this.rptInfo.id;
- return '<span class="d-inline-block">\n' +
- ' <div class="dropdown text-right">\n' +
- ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + tr_id + '_dropdownMenuButton2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
- ` ${name}\n` +
- ' </button>\n' +
- ' <div class="dropdown-menu dropdown-menu-left" id="' + tr_id + '_dropdownMenu2" aria-labelledby="' + tr_id + '_dropdownMenuButton2" style="width:220px">\n' +
- ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
- ' placeholder="姓名/手机 检索" autocomplete="off" data-trid="' + tr_id + '"></div>\n' +
- ' <dl class="list-unstyled book-list">\n' + this.getAccountHtml(this.rptInfo.uid) +
- ' </dl>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span>\n';
- }
- getAuditSelectHtml(i = '终') {
- let html = '<li class="d-flex justify-content-start mb-3">\n' +
- ' <span class="col-auto">' + i + '审</span>\n' +
- ' <span class="col-7 spr-span">\n' + this.getSelectHtml('选择审批人') +
- ' </span>\n' +
- ' </li>';
- return html;
- }
- refreshUserHtml() {
- const html = ['<div class="mr-2">上报人<b class="text-danger">*</b></div>'];
- if (this.rptInfo.uid) {
- const userInfo = _.find(accountList, { id: this.rptInfo.uid });
- if (userInfo) {
- html.push(`<div class="mr-2">${userInfo.name}</div>`, `<div>${this.getSelectHtml('替换')}</div>`);
- } else {
- html.push(`<div class="mr-2">上报人已失效</div>`, `<div>${this.getSelectHtml('替换')}</div>`);
- }
- } else {
- html.push(`<div>${this.getSelectHtml('选择上报人')}</div>`);
- }
- $('[name=user]', this.domId).html(html.join(''));
- }
- setLcShowHtml() {
- if (this.rptInfo.sp_status === sp_status.sqspr) {
- $('.lc-show', this.domId).html('');
- } else if (this.rptInfo.sp_status === sp_status.gdspl) {
- let addhtml = '<ul class="list-unstyled">\n';
- if (this.rptInfo.auditData.length !== 0) {
- for(const [i, audit] of this.rptInfo.auditData.entries()) {
- addhtml += makeAudit(audit, transFormToChinese(i+1));
- }
- addhtml += '<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>';
- } else {
- addhtml += this.getAuditSelectHtml('一');
- }
- addhtml += '</ul>\n';
- $('.lc-show', this.domId).html(addhtml);
- } else if (this.rptInfo.sp_status === sp_status.gdzs) {
- let addhtml = '<ul class="list-unstyled">\n' +
- ' <li class="d-flex justify-content-start mb-3">\n' +
- ' <span class="col-auto">授权审批人</span>\n' +
- ' <span class="col-7">\n' +
- ' <span class="d-inline-block"></span>\n' +
- ' </span>\n' +
- ' </li>\n';
- addhtml += this.rptInfo.auditData ? makeAudit(this.rptInfo.auditData) : this.getAuditSelectHtml();
- addhtml += '</ul>\n';
- $('.lc-show', this.domId).html(addhtml);
- }
- }
- async loadAuditList() {
- const prop = {
- type: 'get-audits',
- tr_id: this.rptInfo.id,
- status: this.rptInfo.sp_status,
- };
- this.rptInfo.auditData = await postDataAsync('process/save', prop);
- this.setLcShowHtml();
- }
- initProgress() {
- this.obj.attr('data-trid', this.rptInfo.id);
- $('.card-title', this.domId).find('.card-title').text(this.rptInfo.rpt_name);
- this.refreshUserHtml();
- $('input[name="detail_process"][value="'+ this.rptInfo.sp_status +'"]', this.obj).prop('checked', true).attr('data-trid', this.rptInfo.id);
- const spt = sp_status_list[this.rptInfo.sp_status];
- $('.alert-warning', this.domId).text(spt.name + ':' + spt.msg);
- this.loadAuditList();
- }
- loadRptInfo(rptInfo) {
- this.rptInfo = rptInfo;
- this.initProgress();
- }
- }
- const safeProgress = new ProgressMaker({ domId: '#safe', rptInfo: safeRpt });
- });
|