|
@@ -812,6 +812,35 @@ $(document).ready(function() {
|
|
|
info.cancel = !_.isEmpty(node.b_code);
|
|
|
break;
|
|
|
}
|
|
|
+ },
|
|
|
+ sortCode: function (sheet) {
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
+ if (!tree) return;
|
|
|
+
|
|
|
+ const select = SpreadJsObj.getSelectObject(sheet);
|
|
|
+ if (!select || !select.code) return;
|
|
|
+
|
|
|
+ const recursiveSortCode = function (data, parentCode, children) {
|
|
|
+ if (!children || children.length === 0) return;
|
|
|
+
|
|
|
+ for (const [i, child] of children.entries()) {
|
|
|
+ const code = parentCode + '-' + (i + 1);
|
|
|
+ const cData = tree.getNodeKeyData(child);
|
|
|
+ cData.code = code;
|
|
|
+ data.push(cData);
|
|
|
+ if (!tree.isLeafXmj(child)) {
|
|
|
+ recursiveSortCode(data, code, child.children);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const data = [];
|
|
|
+ recursiveSortCode(data, select.code, select.children);
|
|
|
+ if (data.length > 0) {
|
|
|
+ postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
|
|
|
+ const refreshNode = tree.loadPostData(result);
|
|
|
+ treeOperationObj.refreshTree(sheet, refreshNode);
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
ledgerTreeCol.initSpreadSetting(ledgerSpreadSetting);
|
|
@@ -1060,6 +1089,18 @@ $(document).ready(function() {
|
|
|
}
|
|
|
},
|
|
|
'sprBlock': '-----------',
|
|
|
+ 'sortChildren': {
|
|
|
+ name: '顺序重排子项编号',
|
|
|
+ icon: 'fa-sort-numeric-asc',
|
|
|
+ disabled: function (key, opt) {
|
|
|
+ const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
|
|
|
+ return !node || !node.code || !node.children || node.children === 0;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ treeOperationObj.sortCode(ledgerSpread.getActiveSheet());
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'sprSort': '-----------',
|
|
|
'batchInsert': {
|
|
|
name: '批量插入',
|
|
|
type: 'batchInsert',
|