|
@@ -224,7 +224,7 @@ function getShenpiHtml (this_code) {
|
|
$(document).ready(function () {
|
|
$(document).ready(function () {
|
|
let timer = null;
|
|
let timer = null;
|
|
let oldSearchVal = null;
|
|
let oldSearchVal = null;
|
|
- const needYB = ['ledger', 'revise', 'change'];
|
|
|
|
|
|
+ const needYB = ['advance', 'ledger', 'revise', 'change', 'audit-ass'];
|
|
$('body').on('input propertychange', '.gr-search', function(e) {
|
|
$('body').on('input propertychange', '.gr-search', function(e) {
|
|
oldSearchVal = e.target.value;
|
|
oldSearchVal = e.target.value;
|
|
timer && clearTimeout(timer);
|
|
timer && clearTimeout(timer);
|
|
@@ -341,12 +341,17 @@ $(document).ready(function () {
|
|
// 选中审批人
|
|
// 选中审批人
|
|
$('body').on('click', 'dl dd', function () {
|
|
$('body').on('click', 'dl dd', function () {
|
|
const id = parseInt($(this).data('id'));
|
|
const id = parseInt($(this).data('id'));
|
|
- if (id) {
|
|
|
|
- const user = _.find(accountList, function (item) {
|
|
|
|
- return item.id === 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());
|
|
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');
|
|
|
|
if (this_status === sp_status.gdspl) {
|
|
if (this_status === sp_status.gdspl) {
|
|
// 判断是否已存在审批人
|
|
// 判断是否已存在审批人
|
|
const aid_num = $(this).parents('ul').find('.remove-audit').length;
|
|
const aid_num = $(this).parents('ul').find('.remove-audit').length;
|
|
@@ -383,7 +388,7 @@ $(document).ready(function () {
|
|
' </div>\n' +
|
|
' </div>\n' +
|
|
' </span> ' +
|
|
' </span> ' +
|
|
' </span></span></span>\n');
|
|
' </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>');
|
|
|
|
|
|
+ // <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>');
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -605,421 +610,191 @@ $(document).ready(function () {
|
|
})
|
|
})
|
|
});
|
|
});
|
|
|
|
|
|
- const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
|
|
|
|
- const treeSetting = {
|
|
|
|
- id: 'ledger_id',
|
|
|
|
- pid: 'ledger_pid',
|
|
|
|
- order: 'order',
|
|
|
|
- level: 'level',
|
|
|
|
- rootId: -1,
|
|
|
|
- fullPath: 'full_path',
|
|
|
|
- };
|
|
|
|
- const ledgerTree = createNewPathTree('base', treeSetting);
|
|
|
|
-
|
|
|
|
- const ledgerSpreadSetting = {
|
|
|
|
- cols: [
|
|
|
|
- {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 165, formatter: '@', readOnly: true, cellType: 'tree'},
|
|
|
|
- {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@', readOnly: true},
|
|
|
|
- {title: '密码', colSpan: '1', rowSpan: '2', field: 'pwd', hAlign: 0, width: 100, formatter: '@', getValue:'getValue.pwd', readOnly: 'readOnly.pwd'},
|
|
|
|
- ],
|
|
|
|
- emptyRows: 0,
|
|
|
|
- headRows: 1,
|
|
|
|
- headRowHeight: [25, 25],
|
|
|
|
- defaultRowHeight: 21,
|
|
|
|
- headerFont: '12px 微软雅黑',
|
|
|
|
- font: '12px 微软雅黑',
|
|
|
|
- // readOnly: true,
|
|
|
|
- localCache: {
|
|
|
|
- key: 'ledger-cooperation',
|
|
|
|
- colWidth: true,
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- const ledgerCol = {
|
|
|
|
- getValue: {
|
|
|
|
- pwd: function (data) {
|
|
|
|
- let txt = '';
|
|
|
|
- // console.log(data);
|
|
|
|
- // if (data.is_leaf) {
|
|
|
|
- if (data.pwd && data.pwd !== '' && data.pwd !== null) {
|
|
|
|
- txt = data.pwd;
|
|
|
|
- } else if(data.can_edit) {
|
|
|
|
- txt = '请输入密码';
|
|
|
|
|
|
+ class AuditAss {
|
|
|
|
+ constructor() {
|
|
|
|
+ this.spread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
|
|
|
|
+ this.sheet = this.spread.getActiveSheet();
|
|
|
|
+ this.tree = createNewPathTree('base', {
|
|
|
|
+ id: 'ledger_id',
|
|
|
|
+ pid: 'ledger_pid',
|
|
|
|
+ order: 'order',
|
|
|
|
+ level: 'level',
|
|
|
|
+ rootId: -1,
|
|
|
|
+ });
|
|
|
|
+ this.spreadSetting = {
|
|
|
|
+ cols: [
|
|
|
|
+ {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 165, formatter: '@', cellType: 'tree'},
|
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 185, formatter: '@'},
|
|
|
|
+ {title: '协同人', colSpan: '1', rowSpan: '2', field: 'ass_name', hAlign: 1, width: 100, formatter: '@'},
|
|
|
|
+ ],
|
|
|
|
+ emptyRows: 0,
|
|
|
|
+ headRows: 1,
|
|
|
|
+ headRowHeight: [25, 25],
|
|
|
|
+ defaultRowHeight: 21,
|
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
|
+ font: '12px 微软雅黑',
|
|
|
|
+ readOnly: true,
|
|
|
|
+ localCache: {
|
|
|
|
+ key: 'ledger-cooperation',
|
|
|
|
+ colWidth: true,
|
|
}
|
|
}
|
|
- // }
|
|
|
|
- return txt;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- readOnly: {
|
|
|
|
- pwd: function (data) {
|
|
|
|
- return !data.can_edit;
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- };
|
|
|
|
|
|
+ };
|
|
|
|
+ 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.SelectionChanged, function() {
|
|
|
|
+ self.refreshOperate();
|
|
|
|
+ });
|
|
|
|
|
|
- const ledgerSpreadObj = {
|
|
|
|
- setFontColor: function(row = null) {
|
|
|
|
- if(row) {
|
|
|
|
- const value = ledgerSpread.getActiveSheet().getValue(row, 2);
|
|
|
|
- if (value === '请输入密码') {
|
|
|
|
- ledgerSpread.getActiveSheet().getCell(row, 2).foreColor('#007bff');
|
|
|
|
- } else {
|
|
|
|
- ledgerSpread.getActiveSheet().getCell(row, 2).foreColor('#000');
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- const rowCount = ledgerSpread.getActiveSheet().getRowCount();
|
|
|
|
- for(let i = 0; i < rowCount; i++){
|
|
|
|
- const value = ledgerSpread.getActiveSheet().getValue(i, 2);
|
|
|
|
- if (value === '请输入密码') {
|
|
|
|
- ledgerSpread.getActiveSheet().getCell(i, 2).foreColor('#007bff');
|
|
|
|
- } else {
|
|
|
|
- ledgerSpread.getActiveSheet().getCell(i, 2).foreColor('#000');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- setAllRightPwd: function(uid) {
|
|
|
|
- selects = [];
|
|
|
|
- for (const l of ledgerTree.nodes) {
|
|
|
|
- const coo = _.find(ledger_cooperation_list, { 'ledger_id': l.ledger_id, 'user_id': parseInt(uid) });
|
|
|
|
- if (l.pwd && !coo) {
|
|
|
|
- delete l.pwd;
|
|
|
|
- l.can_edit = true;
|
|
|
|
- selects.push(l);
|
|
|
|
- } else if(coo) {
|
|
|
|
- l.pwd = coo.pwd;
|
|
|
|
- l.can_edit = true;
|
|
|
|
- selects.push(l);
|
|
|
|
- } else if (l.can_edit === false) {
|
|
|
|
- l.can_edit = true;
|
|
|
|
- selects.push(l);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if(selects.length > 0) {
|
|
|
|
- // updateByCanEdit(ledgerTree.nodes, _.filter(ledger_cooperation_list, { user_id: parseInt(uid) }), false);
|
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: selects});
|
|
|
|
- ledgerSpreadObj.refreshTree(ledgerSpread.getActiveSheet(), refreshNode);
|
|
|
|
- ledgerSpreadObj.setFontColor();
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- refreshTree: function (sheet, data) {
|
|
|
|
- SpreadJsObj.massOperationSheet(sheet, function () {
|
|
|
|
- const tree = sheet.zh_tree;
|
|
|
|
- // 处理删除
|
|
|
|
- if (data.delete) {
|
|
|
|
- data.delete.sort(function (x, y) {
|
|
|
|
- return y.deleteIndex - x.deleteIndex;
|
|
|
|
- });
|
|
|
|
- for (const d of data.delete) {
|
|
|
|
- sheet.deleteRows(d.deleteIndex, 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 处理新增
|
|
|
|
- if (data.create) {
|
|
|
|
- const newNodes = data.create;
|
|
|
|
- if (newNodes) {
|
|
|
|
- newNodes.sort(function (a, b) {
|
|
|
|
- return a.index - b.index;
|
|
|
|
- });
|
|
|
|
|
|
+ $('#stage_audits').change(function () {
|
|
|
|
+ self.uid = $(this).val();
|
|
|
|
+ });
|
|
|
|
|
|
- for (const node of newNodes) {
|
|
|
|
- sheet.addRows(node.index, 1);
|
|
|
|
- SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 处理更新
|
|
|
|
- if (data.update) {
|
|
|
|
- const rows = [];
|
|
|
|
- for (const u of data.update) {
|
|
|
|
- rows.push(tree.nodes.indexOf(u));
|
|
|
|
- }
|
|
|
|
- SpreadJsObj.reLoadRowsData(sheet, rows);
|
|
|
|
- }
|
|
|
|
- // 处理展开
|
|
|
|
- if (data.expand) {
|
|
|
|
- const expanded = [];
|
|
|
|
- for (const e of data.expand) {
|
|
|
|
- if (expanded.indexOf(e) === -1) {
|
|
|
|
- const posterity = tree.getPosterity(e);
|
|
|
|
- for (const p of posterity) {
|
|
|
|
- sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
|
|
|
|
- expanded.push(p);
|
|
|
|
- }
|
|
|
|
|
|
+ // 多人协同
|
|
|
|
+ $('#cooperation').on('shown.bs.modal', function () {
|
|
|
|
+ // 执行一些动作...
|
|
|
|
+ // 更新新的多人协同表格信息
|
|
|
|
+ const newUidList = [];
|
|
|
|
+ $('.stage_div ul li').each(function (k, v) {
|
|
|
|
+ const uid = $(v).find('button').eq(0).data('id');
|
|
|
|
+ if(uid) newUidList.push(uid);
|
|
|
|
+ });
|
|
|
|
+ const oldUidList = [];
|
|
|
|
+ $('#stage_audits option').each(function (k, v) {
|
|
|
|
+ const uid = parseInt($(v).val());
|
|
|
|
+ if(k !== 0) oldUidList.push(uid);
|
|
|
|
+ });
|
|
|
|
+ if (!_.isEqual(oldUidList, newUidList)) {
|
|
|
|
+ const yb = _.find(accountList, { 'id': cur_uid });
|
|
|
|
+ let newhtml = '<option value="' + yb.id + '">' + yb.name + '(原报)</option>';
|
|
|
|
+ if(newUidList.length > 0) {
|
|
|
|
+ for (const [i,id] of newUidList.entries()) {
|
|
|
|
+ const audit = _.find(accountList, { 'id': id });
|
|
|
|
+ newhtml += '<option value="' + audit.id + '">' + audit.name + '(' + transFormToChinese(i+1) + '审)</option>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ $('#stage_audits').html(newhtml);
|
|
|
|
+ self.uid = cur_uid;
|
|
}
|
|
}
|
|
|
|
+ self.initLedgerTree(cur_uid);
|
|
});
|
|
});
|
|
- },
|
|
|
|
- enterCell: function(e, info) {
|
|
|
|
- if (info.sheet.zh_setting && info.col === 2) {
|
|
|
|
- if (ledgerSpread.getActiveSheet().getValue(info.row, info.col) !== '') {
|
|
|
|
- const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
- info.sheet.setActiveCell(info.row, 2);
|
|
|
|
- info.sheet.startEdit(true);
|
|
|
|
- }
|
|
|
|
|
|
+ $('#del-audit-ass').click(function () {
|
|
|
|
+ self.setAuditAssist();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ set uid(id) {
|
|
|
|
+ this._uid = parseInt(id);
|
|
|
|
+ this._refreshAss();
|
|
|
|
+ }
|
|
|
|
+ get uid() {
|
|
|
|
+ return this._uid;
|
|
|
|
+ }
|
|
|
|
+ _refreshAssTable(){
|
|
|
|
+ $('#stage_audit').text($("#stage_audits option:selected").text());
|
|
|
|
+ const html = [];
|
|
|
|
+ for (const sa of this.showAssList) {
|
|
|
|
+ const lid = sa.ass_ledger_id ? sa.ass_ledger_id.split(',') : [];
|
|
|
|
+ html.push(`<tr><td>${sa.name}</td><td>${sa.company}</td><td>${lid.length}</td></tr>`);
|
|
}
|
|
}
|
|
- },
|
|
|
|
- editStarting: function (e, info) {
|
|
|
|
- if (info.sheet.zh_setting) {
|
|
|
|
- const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
|
- const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
- ledgerSpread.getActiveSheet().getCell(info.row, 2).foreColor('#000');
|
|
|
|
- if(col.getValue(select) === '请输入密码') {
|
|
|
|
- ledgerSpread.getActiveSheet().setValue(info.row, 2, '');
|
|
|
|
- }
|
|
|
|
|
|
+ $('#coo_table').html(html.join(''));
|
|
|
|
+ }
|
|
|
|
+ _refreshAssTree() {
|
|
|
|
+ const ledgerAss = {};
|
|
|
|
+ for (const sa of this.showAssList) {
|
|
|
|
+ const ledger = sa.ass_ledger_id ? sa.ass_ledger_id.split(',') : [];
|
|
|
|
+ ledger.forEach(l => { ledgerAss[l] = sa; });
|
|
}
|
|
}
|
|
- },
|
|
|
|
- editEnded: function (e, info) {
|
|
|
|
- if (info.sheet.zh_setting) {
|
|
|
|
- const select = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
|
- const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
- const validText = trimInvalidChar(info.editingText);
|
|
|
|
- const user_id = parseInt($('#stage_audits').val());
|
|
|
|
- const orgValue = select[col.field];
|
|
|
|
- const reg = /^[0-9a-zA-Z]+$/;
|
|
|
|
- if(validText !== '' && !reg.test(validText)) {
|
|
|
|
- toastr.error('不能输入非数字和字母的字符');
|
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
- ledgerSpreadObj.setFontColor(info.row);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if((validText === '' && orgValue === undefined) || validText == orgValue) {
|
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
- ledgerSpreadObj.setFontColor(info.row);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- // const num = _.filter(ledger_cooperation_list, { pwd: validText, status: 1, user_id });
|
|
|
|
- // console.log(num, ledger_cooperation_list);
|
|
|
|
- // if(num.length > 0) {
|
|
|
|
- // toastr.error('同一个审批人密码不能相同');
|
|
|
|
- // SpreadJsObj.reLoadRowData(info.sheet, info.row);
|
|
|
|
- // ledgerSpreadObj.setFontColor(info.row);
|
|
|
|
- // return;
|
|
|
|
- // }
|
|
|
|
- select.pwd = validText;
|
|
|
|
- const data = {
|
|
|
|
- type: 'pwd',
|
|
|
|
- ledger_id: select.ledger_id,
|
|
|
|
- user_id,
|
|
|
|
- pwd: validText,
|
|
|
|
- };
|
|
|
|
- info.sheet.setSelection(info.row, 0, 1, 1);
|
|
|
|
- postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function (result) {
|
|
|
|
- const lcindex = _.findIndex(ledger_cooperation_list, { ledger_id: select.ledger_id, user_id });
|
|
|
|
- let flag = false;
|
|
|
|
- if(lcindex !== -1) {
|
|
|
|
- validText === '' ? ledger_cooperation_list.splice(lcindex, 1) : ledger_cooperation_list.splice(lcindex, 1, result);
|
|
|
|
- flag = validText === '';
|
|
|
|
- } else {
|
|
|
|
- ledger_cooperation_list.push(result);
|
|
|
|
- flag = false;
|
|
|
|
- }
|
|
|
|
- $('#cooperation-num').text(ledger_cooperation_list.length);
|
|
|
|
- setLeftTable(ledgerTree.nodes, ledger_cooperation_list, user_id, $('#stage_audits option:selected').text());
|
|
|
|
- selects = [select];
|
|
|
|
- // if(select) {
|
|
|
|
- // setAllChildrenCanEdit(select, flag);
|
|
|
|
- // setParentCanEdit(ledgerTree.nodes, select.ledger_pid, flag);
|
|
|
|
- // }
|
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: selects});
|
|
|
|
- ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
|
|
|
|
- ledgerSpreadObj.setFontColor();
|
|
|
|
- });
|
|
|
|
|
|
+ for (const n of this.tree.nodes) {
|
|
|
|
+ const la = ledgerAss[n.ledger_id];
|
|
|
|
+ n.ass_audit_id = la ? la.ass_user_id : null;
|
|
|
|
+ n.ass_name = la ? la.name : '';
|
|
}
|
|
}
|
|
- },
|
|
|
|
- deletePress: function (sheet) {
|
|
|
|
- return;
|
|
|
|
- },
|
|
|
|
- clipboardPasted(e, info) {
|
|
|
|
- // 禁止复制粘贴
|
|
|
|
- SpreadJsObj.reLoadSheetHeader(ledgerSpread.getActiveSheet());
|
|
|
|
- SpreadJsObj.reLoadSheetData(ledgerSpread.getActiveSheet());
|
|
|
|
- return;
|
|
|
|
|
|
+ SpreadJsObj.reloadColData(this.sheet, 2);
|
|
|
|
+ }
|
|
|
|
+ _refreshAss() {
|
|
|
|
+ this.showAssList = _.filter(this.assList, { 'user_id': parseInt(this.uid) });
|
|
|
|
+ this._refreshAssTable();
|
|
|
|
+ this._refreshAssTree();
|
|
|
|
+ }
|
|
|
|
+ initLedgerTree(uid) {
|
|
|
|
+ if (this.loaded) return;
|
|
|
|
+ this.spread.refresh();
|
|
|
|
+ const self = this;
|
|
|
|
+
|
|
|
|
+ postData('/tender/' + cur_tenderid + '/shenpi/ass/load', {}, function (data) {
|
|
|
|
+ self.loaded = true;
|
|
|
|
+ self.assList = data.auditAssList;
|
|
|
|
+ self.tree.loadDatas(data.ledgerList);
|
|
|
|
+ SpreadJsObj.loadSheetData(self.sheet, SpreadJsObj.DataType.Tree, self.tree);
|
|
|
|
+ self.uid = uid;
|
|
|
|
+ self.refreshOperate();
|
|
|
|
+ }, null, true);
|
|
}
|
|
}
|
|
- };
|
|
|
|
-
|
|
|
|
- sjsSettingObj.setFxTreeStyle(ledgerSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
|
|
|
|
- if (thousandth) sjsSettingObj.setTpThousandthFormat(ledgerSpreadSetting);
|
|
|
|
- SpreadJsObj.initSpreadSettingEvents(ledgerSpreadSetting, ledgerCol);
|
|
|
|
- SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
|
|
|
|
- SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
|
|
|
|
- ledgerSpread.bind(spreadNS.Events.EditStarting, ledgerSpreadObj.editStarting);
|
|
|
|
- ledgerSpread.bind(spreadNS.Events.EditEnded, ledgerSpreadObj.editEnded);
|
|
|
|
- SpreadJsObj.addDeleteBind(ledgerSpread, ledgerSpreadObj.deletePress);
|
|
|
|
- ledgerSpread.bind(spreadNS.Events.ClipboardPasted, ledgerSpreadObj.clipboardPasted);
|
|
|
|
- ledgerSpread.bind(spreadNS.Events.EnterCell, ledgerSpreadObj.enterCell);
|
|
|
|
- let ledger_data, ledger_cooperation_list = [];
|
|
|
|
|
|
+ loadPostData(data) {
|
|
|
|
+ if (data.add) {
|
|
|
|
+ this.assList.push(data.add);
|
|
|
|
+ }
|
|
|
|
+ if (data.del) {
|
|
|
|
+ this.assList.splice(this.assList.findIndex(x => { return x.id === data.del.id }), 1);
|
|
|
|
+ }
|
|
|
|
+ if (data.update) {
|
|
|
|
+ for (const d of data.update) {
|
|
|
|
+ const od = this.assList.find(x => { return x.id === d.id });
|
|
|
|
+ if (!od) continue;
|
|
|
|
|
|
- // 多人协同
|
|
|
|
- $('#cooperation').on('shown.bs.modal', function () {
|
|
|
|
- // 执行一些动作...
|
|
|
|
- // 更新新的多人协同表格信息
|
|
|
|
- const newUidList = [];
|
|
|
|
- $('.stage_div ul li').each(function (k, v) {
|
|
|
|
- const uid = $(v).find('button').eq(0).data('id');
|
|
|
|
- if(uid) newUidList.push(uid);
|
|
|
|
- });
|
|
|
|
- const oldUidList = [];
|
|
|
|
- $('#stage_audits option').each(function (k, v) {
|
|
|
|
- const uid = parseInt($(v).val());
|
|
|
|
- if(k !== 0) oldUidList.push(uid);
|
|
|
|
- });
|
|
|
|
- if (!_.isEqual(oldUidList, newUidList)) {
|
|
|
|
- const yb = _.find(accountList, { 'id': cur_uid });
|
|
|
|
- let newhtml = '<option value="' + yb.id + '">' + yb.name + '(原报)</option>';
|
|
|
|
- if(newUidList.length > 0) {
|
|
|
|
- for (const [i,id] of newUidList.entries()) {
|
|
|
|
- const audit = _.find(accountList, { 'id': id });
|
|
|
|
- newhtml += '<option value="' + audit.id + '">' + audit.name + '(' + transFormToChinese(i+1) + '审)</option>';
|
|
|
|
|
|
+ od.ass_ledger_id = d.ass_ledger_id;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- $('#stage_audits').html(newhtml);
|
|
|
|
- if(ledger_data) {
|
|
|
|
- setLeftTable(ledgerTree.nodes, ledger_cooperation_list, cur_uid, yb.name + '(原报)');
|
|
|
|
- ledgerSpreadObj.setAllRightPwd(cur_uid);
|
|
|
|
|
|
+ this._refreshAss();
|
|
|
|
+ }
|
|
|
|
+ setAuditAssist(assist){
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(this.sheet);
|
|
|
|
+ if (assist && node.ass_audit_id === assist.id) return;
|
|
|
|
+ if (assist && assist.id === this.uid) {
|
|
|
|
+ toastr.warning('请勿添加本人');
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if(!ledger_data) {
|
|
|
|
- postData('/tender/' + cur_tenderid + '/shenpi/ledger/load', {}, function (data) {
|
|
|
|
- ledger_data = true;
|
|
|
|
- const ledgerList = setRightData(data.ledgerList, data.ledgerCooperationList);
|
|
|
|
- ledgerTree.loadDatas(ledgerList);
|
|
|
|
- // treeCalc.calculateAll(ledgerTree);
|
|
|
|
- selects = [];
|
|
|
|
- // updateByCanEdit(ledgerTree.nodes, _.filter(ledger_cooperation_list, { user_id: cur_uid }), false);
|
|
|
|
- ledgerTree.loadPostData({update: selects});
|
|
|
|
- console.log(ledgerTree);
|
|
|
|
- ledger_cooperation_list = data.ledgerCooperationList;
|
|
|
|
- const yb = _.find(accountList, { 'id': cur_uid });
|
|
|
|
- setLeftTable(ledgerTree.nodes, ledger_cooperation_list, cur_uid, yb.name + '(原报)');
|
|
|
|
- SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, ledgerTree);
|
|
|
|
- ledgerSpreadObj.setFontColor();
|
|
|
|
- }, null, true);
|
|
|
|
- }
|
|
|
|
- ledgerSpread.refresh();
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- $('#stage_audits').change(function () {
|
|
|
|
- const uid = $(this).val();
|
|
|
|
- const title = $("#stage_audits option:selected").text();
|
|
|
|
- setLeftTable(ledgerTree.nodes, ledger_cooperation_list, uid, title);
|
|
|
|
- ledgerSpreadObj.setAllRightPwd(uid);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- $('body').on('click', '.del-pwd', function () {
|
|
|
|
- const ledger_id = parseInt($(this).data('lid'));
|
|
|
|
- const user_id = parseInt($(this).data('uid'));
|
|
|
|
- const data = {
|
|
|
|
- type: 'pwd',
|
|
|
|
- user_id,
|
|
|
|
- ledger_id,
|
|
|
|
- pwd: '',
|
|
|
|
- };
|
|
|
|
- postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function (result) {
|
|
|
|
- const lcindex = _.findIndex(ledger_cooperation_list, { ledger_id, user_id });
|
|
|
|
- ledger_cooperation_list.splice(lcindex, 1);
|
|
|
|
- setLeftTable(ledgerTree.nodes, ledger_cooperation_list, user_id, $('#stage_audits option:selected').text());
|
|
|
|
- const select = _.find(ledgerTree.nodes, { ledger_id });
|
|
|
|
- delete select.pwd;
|
|
|
|
- // const refreshNode = ledgerTree.loadPostData({update: select});
|
|
|
|
- selects = [select];
|
|
|
|
- // if(select) {
|
|
|
|
- // setAllChildrenCanEdit(select, true);
|
|
|
|
- // setParentCanEdit(ledgerTree.nodes, select.ledger_pid, true);
|
|
|
|
- // }
|
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: selects});
|
|
|
|
- ledgerSpreadObj.refreshTree(ledgerSpread.getActiveSheet(), refreshNode);
|
|
|
|
- ledgerSpreadObj.setFontColor();
|
|
|
|
- $('#cooperation-num').text(ledger_cooperation_list.length);
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- $('body').on('click', '.edit-pwd', function () {
|
|
|
|
- const pwd = $(this).data('pwd');
|
|
|
|
- const html = `<div class="input-group input-group-sm">
|
|
|
|
- <input type="text" class="form-control" value="${pwd}" placeholder="输入新密码" aria-describedby="button-${$(this).data('lid')}" style="width:50px">
|
|
|
|
- <div class="input-group-append" id="button-${$(this).data('lid')}">
|
|
|
|
- <button class="btn btn-outline-primary confirm-btn" data-pwd="${pwd}" data-lid="${$(this).data('lid')}" data-uid="${$(this).data('uid')}" type="button">确认</button>
|
|
|
|
- <button class="btn btn-outline-secondary cancel-btn" data-pwd="${pwd}" data-lid="${$(this).data('lid')}" data-uid="${$(this).data('uid')}" type="button">取消</button>
|
|
|
|
- </div>
|
|
|
|
- </div>`;
|
|
|
|
- $(this).parents('td').html(html);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- $('body').on('click', '.cancel-btn', function () {
|
|
|
|
- const html = `<p class="mb-0">${$(this).data('pwd')}</p><a href="javascript:void(0);" data-lid="${$(this).data('lid')}" data-uid="${$(this).data('uid')}" data-pwd="${$(this).data('pwd')}" class="edit-pwd">修改</a> <a href="javascript:void(0)" data-lid="${$(this).data('lid')}" data-uid="${$(this).data('uid')}" class="del-pwd text-danger">移除</a>`;
|
|
|
|
- $(this).parents('td').html(html);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- $('body').on('click', '.confirm-btn', function () {
|
|
|
|
- const validText = $(this).parents('td').find('input').val();
|
|
|
|
- const orgValue = $(this).data('pwd');
|
|
|
|
- const ledger_id = parseInt($(this).data('lid'));
|
|
|
|
- const user_id = parseInt($(this).data('uid'));
|
|
|
|
- const reg = /^[0-9a-zA-Z]+$/;
|
|
|
|
- if(!reg.test(validText)) {
|
|
|
|
- toastr.error('不能输入非数字和字母的字符');
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if(validText == orgValue) {
|
|
|
|
- const html = `<p class="mb-0">${$(this).data('pwd')}</p><a href="javascript:void(0);" data-lid="${$(this).data('lid')}" data-uid="${$(this).data('uid')}" data-pwd="${$(this).data('pwd')}" class="edit-pwd">修改</a> <a href="javascript:void(0)" data-lid="${$(this).data('lid')}" data-uid="${$(this).data('uid')}" class="del-pwd text-danger">移除</a>`;
|
|
|
|
- $(this).parents('td').html(html);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- // const num = _.filter(ledger_cooperation_list, { pwd: validText, status: 1, user_id });
|
|
|
|
- // if(num.length > 0) {
|
|
|
|
- // toastr.error('同一个审批人密码不能相同');
|
|
|
|
- // return;
|
|
|
|
- // }
|
|
|
|
- const data = {
|
|
|
|
- type: 'pwd',
|
|
|
|
- ledger_id,
|
|
|
|
- user_id,
|
|
|
|
- pwd: validText,
|
|
|
|
- };
|
|
|
|
- postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function (result) {
|
|
|
|
- const lcindex = _.findIndex(ledger_cooperation_list, { ledger_id, user_id });
|
|
|
|
- ledger_cooperation_list.splice(lcindex, 1, result);
|
|
|
|
- setLeftTable(ledgerTree.nodes, ledger_cooperation_list, user_id, $('#stage_audits option:selected').text());
|
|
|
|
- const select = _.find(ledgerTree.nodes, { ledger_id });
|
|
|
|
- select.pwd = validText;
|
|
|
|
- const refreshNode = ledgerTree.loadPostData({update: select});
|
|
|
|
- ledgerSpreadObj.refreshTree(ledgerSpread.getActiveSheet(), refreshNode);
|
|
|
|
- ledgerSpreadObj.setFontColor();
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
|
|
- // 上传图片
|
|
|
|
- $('body').on('click', '.upload-img', function () {
|
|
|
|
- $(this).siblings('input').trigger('click');
|
|
|
|
- // $('.upload-img-file').trigger('click');
|
|
|
|
- });
|
|
|
|
- $('body').on('change', '.upload-img-file', function () {
|
|
|
|
- const file = this.files[0];
|
|
|
|
- const ext = file.name.toLowerCase().split('.').splice(-1)[0];
|
|
|
|
- const imgStr = /(png|PNG)$/;
|
|
|
|
- if (!imgStr.test(ext)) {
|
|
|
|
- toastr.error('请上传签名大小为600x300,格式PNG透明背景。');
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if ($(this).val()) {
|
|
|
|
- var _self = $(this);
|
|
|
|
- const formData = new FormData();
|
|
|
|
- formData.append('id', $(this).data('id'));
|
|
|
|
- formData.append('file', this.files[0]);
|
|
|
|
- postDataWithFile(window.location.pathname + '/save-sign', formData, function (result) {
|
|
|
|
- _self.siblings('img').attr('src', '/' + result);
|
|
|
|
- _self.siblings('img').show();
|
|
|
|
- _self.siblings('a').removeClass('btn btn-outline-primary btn-sm').addClass('d-inline-flex').text('更改');
|
|
|
|
- _self.val('');
|
|
|
|
- const lcindex = _.findIndex(ledger_cooperation_list, { id: _self.data('id') });
|
|
|
|
- ledger_cooperation_list[lcindex].sign_path = result;
|
|
|
|
- ledger_cooperation_list.splice(lcindex, 1, ledger_cooperation_list[lcindex]);
|
|
|
|
|
|
+ const self = this;
|
|
|
|
+ const data = { type: 'audit-ass'};
|
|
|
|
+ if (assist) {
|
|
|
|
+ const newAss = this.assList.find(x => { return x.ass_user_id === assist.id; });
|
|
|
|
+ if (!newAss) {
|
|
|
|
+ data.add = { user_id: this.uid, ass_user_id: assist.id, name: assist.name, company: assist.company, role: assist.role, ass_ledger_id: node.ledger_id + '' };
|
|
|
|
+ } else {
|
|
|
|
+ data.update = [{ id: newAss.id, ass_ledger_id: newAss.ass_ledger_id + ',' + node.ledger_id}];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (node.ass_audit_id) {
|
|
|
|
+ const orgAss = this.assList.find(x => { return x.ass_user_id === node.ass_audit_id; });
|
|
|
|
+ const rela_lid = orgAss.ass_ledger_id ? orgAss.ass_ledger_id.split(',') : [];
|
|
|
|
+ rela_lid.splice(rela_lid.indexOf(node.ledger_id + ''), 1);
|
|
|
|
+ if (rela_lid.length === 0) {
|
|
|
|
+ data.del = { id: orgAss.id };
|
|
|
|
+ } else {
|
|
|
|
+ if (data.update) data.update = [];
|
|
|
|
+ data.update.push({ id: orgAss.id, ass_ledger_id: rela_lid.join(',')});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function (result) {
|
|
|
|
+ self.loadPostData(result);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- });
|
|
|
|
-
|
|
|
|
|
|
+ refreshOperate() {
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(this.sheet);
|
|
|
|
+ if (node.ass_audit_id) {
|
|
|
|
+ $('#del-audit-ass').show();
|
|
|
|
+ $('#audit-ass_dropdownMenuButton')[0].innerHTML = '替换协同人';
|
|
|
|
+ } else {
|
|
|
|
+ $('#del-audit-ass').hide();
|
|
|
|
+ $('#audit-ass_dropdownMenuButton')[0].innerHTML = '添加协同人';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const auditAss = new AuditAss();
|
|
|
|
|
|
$.subMenu({
|
|
$.subMenu({
|
|
menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
|
|
menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
|
|
@@ -1106,117 +881,4 @@ $(document).ready(function () {
|
|
const X = $('#tender-list').find('.result').eq(now-1).offset().top;
|
|
const X = $('#tender-list').find('.result').eq(now-1).offset().top;
|
|
$('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() -30);
|
|
$('#tender-list').scrollTop(X - $('#tender-list').offset().top + $('#tender-list').scrollTop() -30);
|
|
});
|
|
});
|
|
-
|
|
|
|
- $('body').on('blur', '#coo_table .edit-company', function () {
|
|
|
|
- const id = $(this).data('id');
|
|
|
|
- const newVal = $(this).val();
|
|
|
|
- const cooInfo = _.find(ledger_cooperation_list, { id: id });
|
|
|
|
- if(cooInfo && cooInfo.company !== newVal) {
|
|
|
|
- const data = {
|
|
|
|
- type: 'company',
|
|
|
|
- id,
|
|
|
|
- company: newVal,
|
|
|
|
- };
|
|
|
|
- postData('/tender/' + cur_tenderid + '/shenpi/audit/save', data, function (result) {
|
|
|
|
- const lcindex = _.findIndex(ledger_cooperation_list, { id: id });
|
|
|
|
- cooInfo.company = newVal;
|
|
|
|
- ledger_cooperation_list.splice(lcindex, 1, cooInfo);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
});
|
|
});
|
|
-
|
|
|
|
-function setRightData(datas, coolist) {
|
|
|
|
- const newdatas = [];
|
|
|
|
- const reg = /(^GD([0-9\-]+))|(^([0-9\-]+)$)/;
|
|
|
|
- for (const l of datas) {
|
|
|
|
- // if (reg.test(l.code) && l.level <= 4) {
|
|
|
|
- if (reg.test(l.code)) {
|
|
|
|
- // if(l.level === 4 && l.is_leaf === false) {
|
|
|
|
- // l.is_leaf = true;
|
|
|
|
- // }
|
|
|
|
- const coo = _.find(coolist, { 'ledger_id': l.ledger_id, 'user_id': cur_uid });
|
|
|
|
- if(coo) {
|
|
|
|
- l.pwd = coo.pwd;
|
|
|
|
- }
|
|
|
|
- l.can_edit = true;
|
|
|
|
- newdatas.push(l);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // for (const nd of newdatas) {
|
|
|
|
- // const child = _.find(newdatas, { 'ledger_pid': nd.ledger_id });
|
|
|
|
- // if (!child && !nd.is_leaf) {
|
|
|
|
- // nd.is_leaf = true;
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return newdatas;
|
|
|
|
-}
|
|
|
|
-function updateByCanEdit(datas, coolist, flag) {
|
|
|
|
- for (const coo of coolist) {
|
|
|
|
- const ledgerInfo = _.find(datas, { 'ledger_id': coo.ledger_id });
|
|
|
|
- if(ledgerInfo) {
|
|
|
|
- setAllChildrenCanEdit(ledgerInfo, flag);
|
|
|
|
- // setParentCanEdit(datas, ledgerInfo.ledger_pid, flag);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-function setParentCanEdit(datas, id, flag) {
|
|
|
|
- if(id !== -1) {
|
|
|
|
- const pl = _.find(datas, { 'ledger_id': id });
|
|
|
|
- // 判断父节点下所有子节点有无pwd,有则为false
|
|
|
|
- if (pl) {
|
|
|
|
- const existfalse = _.find(pl.children, function (item) {
|
|
|
|
- return item.can_edit === false || (item.pwd && item.pwd !== '' && item.pwd !== null);
|
|
|
|
- });
|
|
|
|
- pl.can_edit = existfalse ? false : flag;
|
|
|
|
- selects.push(pl);
|
|
|
|
- setParentCanEdit(datas, pl.ledger_pid, flag);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-function setAllChildrenCanEdit(ledgerInfo, flag) {
|
|
|
|
- if (ledgerInfo.children && ledgerInfo.children.length > 0) {
|
|
|
|
- for(const li of ledgerInfo.children) {
|
|
|
|
- if (li.pwd === undefined || li.pwd === null || li.pwd === '') {
|
|
|
|
- li.can_edit = flag;
|
|
|
|
- selects.push(li);
|
|
|
|
- setAllChildrenCanEdit(li, flag);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-function setLeftTable(ledgerList, coolist, uid, title) {
|
|
|
|
- $('#stage_audit').text(title);
|
|
|
|
- const showCooList = _.filter(coolist, { 'user_id': parseInt(uid) });
|
|
|
|
- const removeList = [];
|
|
|
|
- for (const sc of showCooList) {
|
|
|
|
- const info = _.find(ledgerList, { 'ledger_id': sc.ledger_id });
|
|
|
|
- if (info) {
|
|
|
|
- sc.code = info.code;
|
|
|
|
- sc.name = info.name;
|
|
|
|
- } else {
|
|
|
|
- removeList.push(sc);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (removeList.length > 0) {
|
|
|
|
- // 移除
|
|
|
|
- _.pull(showCooList, ...removeList);
|
|
|
|
- console.log(removeList);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let html = '';
|
|
|
|
- // showCooList 需要根据右边台账顺序进行排序
|
|
|
|
- showCooList.sort(function (a, b) {
|
|
|
|
- return _.findIndex(ledgerList, { ledger_id: a.ledger_id }) - _.findIndex(ledgerList, { ledger_id: b.ledger_id });
|
|
|
|
- });
|
|
|
|
- for (const sc of showCooList) {
|
|
|
|
- const pichtml = sc.sign_path ? `<img src="/${sc.sign_path}" width="60"><input type="file" data-id="${sc.id}" class="upload-img-file" style="display: none;"><a href="javascript: void(0);" class="d-inline-flex upload-img">更改</a>`
|
|
|
|
- : `<img src="" style="display: none" width="60"><input type="file" data-id="${sc.id}" class="upload-img-file" style="display: none;"><a href="javascript: void(0);" class="btn btn-outline-primary btn-sm upload-img">上传签名</a>`;
|
|
|
|
- html += `<tr>` +
|
|
|
|
- `<td>${sc.code} ${sc.name}</td>` +
|
|
|
|
- `<td><p class="mb-0">${sc.pwd}</p><a href="javascript:void(0);" data-lid="${sc.ledger_id}" data-uid="${sc.user_id}" data-pwd="${sc.pwd}" class="edit-pwd">修改</a> <a href="javascript:void(0)" data-lid="${sc.ledger_id}" data-uid="${sc.user_id}" class="del-pwd text-danger">移除</a></td>` +
|
|
|
|
- `<td>${pichtml}</td><td><input type="text" class="form-control form-control-sm edit-company" data-id="${sc.id}" value="${sc.company}" placeholder="输入单位名称或备注"></td>` +
|
|
|
|
- `</tr>`;
|
|
|
|
- }
|
|
|
|
- $('#coo_table').html(html);
|
|
|
|
-}
|
|
|