فهرست منبع

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 2 هفته پیش
والد
کامیت
a7f76350f1

+ 0 - 2
app/controller/ledger_controller.js

@@ -175,7 +175,6 @@ module.exports = app => {
 
 
                 await this.layout('ledger/explode.ejs', renderData, 'ledger/explode_modal.ejs');
                 await this.layout('ledger/explode.ejs', renderData, 'ledger/explode_modal.ejs');
             } catch (err) {
             } catch (err) {
-                console.log(err);
                 ctx.log(err);
                 ctx.log(err);
                 this.postError(err, '标段数据错误');
                 this.postError(err, '标段数据错误');
                 // await this.redirect('/dashboard');
                 // await this.redirect('/dashboard');
@@ -215,7 +214,6 @@ module.exports = app => {
          * @return {Promise<void>}
          * @return {Promise<void>}
          */
          */
         async _base(ctx, type, data) {
         async _base(ctx, type, data) {
-            console.log(1);
             if (isNaN(data.id) || data.id <= 0) throw '数据错误';
             if (isNaN(data.id) || data.id <= 0) throw '数据错误';
             if (type !== 'add') {
             if (type !== 'add') {
                 if (isNaN(data.count) || data.count <= 0) data.count = 1;
                 if (isNaN(data.count) || data.count <= 0) data.count = 1;

+ 8 - 5
app/public/js/cost_tmpl.js

@@ -430,13 +430,16 @@ $(document).ready(() => {
         const getCurTemplate = function() {
         const getCurTemplate = function() {
             return curTemplate;
             return curTemplate;
         };
         };
-        const getTemplateCaptionHtml = function(template) {
+        const getTemplateCaptionInnerHtml = function(template) {
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
-            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}"><div>${template.name}${usedHtml}</div>` +
+            return `<div>${template.name}${usedHtml}</div>` +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
-                '</div></div>';
+                '</div>';
+        };
+        const getTemplateCaptionHtml = function(template) {
+            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}">` + getTemplateCaptionInnerHtml(template) + '</div>';
         };
         };
         const getTemplateHtml = function(template) {
         const getTemplateHtml = function(template) {
             const html = [];
             const html = [];
@@ -469,7 +472,7 @@ $(document).ready(() => {
             });
             });
         };
         };
         if (templates.length > 0) setCurTemplate(templates[0]);
         if (templates.length > 0) setCurTemplate(templates[0]);
-        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml }
+        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml, getTemplateCaptionInnerHtml }
     })(templateList);
     })(templateList);
 
 
     $('body').on('click', '.table-file', function(e) {
     $('body').on('click', '.table-file', function(e) {
@@ -513,7 +516,7 @@ $(document).ready(() => {
         const template = templateList.find(x => { return x.id === templateId; });
         const template = templateList.find(x => { return x.id === templateId; });
         if (!template) return;
         if (!template) return;
 
 
-        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionHtml(template));
+        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionInnerHtml(template));
     });
     });
 
 
     $('body').on('click', 'a[name=delTemplate]', function(e) {
     $('body').on('click', 'a[name=delTemplate]', function(e) {

+ 31 - 4
app/public/js/ledger.js

@@ -164,7 +164,9 @@ $(document).ready(function() {
                     specCol.comboItems = template.specValue.map(x => { return x.spec; });
                     specCol.comboItems = template.specValue.map(x => { return x.spec; });
                     specCol.cellType = 'customizeCombo';
                     specCol.cellType = 'customizeCombo';
                     specCol.cellTypeKey = 'specSelect';
                     specCol.cellTypeKey = 'specSelect';
+                    specCol.maxDrop = 10;
                 }
                 }
+                template.spread_cache.forceLoadEmpty = true;
                 SpreadJsObj.initSheet(sheet, template.spread_cache);
                 SpreadJsObj.initSheet(sheet, template.spread_cache);
             } else {
             } else {
                 SpreadJsObj.initSheet(sheet, emptySetting);
                 SpreadJsObj.initSheet(sheet, emptySetting);
@@ -669,7 +671,7 @@ $(document).ready(function() {
             const preNode = tree.getPreSiblingNode(first);
             const preNode = tree.getPreSiblingNode(first);
             const valid = !sheet.zh_setting.readOnly;
             const valid = !sheet.zh_setting.readOnly;
 
 
-            setObjEnable($('#insert'), valid && first && !first._invalid && first.level > 1);
+            setObjEnable($('#insert'), valid && first && (!first._invalid || first._insertValid) && first.level > 1);
             setObjEnable($('#delete'), valid && first && !first._invalid && sameParent && !(first.level === 1 && first.node_type));
             setObjEnable($('#delete'), valid && first && !first._invalid && sameParent && !(first.level === 1 && first.node_type));
             setObjEnable($('#up-move'), valid && first && !first._invalid  && sameParent && first.level > 1 && preNode);
             setObjEnable($('#up-move'), valid && first && !first._invalid  && sameParent && first.level > 1 && preNode);
             setObjEnable($('#down-move'), valid && first && !first._invalid  && sameParent && first.level > 1 && !tree.isLastSibling(last));
             setObjEnable($('#down-move'), valid && first && !first._invalid  && sameParent && first.level > 1 && !tree.isLastSibling(last));
@@ -991,7 +993,9 @@ $(document).ready(function() {
                 }
                 }
                 if (result.detail) {
                 if (result.detail) {
                     posCalcDetail.detail.updateDatas({ update: result.detail });
                     posCalcDetail.detail.updateDatas({ update: result.detail });
-                    posCalcDetail.reloadCurDetailData();
+                    posCalcDetail.loadCurDetailData();
+                } else if (updateData.postType === 'extra') {
+                    posCalcDetail.loadCurDetailData();
                 }
                 }
             }, function() {
             }, function() {
                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -1999,6 +2003,9 @@ $(document).ready(function() {
             name: '粘贴整块',
             name: '粘贴整块',
             icon: 'fa-clipboard',
             icon: 'fa-clipboard',
             disabled: function (key, opt) {
             disabled: function (key, opt) {
+                const node = SpreadJsObj.getSelectObject(ledgerSheet);
+                if (!node || node._invalid) return true;
+
                 //const block = treeOperationObj.block || [];
                 //const block = treeOperationObj.block || [];
                 const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
                 const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
                 return !(copyInfo && copyInfo.block && copyInfo.block.length > 0);
                 return !(copyInfo && copyInfo.block && copyInfo.block.length > 0);
@@ -2375,7 +2382,7 @@ $(document).ready(function() {
         loadCurPosData: function (refreshDetail = true) {
         loadCurPosData: function (refreshDetail = true) {
             //spreadJsObj.reinitSheet(posSpread.getActiveSheet());
             //spreadJsObj.reinitSheet(posSpread.getActiveSheet());
             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
-            if (node) {
+            if (node && !node._invalid) {
                 const posData = pos.ledgerPos[itemsPre + node.id] || [];
                 const posData = pos.ledgerPos[itemsPre + node.id] || [];
                 SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', posData);
                 SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', posData);
                 getNodeList(node.id);
                 getNodeList(node.id);
@@ -3357,6 +3364,26 @@ $(document).ready(function() {
                 toastr.warning('非最底层项目下,不应添加清单');
                 toastr.warning('非最底层项目下,不应添加清单');
                 return;
                 return;
             }
             }
+            if (tender.isAssUser && (mainNode._invalid && !mainNode._insertValid)) {
+                toastr.warning('非协作范围内,不可添加');
+                return;
+            }
+        }
+        if (updateData.postData.stdType === 'xmj' && tender.isAssUser) {
+            let leafRelaXmj = null;
+            for (const sd of updateData.postData.stdData) {
+                let rela = _.find(ledgerTree.nodes, {code: sd.code, name: sd.name});
+                if (!rela && sd.name.indexOf('x') >= 0) rela = _.find(ledgerTree.nodes, {code: sd.code});
+                if (rela) {
+                    leafRelaXmj = rela;
+                } else {
+                    break;
+                }
+            }
+            if (!leafRelaXmj || (leafRelaXmj._invalid && !leafRelaXmj._insertValid)) {
+                toastr.warning('非协作范围内,不可添加');
+                return;
+            }
         }
         }
 
 
         updateData.postData.id = ledgerTree.getNodeKey(mainNode);
         updateData.postData.id = ledgerTree.getNodeKey(mainNode);
@@ -3521,7 +3548,7 @@ $(document).ready(function() {
                             selectedBackColor: '#fffacd',
                             selectedBackColor: '#fffacd',
                             readOnly: true,
                             readOnly: true,
                         },
                         },
-                        skipFilter: true,
+                        skipFilter: { field: 'filter', value: true },
                         locate: function(cur) {
                         locate: function(cur) {
                             if (!cur.lid) return;
                             if (!cur.lid) return;
 
 

+ 85 - 27
app/public/js/material_list.js

@@ -120,33 +120,6 @@ function getPasteHint (str, row = '') {
     return returnObj;
     return returnObj;
 }
 }
 
 
-// 重新计算列表的价差
-function calculateJiaCha(data, index) {
-    // 计算单条的
-    if (index) {
-        const gcld = data[index]
-        let total_jiacha = 0;
-        for (const [index, xmj] of gcld.leafXmjs.entries()) {
-            const jiacha = calcOneBQJC(xmj);
-            gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
-            gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
-            total_jiacha += jiacha;
-        }
-        gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp)
-    } else {
-        for(const gcld of data) {
-            let total_jiacha = 0;
-            for (const [index, xmj] of gcld.leafXmjs.entries()) {
-                const jiacha = calcOneBQJC(xmj);
-                gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
-                gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
-                total_jiacha += jiacha;
-            }
-            gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp)
-        }
-    }
-}
-
 const is_numeric = (value) => {
 const is_numeric = (value) => {
     if (typeof(value) === 'object') {
     if (typeof(value) === 'object') {
         return false;
         return false;
@@ -217,6 +190,7 @@ $(document).ready(() => {
         ledgerCols.push({title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 110, type: 'Number'});
         ledgerCols.push({title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 110, type: 'Number'});
         ledgerCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 110, type: 'Number', getValue: 'getValue.gather_qty'});
         ledgerCols.push({title: '|小计', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 110, type: 'Number', getValue: 'getValue.gather_qty'});
     }
     }
+    ledgerCols.push({title: '本期调差数量', colSpan: '1', rowSpan: '2', field: 'total_qty', hAlign: 2, width: 110, type: 'Number'});
     ledgerCols.push({title: '本期完成金额', colSpan: '1', rowSpan: '2', field: 'gather_tp', hAlign: 2, width: 110, type: 'Number', getValue: 'getValue.gather_tp'});
     ledgerCols.push({title: '本期完成金额', colSpan: '1', rowSpan: '2', field: 'gather_tp', hAlign: 2, width: 110, type: 'Number', getValue: 'getValue.gather_tp'});
     ledgerCols.push({title: '本期价差', colSpan: '1', rowSpan: '2', field: 'total_jiacha', hAlign:3, width: 110, type: 'Number'});
     ledgerCols.push({title: '本期价差', colSpan: '1', rowSpan: '2', field: 'total_jiacha', hAlign:3, width: 110, type: 'Number'});
     const ledgerSpreadSetting = {
     const ledgerSpreadSetting = {
@@ -257,6 +231,64 @@ $(document).ready(() => {
         }
         }
     }
     }
     ledgerSpreadSetting.cols = ledgerCols;
     ledgerSpreadSetting.cols = ledgerCols;
+    const totalQtyColIndex = _.findIndex(ledgerCols, {field: 'total_qty'});
+    // 重新计算列表的价差
+    function calculateJiaCha(data, index) {
+        // 计算单条的
+        if (index) {
+            const gcld = data[index]
+            let total_jiacha = 0;
+            let total_qty = 0;
+            let edit_qty = false;
+            for (const [index, xmj] of gcld.leafXmjs.entries()) {
+                const jiacha = calcOneBQJC(xmj);
+                gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
+                gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
+                total_jiacha += jiacha;
+                total_qty = ZhCalc.add(total_qty, gcld.leafXmjs[index].qty);
+                if (findQtyLeafXmj(xmj)) {
+                    edit_qty = true;
+                }
+            }
+            gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp);
+            gcld.total_qty = ZhCalc.round(total_qty, materialDecimal.qty);
+            gcld.edit_qty = edit_qty;
+        } else {
+            if (!data || data.length === 0) {
+                return;
+            }
+            for(const [row, gcld] of data.entries()) {
+                let total_jiacha = 0;
+                let total_qty = 0;
+                let edit_qty = false;
+                for (const [index, xmj] of gcld.leafXmjs.entries()) {
+                    const jiacha = calcOneBQJC(xmj);
+                    gcld.leafXmjs[index].jiacha = jiacha !== 0 ? jiacha : null;
+                    gcld.leafXmjs[index].qty = getOneQtyByLeafXmj(xmj);
+                    total_jiacha += jiacha;
+                    total_qty = ZhCalc.add(total_qty, gcld.leafXmjs[index].qty);
+                    if (findQtyLeafXmj(xmj)) {
+                        edit_qty = true;
+                    }
+                }
+                gcld.total_jiacha = ZhCalc.round(total_jiacha, materialDecimal.tp);
+                gcld.total_qty = ZhCalc.round(total_qty, materialDecimal.qty);
+                gcld.edit_qty = edit_qty;
+            }
+        }
+    }
+
+    function refreshTotalQtyColor(datas, row = null) {
+        const ledgerSheet = ledgerSpread.getActiveSheet();
+        console.log(datas);
+        if (row !== null && datas && datas.edit_qty) {
+            ledgerSheet.getCell(row, totalQtyColIndex).backColor('#f8d7da');
+        } else if (row === null && datas && datas.length > 0) {
+            for (const [gcldIndex, gcld] of datas.entries()) {
+                if (gcld.edit_qty) ledgerSheet.getCell(gcldIndex, totalQtyColIndex).backColor('#f8d7da');
+            }
+        }
+    }
     // let gclGatherData = gclGatherModel.gatherGclData()
     // let gclGatherData = gclGatherModel.gatherGclData()
     // 获取项目节数据
     // 获取项目节数据
     function loadLeafXmjData(iGclRow) {
     function loadLeafXmjData(iGclRow) {
@@ -530,10 +562,12 @@ $(document).ready(() => {
                     });
                     });
                 }
                 }
                 calculateJiaCha(gclGatherData);
                 calculateJiaCha(gclGatherData);
+                console.log(gclGatherData);
                 SpreadJsObj.initSpreadSettingEvents(leafXmjSpreadSetting, leafXmjCol);
                 SpreadJsObj.initSpreadSettingEvents(leafXmjSpreadSetting, leafXmjCol);
                 SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
                 SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
                 // 加载清单数据
                 // 加载清单数据
                 SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
                 SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
+                refreshTotalQtyColor(gclGatherData);
                 loadLeafXmjData(0);
                 loadLeafXmjData(0);
                 loadMaterialData(0);
                 loadMaterialData(0);
                 loadXmjMaterialData(0, 0);
                 loadXmjMaterialData(0, 0);
@@ -656,6 +690,7 @@ $(document).ready(() => {
             SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
             SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
             // 加载清单数据
             // 加载清单数据
             SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
             SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
+            refreshTotalQtyColor(gclGatherData);
             loadLeafXmjData(0);
             loadLeafXmjData(0);
             loadMaterialData(0);
             loadMaterialData(0);
             loadXmjMaterialData(0, 0);
             loadXmjMaterialData(0, 0);
@@ -668,6 +703,7 @@ $(document).ready(() => {
             selfSheet.setCellType(1, 3, new TipCellType(), spreadNS.SheetArea.colHeader);
             selfSheet.setCellType(1, 3, new TipCellType(), spreadNS.SheetArea.colHeader);
             selfSheet.resumePaint();
             selfSheet.resumePaint();
             ledgerSpread.getActiveSheet().setSelection(0, 0, 1, 1);
             ledgerSpread.getActiveSheet().setSelection(0, 0, 1, 1);
+
             checkNotJoinMaterialData();
             checkNotJoinMaterialData();
         }
         }
     }
     }
@@ -1008,6 +1044,7 @@ $(document).ready(() => {
                 // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                 // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                 loadMaterialData(index);
                 loadMaterialData(index);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
+                refreshTotalQtyColor(gclGatherData[index], index);
                 $('#addgl').modal('hide');
                 $('#addgl').modal('hide');
             });
             });
         } else if (type === 'self') {
         } else if (type === 'self') {
@@ -1087,6 +1124,7 @@ $(document).ready(() => {
                 leafXmjSpreadObj.refreshQtyColor(select, nRow);
                 leafXmjSpreadObj.refreshQtyColor(select, nRow);
                 loadMaterialData(iGclRow);
                 loadMaterialData(iGclRow);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
+                refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
             });
             });
         },
         },
         checkChangeMaterial: function (type) {
         checkChangeMaterial: function (type) {
@@ -1114,6 +1152,7 @@ $(document).ready(() => {
                 leafXmjSpreadObj.refreshQtyColor(select, nRow);
                 leafXmjSpreadObj.refreshQtyColor(select, nRow);
                 loadMaterialData(iGclRow);
                 loadMaterialData(iGclRow);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
+                refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
             });
             });
         },
         },
         checkSelfMaterial: function (type) {
         checkSelfMaterial: function (type) {
@@ -1187,6 +1226,7 @@ $(document).ready(() => {
                 leafXmjSpreadObj.refreshQtyColor(select, nRow);
                 leafXmjSpreadObj.refreshQtyColor(select, nRow);
                 loadXmjMaterialData(iGclRow, nRow);
                 loadXmjMaterialData(iGclRow, nRow);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
                 SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
+                refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
             });
             });
         },
         },
         refreshQtyColor(xmj, row) {
         refreshQtyColor(xmj, row) {
@@ -1209,11 +1249,13 @@ $(document).ready(() => {
                     const orgValue = select[col.field];
                     const orgValue = select[col.field];
                     if (orgValue == validText || ((orgValue === '' || orgValue === null) && (validText === '' || validText === null))) {
                     if (orgValue == validText || ((orgValue === '' || orgValue === null) && (validText === '' || validText === null))) {
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        leafXmjSpreadObj.refreshQtyColor(select, nRow);
                         return;
                         return;
                     }
                     }
                     if (isNaN(validText)) {
                     if (isNaN(validText)) {
                         toastr.error('不能输入其它非数字类型字符');
                         toastr.error('不能输入其它非数字类型字符');
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        leafXmjSpreadObj.refreshQtyColor(select, nRow);
                         return;
                         return;
                     }
                     }
                     const qty = parseFloat(validText) !== 0 ? ZhCalc.round(parseFloat(validText), materialDecimal.qty) : 0;
                     const qty = parseFloat(validText) !== 0 ? ZhCalc.round(parseFloat(validText), materialDecimal.qty) : 0;
@@ -1253,8 +1295,10 @@ $(document).ready(() => {
                         leafXmjSpreadObj.refreshQtyColor(select, nRow);
                         leafXmjSpreadObj.refreshQtyColor(select, nRow);
                         loadXmjMaterialData(iGclRow, nRow);
                         loadXmjMaterialData(iGclRow, nRow);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
+                        refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
                     }, function () {
                     }, function () {
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        leafXmjSpreadObj.refreshQtyColor(select, nRow);
                     });
                     });
                     return;
                     return;
                 }
                 }
@@ -1333,6 +1377,7 @@ $(document).ready(() => {
                     loadMaterialData(index);
                     loadMaterialData(index);
                     checkNotJoinMaterialData();
                     checkNotJoinMaterialData();
                     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
                     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
+                    refreshTotalQtyColor(gclGatherData[index], index);
                     // leafXmjSpread.getActiveSheet().setSelection(info.cellRange.row, info.cellRange.col, info.cellRange.rowCount, info.cellRange.colCount);
                     // leafXmjSpread.getActiveSheet().setSelection(info.cellRange.row, info.cellRange.col, info.cellRange.rowCount, info.cellRange.colCount);
                 }, function () {
                 }, function () {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -1373,6 +1418,7 @@ $(document).ready(() => {
                         loadMaterialData(index);
                         loadMaterialData(index);
                         checkNotJoinMaterialData();
                         checkNotJoinMaterialData();
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
+                        refreshTotalQtyColor(gclGatherData[index], index);
                     }, function () {
                     }, function () {
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     });
                     });
@@ -1393,11 +1439,15 @@ $(document).ready(() => {
             $.contextMenu({
             $.contextMenu({
                 selector: '#leaf-xmj-spread',
                 selector: '#leaf-xmj-spread',
                 build: function ($trigger, e) {
                 build: function ($trigger, e) {
+                    const oldSelections = SpreadJsObj.getSelectObject(leafXmjSpread.getActiveSheet());
+                    const selections = leafXmjSpread.getActiveSheet().getSelections();
+                    const oldRow = selections && selections.length > 0 ? selections[0].row : null;
                     const target = SpreadJsObj.safeRightClickSelection($trigger, e, leafXmjSpread);
                     const target = SpreadJsObj.safeRightClickSelection($trigger, e, leafXmjSpread);
                     const sheet = ledgerSpread.getActiveSheet();
                     const sheet = ledgerSpread.getActiveSheet();
                     const select = SpreadJsObj.getSelectObject(sheet);
                     const select = SpreadJsObj.getSelectObject(sheet);
                     const index = gclGatherData.indexOf(select);
                     const index = gclGatherData.indexOf(select);
                     const xmj = target.row !== undefined ? gclGatherData[index].leafXmjs[target.row] : null;
                     const xmj = target.row !== undefined ? gclGatherData[index].leafXmjs[target.row] : null;
+                    if (oldSelections && oldRow !== null) leafXmjSpreadObj.refreshQtyColor(oldSelections, oldRow);
                     if (xmj) leafXmjSpreadObj.refreshQtyColor(xmj, target.row);
                     if (xmj) leafXmjSpreadObj.refreshQtyColor(xmj, target.row);
                     return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
                     return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
                 },
                 },
@@ -1645,6 +1695,7 @@ $(document).ready(() => {
                     // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                     // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                     loadMaterialData(index);
                     loadMaterialData(index);
                     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
                     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
+                    refreshTotalQtyColor(gclGatherData[index], index);
                 });
                 });
                 // postData(window.location.pathname + '/save', {type: 'del', id: select.id, mb_id: select.mb_id}, function (result) {
                 // postData(window.location.pathname + '/save', {type: 'del', id: select.id, mb_id: select.mb_id}, function (result) {
                     // const index = materialList.indexOf(select);
                     // const index = materialList.indexOf(select);
@@ -1772,6 +1823,7 @@ $(document).ready(() => {
                         // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                         // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                         loadMaterialData(index);
                         loadMaterialData(index);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
+                        refreshTotalQtyColor(gclGatherData[index], index);
                         materialSpread.getActiveSheet().setSelection(info.row + 1, info.col, 1, 1);
                         materialSpread.getActiveSheet().setSelection(info.row + 1, info.col, 1, 1);
                     }, function () {
                     }, function () {
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -1927,6 +1979,7 @@ $(document).ready(() => {
                     // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                     // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
                     loadMaterialData(index);
                     loadMaterialData(index);
                     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
                     SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
+                    refreshTotalQtyColor(gclGatherData[index], index);
                     materialSpread.getActiveSheet().setSelection(info.cellRange.row, info.cellRange.col, info.cellRange.rowCount, info.cellRange.colCount);
                     materialSpread.getActiveSheet().setSelection(info.cellRange.row, info.cellRange.col, info.cellRange.rowCount, info.cellRange.colCount);
                 }, function () {
                 }, function () {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -2100,6 +2153,7 @@ $(document).ready(() => {
                         lsheet.getRange(nRow, -1, 1, -1).backColor(color);
                         lsheet.getRange(nRow, -1, 1, -1).backColor(color);
                         leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
                         leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
+                        refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
                     });
                     });
                 },
                 },
                 deletePress: function (sheet) {
                 deletePress: function (sheet) {
@@ -2185,6 +2239,7 @@ $(document).ready(() => {
                             sheet.getRange(nRow, -1, 1, -1).backColor(color);
                             sheet.getRange(nRow, -1, 1, -1).backColor(color);
                             leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
                             leafXmjSpreadObj.refreshQtyColor(lselect, nRow);
                             SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
                             SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
+                            refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
                         }, function () {
                         }, function () {
                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
                         });
                         });
@@ -2282,6 +2337,7 @@ $(document).ready(() => {
                         calculateJiaCha(gclGatherData, iGclRow);
                         calculateJiaCha(gclGatherData, iGclRow);
                         SpreadJsObj.reLoadRowData(sheet, nRow);
                         SpreadJsObj.reLoadRowData(sheet, nRow);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
                         SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), iGclRow);
+                        refreshTotalQtyColor(gclGatherData[iGclRow], iGclRow);
                         loadXmjMaterialData(iGclRow, nRow);
                         loadXmjMaterialData(iGclRow, nRow);
                     }, function () {
                     }, function () {
                         SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
                         SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
@@ -2441,6 +2497,7 @@ $(document).ready(() => {
             // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
             // const xmjIndex = gclGatherData[index].leafXmjs.indexOf(xmjSelect);
             loadMaterialData(index);
             loadMaterialData(index);
             SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
             SpreadJsObj.reLoadRowData(ledgerSpread.getActiveSheet(), index);
+            refreshTotalQtyColor(gclGatherData[index], index);
         });
         });
     });
     });
 
 
@@ -2514,6 +2571,7 @@ $(document).ready(() => {
         }
         }
         calculateJiaCha(gclGatherData);
         calculateJiaCha(gclGatherData);
         SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
         SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
+        refreshTotalQtyColor(gclGatherData);
         loadLeafXmjData(0);
         loadLeafXmjData(0);
         loadMaterialData(0);
         loadMaterialData(0);
         loadXmjMaterialData(0, 0);
         loadXmjMaterialData(0, 0);

+ 8 - 5
app/public/js/pos_calc_tmpl.js

@@ -305,13 +305,16 @@ $(document).ready(() => {
         const getCurTemplate = function() {
         const getCurTemplate = function() {
             return curTemplate;
             return curTemplate;
         };
         };
-        const getTemplateCaptionHtml = function(template) {
+        const getTemplateCaptionInnerHtml = function(template) {
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
             const usedHtml = template.used_count > 0 ? '<i class="ml-1 fa fa-lock text-danger"></i>' : '';
-            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}"><div>${template.name}${usedHtml}</div>` +
+            return `<div>${template.name}${usedHtml}</div>` +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <div class="btn-group-table" style="display: none;">\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="编辑" name="renameTemplate"><i class="fa fa-pencil fa-fw"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
                 '    <a href="javascript: void(0);" class="mr-1" data-toggle="tooltip" data-placement="bottom" data-original-title="删除" name="delTemplate"><i class="fa fa-trash-o fa-fw text-danger"></i></a>\n' +
-                '</div></div>';
+                '</div>';
+        };
+        const getTemplateCaptionHtml = function(template) {
+            return `<div class="d-flex justify-content-between align-items-center table-file" templateId="${template.id}">` + getTemplateCaptionInnerHtml(template) + '</div>';
         };
         };
         const getTemplateHtml = function(template) {
         const getTemplateHtml = function(template) {
             const html = [];
             const html = [];
@@ -344,7 +347,7 @@ $(document).ready(() => {
             });
             });
         };
         };
         if (templates.length > 0) setCurTemplate(templates[0]);
         if (templates.length > 0) setCurTemplate(templates[0]);
-        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml }
+        return { setCurTemplate, getCurTemplate, addTemplate, delTemplate, renameTemplate, getTemplateCaptionHtml, getTemplateCaptionInnerHtml }
     })(templateList);
     })(templateList);
 
 
     $('body').on('click', '.table-file', function(e) {
     $('body').on('click', '.table-file', function(e) {
@@ -388,7 +391,7 @@ $(document).ready(() => {
         const template = templateList.find(x => { return x.id === templateId; });
         const template = templateList.find(x => { return x.id === templateId; });
         if (!template) return;
         if (!template) return;
 
 
-        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionHtml(template));
+        $(`.table-file[templateId=${templateId}]`).html(templateObj.getTemplateCaptionInnerHtml(template));
     });
     });
     $('body').on('click', 'a[name=delTemplate]', function(e) {
     $('body').on('click', 'a[name=delTemplate]', function(e) {
         e.stopPropagation();
         e.stopPropagation();

+ 1 - 1
app/public/js/shares/cs_tools.js

@@ -806,7 +806,7 @@ const showSelectTab = function(select, spread, afterShow) {
         SpreadJsObj.initSheet(resultSpread.getActiveSheet(), setting.resultSpreadSetting);
         SpreadJsObj.initSheet(resultSpread.getActiveSheet(), setting.resultSpreadSetting);
         let searchResult = [];
         let searchResult = [];
         const defaultCheck = function(node, keyword) {
         const defaultCheck = function(node, keyword) {
-            if (setting.skipFilter && node.filter === true) return false;
+            if (setting.skipFilter && node[setting.skipFilter.field] === setting.skipFilter.value) return false;
 
 
             const keyNum = _.toNumber(keyword);
             const keyNum = _.toNumber(keyword);
             return (node.code && node.code.indexOf(keyword) > -1) ||
             return (node.code && node.code.indexOf(keyword) > -1) ||

+ 8 - 4
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -780,7 +780,7 @@ const SpreadJsObj = {
         if (colSetting.cellType === 'customizeCombo') {
         if (colSetting.cellType === 'customizeCombo') {
             const cellKey = colSetting.cellTypeKey ? 'customizeCombo-' + colSetting.cellTypeKey : 'customizeCombo';
             const cellKey = colSetting.cellTypeKey ? 'customizeCombo-' + colSetting.cellTypeKey : 'customizeCombo';
             if (!sheet.extendCellType[cellKey]) {
             if (!sheet.extendCellType[cellKey]) {
-                sheet.extendCellType[cellKey] = this.CellType.getCustomizeComboCellType(colSetting.comboItems);
+                sheet.extendCellType[cellKey] = this.CellType.getCustomizeComboCellType(colSetting.comboItems, colSetting.maxDrop);
                 SpreadJsObj._addActivePaintEvents(sheet, sheet.extendCellType[cellKey]);
                 SpreadJsObj._addActivePaintEvents(sheet, sheet.extendCellType[cellKey]);
             }
             }
             sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType[cellKey]);
             sheet.getRange(-1, col, -1, 1).cellType(sheet.extendCellType[cellKey]);
@@ -2536,26 +2536,28 @@ const SpreadJsObj = {
         getUnitCellType: function (comboEdit, items = ['m', 'km', 'm2', 'm3', 'dm3', 'kg', 't', 'm3·km',
         getUnitCellType: function (comboEdit, items = ['m', 'km', 'm2', 'm3', 'dm3', 'kg', 't', 'm3·km',
             '总额', '月' ,'项', '处' ,'个', '根', '棵', '块', '台', '系统', '延米', '每一试桩',
             '总额', '月' ,'项', '处' ,'个', '根', '棵', '块', '台', '系统', '延米', '每一试桩',
             '桥长米', '公路公里', '株', '组', '座', '元', '工日', '套', '台班', '辆', '艘班', '亩', '片',
             '桥长米', '公路公里', '株', '组', '座', '元', '工日', '套', '台班', '辆', '艘班', '亩', '片',
-            'm/处', 'm/道', 'm/座', 'm2/m', 'm3/m', 'm3/处', '根/米', 'm3/m2']) {
+            'm/处', 'm/道', 'm/座', 'm2/m', 'm3/m', 'm3/处', '根/米', 'm3/m2'], maxDrop) {
             let combo = this.getActiveComboCellType();
             let combo = this.getActiveComboCellType();
             combo.editable(comboEdit);
             combo.editable(comboEdit);
             combo.itemHeight(10).items(items);
             combo.itemHeight(10).items(items);
+            if (maxDrop) combo.maxDropDownItems(maxDrop);
             return combo;
             return combo;
         },
         },
         /**
         /**
          * 获取 自定义的CellType
          * 获取 自定义的CellType
          * @returns {GC.Spread.Sheets.CellTypes.ComboBox}
          * @returns {GC.Spread.Sheets.CellTypes.ComboBox}
          */
          */
-        getCustomizeComboCellType: function (items) {
+        getCustomizeComboCellType: function (items, maxDrop) {
             let combo = this.getActiveComboCellType();
             let combo = this.getActiveComboCellType();
             if (typeof items[0] === 'string') {
             if (typeof items[0] === 'string') {
                 combo.itemHeight(10).items(items);
                 combo.itemHeight(10).items(items);
             } else {
             } else {
                 combo.itemHeight(10).editorValueType(spreadNS.CellTypes.EditorValueType.value).items(items);
                 combo.itemHeight(10).editorValueType(spreadNS.CellTypes.EditorValueType.value).items(items);
             }
             }
+            if (maxDrop) combo.maxDropDownItems(maxDrop);
             return combo;
             return combo;
         },
         },
-        getSpecComboCellType: function (items) {
+        getSpecComboCellType: function (items, maxDrop) {
             const ComboCellType = function () {};
             const ComboCellType = function () {};
             ComboCellType.prototype = new spreadNS.CellTypes.ComboBox();
             ComboCellType.prototype = new spreadNS.CellTypes.ComboBox();
             const proto = ComboCellType.prototype;
             const proto = ComboCellType.prototype;
@@ -2601,6 +2603,7 @@ const SpreadJsObj = {
             };
             };
             const combo = new ComboCellType();
             const combo = new ComboCellType();
             combo.itemHeight(10).items(items).editorValueType(spreadNS.CellTypes.EditorValueType.value);
             combo.itemHeight(10).items(items).editorValueType(spreadNS.CellTypes.EditorValueType.value);
+            if (maxDrop) combo.maxDropDownItems(maxDrop);
             return combo;
             return combo;
         },
         },
         getStageComboCellType: function () {
         getStageComboCellType: function () {
@@ -2612,6 +2615,7 @@ const SpreadJsObj = {
                 const col = setting.cols[context.col];
                 const col = setting.cols[context.col];
                 const data = SpreadJsObj.getSelectObject(context.sheet);
                 const data = SpreadJsObj.getSelectObject(context.sheet);
                 this.itemHeight(10).editorValueType(spreadNS.CellTypes.EditorValueType.value).items(col.getItems(data));
                 this.itemHeight(10).editorValueType(spreadNS.CellTypes.EditorValueType.value).items(col.getItems(data));
+                if (col.maxDrop) combo.maxDropDownItems(col.maxDrop);
             };
             };
             return new ComboCellType();
             return new ComboCellType();
         },
         },

+ 1 - 1
app/service/calc_tmpl.js

@@ -18,7 +18,7 @@ const ValidTemplateType = ['posCalc', 'cost'];
 const PosCalc = (function(){
 const PosCalc = (function(){
     const EmptySpreadCache = {
     const EmptySpreadCache = {
         cols: [],
         cols: [],
-        emptyRows: 3,
+        emptyRows: 6,
         headRows: 1,
         headRows: 1,
         headRowHeight: [32],
         headRowHeight: [32],
         defaultRowHeight: 21,
         defaultRowHeight: 21,

+ 1 - 1
app/service/ledger.js

@@ -881,7 +881,7 @@ module.exports = app => {
                     await conn.insert(this.service.ledgerExtra.tableName, { id: data.id, tid, calc_template: data.calc_template });
                     await conn.insert(this.service.ledgerExtra.tableName, { id: data.id, tid, calc_template: data.calc_template });
                 }
                 }
                 // 重算所有数据
                 // 重算所有数据
-                await this.ctx.service.posCalcDetail.resetBillsCalcTemplate(conn, data.id, data.calc_template);
+                const calc = await this.ctx.service.posCalcDetail.resetBillsCalcTemplate(conn, data.id, data.calc_template);
                 await conn.commit();
                 await conn.commit();
             } catch (err) {
             } catch (err) {
                 await conn.rollback();
                 await conn.rollback();

+ 1 - 1
app/service/material_exponent_shard.js

@@ -235,7 +235,7 @@ module.exports = app => {
                 bq.value = calc.value;
                 bq.value = calc.value;
                 bq.select = oldcalc ? oldcalc.select : false;
                 bq.select = oldcalc ? oldcalc.select : false;
             }
             }
-            await this.calcMaterialExTp(transaction, new_ex_calc, mid, msid, decimal, rate);
+            await this.calcMaterialExTp(transaction, new_ex_calc, mid, msid, null, decimal, rate);
             return new_ex_calc;
             return new_ex_calc;
         }
         }
 
 

+ 7 - 2
app/service/pos_calc_detail.js

@@ -10,6 +10,10 @@
 const strField = ['str1', 'str2', 'str3', 'str4'];
 const strField = ['str1', 'str2', 'str3', 'str4'];
 const numField = ['num_a', 'num_b', 'num_c', 'num_d', 'num_e', 'num_f', 'num_g', 'num_h', 'num_i'];
 const numField = ['num_a', 'num_b', 'num_c', 'num_d', 'num_e', 'num_f', 'num_g', 'num_h', 'num_i'];
 const specialField = ['spec', 'qty', 'expr'];
 const specialField = ['spec', 'qty', 'expr'];
+const math = require('mathjs');
+math.config({
+    number: 'BigNumber',
+});
 
 
 module.exports = app => {
 module.exports = app => {
 
 
@@ -51,7 +55,8 @@ module.exports = app => {
             }
             }
         }
         }
         _reCalcQty(data, template) {
         _reCalcQty(data, template) {
-            const result = { id: data.id, expr: template.calc_expr };
+            const qtyExpr = template.calc_expr.find(x => { return x.field === 'qty'; });
+            const result = { id: data.id, expr: qtyExpr ? qtyExpr.expr : '' };
             for (const nf of numField) {
             for (const nf of numField) {
                 result[nf] = this.ctx.helper.round(data[nf] || 0, this.getDecimal(template.decimal, nf));
                 result[nf] = this.ctx.helper.round(data[nf] || 0, this.getDecimal(template.decimal, nf));
                 result.expr = result.expr.replace(new RegExp(nf, 'gm'), data[nf] || 0);
                 result.expr = result.expr.replace(new RegExp(nf, 'gm'), data[nf] || 0);
@@ -290,7 +295,7 @@ module.exports = app => {
                     detailUpdateDatas.push(ud);
                     detailUpdateDatas.push(ud);
                     pQty = this.ctx.helper.add(ud.qty, pQty);
                     pQty = this.ctx.helper.add(ud.qty, pQty);
                 }
                 }
-                const up = { id: p.id, sgfh_qty: this.ctx.helper.round(pQty, precision.value) };
+                const up = { id: p.id, sgfh_qty: this.ctx.helper.round(pQty, precision.value), sgfh_expr: '' };
                 up.quantity = this.ctx.helper.sum([up.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
                 up.quantity = this.ctx.helper.sum([up.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
                 posUpdateData.push(up);
                 posUpdateData.push(up);
                 bQty = this.ctx.helper.add(bQty, up.sgfh_qty);
                 bQty = this.ctx.helper.add(bQty, up.sgfh_qty);