Bladeren bron

单价调整相关

MaiXinRong 2 jaren geleden
bovenliggende
commit
11b81bb279
3 gewijzigde bestanden met toevoegingen van 52 en 39 verwijderingen
  1. 37 2
      app/public/js/path_tree.js
  2. 13 35
      app/public/js/revise_price.js
  3. 2 2
      app/public/js/spreadjs_rela/spreadjs_zh.js

+ 37 - 2
app/public/js/path_tree.js

@@ -387,6 +387,31 @@ const createNewPathTree = function (type, setting) {
             }
         }
 
+        loadFilter(select, filterType = 'filter') {
+            const defaultValue = filterType === 'filter' ? true : false;
+            this.select = select ? select.split(',') : [];
+            for (const d of this.datas) {
+                d.filter = defaultValue;
+            }
+            for (const s of this.select) {
+                const node = this.getItems(s);
+                if (!node) continue;
+                node.filter = !defaultValue;
+                const posterity = this.getPosterity(node);
+                for (const p of posterity) {
+                    p.filter = !defaultValue;
+                }
+                const parents = this.getAllParents(node);
+                for (const p of parents) {
+                    p.filter = !defaultValue;
+                }
+            }
+            for (const node of this.datas) {
+                const parent = this.getParent(node);
+                node.visible = parent ? (parent.expanded && parent.visible && !node.filter) : !node.filter;
+            }
+        }
+
         getItemsByIndex(index) {
             return this.nodes[index];
         }
@@ -538,6 +563,16 @@ const createNewPathTree = function (type, setting) {
         };
 
         /**
+         * 查询node是否是父节点的最后一个可见子节点
+         * @param {Object} node
+         * @returns {boolean}
+         */
+        isLastViewSibling(node) {
+            const siblings = (this.getChildren(this.getParent(node))).filter(x => { return !x.filter });
+            return (siblings && siblings.length > 0) ? node.order === siblings[siblings.length - 1].order : false;
+        };
+
+        /**
          * 提取节点key和索引数据
          * @param {Object} node - 节点
          * @returns {key}
@@ -601,7 +636,7 @@ const createNewPathTree = function (type, setting) {
             }
             if (node.children && node.children.length > 0) {
                 for (const child of node.children) {
-                    child.visible = node.expanded && node.visible;
+                    child.visible = node.expanded && node.visible && !child.filter;
                     this._refreshChildrenVisible(child);
                 }
             }
@@ -631,7 +666,7 @@ const createNewPathTree = function (type, setting) {
                     node.expanded = expanded;
                     this._markExpandFold(node);
                 }
-                node.visible = parent ? (parent.expanded && parent.visible) : true;
+                node.visible = parent ? (parent.expanded && parent.visible && !node.filter) : !node.filter;
                 this._recursiveExpand(node.children, node, checkFun);
             }
         }

+ 13 - 35
app/public/js/revise_price.js

@@ -102,12 +102,6 @@ $(document).ready(() => {
         headerFont: '12px 微软雅黑',
         font: '12px 微软雅黑',
         readOnly: true,
-        // getColor: function (sheet, data, row, col, defaultColor) {
-        //     return data && data.valid ? defaultColor : '#ddd';
-        // },
-        getForeColor: function (sheet, data, row, col, defaultColor) {
-            return data && data.valid ? defaultColor : '#ddd';
-        },
     };
     sjsSettingObj.setFxTreeStyle(priceBwSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
     const priceChangeSpreadSetting = {
@@ -159,19 +153,12 @@ $(document).ready(() => {
                 return a.order - b.order;
             });
         }
-        analysisRelaLid(price) {
-            const tree = this.tree;
-            const rela_lid = price.rela_lid ? price.rela_lid.split(',') : [];
-            price.rela_hint = rela_lid.map(x => {
-                const node = tree.getItems(parseInt(x));
-                return node ? node.code || node.name : '';
-            }).join(',');
-        }
         loadDatas(datas, treeData, changeData) {
             this.data = datas;
             this.tree.loadDatas(treeData);
             this.resortData();
             this.change = changeData;
+            this.relaChange = [];
             if (this.data.length > 0) this.refreshRela(this.data[0]);
         }
         loadUpdateData(updateData) {
@@ -207,25 +194,14 @@ $(document).ready(() => {
         }
         refreshTreeRela(price, samePrice) {
             if (price.rela_lid) {
-                const choose = price.rela_lid.split(',');
-                for (const node of this.tree.nodes) {
-                    node.rela = choose.indexOf(node.ledger_id + '') >= 0;
-                }
-                for (const node of this.tree.nodes) {
-                    node.valid = node.rela || this.tree.checkParent(node, 'rela') || this.tree.checkChildren(node, 'rela');
-                }
+                this.tree.loadFilter(price.rela_lid);
             } else {
                 const invalid = [];
                 for (const sp of samePrice) {
                     const lid = sp.rela_lid ? sp.rela_lid.split(',') : [];
                     invalid.push(...lid);
                 }
-                for (const node of this.tree.nodes) {
-                    node.rela = invalid.indexOf(node.ledger_id + '') >= 0;
-                }
-                for (const node of this.tree.nodes) {
-                    node.valid = !(node.rela || this.tree.checkParent(node, 'rela'));
-                }
+                this.tree.loadFilter(invalid.join(','), 'access');
             }
         }
         refreshChangeRela(price, samePrice) {
@@ -253,6 +229,11 @@ $(document).ready(() => {
                     }
                 }
             }
+            this.relaChange.length = 0;
+
+            for (const c of this.change) {
+                if (c.valid) this.relaChange.push(c);
+            }
         }
         refreshRela(price) {
             const samePrice = this.getSamePrice(price);
@@ -458,10 +439,8 @@ $(document).ready(() => {
         selectionChanged: function () {
             const price = SpreadJsObj.getSelectObject(priceSheet);
             revisePrice.refreshRela(price);
-            // SpreadJsObj.reloadRowBackColor(priceBwSheet, 0, priceBwSheet.getRowCount());
-            // SpreadJsObj.reloadRowBackColor(priceChangeSheet, 0, priceChangeSheet.getRowCount());
-            SpreadJsObj.reloadRowForeColor(priceBwSheet, 0, priceBwSheet.getRowCount());
-            SpreadJsObj.reloadRowForeColor(priceChangeSheet, 0, priceChangeSheet.getRowCount());
+            SpreadJsObj.refreshTreeRowVisible(priceBwSheet);
+            SpreadJsObj.reLoadSheetData(priceChangeSheet);
         },
     };
     if (!readOnly) {
@@ -864,7 +843,6 @@ $(document).ready(() => {
                 }
             };
             SpreadJsObj.initSheet(this.sheet, spreadSetting);
-            const self = this;
             this.spread.bind(spreadNS.Events.ButtonClicked, function (e, info) {
                 const sheet = info.sheet, cellType = sheet.getCellType(info.row, info.col);
                 if (!sheet.zh_setting) return;
@@ -903,11 +881,11 @@ $(document).ready(() => {
             for (const c of this.change) {
                 c.check = this.choose.indexOf(c.cid + '') >= 0;
                 c.invalid = this.invalid.indexOf(c.cid + '') >= 0;
-                if (!c.check && c.invalid) {
+                if (!c.check && !c.invalid) {
                     const exist = c.bills.find(x => {
                         return x.code === price.b_code && x.name === price.name && x.unit === price.unit && x.unit_price === price.org_price;
                     });
-                    c.invalid = !exist;
+                    c.visible = !exist;
                 }
             }
             $('#choose-rela-change').modal('show');
@@ -922,7 +900,7 @@ $(document).ready(() => {
         chooseRelaBw.loadTree(result.bills);
         chooseRelaChange.loadChange(result.change);
         SpreadJsObj.loadSheetData(priceBwSheet, SpreadJsObj.DataType.Tree, revisePrice.tree);
-        SpreadJsObj.loadSheetData(priceChangeSheet, SpreadJsObj.DataType.Data, revisePrice.change);
+        SpreadJsObj.loadSheetData(priceChangeSheet, SpreadJsObj.DataType.Data, revisePrice.relaChange);
         $("[content='#ledgerGcl']").click();
     });
 

+ 2 - 2
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -1407,7 +1407,7 @@ const SpreadJsObj = {
                             }
                             // Draw Vertical Line
                             if (centerX < x + w) {
-                                const y1 = tree.isLastSibling(node) ? centerY : y + h;
+                                const y1 = tree.isLastViewSibling(node) ? centerY : y + h;
                                 const parent = tree.getParent(node);
                                 const y2 = y1 - centerY;
                                 if (node.order === 1 && !parent) {
@@ -1437,7 +1437,7 @@ const SpreadJsObj = {
                         if (showTreeLine) {
                             let parent = tree.getParent(node), parentCenterX = centerX - indent - levelIndent;
                             while (parent) {
-                                if (!tree.isLastSibling(parent)) {
+                                if (!tree.isLastViewSibling(parent)) {
                                     if (parentCenterX < x + w) {
                                         if (dotLine) {
                                             drawDotLine(canvas, parentCenterX, y, parentCenterX, y + h, lineColor);