Browse Source

台账修订,单元格编辑问题

MaiXinRong 2 weeks ago
parent
commit
5e1092bc5f
1 changed files with 54 additions and 50 deletions
  1. 54 50
      app/public/js/revise.js

+ 54 - 50
app/public/js/revise.js

@@ -536,55 +536,56 @@ $(document).ready(() => {
          * @param {Object} info
          */
         editEnded: function (e, info) {
-            if (info.sheet.zh_setting) {
-                const col = info.sheet.zh_setting.cols[info.col];
-                const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
-                const node = sortData[info.row];
-                const data = {
-                    id: node.id,
-                    tender_id: node.tender_id,
-                    ledger_id: node.ledger_id
-                };
-                // 未改变值则不提交
-                const orgValue = node[col.field];
-                if (info.editingText === null) info.editingText = '';
-                const newValue = col.wordWrap ? info.editingText : trimInvalidChar(info.editingText);
-                if (orgValue == info.editingText || ((!orgValue || orgValue === '') && (newValue === ''))) {
-                    return;
-                }
-                // 台账模式,检查计量单元相关
-                // if (isTz) {
-                    if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
-                        col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
-                        col.field === 'qtcl_qty' || col.field === 'qtcl_tp'||
-                        col.field === 'ex_qty1' || col.field === 'ex_tp1') {
-                        if (!node.children || node.children.length ===0) {
-                            const lPos = pos.getLedgerPos(node.id);
-                            if (lPos && lPos.length > 0) {
-                                toastr.error('清单含有计量单元,不可修改施工图复核数量');
-                                SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                                return;
-                            }
-                        }
-                    }
-                    if (col.field === 'b_code' && (newValue === '' || !newValue)) {
-                        const lPos = pos.getLedgerPos(node.id);
-                        if (lPos && lPos.length > 0) {
-                            toastr.error('清单含有计量单元,请先删除计量单元,再删除清单编号');
-                            SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                            return;
-                        }
-                    }
-                // }
-                if (col.field === 'node_type' && newValue && newValue !== '0' && newValue !== '19') {
-                    const sameNodeType = sortData.find(x => { return x.node_type == newValue; });
-                    if (sameNodeType) {
-                        toastr.error('已存在该费用类别,请勿重复选择');
+            if (!info.sheet.zh_setting) return;
+
+            const col = info.sheet.zh_setting.cols[info.col];
+            const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
+            const node = sortData[info.row];
+            const data = {
+                id: node.id,
+                tender_id: node.tender_id,
+                ledger_id: node.ledger_id
+            };
+            // 未改变值则不提交
+            const orgValue = node[col.field];
+            if (info.editingText === null) info.editingText = '';
+            const newValue = col.wordWrap ? info.editingText : trimInvalidChar(info.editingText);
+            if (orgValue == info.editingText || ((!orgValue || orgValue === '') && (newValue === ''))) {
+                return;
+            }
+            // 台账模式,检查计量单元相关
+            if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
+                col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
+                col.field === 'qtcl_qty' || col.field === 'qtcl_tp'||
+                col.field === 'ex_qty1' || col.field === 'ex_tp1') {
+                if (!node.children || node.children.length ===0) {
+                    const lPos = pos.getLedgerPos(node.id);
+                    if (lPos && lPos.length > 0) {
+                        toastr.error('清单含有计量单元,不可修改施工图复核数量');
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         return;
                     }
                 }
-                // 获取更新数据
+            }
+            if (col.field === 'b_code' && (newValue === '' || !newValue)) {
+                const lPos = pos.getLedgerPos(node.id);
+                if (lPos && lPos.length > 0) {
+                    toastr.error('清单含有计量单元,请先删除计量单元,再删除清单编号');
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+            }
+
+            if (col.field === 'node_type' && newValue && newValue !== '0' && newValue !== '19') {
+                const sameNodeType = sortData.find(x => { return x.node_type == newValue; });
+                if (sameNodeType) {
+                    toastr.error('已存在该费用类别,请勿重复选择');
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+            }
+            // 获取更新数据
+            if (col.type === 'Number') {
                 const exprInfo = getExprInfo(col.field);
                 if (info.editingText) {
                     const text = newValue;
@@ -626,12 +627,15 @@ $(document).ready(() => {
                         data[exprInfo.expr] = '';
                     }
                 }
-                // 更新至服务器
-                postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
-                    const refreshNode = billsTree.loadPostData(result);
-                    billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
-                });
+            } else {
+                data[col.field] = newValue;
             }
+
+            // 更新至服务器
+            postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
+                const refreshNode = billsTree.loadPostData(result);
+                billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
+            });
         },
         clipboardPasting: function (e, info) {
             const tree = info.sheet.zh_tree, setting = info.sheet.zh_setting;