Browse Source

修复升降级bug

ellisran 9 tháng trước cách đây
mục cha
commit
7350569e6c
2 tập tin đã thay đổi với 25 bổ sung21 xóa
  1. 11 9
      app/public/js/contract_detail.js
  2. 14 12
      app/service/contract_tree.js

+ 11 - 9
app/public/js/contract_detail.js

@@ -175,12 +175,13 @@ $(document).ready(function() {
                 invalidAll();
                 return;
             }
-            let last = first, sameParent = true, childCanDel = true, hadContract = this.checkContract(first);
+            let last = first, sameParent = true, childCanDel = true;
+                // hadContract = this.checkContract(first);
             if (sel.rowCount > 1 && first) {
                 for (let r = 1; r < sel.rowCount; r++) {
                     const rNode = tree.nodes[sel.row + r];
                     childCanDel = this.checkDelete(rNode, childCanDel);
-                    if (!hadContract) hadContract = this.checkContract(rNode);
+                    // if (!hadContract) hadContract = this.checkContract(rNode);
                     if (!rNode) {
                         sameParent = false;
                         break;
@@ -204,11 +205,12 @@ $(document).ready(function() {
             //     }
             // }
             const nextNodes = _.filter(tree.getChildren(tree.getParent(first)), function (item){ return item.order > first.order });
-            let nextHadContract = false;
-            for (const next of nextNodes) {
-                if (nextHadContract) continue;
-                nextHadContract = this.checkContract(next);
-            }
+            // let nextHadContract = false;
+            // for (const next of nextNodes) {
+            //     if (nextHadContract) continue;
+            //     nextHadContract = this.checkContract(next);
+            // }
+            const nextHadContract = _.findIndex(nextNodes, function(item) { return item.c_code; }) !== -1;
             const valid = !sheet.zh_setting.readOnly;
 
             setObjEnable($('a[name=base-opr][type=add]'), valid && first && first.level > 1);
@@ -217,9 +219,9 @@ $(document).ready(function() {
             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 && (!nextHadContract || tree.isLastSibling(last)) && upPower && !hadContract);
+                && first.level > 2 && (!nextHadContract || tree.isLastSibling(last)) && upPower && first.c_code === undefined);
             setObjEnable($('a[name=base-opr][type=down-level]'), valid && first && sameParent
-                && first.level > 1 && preNode && (preNode.children.length > 0 || preNode.children.length === 0) && !hadContract && preNode.c_code === undefined);
+                && first.level > 1 && preNode && (preNode.children.length > 0 || preNode.children.length === 0) && preNode.c_code === undefined);
             // setObjEnable($('#cut'), valid);
             // setObjEnable($('#paste'), valid);
         },

+ 14 - 12
app/service/contract_tree.js

@@ -958,12 +958,12 @@ module.exports = app => {
          * @private
          */
         async _syncUplevelChildren(options, select, transaction = null) {
-            const children = await this.getDataByFullPath(options, select[this.setting.fullPath] + '-%');
-            if (this._.findIndex(children, function (item) {
-                return item.c_code;
-            }) !== -1) {
-                throw '存在合同节点不可升级';
-            }
+            // const children = await this.getDataByFullPath(options, select[this.setting.fullPath] + '-%');
+            // if (this._.findIndex(children, function (item) {
+            //     return item.c_code;
+            // }) !== -1) {
+            //     throw '存在合同节点不可升级';
+            // }
             // this.initSqlBuilder();
             // this.sqlBuilder.setAndWhere(this.setting.mid, {
             //     value: select[this.setting.mid],
@@ -987,6 +987,7 @@ module.exports = app => {
                 'WHERE ' + this.ctx.helper._getOptionsSql(options) + ' AND ' + this.setting.fullPath + ' LIKE ?';
             const sqlParam = [this.tableName, select[this.setting.fullPath] + '-%'];
             const data = transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
+            transaction ? await transaction.query(sql, [this.ctx.service.contract.tableName, select[this.setting.fullPath] + '-%']) : await this.db.query(sql, [this.ctx.service.contract.tableName, select[this.setting.fullPath] + '-%']);
 
             return data;
         }
@@ -999,12 +1000,12 @@ module.exports = app => {
          * @private
          */
         async _syncDownlevelChildren(options, select, newFullPath, transaction = null) {
-            const children = await this.getDataByFullPath(options, select[this.setting.fullPath] + '-%');
-            if (this._.findIndex(children, function (item) {
-                return item.c_code;
-            }) !== -1) {
-                throw '存在合同节点不可降级';
-            }
+            // const children = await this.getDataByFullPath(options, select[this.setting.fullPath] + '-%');
+            // if (this._.findIndex(children, function (item) {
+            //     return item.c_code;
+            // }) !== -1) {
+            //     throw '存在合同节点不可降级';
+            // }
             // this.initSqlBuilder();
             // this.sqlBuilder.setAndWhere(this.setting.mid, {
             //     value: select[this.setting.mid],
@@ -1028,6 +1029,7 @@ module.exports = app => {
                 'WHERE ' + this.ctx.helper._getOptionsSql(options) + ' AND ' + this.setting.fullPath + ' LIKE ?';
             const sqlParam = [this.tableName, select[this.setting.fullPath] + '-%'];
             const data = transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
+            transaction ? await transaction.query(sql, [this.ctx.service.contract.tableName, select[this.setting.fullPath] + '-%']) : await this.db.query(sql, [this.ctx.service.contract.tableName, select[this.setting.fullPath] + '-%']);
 
             return data;
         }