| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211 |
- 'use strict';
- /**
- *
- *
- * @author Ellisran
- * @date 2020/10/09
- * @version
- */
- let auditUtils;
- const needYB = ['contract'];
- function getShenpiHtml (this_code) {
- const html = [];
- html.push('<table class="table table-hover table-bordered">');
- html.push('<thead>', '<tr>');
- html.push('<th>名称</th>');
- html.push('<th width="100">审批流程</th>');
- html.push('<th width="40">选择</th>');
- html.push('</tr>', '</thead>');
- for (const sp of sp_lc) {
- html.push('<tr>');
- html.push('<td>', sp.name, '</td>');
- html.push('<td>');
- const this_status = parseInt($('.' + sp.code + '_div').children('.lc-show').siblings('.form-group').find('input:checked').val());
- html.push(sp_status_list[this_status].name);
- if(this_status !== sp_status.sqspr) {
- const nameList = [];
- const aid_num = $('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').length;
- const aidList = [];
- for (let i = 0; i < aid_num; i++) {
- const aid = parseInt($('.' + sp.code + '_div').children('.lc-show').children('ul').find('.remove-audit').eq(i).data('id'));
- aidList.push(aid);
- }
- if(aidList.length > 0) {
- for (const uid of aidList) {
- const user = _.find(accountList, { id: uid });
- if (user) nameList.push(user.name);
- }
- }
- html.push('<i class="fa fa-question-circle text-primary" data-container="body" data-toggle="tooltip" data-placement="bottom" ' +
- 'data-original-title="'+ (nameList.length > 0 ? nameList.join('-') : '') +'"></i>');
- }
- html.push('</td>');
- html.push('<td>', this_code !== sp.code ? '<input type="checkbox" data-code="'+ sp.code +'"' + (sp.groupList && sp.groupList.length > 0 ? 'disabled' : '') + '>' : '', '</td>');
- html.push('</tr>');
- }
- html.push('</table>');
- return html.join('');
- }
- $(document).ready(function () {
- auditUtils = {
- getAuditHtml: function(audit) {
- return '<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> ' +
- ' </span></span>\n'
- },
- getAuditTypeHtml: function(code, type) {
- const html = [];
- html.push(`<span class="d-inline-block"><select class="form-control form-control-sm audit-type-key" data-type="${type}">`);
- for (const t of auditType.types) {
- if (t.valid && t.valid.indexOf(code) < 0) continue;
- html.push(`<option value="${t.value}" ${t.value === type ? 'selected' : ''}>${t.name}</option>`);
- }
- html.push('</select></span> ');
- return html.join('');
- },
- getSelectAuditHtml: function (code) {
- let divhtml = '';
- accountGroup.forEach((group, idx) => {
- let didivhtml = '';
- if(group) {
- group.groupList.forEach(item => {
- didivhtml += (item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1)) ? '<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';
- }
- });
- const html =
- ' <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="' + code + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
- ' 选择审批人\n' +
- ' </button>\n' +
- ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_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-code="' + code + '"></div>\n' +
- ' <dl class="list-unstyled book-list">\n' + divhtml +
- ' </dl>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span>\n';
- return html;
- },
- // 以下i从1开始
- getAuditGroupInnerHtml: function(code, auditGroup, i) {
- const html = [];
- const type = auditGroup.length > 0 ? auditGroup[0].audit_type : auditType.key.common;
- html.push(`<span class="col-auto">${transFormToChinese(i)}审</span><span class="col-7 spr-span">`);
- html.push(this.getAuditTypeHtml(code, type));
- for (const audit of auditGroup) {
- html.push(this.getAuditHtml(audit));
- }
- if (type !== auditType.key.common || auditGroup.length === 0) {
- html.push(this.getSelectAuditHtml(code));
- }
- if (type === auditType.key.and && auditType.info[auditType.key.and].setValid.indexOf(code) >= 0 && auditGroup.length > 0) {
- html.push(`<button class="btn btn-sm btn-outline-primary" sp_type="${code}" audit_order="${i}" name="and-set">会签设置</button>`);
- }
- if (type === auditType.key.or && auditType.info[auditType.key.or].setValid.indexOf(code) >= 0 && auditGroup.length > 0) {
- html.push(`<button class="btn btn-sm btn-outline-primary" sp_type="${code}" audit_order="${i}" name="or-set">或签设置</button>`);
- }
- if (type === auditType.key.multi && auditGroup.length > 0) {
- html.push(`<button class="btn btn-sm btn-outline-primary" sp_type="${code}" audit_order="${i}" name="multi-set">分组设置</button>`);
- }
- if (type === auditType.key.union && auditGroup.length > 0) {
- html.push(`<button class="btn btn-sm btn-outline-primary" sp_type="${code}" audit_order="${i}" name="union-set">协同设置</button>`);
- }
- html.push('</span>');
- return html.join('');
- },
- getAuditGroupHtml: function (code, auditGroup, i) {
- return `<li class="d-flex justify-content-start align-items-center mb-3">${this.getAuditGroupInnerHtml(code, auditGroup, i)}</li>`;
- },
- getFinalAuditHtml: function (audit) {
- const html = [];
- html.push('<li class="d-flex justify-content-start mb-3"><span class="col-auto">终审</span><span class="col-7 spr-span">');
- html.push(this.getAuditHtml(audit));
- html.push('</span></span></li>');
- return html.join('');
- },
- getGroupHtml: function (flow, this_code) {
- let html = '';
- if (flow && flow.groupList && flow.groupList.length > 0) {
- let groupSelectHtml = '';
- for (const group of flow.groupList) {
- groupSelectHtml += `<option value="${group.id}" ${group.is_select === 1 ? 'selected' : ''}>${group.name}</option>`;
- }
- const selectGroup = flow.groupList.find(x => { return x.is_select === 1 });
- html += '<div class="d-flex justify-content-start align-items-center mb-3">\n' +
- ' <span class="col-auto">当前审批组:</span>\n' +
- ' <span style="width: 200px;">\n' +
- ' <select class="form-control form-control-sm group-list">\n' +
- groupSelectHtml +
- ' </select>\n' +
- ' </span>\n' +
- ` <span class="pl-3"><a href="javascript:void(0);" class="show-spzsave edit-spzsave" data-group="${selectGroup.id}" data-code="${this_code}"><i class="fa fa-edit"></i> 编辑审批组</a></span>\n` +
- ` <span class="pl-3"><a href="javascript:void(0);" class="show-spzsave" data-code="${this_code}"><i class="fa fa-plus"></i> 添加审批组</a></span>\n` +
- ' </div>';
- }
- return html;
- },
- getgdsplHtml(flow, this_code) {
- let addhtml = '';
- if (flow.auditGroupList.length !== 0) {
- for(const [i, auditGroup] of flow.auditGroupList.entries()) {
- addhtml += this.getAuditGroupHtml(this_code, auditGroup, i + 1);
- }
- const addGroupHtml = (this_code === 'change' || this_code === 'stage' || this_code === 'contract') && (!flow.groupList || (flow.groupList && flow.groupList.length === 0)) ?
- `<span class="pl-3"><a href="javascript:void(0);" class="show-spzsave" data-code="${this_code}"><i class="fa fa-save"></i> 存为审批组</a></span>\n` : '';
- addhtml += '<li>\n' +
- ' <span class="pl-3"><a href="javascript:void(0);" class="add-audit" ><i class="fa fa-plus"></i> 添加流程</a></span>\n' + addGroupHtml +
- ' </li>';
- } else {
- addhtml += this.getAuditGroupHtml(this_code, [], 1);
- }
- return addhtml;
- },
- // 以下i从0开始
- addAudit: function (code, user, i) {
- const flow = sp_lc.find(x => { return x.code === code });
- if (!flow.auditGroupList) flow.auditGroupList = [];
- if (!flow.auditGroupList[i]) flow.auditGroupList[i] = [];
- flow.auditGroupList[i].push(user);
- return flow.auditGroupList[i];
- },
- removeAudit: function (code, audit_id, i) {
- const flow = sp_lc.find(x => { return x.code === code });
- if (flow.auditGroupList[i].length === 1) {
- flow.auditGroupList.splice(i, 1);
- return null;
- }
- flow.auditGroupList[i].splice(flow.auditGroupList[i].findIndex(x => { return x.audit_id === audit_id; }), 1);
- return flow.auditGroupList[i];
- },
- setAuditType: function (code, audit_type, i) {
- const flow = sp_lc.find(x => { return x.code === code });
- if (!flow || !flow.auditGroupList || !flow.auditGroupList[i]) return;
- flow.auditGroupList[i].forEach(x => { x.audit_type = audit_type});
- return flow.auditGroupList[i];
- }
- };
- let timer = null;
- let oldSearchVal = null;
- $('body').on('input propertychange', 'div[id$="_dropdownMenu"] .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.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1)) && (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>`
- });
- $('#' + 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 ((item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1))) {
- 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);
- }
- }
- }, 400);
- });
- // 添加审批流程按钮逻辑
- $('body').on('click', 'div[id$="_dropdownMenu"] .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('change', '.form-check input[type="radio"]', function () {
- // 获取所有审批的checked值并更新
- const this_status = parseInt($(this).val());
- const this_code = $(this).data('code');
- const spt = sp_status_list[this_status];
- $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
- // 拼接post json
- const prop = {
- code: this_code,
- status: this_status
- };
- const _self = $(this);
- postData('/sp/' + spid + '/shenpi/save', prop, function (data) {
- if (this_status === sp_status.sqspr) {
- _self.parents('.form-group').siblings('.lc-show').html('');
- } else if (this_status === sp_status.gdspl) {
- const flow = sp_lc.find(x => { return x.code === this_code; });
- flow.auditGroupList = data.auditList;
- flow.groupList = data.groupList;
- let addhtml = auditUtils.getGroupHtml(flow, this_code);
- addhtml += '<ul class="list-unstyled">\n';
- addhtml += auditUtils.getgdsplHtml(flow, this_code);
- addhtml += '</ul>\n';
- _self.parents('.form-group').siblings('.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.auditList ? makeAudit(data.auditList) : makeSelectAudit(this_code);
- addhtml += '</ul>\n';
- _self.parents('.form-group').siblings('.lc-show').html(addhtml);
- }
- if(this_code === 'stage') {
- if(this_status === sp_status.gdspl) {
- $('#stage_cooperation').show();
- } else {
- $('#stage_cooperation').hide();
- }
- }
- });
- });
- // 选中审批人
- $('body').on('click', 'div[id$="_dropdownMenu"] dl dd', function () {
- const id = parseInt($(this).data('id'));
- if (!id) return;
- let this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
- if (!this_code) this_code = $(this).parents('.dropdown').data('code');
- const user = _.find(accountList, function (item) {
- return item.id === id;
- });
- if (this_code === 'audit-ass') {
- auditAss.setAuditAssist(user);
- } else {
- 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,
- code: sp_type[this_code],
- audit_id: id,
- type: 'add',
- };
- if (this_status === sp_status.gdspl) {
- prop.audit_type = parseInt($(this).parents('li').find('select[class*="audit-type-key"]')[0].value);
- prop.audit_order = $(this).parents('li').index() + 1;
- }
- const _self = $(this);
- postData('/sp/' + spid + '/shenpi/audit/save', prop, function (data) {
- if (this_status === sp_status.gdspl) {
- const auditGroup = auditUtils.addAudit(this_code, data, prop.audit_order - 1);
- if (_self.parents('ul').find('.add-audit').length === 0) {
- const flow = sp_lc.find(x => { return x.code === this_code; });
- const addGroupHtml = (this_code === 'change'||this_code ==='stage' || this_code === 'contract') && (!flow.groupList || (flow.groupList && flow.groupList.length === 0)) ?
- `<span class="pl-3"><a href="javascript:void(0);" class="show-spzsave" data-code="${this_code}"><i class="fa fa-save"></i> 存为审批组</a></span>\n` : '';
- _self.parents('ul').append('<li>\n' +
- ' <span class="pl-3"><a href="javascript:void(0);" class="add-audit" ><i class="fa fa-plus"></i> 添加流程</a></span>\n' + addGroupHtml +
- ' </li>');
- }
- _self.parents('li').html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, prop.audit_order));
- } else {
- _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');
- }
- });
- }
- });
- // 移除审批人
- $('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_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
- const prop = {
- status: this_status,
- code: sp_type[this_code],
- audit_id: id,
- type: 'del',
- };
- const _self = $(this);
- postData('/sp/' + spid + '/shenpi/audit/save', prop, function (data) {
- if (this_status === sp_status.gdspl) {
- const index = _self.parents('li').index();
- const auditGroup = auditUtils.removeAudit(this_code, id, index);
- if (auditGroup) {
- _self.parents('li').html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, index + 1));
- } else {
- 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) {
- _selflc.children('ul').html(auditUtils.getAuditGroupHtml(this_code, [], 1));
- } 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_code);
- addhtml += '</ul>\n';
- _self.parents('.lc-show').html(addhtml);
- }
- })
- });
- // 固定审批流-添加流程
- $('body').on('click', '.add-audit', function () {
- const num = $(this).parents('ul').children('li').length;
- const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
- //const addhtml = makeSelectAudit(this_code, transFormToChinese(num));
- const addhtml = auditUtils.getAuditGroupHtml(this_code, [], num);
- $(this).parents('ul').append(addhtml);
- $(this).parents('li').remove();
- });
- // $('body').on('click', '.set-otherTender', function () {
- // const this_code = $(this).data('code');
- // const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
- // const lis = $(this).siblings('.lc-show').find('li');
- // const auditList = [], aidList = [];
- //
- // const flow = sp_lc.find(x => { return x.code === this_code; });
- // lis.each((i, li) => {
- // const removes = $(li).find('.remove-audit');
- // if (removes.length === 0) return;
- //
- // const select = $(li).find('select[class*="audit-type-key"]');
- // const audit_type = select.length > 0 ? parseInt(select.val()) : 1;
- // const multiData = flow.auditGroupList.find(x => { return x[0].audit_order == i+1; });
- // for (const remove of removes) {
- // const auditData = { audit_id: parseInt(remove.getAttribute('data-id')), audit_type, audit_order: i + 1 };
- // const removeMultiData = multiData.find(x => { return x.audit_id === auditData.audit_id; });
- // auditData.audit_group = removeMultiData ? removeMultiData.audit_group : '';
- // auditData.audit_group_order = removeMultiData ? removeMultiData.audit_group_order : 0;
- // auditData.audit_group_limit = removeMultiData ? removeMultiData.audit_group_limit : 0;
- // auditList.push(auditData);
- // aidList.push(parseInt(remove.getAttribute('data-id')));
- // }
- // });
- // $('#shenpi-name').text($(this).data('name'));
- // $('#shenpi_code').val(this_code);
- // $('#shenpi_status').val(this_status);
- // $('#shenpi_auditors').val(JSON.stringify(auditList));
- // $('#search-audit').val('');
- // $('#search-result').text('0/0');
- // $('#up-search').attr('disabled', true);
- // $('#down-search').attr('disabled', true);
- // });
- // $('#save-other-tender').click(function () {
- // $(this).attr('disabled', true);
- // const num = $('#tender-list input:checked').length;
- // if (num < 2) {
- // toastr.warning('请选择需要设置审批同步的标段');
- // $(this).removeAttr('disabled');
- // return;
- // }
- // const data = {
- // type: 'copy2ot',
- // status: parseInt($('#shenpi_status').val()),
- // code: $('#shenpi_code').val(),
- // };
- // if(data.status !== shenpi_status.gdspl) {
- // data.auditList = JSON.parse($('#shenpi_auditors').val());
- // }
- // // 获取已选中的标段
- // const tenderList = [];
- // for (let i = 0; i < num; i++) {
- // const tid = parseInt($('#tender-list input:checked').eq(i).data('tid'));
- // if (tid !== cur_tenderid) {
- // tenderList.push(tid);
- // }
- // }
- // data.tidList = tenderList.join(',');
- // postData('/sp/' + spid + '/shenpi/audit/save', data, function () {
- // toastr.success('设置成功');
- // setTimeout(function () {
- // window.location.reload();
- // }, 1000)
- // })
- // });
- $('body').on('click', '.set-otherShenpi', function () {
- let canSetOther = true;
- const this_code = $(this).data('code');
- // if (['stage', 'change'].indexOf(this_code) !== -1) {
- // const select = $(this).siblings('.lc-show').find('select[class*="audit-type-key"]');
- // select.each((i, s) => {
- // if (s.value !== '1') canSetOther = false;
- // });
- // }
- // if (!canSetOther) {
- // toastr.warning('该流程含有会签或签,不可同步至其他流程');
- // $('#batch2').modal('hide');
- // return;
- // }
- const this_status = parseInt($(this).siblings('.lc-show').siblings('.form-group').find('input:checked').val());
- const copyFlow = [];
- const flow = $('li.d-flex', $(this).siblings('.lc-show'));
- for (const f of flow) {
- const audit_type = $('select', f).val() || 1;
- const auditors = $('.remove-audit', f);
- if (auditors.length === 0) continue;
- const aid = [];
- for (const a of auditors) {
- aid.push(a.getAttribute('data-id'));
- }
- copyFlow.push(`${audit_type}:${aid.join(',')}`);
- }
- const html = getShenpiHtml(this_code);
- $('#shenpi-name2').text($(this).data('name'));
- $('#shenpi_code2').val(this_code);
- $('#shenpi_status2').val(this_status);
- $('#shenpi_auditors2').val(copyFlow.join(';'));
- $('#shenpi-list').html(html);
- setTimeout(function () { $("#shenpi-list [data-toggle='tooltip']").tooltip(); },800);
- $('#batch2').modal('show');
- });
- $('#save-other-shenpi').click(function () {
- $(this).attr('disabled', true);
- const num = $('#shenpi-list input:checked').length;
- if (num < 1) {
- toastr.warning('请选择需要设置审批同步的流程');
- $(this).removeAttr('disabled');
- return;
- }
- const data = {
- type: 'copy2os',
- status: parseInt($('#shenpi_status2').val()),
- code: $('#shenpi_code2').val(),
- };
- if(data.status !== shenpi_status.gdspl) {
- data.flowList = $('#shenpi_auditors2').val();
- }
- // 获取已选中的标段
- const shenpiList = [];
- for (let i = 0; i < num; i++) {
- const code = $('#shenpi-list input:checked').eq(i).data('code');
- shenpiList.push(code);
- }
- data.shenpiList = shenpiList.join(',');
- postData('/sp/' + spid + '/shenpi/audit/save', data, function () {
- toastr.success('设置成功');
- setTimeout(function () {
- window.location.reload();
- }, 1000)
- })
- });
- // 设置会签、或签
- $('body').on('change', 'select[class*="audit-type-key"]', function() {
- const removes = $(this).parents('.d-flex').find('.remove-audit');
- if (removes.length === 0) return;
- const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
- const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
- const ids = [];
- const liParent = $(this).parents('li');
- removes.each((i, r) => { ids.push(parseInt(r.getAttribute('data-id'))); });
- const prop = {
- status: this_status,
- code: sp_type[this_code],
- audit_id: ids,
- audit_type: parseInt(this.value),
- type: 'audit-type',
- };
- if (prop.audit_type === auditType.key.common && ids.length > 1) {
- toastr.warning('设置个人审批前请先删除多余的审批人');
- this.value = this.getAttribute('data-type');
- return;
- }
- const _self = this;
- postData('/sp/' + spid + '/shenpi/audit/save', prop, function () {
- _self.setAttribute('data-type', _self.value);
- const auditGroup = auditUtils.setAuditType(this_code, prop.audit_type, liParent.index());
- liParent.html(auditUtils.getAuditGroupInnerHtml(this_code, auditGroup, liParent.index() + 1));
- });
- });
- class AuditUnion {
- constructor() {
- this.spread = SpreadJsObj.createNewSpread($('#union-spread')[0]);
- this.sheet = this.spread.getActiveSheet();
- this.tree = createNewPathTree('base', {
- id: 'ledger_id',
- pid: 'ledger_pid',
- order: 'order',
- level: 'level',
- rootId: -1,
- });
- this.selectUnion = [{ value: 0, text: '' }];
- this.spreadSetting = {
- cols: [
- {title: '编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 165, formatter: '@', cellType: 'tree', readOnly: true },
- {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 185, formatter: '@', readOnly: true },
- {title: '协同人', colSpan: '1', rowSpan: '1', field: 'audit_id', hAlign: 1, width: 100, cellType: 'customizeCombo', comboItems: this.selectUnion },
- ],
- emptyRows: 0,
- headRows: 1,
- headRowHeight: [32],
- defaultRowHeight: 21,
- headerFont: '12px 微软雅黑',
- font: '12px 微软雅黑',
- };
- sjsSettingObj.setFxTreeStyle(this.spreadSetting, sjsSettingObj.FxTreeStyle.jz);
- SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
- const self = this;
- SpreadJsObj.addDeleteBind(this.spread, function() { return; });
- SpreadJsObj.selChangedRefreshBackColor(this.sheet);
- this.spread.bind(spreadNS.Events.EditEnded, function(e, info) {
- const node = SpreadJsObj.getSelectObject(info.sheet);
- if (!node) return;
- const refreshAuditId = [];
- if (node.audit_id) refreshAuditId.push(node.audit_id);
- const col = info.sheet.zh_setting.cols[info.col];
- node[col.field] = info.editingText;
- if (node.audit_id) refreshAuditId.push(node.audit_id);
- self.refreshUnionCount(refreshAuditId);
- });
- $('#union').on('shown.bs.modal', function() {
- self.spread.refresh();
- });
- $('#union-ok').click(function() {
- const data = self.getUnionAuditLedgerData();
- postData(`/sp/${spid}/shenpi/union/save`, data, function(result) {
- $('#union').modal('hide');
- });
- });
- $('body').on('click', '[name=clear-union]', function() {
- const aid = parseInt(this.getAttribute('aid'));
- for (const node of self.tree.nodes) {
- if (node.audit_id === aid) node.audit_id = 0;
- }
- SpreadJsObj.reloadColData(self.sheet, 2);
- self.refreshUnionCount(aid);
- });
- }
- _refreshUnionTree() {
- const ledgerAss = {};
- for (const a of this.auditors) {
- a.lid.forEach(l => { ledgerAss[l] = a; });
- }
- for (const n of this.tree.nodes) {
- const la = ledgerAss[n.ledger_id];
- n.audit_id = la ? la.audit_id : 0;
- n.audit_name = la ? la.name : '';
- }
- SpreadJsObj.reloadColData(this.sheet, 2);
- }
- setUnionAuditors(auditors) {
- this.auditors = auditors;
- this.selectUnion.length = 1;
- const html = [];
- for (const auditor of auditors) {
- auditor.lid = auditor.audit_ledger_id ? auditor.audit_ledger_id.split(',') : [];
- html.push(`<tr><td>${auditor.name}</td><td>${auditor.company}</td><td><span aid="${auditor.audit_id}">${auditor.lid.length}</span><button class="ml-2 btn btn-sm btn-outline-danger" name="clear-union" aid="${auditor.audit_id}">清空</button></td></tr>`);
- this.selectUnion.push({ value: auditor.audit_id, text: auditor.name });
- }
- $('#union_table').html(html.join(''));
- this._refreshUnionTree();
- }
- refreshUnionCount(auditId) {
- const auditIds = auditId instanceof Array ? auditId : [auditId];
- for (const aid of auditIds) {
- const unionNodes = this.tree.nodes.filter(x => { return x.audit_id === aid; });
- $(`span[aid=${aid}]`).html(unionNodes.length);
- }
- }
- loadUnionData(sp_type, audit_order) {
- const data = { sp_type, audit_order };
- if (!this.loaded) data.ledger = 1;
- const self = this;
- postData(`/sp/${spid}/shenpi/union/load`, data, function(result) {
- self.loaded = true;
- if (result.ledgerList) {
- self.tree.loadDatas(result.ledgerList);
- SpreadJsObj.loadSheetData(self.sheet, SpreadJsObj.DataType.Tree, self.tree);
- }
- self.setUnionAuditors(result.unionAuditors);
- if (self.auditors.length > 0) {
- $('#union').modal('show');
- } else {
- toastr.warning(`${audit_order}审未添加任何协同人,请先添加协同人再分配协同台账`);
- }
- });
- }
- getUnionAuditLedgerData() {
- this.auditors.forEach(a => { a.lid = []; });
- for (const node of this.tree.nodes) {
- if (node.audit_id > 0) {
- const relaAudit = this.auditors.find(x => { return x.audit_id === node.audit_id; });
- if (relaAudit) relaAudit.lid.push(node.ledger_id);
- }
- }
- return this.auditors.map(a => {
- return { id: a.id, audit_ledger_id: a.lid.join(',') };
- });
- }
- }
- const auditUnion = new AuditUnion();
- $('body').on('click', '[name=union-set]', function() {
- auditUnion.loadUnionData(this.getAttribute('sp_type'), this.getAttribute('audit_order'));
- });
- class AuditMulti {
- constructor() {
- this.spread = SpreadJsObj.createNewSpread($('#multi-spread')[0]);
- this.sheet = this.spread.getActiveSheet();
- this.spreadSetting = {
- cols: [
- {title: '审批人', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 1, width: 80, formatter: '@', readOnly: true },
- {title: '分组/部门', colSpan: '1', rowSpan: '1', field: 'audit_group', hAlign: 0, width: 100, formatter: '@' },
- {title: '顺序', colSpan: '1', rowSpan: '1', field: 'audit_group_order', hAlign: 1, width: 80 },
- {title: '受限', colSpan: '1', rowSpan: '1', field: 'audit_group_limit', hAlign: 1, width: 60, cellType: 'checkbox' },
- {title: '允许退回', colSpan: '1', rowSpan: '1', field: 'audit_checkno_valid', hAlign: 1, width: 60, cellType: 'checkbox' },
- {title: '最少审批', colSpan: '1', rowSpan: '1', field: 'audit_group_need', hAlign: 1, width: 80 },
- ],
- emptyRows: 0,
- headRows: 1,
- headRowHeight: [32],
- defaultRowHeight: 21,
- headerFont: '12px 微软雅黑',
- font: '12px 微软雅黑',
- };
- SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
- const self = this;
- SpreadJsObj.selChangedRefreshBackColor(this.sheet);
- $('#multi').on('shown.bs.modal', function() {
- self.spread.refresh();
- });
- $('#multi-ok').click(function() {
- const data = self.getAuditData();
- if (self.audit_type === auditType.key.and) {
- const exist = !data[0].audit_group_order ? data.find(x => { return !!x.audit_group_order; }) : data.find(x => { return !x.audit_group_order; });
- if (exist) {
- toastr.error('如需设置顺序,所有审批人均应配置顺序');
- return;
- }
- } else if (self.audit_type === auditType.key.multi) {
- const exist = data.find(x => { return !x.audit_group || !x.audit_group_order; });
- if (exist) {
- toastr.error('分组审批时,分组/部门、顺序均不可为空');
- return;
- }
- } else if (self.audit_type === auditType.key.or) {
- for (const d of data) {
- if (!d.audit_group_need) {
- toastr.error('或签必须设置最少审批人数');
- return;
- }
- if (d.audit_group_need < 1 || d.audit_group_need >= data.length) {
- toastr.error('最少审批人数必须大于0,小于审批人数');
- return;
- }
- }
- }
- postData(`/sp/${spid}/shenpi/multi/save`, data, function(result) {
- const flow = sp_lc.find(x => { return x.code === self.sp_type; });
- const multiData = flow.auditGroupList.find(x => { return x[0].audit_order == self.audit_order});
- for (const d of result) {
- const md = multiData.find(x => { return x.id === d.id; });
- if (!md) continue;
- for (const prop in d) {
- md[prop] = d[prop];
- }
- }
- multiData.sort((a, b) => {
- if (a.audit_group === b.audit_group) {
- return a.audit_group_order - b.audit_group_order;
- } else {
- return a.audit_group === b.audit_group ? 0 : (a.audit_group < b.audit_group ? -1 : 1)
- }
- });
- $('#multi').modal('hide');
- $(self.multiBtn).parent().parent().html(auditUtils.getAuditGroupInnerHtml(self.sp_type, multiData, self.audit_order));
- });
- });
- }
- loadData(audit_type, sp_type, audit_order, multiBtn) {
- this.audit_type = audit_type;
- if (this.audit_type === auditType.key.multi) {
- $('#multi-title').html('分组审批');
- } else if (this.audit_type === auditType.key.and) {
- $('#multi-title').html('会签设置');
- } else if (this.audit_type === auditType.key.or) {
- $('#multi-title').html('或签设置');
- }
- $('[name=set-hint]').hide();
- $(`[name=set-hint][htype=${audit_type}]`).show();
- this.multiBtn = multiBtn;
- this.sp_type = sp_type;
- this.audit_order = audit_order;
- const flow = sp_lc.find(x => { return x.code === sp_type; });
- const multiData = flow.auditGroupList.find(x => { return x[0].audit_order == audit_order});
- this.data = JSON.parse(JSON.stringify(multiData));
- const typeNeedCol = [
- { key: auditType.key.multi, cols: ['name', 'audit_group', 'audit_group_limit', 'audit_group_order', 'audit_checkno_valid'] },
- { key: auditType.key.and, cols: ['name', 'audit_group_order', 'audit_checkno_valid'] },
- { key: auditType.key.or, cols: ['name', 'audit_group_need'] },
- ];
- const needCol = typeNeedCol.find(x => { return x.key === this.audit_type; });
- this.sheet.zh_setting.cols.forEach(c => {
- c.visible = needCol.cols.indexOf(c.field) >= 0;
- });
- SpreadJsObj.refreshColumnVisible(this.sheet);
- SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Data, this.data);
- $('#multi').modal('show');
- }
- getAuditData() {
- const sheet = this.sheet;
- const col = { group: 1, order: 2, limit: 3, checkno: 4, need: 5, };
- const updateData = this.data.map((x, i) => {
- const data = { id: x.id };
- data.audit_group = this.audit_type === auditType.key.multi ? sheet.getText(i, col.group) : '';
- const order = sheet.getText(i, col.order);
- data.audit_group_order = order ? _.parseInt(order) || 0 : 0;
- data.audit_group_limit = this.audit_type === auditType.key.multi ? (sheet.getValue(i, col.limit) ? 1 : 0) : 0;
- data.audit_checkno_valid = sheet.getValue(i, col.checkno) ? 1 : 0;
- const need = sheet.getText(i, col.need);
- data.audit_group_need = this.audit_type === auditType.key.or ? (need ? _.parseInt(need) || 1 : 1) : 1;
- return data;
- });
- return updateData;
- }
- }
- const auditMulti = new AuditMulti();
- $('body').on('click', '[name=multi-set]', function() {
- auditMulti.loadData(auditType.key.multi, this.getAttribute('sp_type'), this.getAttribute('audit_order'), this);
- });
- $('body').on('click', '[name=and-set]', function() {
- auditMulti.loadData(auditType.key.and, this.getAttribute('sp_type'), this.getAttribute('audit_order'), this);
- });
- $('body').on('click', '[name=or-set]', function() {
- auditMulti.loadData(auditType.key.or, this.getAttribute('sp_type'), this.getAttribute('audit_order'), this);
- });
- $.subMenu({
- menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
- toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
- key: 'menu.1.0.0',
- miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
- callback: function (info) {
- if (info.mini) {
- $('.panel-title').addClass('fluid');
- $('#sub-menu').removeClass('panel-sidebar');
- } else {
- $('.panel-title').removeClass('fluid');
- $('#sub-menu').addClass('panel-sidebar');
- }
- autoFlashHeight();
- }
- });
- // let timer2 = null;
- // let oldSearchVal2 = null;
- // $('body').on('input propertychange', '#batch input[name="audit-name"]', function(e) {
- // oldSearchVal2 = e.target.value;
- // timer2 && clearTimeout(timer2);
- // timer2 = setTimeout(() => {
- // const newVal = $(this).val();
- //
- // const resultLength = $('#tender-list').find('.result').length;
- // if (resultLength > 0) {
- // let content = $('#tender-list').html();
- // const replaceStr = $('#tender-list').find('.result').eq(0).html();
- // const regExp2 = new RegExp('<span class="result" style="background: yellow;">' + replaceStr + '</span>', 'g');
- // content = content.replace(regExp2, replaceStr);
- // const regExp3 = new RegExp('<span class="result" style="background: orange;">' + replaceStr + '</span>', 'g');
- // content = content.replace(regExp3, replaceStr);
- // $('#tender-list').html(content);
- // }
- // $('#search-result').text('0/0');
- // $('#up-search').attr('disabled', true);
- // $('#down-search').attr('disabled', true);
- // if (newVal && newVal === oldSearchVal2) {
- // const regExp = new RegExp(newVal, 'g');
- // for (let i = 0; i < $('#tender-list tr').length; i++) {
- // if (_.includes($('#tender-list tr').eq(i).children('td').eq(2).html(), newVal)) {
- // $('#tender-list tr').eq(i).children('td').eq(2).html($('#tender-list tr').eq(i).children('td').eq(2).html().replace(regExp, '<span class="result" style="background: yellow;">' + newVal + '</span>'))
- // }
- // }
- // const resultLength2 = $('#tender-list').find('.result').length;
- // if (resultLength2 > 0) {
- // $('#tender-list').find('.result').eq(0).css('background', 'orange');
- // $('#search-result').text('1/' + resultLength2);
- // $('#up-search').attr('disabled', false);
- // $('#down-search').attr('disabled', false);
- // }
- // }
- // if($('#tender-list').find('.result').length > 0) {
- // const X = $('#tender-list').find('.result').eq(0).offset().top;
- // $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() - 30);
- // }
- // }, 400);
- // });
- // $('#up-search').on('click', function () {
- // const cur = parseInt($('#search-result').text().split('/')[0]);
- // const total = parseInt($('#search-result').text().split('/')[1]);
- // const now = cur - 1 !== 0 ? cur - 1: total;
- // $('#tender-list').find('.result').eq(cur-1).css('background', 'yellow');
- // $('#tender-list').find('.result').eq(now-1).css('background', 'orange');
- // // $('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html().replace('<span class="result" style="background:orange;">', '<span class="result" style="background:yellow;">'))
- // // $('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html().replace('<span class="result" style="background:yellow;">', '<span class="result" style="background:orange;">'))
- // $('#search-result').text(now + '/' + total);
- // const X = $('#tender-list').find('.result').eq(now-1).offset().top;
- // $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() - 30);
- // });
- //
- // $('#down-search').on('click', function () {
- // const cur = parseInt($('#search-result').text().split('/')[0]);
- // const total = parseInt($('#search-result').text().split('/')[1]);
- // const now = cur + 1 > total ? 1: cur + 1;
- // $('#tender-list').find('.result').eq(cur-1).css('background', 'yellow');
- // $('#tender-list').find('.result').eq(now-1).css('background', 'orange');
- // // $('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html().replace('<span class="result" style="background:orange;">', '<span class="result" style="background:yellow;">'))
- // // $('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html().replace('<span class="result" style="background:yellow;">', '<span class="result" style="background:orange;">'))
- // $('#search-result').text(now + '/' + total);
- // const X = $('#tender-list').find('.result').eq(now-1).offset().top;
- // $('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() -30);
- // });
- // 审批组
- $('body').on('click', '.show-spzsave', function () {
- const this_code = $(this).attr('data-code');
- const groupId = $(this).attr('data-group') || null;
- const flow = sp_lc.find(x => { return x.code === this_code; });
- $('#save-code').val(this_code);
- const group = groupId ? flow.groupList.find(x => { return x.id === parseInt(groupId); }) : null;
- if (group) {
- $('#save-group-id').val(group.id);
- $('#spzsave input[name="group_name"]').val(group.name);
- $('#show-delete-group-btn').show();
- } else {
- $('#save-group-id').val('');
- $('#spzsave input[name="group_name"]').val('');
- $('#show-delete-group-btn').hide();
- }
- if (this_code === 'contract') {
- if (group) {
- $('#show-contract-type input').each(function () {
- if (group.change_type[$(this).data('type')]) {
- $(this).prop('checked', true);
- } else {
- $(this).prop('checked', false);
- }
- });
- } else {
- $('#show-contract-type input').each(function () {
- $(this).prop('checked', false);
- });
- $('#show-contract-type input[data-type="contract"]').prop('checked', true);
- }
- $('#show-contract-type input').removeAttr('disabled');
- $('#show-contract-type').show();
- } else {
- $('#show-contract-type input').attr('disabled', true);
- $('#show-contract-type').hide();
- }
- $('#spzsave').modal('show');
- });
- $('#save-group-btn').click(function () {
- const name = _.trim($('#spzsave input[name="group_name"]').val());
- if (!name) {
- toastr.error('审批组名称不能为空');
- return false;
- }
- if (name.length > 50) {
- toastr.error('审批组名称不能超过50个字符');
- return false;
- }
- const code = $('#save-code').val();
- const prop = {
- type: 'save-group',
- name,
- code,
- }
- const groupId = $('#save-group-id').val();
- const flow = sp_lc.find(x => { return x.code === code; });
- if (flow.groupList && flow.groupList.length >= 0 && _.findIndex(flow.groupList, function (item) {
- return item.name === name && item.id !== parseInt(groupId);
- }) !== -1) {
- toastr.error('审批组名称已存在, 请更改名称');
- return false;
- }
- if (groupId) {
- const group = groupId ? flow.groupList.find(x => { return x.id === parseInt(groupId); }) : null;
- if (!group) {
- toastr.error('审批组不存在');
- return false;
- }
- prop.groupId = group.id;
- }
- if (code === 'change') {
- const change_type = {};
- let change_flag = false;
- $('#show-change-type input').each(function () {
- change_type[$(this).data('type')] = $(this).prop('checked');
- if ($(this).prop('checked')) {
- change_flag = true;
- }
- });
- if (!change_flag) {
- toastr.error('请至少选择一种变更显示模块');
- return false;
- }
- prop.change_type = change_type;
- } else if (code === 'contract') {
- const change_type = {};
- let contract_flag = false;
- $('#show-contract-type input').each(function () {
- change_type[$(this).data('type')] = $(this).prop('checked');
- if ($(this).prop('checked')) {
- contract_flag = true;
- }
- });
- if (!contract_flag) {
- toastr.error('请至少选择一种合同显示模块');
- return false;
- }
- prop.change_type = change_type;
- }
- console.log(prop);
- postData('/sp/' + spid + '/shenpi/audit/save', prop, function (data) {
- flow.auditGroupList = data.group.auditGroupList || [];
- if (groupId) {
- const index = flow.groupList.findIndex(x => { return x.id === parseInt(groupId); });
- flow.groupList[index] = data.group;
- } else {
- if (!flow.groupList) flow.groupList = [];
- for (const g of flow.groupList) {
- g.is_select = 0;
- }
- flow.groupList.push(data.group);
- }
- // 配置页面
- let addhtml = auditUtils.getGroupHtml(flow, code);
- addhtml += '<ul class="list-unstyled">\n';
- addhtml += auditUtils.getgdsplHtml(flow, code);
- addhtml += '</ul>\n';
- $('.' + code + '_div').children('.lc-show').html(addhtml);
- $('#spzsave').modal('hide');
- });
- });
- // 切换审批组
- $('body').on('change', '.group-list', function () {
- const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
- const flow = sp_lc.find(x => { return x.code === this_code; });
- const groupId = parseInt($(this).val());
- const _self = $(this);
- const prop = {
- type: 'change-group',
- groupId,
- }
- postData('/sp/' + spid + '/shenpi/audit/save', prop, function (data) {
- flow.groupList.forEach(function (item) {
- item.is_select = 0;
- });
- const group = flow.groupList.find(x => { return x.id === groupId; });
- group.is_select = 1;
- flow.auditGroupList = group.auditGroupList;
- const addhtml = auditUtils.getgdsplHtml(flow, this_code);
- _self.parents('.lc-show').children('ul').html(addhtml);
- _self.parents('.lc-show').find('.edit-spzsave').attr('data-group', groupId);
- });
- });
- $('#show-delete-group-btn').click(function () {
- const code = $('#save-code').val();
- const groupId = $('#save-group-id').val();
- const flow = sp_lc.find(x => { return x.code === code; });
- const group = groupId ? flow.groupList.find(x => { return x.id === parseInt(groupId); }) : null;
- if (!group) {
- toastr.error('该审批组不存在');
- return false;
- }
- $('#delete-group-name').text(group.name);
- $('#delete-group-id').val(group.id);
- $('#delete-code').val(code);
- $('#spzsave').modal('hide');
- $('#spzdelete').modal('show');
- });
- $('#delete-group-btn').click(function () {
- const code = $('#delete-code').val();
- const groupId = $('#delete-group-id').val();
- const flow = sp_lc.find(x => { return x.code === code; });
- const group = groupId ? flow.groupList.find(x => { return x.id === parseInt(groupId); }) : null;
- if (!group) {
- toastr.error('该审批组不存在');
- return false;
- }
- const prop = {
- type: 'delete-group',
- groupId: group.id,
- }
- console.log(prop);
- postData('/sp/' + spid + '/shenpi/audit/save', prop, function (data) {
- // const flow = findSplc(code);
- const index = flow.groupList.findIndex(x => { return x.id === group.id; });
- flow.groupList.splice(index, 1);
- flow.auditGroupList = flow.groupList.length > 0 ? flow.groupList[0].auditGroupList : [];
- if (flow.groupList.length > 0) flow.groupList[0].is_select = 1;
- // 配置页面
- let addhtml = auditUtils.getGroupHtml(flow, code);
- addhtml += '<ul class="list-unstyled">\n';
- addhtml += auditUtils.getgdsplHtml(flow, code);
- addhtml += '</ul>\n';
- $('.' + code + '_div').children('.lc-show').html(addhtml);
- $('#spzdelete').modal('hide');
- });
- });
- });
- // 审批流程-审批人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(code, i = '终') {
- let divhtml = '';
- accountGroup.forEach((group, idx) => {
- let didivhtml = '';
- if(group) {
- group.groupList.forEach(item => {
- didivhtml += (item.id !== cur_uid || (item.id === cur_uid && needYB.indexOf(code) !== -1)) ? '<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="' + code + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
- ' 选择审批人\n' +
- ' </button>\n' +
- ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_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-code="' + code + '"></div>\n' +
- ' <dl class="list-unstyled book-list">\n' + divhtml +
- ' </dl>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span>\n' +
- ' </span>\n' +
- ' </li>';
- return html;
- }
|