|
@@ -5477,13 +5477,28 @@ $(document).ready(() => {
|
|
|
|
|
|
|
|
// 审批退回锁定
|
|
// 审批退回锁定
|
|
|
const spBackLock = (function(){
|
|
const spBackLock = (function(){
|
|
|
- let lockSpread, lockSheet, lockTree;
|
|
|
|
|
|
|
+ let lockSpread, lockSheet, lockTree, auditLockedHis;
|
|
|
|
|
+ let lockType;
|
|
|
const getLockedLid = function() {
|
|
const getLockedLid = function() {
|
|
|
if (!lockTree) return '';
|
|
if (!lockTree) return '';
|
|
|
const lockedLid = lockTree.nodes.filter(x => { return x.locked; }).map(y => { return y.ledger_id; });
|
|
const lockedLid = lockTree.nodes.filter(x => { return x.locked; }).map(y => { return y.ledger_id; });
|
|
|
if (lockedLid.length > 200) throw '锁定的节点过多,请尽量在父项锁定数据';
|
|
if (lockedLid.length > 200) throw '锁定的节点过多,请尽量在父项锁定数据';
|
|
|
return lockedLid.join(',');
|
|
return lockedLid.join(',');
|
|
|
};
|
|
};
|
|
|
|
|
+ const getAuditLocked = function() {
|
|
|
|
|
+ if (!lockTree) return [];
|
|
|
|
|
+ const lockedLid = lockTree.nodes.filter(x => { return x.locked; }).map(y => { return y.ledger_id});
|
|
|
|
|
+ auditLockedHis.forEach(x => {
|
|
|
|
|
+ x.org_locked_lid = x.audit_locked_lid.split(',').map(y => { return parseInt(y); });
|
|
|
|
|
+ x.new_locked_lid = [];
|
|
|
|
|
+ for (const lid in x.org_locked_lid) {
|
|
|
|
|
+ if (lockedLid.indexOf(lid) >= 0) x.new_locked_lid.push(lid);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ const result = auditLockedHis.filter(x => { return x.new_locked_lid.length < x.org_locked_lid.length; })
|
|
|
|
|
+ .map(y => { return { id: y.id, audit_locked_lid: y.new_locked_lid.join(',') }; });
|
|
|
|
|
+ return result;
|
|
|
|
|
+ };
|
|
|
const init = function(setting) {
|
|
const init = function(setting) {
|
|
|
if (lockSpread) return;
|
|
if (lockSpread) return;
|
|
|
lockSpread = SpreadJsObj.createNewSpread($('#sp-lock-spread')[0]);
|
|
lockSpread = SpreadJsObj.createNewSpread($('#sp-lock-spread')[0]);
|
|
@@ -5533,32 +5548,53 @@ $(document).ready(() => {
|
|
|
lockTree.refreshNodeVisible();
|
|
lockTree.refreshNodeVisible();
|
|
|
SpreadJsObj.loadSheetData(lockSheet, SpreadJsObj.DataType.Tree, lockTree);
|
|
SpreadJsObj.loadSheetData(lockSheet, SpreadJsObj.DataType.Tree, lockTree);
|
|
|
|
|
|
|
|
- lockSpread.bind(spreadNS.Events.ButtonClicked, function(e, info) {
|
|
|
|
|
- if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
|
|
|
|
|
|
|
+ if (lockType === 'lock') {
|
|
|
|
|
+ lockSpread.bind(spreadNS.Events.ButtonClicked, function(e, info) {
|
|
|
|
|
+ if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
|
|
|
|
|
|
|
|
- const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
|
- if (col.field !== 'locked') return;
|
|
|
|
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
|
+ if (col.field !== 'locked') return;
|
|
|
|
|
|
|
|
- const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
|
|
- if (node._fixed) {
|
|
|
|
|
- toastr.warning('无权锁定该节点,如需锁定,请在子项尝试');
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- if (!node.locked) {
|
|
|
|
|
- const parents = info.sheet.zh_tree.getAllParents(node);
|
|
|
|
|
- if (parents.find(x => { return x.locked; })) {
|
|
|
|
|
- toastr.warning('父项已锁定,请勿在子项重复锁定');
|
|
|
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
|
|
+ if (node._fixed) {
|
|
|
|
|
+ toastr.warning('无权锁定该节点,如需锁定,请在子项尝试');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- node.locked = !node.locked;
|
|
|
|
|
- SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (!node.locked) {
|
|
|
|
|
+ const parents = info.sheet.zh_tree.getAllParents(node);
|
|
|
|
|
+ if (parents.find(x => { return x.locked; })) {
|
|
|
|
|
+ toastr.warning('父项已锁定,请勿在子项重复锁定');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ node.locked = !node.locked;
|
|
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ lockSpread.bind(spreadNS.Events.ButtonClicked, function(e, info) {
|
|
|
|
|
+ if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
|
|
|
|
|
+
|
|
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
|
|
+ if (col.field !== 'locked') return;
|
|
|
|
|
+
|
|
|
|
|
+ const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
|
|
+ if (!node.locked && !node.org_locked) {
|
|
|
|
|
+ toastr.warning('仅可解锁节点,不可锁定新节点');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ node.locked = !node.locked;
|
|
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$('#sp-lock-ok').click(function() {
|
|
$('#sp-lock-ok').click(function() {
|
|
|
- setting.callback(getLockedLid());
|
|
|
|
|
|
|
+ if (lockType === 'lock') {
|
|
|
|
|
+ setting.callback(getLockedLid());
|
|
|
|
|
+ } else if (lockType === 'unlock') {
|
|
|
|
|
+ setting.callback(getAuditLocked());
|
|
|
|
|
+ }
|
|
|
$('#sp-lock').modal('hide');
|
|
$('#sp-lock').modal('hide');
|
|
|
- $('#sp-back').modal('show');
|
|
|
|
|
});
|
|
});
|
|
|
$('#sp-lock').on('shown.bs.modal', function() {
|
|
$('#sp-lock').on('shown.bs.modal', function() {
|
|
|
lockSpread.refresh();
|
|
lockSpread.refresh();
|
|
@@ -5568,24 +5604,64 @@ $(document).ready(() => {
|
|
|
if (!lid) return;
|
|
if (!lid) return;
|
|
|
const lidList = lid.split(',');
|
|
const lidList = lid.split(',');
|
|
|
lockTree.nodes.forEach(x => {
|
|
lockTree.nodes.forEach(x => {
|
|
|
- if (lidList.indexOf(x.ledger_id + '') >= 0) x.locked = 1;
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if (lidList.indexOf(x.ledger_id + '') >= 0) {
|
|
|
|
|
+ x.locked = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ const loadAuditLocked = function(auditLocked) {
|
|
|
|
|
+ auditLockedHis = auditLocked;
|
|
|
|
|
+ const lidList = auditLockedHis.map(x => { return x.audit_locked_lid; }).join(',').split(',');
|
|
|
|
|
+ lockTree.nodes.forEach(x => {
|
|
|
|
|
+ if (lidList.indexOf(x.ledger_id + '') >= 0) {
|
|
|
|
|
+ x.locked = 1;
|
|
|
|
|
+ x.org_locked = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ SpreadJsObj.reloadColData(lockSheet, 0);
|
|
|
};
|
|
};
|
|
|
- const show = function(setting) {
|
|
|
|
|
|
|
+ const showLocked = function(setting) {
|
|
|
|
|
+ lockType = 'lock';
|
|
|
init(setting);
|
|
init(setting);
|
|
|
loadLockedLid(setting.locked_lid);
|
|
loadLockedLid(setting.locked_lid);
|
|
|
$('#sp-back').modal('hide');
|
|
$('#sp-back').modal('hide');
|
|
|
$('#sp-lock').modal('show');
|
|
$('#sp-lock').modal('show');
|
|
|
};
|
|
};
|
|
|
- return { show }
|
|
|
|
|
|
|
+ const showUnlocked = function(setting) {
|
|
|
|
|
+ lockType = 'unlock';
|
|
|
|
|
+ init(setting);
|
|
|
|
|
+ loadAuditLocked(setting.auditLocked);
|
|
|
|
|
+ $('#sp-lock').modal('show');
|
|
|
|
|
+ };
|
|
|
|
|
+ return { showLocked, showUnlocked }
|
|
|
})();
|
|
})();
|
|
|
$('#sp-back-lock').click(function(){
|
|
$('#sp-back-lock').click(function(){
|
|
|
- spBackLock.show({
|
|
|
|
|
|
|
+ spBackLock.showLocked({
|
|
|
tree: stageTree,
|
|
tree: stageTree,
|
|
|
locked_lid: $('[name=audit_locked_lid]').val(),
|
|
locked_lid: $('[name=audit_locked_lid]').val(),
|
|
|
- callback: function(lid) { $('[name=audit_locked_lid]').val(lid) },
|
|
|
|
|
|
|
+ callback: function(lid) {
|
|
|
|
|
+ $('[name=audit_locked_lid]').val(lid);
|
|
|
|
|
+ $('#sp-back').modal('show');
|
|
|
|
|
+ },
|
|
|
})
|
|
})
|
|
|
});
|
|
});
|
|
|
|
|
+ $('#sp-unlock').click(function(){
|
|
|
|
|
+ postData(window.location.pathname + '/load', { filter: 'auditLocked'}, function(result){
|
|
|
|
|
+ if (!result.auditLocked || result.auditLocked.length === 0) {
|
|
|
|
|
+ toastr.warning('暂无需要解锁的数据');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ spBackLock.showUnlocked({
|
|
|
|
|
+ tree: stageTree,
|
|
|
|
|
+ auditLocked: result.auditLocked,
|
|
|
|
|
+ callback: async function(auditLocked) {
|
|
|
|
|
+ const newAuditLocked = await postDataAsync(window.location.pathname + '/unlock', { updateType: 'audit_locked_lid', updateData: auditLocked});
|
|
|
|
|
+ if (newAuditLocked.length === 0) $('#sp-unlock').hide();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
function makeOneShouFang(sf) {
|
|
function makeOneShouFang(sf) {
|
|
|
const lData = _.find(ledgerData, { id: sf.lid });
|
|
const lData = _.find(ledgerData, { id: sf.lid });
|