|
|
@@ -302,6 +302,15 @@ $(document).ready(function () {
|
|
|
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>`);
|
|
|
}
|
|
|
@@ -530,7 +539,7 @@ $(document).ready(function () {
|
|
|
const _self = $(this);
|
|
|
postData('/tender/' + cur_tenderid + '/shenpi/audit/save', prop, function (data) {
|
|
|
if (this_status === sp_status.gdspl) {
|
|
|
- const auditGroup = auditUtils.addAudit(this_code, { audit_id: data.audit_id, name: user.name, audit_type: data.audit_type, audit_order: data.audit_order }, prop.audit_order - 1);
|
|
|
+ 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') && (!flow.groupList || (flow.groupList && flow.groupList.length === 0)) ?
|
|
|
@@ -621,14 +630,22 @@ $(document).ready(function () {
|
|
|
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) {
|
|
|
- auditList.push({ audit_id: parseInt(remove.getAttribute('data-id')), audit_type, audit_order: i + 1 });
|
|
|
+ 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')));
|
|
|
}
|
|
|
});
|
|
|
@@ -1100,6 +1117,142 @@ $(document).ready(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(`/tender/${cur_tenderid}/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',
|