ソースを参照

1. 动态投资,允许删除首层节点
2. 动态投资,允许从项目节添加首层节点

MaiXinRong 4 週間 前
コミット
0f8d3564fa
2 ファイル変更12 行追加11 行削除
  1. 1 1
      app/controller/budget_controller.js
  2. 11 10
      app/public/js/budget_detail.js

+ 1 - 1
app/controller/budget_controller.js

@@ -246,7 +246,7 @@ module.exports = app => {
             }
         }
         async _addStd(relaService, data) {
-            if ((isNaN(data.id) || data.id <= 0) || !data.stdType || !data.stdNode) throw '参数错误';
+            if (!data.stdType || !data.stdNode) throw '参数错误';
 
             let stdLib, addType;
             switch (data.stdType) {

+ 11 - 10
app/public/js/budget_detail.js

@@ -146,10 +146,10 @@ $(document).ready(() => {
         },
         getDefaultSelectInfo: function (sheet) {
             const tree = sheet.zh_tree;
-            if (!tree) return;
+            if (!tree) return [null, null, 0];
             const sel = sheet.getSelections()[0];
             const node = sheet.zh_tree.nodes[sel.row];
-            if (!node) return;
+            if (!node) return [tree, null, 0];
             let count = 1;
             if (sel.rowCount > 1) {
                 for (let r = 1; r < sel.rowCount; r++) {
@@ -217,7 +217,7 @@ $(document).ready(() => {
             const valid = !readOnly;
 
             setObjEnable($('a[name=base-opr][type=add]'), valid && first && first.level > 1);
-            setObjEnable($('a[name=base-opr][type=delete]'), valid && first && sameParent && first.level > 1);
+            setObjEnable($('a[name=base-opr][type=delete]'), valid && first && sameParent);
             setObjEnable($('a[name=base-opr][type=up-move]'), valid && first && sameParent && first.level > 1 && preNode);
             setObjEnable($('a[name=base-opr][type=down-move]'), valid && first && sameParent && first.level > 1 && !tree.isLastSibling(last));
             setObjEnable($('a[name=base-opr][type=up-level]'), valid && first && sameParent && tree.getParent(first) && first.level > 2 && tree.isLastSibling(last));
@@ -237,7 +237,8 @@ $(document).ready(() => {
         baseOpr: function (sheet, type, addCount = 1) {
             const self = this;
             const [tree, node, count] = this.getDefaultSelectInfo(sheet);
-            if (!tree || !node || !count) return;
+            if (!tree) return;
+            if (type !== 'add' && (!node || !count)) return;
 
             if (type === 'delete') {
                 deleteAfterHint(function () {
@@ -257,7 +258,7 @@ $(document).ready(() => {
             } else {
                 postData(window.location.pathname + '/update', {
                     postType: type,
-                    postData: { id: node.tree_id, count: type === 'add' ? addCount : count }
+                    postData: { id: node ? node.tree_id : -1, count: type === 'add' ? addCount : count }
                 }, function (result) {
                     const refreshData = tree.loadPostData(result);
                     self.refreshTree(sheet, refreshData);
@@ -656,17 +657,17 @@ $(document).ready(() => {
                 return;
             }
         }
-
-        postData(window.location.pathname + '/update', {
+        const stdUpdateData = {
             postType: 'add-std',
             postData: {
-                id: budgetTree.getNodeKey(mainNode),
-                tender_id: mainNode.tender_id,
                 stdType: updateData.postData.stdType,
                 stdLibId: stdNode.list_id,
                 stdNode: stdTree.getNodeKey(stdNode)
             }
-        }, function (result) {
+        };
+        stdUpdateData.postData.id = mainNode ? budgetTree.getNodeKey(mainNode) : -1;
+
+        postData(window.location.pathname + '/update', stdUpdateData, function (result) {
             const sel = budgetSheet.getSelections()[0];
             const refreshNode = budgetTree.loadPostData(result);
             budgetTreeOpr.refreshTree(budgetSheet, refreshNode);