Browse Source

台账分解,台账修订,清单编号、项目节编号相关

MaiXinRong 5 years ago
parent
commit
832fbe07b3
3 changed files with 46 additions and 17 deletions
  1. 5 0
      app/base/base_bills_service.js
  2. 26 15
      app/public/js/ledger.js
  3. 15 2
      app/public/js/revise.js

+ 5 - 0
app/base/base_bills_service.js

@@ -35,6 +35,7 @@ class BaseBillsSerivce extends TreeService {
         data.deal_tp = null;
     }
 
+
     /**
      * 从标准数据中提取有效数据
      * @param {Object} stdData - 从标准库中查询所得
@@ -384,6 +385,10 @@ class BaseBillsSerivce extends TreeService {
                 if (row.b_code) {
                     row.dgn_qty1 = null;
                     row.dgn_qty2 = null;
+                    row.code = null;
+                }
+                if (row.code) {
+                    row.b_code = null;
                 }
                 if (this._checkCalcField(row)) {
                     let calcData = JSON.parse(JSON.stringify(row));

+ 26 - 15
app/public/js/ledger.js

@@ -21,6 +21,7 @@ const invalidFields = {
     gcl: ['dgn_qty1', 'dgn_qty2'],
     posCode: ['b_code'],
     posCalc: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp'],
+    posXmj: ['code'],
 };
 function transExpr(expr) {
     return expr.replace('=', '').replace('%', '/100');
@@ -567,7 +568,14 @@ $(document).ready(function() {
                 : (info.pasteData.text === ''
                     ? SpreadJsObj.Clipboard.getAnalysisPasteText()
                     : SpreadJsObj.analysisPasteText(info.pasteData.text));
-            let bParentHint = false, bGclHint = false, bCodeHint = false, bQtyHint = false, bNumHint = false;
+            const hint = {
+                invalidExpr: {type: 'warning', msg: '粘贴的表达式非法'},
+                posCode: {type: 'warning', msg: '清单含有计量单元,不可粘贴清单编号为空'},
+                posQty: {type: 'warning', msg: '清单含有计量单元,数量金额根据计量单元汇总计算所得,不可粘贴'},
+                parent: {type: 'warning', msg: '含有子项的清单,不可粘贴数量、单价、金额'},
+                gcl: {type: 'warning', msg: '工程量清单,不可粘贴项目节数量'},
+                posXmj: {type: 'warning', msg: '清单含有计量单元,不可粘贴项目节编号'},
+            };
             const datas = [], filterNodes = [];
             for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
                 const curRow = info.cellRange.row + iRow;
@@ -582,20 +590,24 @@ $(document).ready(function() {
                     const value = trimInvalidChar(pasteData[iRow][iCol]);
                     const lPos = pos.getLedgerPos(node.id);
                     if (node.children && node.children.length > 0 && invalidFields.parent.indexOf(colSetting.field) >= 0) {
-                        if (!bParentHint) bParentHint = true;
+                        toastMessageUniq(hint.parent);
                         continue;
                     }
                     if (!_.isEmpty(node.b_code) && invalidFields.gcl.indexOf(colSetting.field) >= 0) {
-                        if (!bGclHint) bGclHint = true;
+                        toastMessageUniq(hint.gcl);
                         continue;
                     }
                     if (lPos && lPos.length > 0) {
                         if (value === '' && invalidFields.posCode.indexOf(colSetting.field) >= 0) {
-                            if (!bCodeHint) bCodeHint = true;
+                            toastMessageUniq(hint.posCode);
                             continue;
                         }
                         if (invalidFields.posCalc.indexOf(colSetting.field) >= 0) {
-                            if (!bQtyHint) bQtyHint = true;
+                            toastMessageUniq(hint.posQty);
+                            continue;
+                        }
+                        if (value !== '' && invalidFields.posXmj.indexOf(colSetting.field) >= 0) {
+                            toastMessageUniq(hint.posXmj);
                             continue;
                         }
                     }
@@ -608,7 +620,7 @@ $(document).ready(function() {
                             try {
                                 data[colSetting.field] = math.evaluate(transExpr(value));
                             } catch(err) {
-                                bNumHint = true;
+                                toastMessageUniq(hint.invalidExpr);
                             }
                         }
                     } else {
@@ -622,15 +634,6 @@ $(document).ready(function() {
                     filterNodes.push(node);
                 }
             }
-            const hint = [];
-            if (bParentHint) hint.push('含有子项的清单,不可粘贴数量、单价、金额');
-            if (bGclHint) hint.push('工程量清单,不可粘贴项目节数量');
-            if (bQtyHint) hint.push('含有计量单元的清单,不可粘贴数量');
-            if (bCodeHint) hint.push('含有计量单元的清单,清单编号不可粘贴空值');
-            if (bNumHint) hint.push('单价、数量等应输入数字或可计算的表达式');
-            // if (hint.length > 0) hint.unshift('复制粘贴的数据中,存在非法数据,已过滤:');
-            // if (hint.length > 0) toastr.warning(hint.join('</br>'));
-            if (hint.length > 0) toastr.warning('复制粘贴的数据中,存在非法数据,已过滤');
             if (datas.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
                     const refreshNode = tree.loadPostData(result);
@@ -794,7 +797,15 @@ $(document).ready(function() {
             if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
             const col = info.sheet.zh_setting.cols[info.col];
             const node = info.sheet.zh_tree.nodes[info.row];
+            if (!node) {
+                info.cancel = true;
+                return;
+            }
             switch (col.field) {
+                case 'code':
+                    const posRange = pos.getLedgerPos(node.id);
+                    info.cancel = posRange && posRange.length > 0;
+                    break;
                 case 'unit_price':
                 case 'sgfh_qty':
                 case 'sgfh_tp':

+ 15 - 2
app/public/js/revise.js

@@ -14,6 +14,7 @@ const invalidFields = {
     gcl: ['dgn_qty1', 'dgn_qty2'],
     posCode: ['b_code'],
     posCalc: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp'],
+    posXmj: ['code'],
 };
 function transExpr(expr) {
     return $.trim(expr).replace('\t', '').replace('=', '').replace('%', '/100');
@@ -416,10 +417,11 @@ $(document).ready(() => {
                 usedUp: {type: 'warning', msg: '节点已计量,不可修改单价'},
                 usedCode: {type: 'warning', msg: '节点已计量,编号不可修改为空值'},
                 invalidExpr: {type: 'warning', msg: '粘贴的表达式非法'},
-                posCode: {type: 'warning', msg: '清单含有计量单元,请先删除计量单元,再修改清单编号为空'},
-                posQty: {type: 'warning', msg: '清单含有计量单元,数量金额根据计量单元汇总计算所得,不可修改'},
+                posCode: {type: 'warning', msg: '清单含有计量单元,不可粘贴清单编号为空'},
+                posQty: {type: 'warning', msg: '清单含有计量单元,数量金额根据计量单元汇总计算所得,不可粘贴'},
                 parent: {type: 'warning', msg: '含有子项的清单,不可粘贴数量、单价、金额'},
                 gcl: {type: 'warning', msg: '工程量清单,不可粘贴项目节数量'},
+                posXmj: {type: 'warning', msg: '清单含有计量单元,不可粘贴项目节编号'},
             };
             const datas = [], filterNodes = [];
 
@@ -454,6 +456,10 @@ $(document).ready(() => {
                             toastMessageUniq(hint.posQty);
                             continue;
                         }
+                        if (value !== '' && invalidFields.posXmj.indexOf(colSetting.field) >= 0) {
+                            toastMessageUniq(hint.posXmj);
+                            continue;
+                        }
                     }
 
                     const value = trimInvalidChar(pasteData[iRow][iCol]);
@@ -642,7 +648,14 @@ $(document).ready(() => {
             if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
             const col = info.sheet.zh_setting.cols[info.col];
             const node = info.sheet.zh_tree.nodes[info.row];
+            if (!node) {
+                info.cancel = true;
+                return;
+            }
             switch (col.field) {
+                case 'code':
+                    const posRange = pos.getLedgerPos(node.id);
+                    return posRange && posRange.length > 0;
                 case 'unit_price':
                     info.cancel = (node.children && node.children.length > 0) || node.used;
                     break;