Browse Source

Merge branch 'minusNoValue' into dev

Conflicts:
	app/controller/stage_controller.js
	sql/update.sql
MaiXinRong 3 years atrás
parent
commit
8cb1249016

+ 11 - 8
app/base/base_tree_service.js

@@ -747,7 +747,7 @@ class TreeService extends Service {
             selfOperate: '-',
         });
         this.sqlBuilder.setUpdateData(this.setting.fullPath, {
-            value: [this.setting.fullPath, this.db.escape(select[this.setting.pid] + '-'), this.db.escape('')],
+            value: [this.setting.fullPath, this.db.escape(`-${select[this.setting.pid]}-`), this.db.escape('-')],
             literal: 'Replace',
         });
         const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
@@ -852,7 +852,7 @@ class TreeService extends Service {
                 updateData[this.setting.pid] = parent[this.setting.pid];
                 updateData[this.setting.order] = parent[this.setting.order] + i + 1;
                 updateData[this.setting.level] = s[this.setting.level] - 1;
-                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(s[this.setting.pid] + '-', '');
+                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(`-${s[this.setting.pid]}-`, '-');
                 newPath.push(updateData[this.setting.fullPath]);
                 if (s.is_leaf && s.id === last.id) {
                     const nexts = await this.getNextsData(mid, parent[this.setting.kid], last[this.setting.order]);
@@ -891,7 +891,7 @@ class TreeService extends Service {
      * @return {Promise<*>}
      * @private
      */
-    async _syncDownlevelChildren(select, pre) {
+    async _syncDownlevelChildren(select, newFullPath) {
         this.initSqlBuilder();
         this.sqlBuilder.setAndWhere(this.setting.mid, {
             value: select[this.setting.mid],
@@ -906,7 +906,7 @@ class TreeService extends Service {
             selfOperate: '+',
         });
         this.sqlBuilder.setUpdateData(this.setting.fullPath, {
-            value: [this.setting.fullPath, this.db.escape(select[this.setting.kid] + '-'), this.db.escape(pre[this.setting.kid] + '-' + select[this.setting.kid] + '-')],
+            value: [this.setting.fullPath, this.db.escape(select[this.setting.fullPath] + '-'), this.db.escape(newFullPath + '-')],
             literal: 'Replace',
         });
         const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
@@ -943,13 +943,16 @@ class TreeService extends Service {
                 updateData[this.setting.pid] = pre[this.setting.kid];
                 updateData[this.setting.order] = preLastChild ? preLastChild[this.setting.order] + i + 1 : i + 1;
                 updateData[this.setting.level] = s[this.setting.level] + 1;
-                const orgLastPath = s[this.setting.level] === 1 ? s[this.setting.kid] : '-' + s[this.setting.kid];
-                const newLastPath = s[this.setting.level] === 1 ? pre[this.setting.kid] + '-' + s[this.setting.kid] : '-' + pre[this.setting.kid] + '-' + s[this.setting.kid];
-                updateData[this.setting.fullPath] = s[this.setting.fullPath].replace(orgLastPath, newLastPath);
+                if (s[this.setting.level] === 1) {
+                    updateData[this.setting.fullPath] = pre[this.setting.kid] + '-' + s[this.setting.kid];
+                } else {
+                    const index = s[this.setting.fullPath].lastIndexOf(s[this.setting.kid]);
+                    updateData[this.setting.fullPath] = s[this.setting.fullPath].substring(0, index) + '-' + pre[this.setting.kid] + '-' + s[this.setting.kid];
+                }
                 newPath.push(updateData[this.setting.fullPath]);
                 await this.transaction.update(this.tableName, updateData);
                 // 选中节点--全部子节点(含孙) level++, full_path
-                await this._syncDownlevelChildren(s, pre);
+                await this._syncDownlevelChildren(s, updateData[this.setting.fullPath]);
             }
             // 选中节点--前兄弟节点 is_leaf应为false, 清空计算相关字段
             const updateData2 = { id: pre.id };

+ 14 - 7
app/const/spread.js

@@ -17,6 +17,7 @@ const thirdPartyCols = {
     gxby: ['gxby'],
     dagl: ['dagl']
 };
+const minusNoValueCols = ['qc_minus_qty'];
 
 const withCl = {
     ledger: {
@@ -195,8 +196,9 @@ const stageTz = {
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'contract_tp', hAlign: 2, width: 60, type: 'Number'},
-            {title: '本期数量变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期数量变更|数量', colSpan: '3|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '本期完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '截止本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
@@ -236,8 +238,9 @@ const stageTz = {
             {title: '台账数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 60, formatter: '@', readOnly: true},
             {title: '现场实际数量', colSpan: '1', rowSpan: '2', field: 'real_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '预计变更数量', colSpan: '1', rowSpan: '2', field: 'estimate_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期计量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -273,8 +276,9 @@ const stageCl = {
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'contract_tp', hAlign: 2, width: 60, type: 'Number'},
-            {title: '本期数量变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
+            {title: '本期数量变更|数量', colSpan: '3|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '本期完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '截止本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
@@ -312,8 +316,9 @@ const stageCl = {
             {title: '位置', colSpan: '1', rowSpan: '2', field: 'position', hAlign: 0, width: 60, formatter: '@'},
             {title: '现场实际数量', colSpan: '1', rowSpan: '2', field: 'real_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '预计变更数量', colSpan: '1', rowSpan: '2', field: 'estimate_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期计量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -350,8 +355,9 @@ const stageNoCl = {
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'contract_tp', hAlign: 2, width: 60, type: 'Number'},
-            {title: '本期数量变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
+            {title: '本期数量变更|数量', colSpan: '3|1', rowSpan: '1|1', field: 'qc_qty', hAlign: 2, width: 60, type: 'Number',},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'qc_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '本期完成计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'gather_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
             {title: '截止本期合同计量|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, readOnly: true, type: 'Number'},
@@ -389,8 +395,9 @@ const stageNoCl = {
             {title: 'ex_memo1', colSpan: '1', rowSpan: '2', field: 'ex_memo1', hAlign: 0, width: 100, formatter: '@', cellType: 'ellipsisAutoTip'},
             {title: '现场实际数量', colSpan: '1', rowSpan: '2', field: 'real_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '预计变更数量', colSpan: '1', rowSpan: '2', field: 'estimate_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
-            {title: '本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
+            {title: '本期计量|合同', colSpan: '4|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'qc_qty', hAlign: 2, width: 80, type: 'Number'},
+            {title: '|不计价', colSpan: '|1', rowSpan: '|1', field: 'qc_minus_qty', hAlign: 2, width: 60, type: 'Number'},
             {title: '|完成', colSpan: '|1', rowSpan: '|1', field: 'gather_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '截止本期计量|合同', colSpan: '3|1', rowSpan: '1|1', field: 'end_contract_qty', hAlign: 2, width: 60, type: 'Number', readOnly: true},
             {title: '|数量变更', colSpan: '|1', rowSpan: '|1', field: 'end_qc_qty', hAlign: 2, width: 80, type: 'Number', readOnly: true},
@@ -587,7 +594,7 @@ module.exports = {
     stageNoCl,
     stageGather,
     stageCompare,
-    filterCols: { tzWithoutCols, dgnCols, clCols, stageDgnCols, realCompleteCols, thirdPartyCols},
+    filterCols: { tzWithoutCols, dgnCols, clCols, stageDgnCols, realCompleteCols, thirdPartyCols, minusNoValueCols},
     measure,
     blank,
 };

+ 15 - 0
app/const/stage_filter.js

@@ -0,0 +1,15 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+module.exports = {
+    stageBills: { index: ['lid'], times: 'times', order: 'order' },
+    stagePos: { index: ['pid'], times: 'times', order: 'order' },
+    stageChange: { index: ['lid', 'pid', 'cbid', 'no_value'], times: 'stimes', order: 'sorder', },
+};

+ 3 - 0
app/const/tender_info.js

@@ -166,6 +166,9 @@ const defaultInfo = {
     },
     fun_rela: {
         hintOver: true,
+        stage_change: {
+            minusNoValue: false,
+        },
         sum_load: {
             ignoreParent: false,
         },

+ 34 - 9
app/controller/stage_controller.js

@@ -88,13 +88,21 @@ module.exports = app => {
          * 获取SpreadSetting
          * @private
          */
-        _getSpreadSetting() {
+        _getSpreadSetting(funInfo) {
             const _ = this.app._;
             function removeFieldCols(setting, cols) {
                 _.remove(setting.cols, function(c) {
                     return cols.indexOf(c.field) > -1;
                 });
             }
+            function hiddenFieldCols(setting, cols) {
+                setting.cols.forEach(x => {
+                    if (cols.indexOf(x.field) >= 0) {
+                        x.defaultVisible = false;
+                        x.visible = false;
+                    }
+                });
+            }
             const tender = this.ctx.tender,
                 stage = this.ctx.stage;
             const stageSetting = tender.data.measure_type === measureType.tz.value
@@ -116,6 +124,10 @@ module.exports = app => {
                 removeFieldCols(ledger, spreadConst.filterCols.thirdPartyCols.dagl);
                 removeFieldCols(pos, spreadConst.filterCols.thirdPartyCols.dagl);
             }
+            if (!funInfo.minusNoValue || !tender.info.fun_rela.stage_change.minusNoValue) {
+                hiddenFieldCols(ledger, spreadConst.filterCols.minusNoValueCols);
+                hiddenFieldCols(pos, spreadConst.filterCols.minusNoValueCols);
+            }
             if (this.ctx.stage.readOnly || this.ctx.stage.revising) {
                 ledger.readOnly = true;
                 pos.readOnly = true;
@@ -168,7 +180,8 @@ module.exports = app => {
             try {
                 await this._getStageAuditViewData(ctx);
                 const renderData = await this._getDefaultRenderData(ctx);
-                [renderData.ledgerSpread, renderData.posSpread] = this._getSpreadSetting();
+                const projectFunInfo = await this.ctx.service.project.getFunRela(ctx.session.sessionProject.id);
+                [renderData.ledgerSpread, renderData.posSpread] = this._getSpreadSetting(projectFunInfo);
                 const sjsRela = await this.ctx.service.project.getSjsRela(ctx.session.sessionProject.id);
                 this.ctx.helper.refreshSpreadShow(sjsRela.ledgerCol, [renderData.ledgerSpread, renderData.posSpread]);
                 renderData.changeConst = changeConst;
@@ -193,7 +206,7 @@ module.exports = app => {
                 renderData.sfData = sfData;
                 // 收方单附件删除权限
                 renderData.sfAttDelPower = ctx.session.sessionUser.accountId === ctx.stage.user_id || ctx.helper._.findIndex(ctx.stage.auditors2, { aid: ctx.session.sessionUser.accountId }) !== -1;
-                const projectFunInfo = await this.ctx.service.project.getFunRela(ctx.session.sessionProject.id);
+                renderData.minusNoValue = projectFunInfo.minusNoValue && ctx.tender.info.fun_rela.stage_change.minusNoValue;
                 renderData.hintOver = projectFunInfo.hintOver && ctx.tender.info.fun_rela.hintOver;
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 await this.layout('stage/index.ejs', renderData, 'stage/modal.ejs');
@@ -272,11 +285,18 @@ module.exports = app => {
             // 查询截止上期数据
             const preStageData = ctx.stage.order > 1 ? await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1) : [];
             this.ctx.helper.assignRelaData(ledgerData, [
+<<<<<<< HEAD
                 { data: dgnData, fields: ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'], prefix: '', relaId: 'id' },
                 { data: extraData, fields: this.ledgerExtraColumn, prefix: '', relaId: 'id' },
                 { data: importData, fields: ['is_import'], prefix: '', relaId: 'lid' },
                 { data: curStageData, fields: ['contract_qty', 'contract_expr', 'contract_tp', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid' },
                 { data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'used'], prefix: 'pre_', relaId: 'lid' },
+=======
+                { data: dgnData, fields: ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'], prefix: '', relaId: 'id'},
+                { data: importData, fields: ['is_import'], prefix: '', relaId: 'lid'},
+                { data: curStageData, fields: ['contract_qty', 'contract_expr', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'lid' },
+                { data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'used'], prefix: 'pre_', relaId: 'lid' },
+>>>>>>> minusNoValue
             ]);
             return ledgerData;
         }
@@ -301,9 +321,14 @@ module.exports = app => {
             // 查询截止上期数据
             const preStageData = ctx.stage.order > 1 ? await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.order - 1) : [];
             this.ctx.helper.assignRelaData(posData, [
+<<<<<<< HEAD
                 { data: extraData, fields: this.posExtraColumn, prefix: '', relaId: 'id'},
                 { data: curStageData, fields: ['contract_qty', 'contract_expr', 'qc_qty', 'postil'], prefix: '', relaId: 'pid' },
                 { data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid' },
+=======
+                { data: curStageData, fields: ['contract_qty', 'contract_expr', 'qc_qty', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'pid' },
+                { data: preStageData, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'], prefix: 'pre_', relaId: 'pid' },
+>>>>>>> minusNoValue
             ]);
             return posData;
         }
@@ -448,8 +473,8 @@ module.exports = app => {
                     preStageData = [];
                 }
                 this.ctx.helper.assignRelaData(responseData.data, [
-                    { data: curStageData, fields: ['contract_qty', 'qc_qty', 'postil'], prefix: '', relaId: 'pid' },
-                    { data: preStageData, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid' },
+                    { data: curStageData, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'pid' },
+                    { data: preStageData, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'], prefix: 'pre_', relaId: 'pid' },
                 ]);
                 ctx.body = responseData;
             } catch (err) {
@@ -509,7 +534,7 @@ module.exports = app => {
                 }
                 const bills = data.bills ? data.bills : await ctx.service.ledger.getDataById(data.pos.lid);
                 const pos = data.pos;
-                const changes = await ctx.service.change.getValidChanges(ctx.tender, ctx.stage, bills);
+                const changes = await ctx.service.change.getValidChanges(ctx.tender, ctx.stage, data);
                 const useChanges = ctx.stage.readOnly
                     ? await ctx.service.stageChange.getAuditorStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder, bills.id, pos ? pos.id : -1)
                     : await ctx.service.stageChange.getLastestStageData(ctx.tender.id, ctx.stage.id, bills.id, pos ? pos.id : -1);
@@ -532,14 +557,14 @@ module.exports = app => {
                 if (!data.target || (!data.target.bills && !data.target.pos) || !data.change) {
                     throw '调用变更令数据错误';
                 }
-                let result, minus, posMinus;
+                let result;
                 if (data.target.pos) {
-                    result = await ctx.service.stageChange.posChange(data.target.pos, data.change);
+                    result = await ctx.service.stageChange.posChange(data.target.pos, data.target.minus, data.change);
                     result.change = { target: { lid: data.target.pos.lid, pid: data.target.pos.id } };
                     result.change.data = await ctx.service.stageChange.getLastestStageData(ctx.tender.id,
                         ctx.stage.id, data.target.pos.lid, data.target.pos.id);
                 } else {
-                    result = await ctx.service.stageChange.billsChange(data.target.bills, data.change);
+                    result = await ctx.service.stageChange.billsChange(data.target.bills, data.target.minus, data.change);
                     result.change = { target: { lid: data.target.bills.id, pid: '-1' } };
                     result.change.data = await ctx.service.stageChange.getLastestStageData(ctx.tender.id,
                         ctx.stage.id, data.target.bills.id, '-1');

+ 1 - 1
app/lib/rptCustomData.js

@@ -304,7 +304,7 @@ class jhHelper {
         this.ctx.helper.saveBufferFile(JSON.stringify(stageChangeDetail, '', '\t'), this.ctx.app.baseDir + '/temp.json');
         for (const dc of gsDefine.defaultCompare) {
             if (!auditors[dc]) continue;
-             const scd = helper.filterTimesOrderData(stageChangeDetail, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder', auditors[dc].times, auditors[dc].order);
+             const scd = helper.filterTimesOrderData(stageChangeDetail, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder', auditors[dc].times, auditors[dc].order);
             this._loadChangeDetail(billsIndex, scd, gsDefine, `r${dc}_`);
             this.prefixes.push(`r${dc}_`);
         }

+ 13 - 1
app/public/js/shares/sjs_setting.js

@@ -80,5 +80,17 @@ const sjsSettingObj = (function () {
             }
         }
     };
-    return {setFxTreeStyle, FxTreeStyle, setGridSelectStyle, setTpThousandthFormat, setThousandthFormat, setTpColsThousandthFormat, setPropValue, set3FCols};
+    const setQcCols = function (cols, rela){
+        for (const r of rela) {
+            const col = _.find(cols, {field: r.field});
+            if (!col) continue;
+
+            col.readOnly = true;
+            col.cellType = 'activeImageBtn';
+            col.normalImg = '#ellipsis-icon';
+            col.indent = 5;
+            col.showImage = r.showImage;
+        }
+    };
+    return {setFxTreeStyle, FxTreeStyle, setGridSelectStyle, setTpThousandthFormat, setThousandthFormat, setTpColsThousandthFormat, setPropValue, set3FCols, setQcCols};
 })();

+ 6 - 0
app/public/js/sr_detail.js

@@ -894,6 +894,8 @@ $(document).ready(() => {
                 SpreadJsObj.reLoadSheetHeader(self.sheet);
                 $('[name=type-title-contract]').text('本期合同计量金额');
                 $('[name=type-title-qc]').text('本期变更计量金额');
+                $('#show-qc-minus-jl').parent().hidden();
+                $('#qc-minus-jl').parent().hidden();
             } else {
                 const jlCol = self.spreadSetting.cols.find(function (x) {return x.field === 'jl'});
                 jlCol.title = '本期计量数量';
@@ -967,6 +969,10 @@ $(document).ready(() => {
             $('#show-qc-jl').text(qcJl);
             $('#qc-jl').val(qcJl);
 
+            const qcMinusJl = data && data.qc_minus_jl ? data.qc_minus_jl : '';
+            $('#show-qc-minus-jl').text(qcMinusJl);
+            $('#qc-jl-minus-jl').val(qcMinusJl);
+
             const bglCode = data && data.bgl_code ? data.bgl_code : '';
             $('#show-bgl-code').text(bglCode);
             $('#bgl-code').val(bglCode);

+ 42 - 28
app/public/js/stage.js

@@ -32,7 +32,7 @@ function getExprInfo (field) {
 function customColDisplay () {
     const defaultSetting = [
         { title: '本期计量合同', fields: ['contract_qty', 'contract_tp'], visible: true },
-        { title: '本期数量变更', fields: ['qc_qty', 'qc_tp', 'qc_bgl'], visible: true },
+        { title: '本期数量变更', fields: ['qc_qty', 'qc_tp', 'qc_bgl', 'qc_minus_qty'], visible: true },
         { title: '本期完成计量', fields: ['gather_qty', 'gather_tp'], visible: true },
         { title: '截止本期计量合同', fields: ['end_contract_qty', 'end_contract_tp'], visible: true },
         { title: '截止本期数量变更', fields: ['end_qc_qty', 'end_qc_tp', 'end_qc_bgl'], visible: true },
@@ -65,7 +65,7 @@ function customizeStageTreeSetting(setting, customDisplay) {
     for (const cd of customDisplay) {
         for (const c of setting.cols) {
             if (cd.fields.indexOf(c.field) !== -1) {
-                c.visible = cd.visible;
+                c.visible = c.defaultVisible === undefined ? cd.visible : c.defaultVisible && cd.visible;
             }
         }
     }
@@ -226,7 +226,7 @@ $(document).ready(() => {
         empty_code: { enable: 0 },
         calc: {
             enable: 1,
-            fields: ['contract_qty', 'qc_qty'],
+            fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'],
         },
         zero: { enable: 0 },
         tp: {
@@ -267,7 +267,7 @@ $(document).ready(() => {
         markExpandSubKey: window.location.pathname.split('/')[2],
     };
     // 台账树结构计算相关设置
-    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
+    stageTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'postil', 'used', 'contract_expr'];
     stageTreeSetting.calcFields = ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
         'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
     stageTreeSetting.calcFun = function (node) {
@@ -276,6 +276,7 @@ $(document).ready(() => {
             node.gather_qty = ZhCalc.add(node.contract_qty, node.qc_qty);
             node.end_contract_qty = ZhCalc.add(node.pre_contract_qty, node.contract_qty);
             node.end_qc_qty = ZhCalc.add(node.pre_qc_qty, node.qc_qty);
+            node.end_qc_minus_qty = ZhCalc.add(node.pre_qc_minus_qty, node.qc_minus_qty);
             node.end_gather_qty = ZhCalc.add(node.pre_gather_qty, node.gather_qty);
         }
         node.pre_gather_tp = ZhCalc.add(node.pre_contract_tp, node.pre_qc_tp);
@@ -300,13 +301,14 @@ $(document).ready(() => {
     // 初始化 计量单元 数据结构
     const stagePosSetting = {
         id: 'id', ledgerId: 'lid',
-        updateFields: ['contract_qty', 'qc_qty', 'postil', 'contract_expr'],
+        updateFields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'postil', 'contract_expr'],
     };
     stagePosSetting.calcFun = function (pos) {
         pos.pre_gather_qty = ZhCalc.add(pos.pre_contract_qty, pos.pre_qc_qty);
         pos.gather_qty = ZhCalc.add(pos.contract_qty, pos.qc_qty);
         pos.end_contract_qty = ZhCalc.add(pos.pre_contract_qty, pos.contract_qty);
         pos.end_qc_qty = ZhCalc.add(pos.pre_qc_qty, pos.qc_qty);
+        pos.end_qc_minus_qty = ZhCalc.add(pos.pre_qc_minus_qty, pos.qc_minus_qty);
         pos.end_gather_qty = ZhCalc.add(pos.pre_gather_qty, pos.gather_qty);
         pos.sum = ZhCalc.add(pos.end_qc_qty, pos.quantity);
         pos.end_gather_percent = ZhCalc.mul(ZhCalc.div(pos.end_gather_qty, pos.sum), 100, 2);
@@ -413,10 +415,7 @@ $(document).ready(() => {
             // 切换变更令,加载右侧明细数据
             this.spread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
                 const change = SpreadJsObj.getSelectObject(info.sheet);
-                console.log(change);
-                if(change) {
-                    self._loadChangeDetail(change);
-                }
+                if(change) self._loadChangeDetail(change);
             });
             // 填写本期计量
             this.spread.bind(spreadNS.Events.EditEnded, function (e, info) {
@@ -528,7 +527,7 @@ $(document).ready(() => {
             for (const c of this.changes) {
                 c.bamount = _.toNumber(c.b_amount);
                 c.vamount = ZhCalc.sub(ZhCalc.sub(c.bamount, c.used_amount), c.stage_used_amount);
-                const uc = _.find(this.useChanges, {cid: c.cid, cbid: c.cbid});
+                const uc = _.find(this.useChanges, {cid: c.cid, cbid: c.cbid, no_value: this.callData.noValue});
                 if (uc) {
                     c.org_uamount = uc.qty;
                     c.uamount = uc.qty;
@@ -639,12 +638,7 @@ $(document).ready(() => {
     const slSpread = SpreadJsObj.createNewSpread($('#stage-ledger')[0]);
     customizeStageTreeSetting(ledgerSpreadSetting, customColDisplay());
     // 数量变更列,添加按钮
-    const qcCol = _.find(ledgerSpreadSetting.cols, {field: 'qc_qty'});
-    qcCol.readOnly = true;
-    qcCol.cellType = 'activeImageBtn';
-    qcCol.normalImg = '#ellipsis-icon';
-    qcCol.indent = 5;
-    qcCol.showImage = function (data) {
+    const qcColShowImage = function (data) {
         if (!data || (data.children && data.children.length > 0) || !(data.b_code && data.b_code !== '')) {
             return false;
         } else {
@@ -652,6 +646,10 @@ $(document).ready(() => {
             return !(nodePos && nodePos.length > 0);
         }
     };
+    sjsSettingObj.setQcCols(ledgerSpreadSetting.cols, [
+        {field: 'qc_qty', showImage: qcColShowImage},
+        {field: 'qc_minus_qty', showImage: qcColShowImage},
+    ]);
     const ratioCol = ledgerSpreadSetting.cols.find(x => {return x.field === 'end_gather_percent' || x.field === 'end_correct_percent'});
     if (ratioCol) ratioCol.field = tenderInfo.display.stage.correct ? 'end_correct_percent' : 'end_gather_percent';
     ledgerSpreadSetting.imageClick = function (data, hitinfo) {
@@ -660,10 +658,12 @@ $(document).ready(() => {
             case 'dagl': data.dagl_url && window.open(data.dagl_url); break;
             case 'gxby': data.gxby_url && window.open(data.gxby_url); break;
             case 'qc_qty':
+            case 'qc_minus_qty':
                 if (data.children && data.children.length > 0 || data.lock || data.is_import) return;
                 const nodePos = stagePos.getLedgerPos(data.id);
                 if (nodePos && nodePos.length > 0) return;
-                changesObj.loadChanges({bills: data});
+                const minus = col.field === 'qc_minus_qty' ? 1 : 0;
+                changesObj.loadChanges({bills: data, minus, noValue: minus});
                 break;
             default: return;
         }
@@ -737,23 +737,24 @@ $(document).ready(() => {
 
     // 初始化 计量单元 Spread
     const spSpread = SpreadJsObj.createNewSpread($('#stage-pos')[0]);
-    const spCol = _.find(posSpreadSetting.cols, {field: 'qc_qty'});
-    spCol.readOnly = true;
-    spCol.cellType = 'activeImageBtn';
-    spCol.normalImg = '#ellipsis-icon';
-    spCol.indent = 5;
-    spCol.showImage = function (data) {
+    const posQcColShowImage = function (data) {
         return data !== undefined && data !== null;
     };
+    sjsSettingObj.setQcCols(posSpreadSetting.cols, [
+        { field: 'qc_qty', showImage: posQcColShowImage },
+        { field: 'qc_minus_qty', showImage: posQcColShowImage }
+    ]);
     posSpreadSetting.imageClick = function (data, hitinfo) {
         const col = hitinfo.sheet.zh_setting.cols[hitinfo.col];
         switch (col.field) {
             case 'gxby': data.gxby_url && window.open(data.gxby_url); break;
             case 'dagl': data.dagl_url && window.open(data.dagl_url); break;
             case 'qc_qty':
+            case 'qc_minus_qty':
                 const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
                 if (node.lock) return;
-                changesObj.loadChanges({bills: node, pos: data});
+                const minus = col.field === 'qc_minus_qty' ? 1 : 0;
+                changesObj.loadChanges({bills: node, pos: data, minus, noValue: minus});
                 break;
             default: return;
         }
@@ -992,7 +993,7 @@ $(document).ready(() => {
                 const validCols = [];
                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
                     const colSetting = sheet.zh_setting.cols[iCol];
-                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty') {
+                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty' && colSetting.field !== 'minus_qc_qty') {
                         validCols.push(iCol);
                     }
                 }
@@ -1068,7 +1069,7 @@ $(document).ready(() => {
             if (info.sheet.zh_setting) {
                 const setting = info.sheet.zh_setting;
                 const range = info.cellRange;
-                const validField = ['contract_qty', 'contract_tp', 'qc_qty', 'postil'].concat(['memo', 'ex_memo1', 'ex_memo2', 'ex_memo3'], setting.dgnUpFields);
+                const validField = ['contract_qty', 'contract_tp', 'qc_qty', 'minus_qc_qty', 'postil'].concat(['memo', 'ex_memo1', 'ex_memo2', 'ex_memo3'], setting.dgnUpFields);
                 for (let iCol = range.col; iCol < range.col + range.colCount; iCol++) {
                     const col = info.sheet.zh_setting.cols[iCol];
                     if ((validField.indexOf(col.field) === -1)) {
@@ -1247,6 +1248,7 @@ $(document).ready(() => {
             switch (col.field) {
                 case 'contract_qty':
                 case 'qc_qty':
+                case 'qc_minus_qty':
                     info.cancel = node.is_tp;
                     break;
                 case 'contract_tp':
@@ -1771,7 +1773,7 @@ $(document).ready(() => {
             if (info.sheet.zh_setting) {
                 const sortData = info.sheet.zh_data;
                 const range = info.cellRange;
-                const validField = ['contract_qty', 'qc_qty', 'postil', 'real_qty', 'ex_memo1', 'ex_memo2', 'ex_memo3'];
+                const validField = ['contract_qty', 'qc_qty', 'minus_qc_qty', 'postil', 'real_qty', 'ex_memo1', 'ex_memo2', 'ex_memo3'];
                 if (!checkTzMeasureType()) {
                     validField.push('name', 'sgfh_qty', 'sjcl_qty', 'qtcl_qty', 'position', 'drawing_code');
                 }
@@ -1930,7 +1932,7 @@ $(document).ready(() => {
                 const validCols = [];
                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
                     const colSetting = sheet.zh_setting.cols[iCol];
-                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty') {
+                    if (!colSetting.readOnly && colSetting.field !== 'qc_qty' && colSetting.field !== 'minus_qc_qty') {
                         validCols.push(iCol);
                     }
                 }
@@ -2907,12 +2909,16 @@ $(document).ready(() => {
                 SpreadJsObj.reLoadSheetHeader(self.sheet);
                 $('[name=type-title-contract]').text('本期合同计量金额');
                 $('[name=type-title-qc]').text('本期变更计量金额');
+                $('#show-qc-minus-jl').parent().hide();
+                $('#qc-minus-jl').parent().hide();
             } else {
                 const jlCol = self.spreadSetting.cols.find(function (x) {return x.field === 'jl'});
                 jlCol.title = '本期计量数量';
                 SpreadJsObj.reLoadSheetHeader(self.sheet);
                 $('[name=type-title-contract]').text('本期合同计量数量');
                 $('[name=type-title-qc]').text('本期变更计量数量');
+                $('#show-qc-minus-jl').parent().show();
+                $('#qc-minus-jl').parent().show();
             }
             if (stage.im_type === imType.bb.value || stage.im_type === imType.bw.value) {
                 $('#show-jldy').parent().show();
@@ -3002,12 +3008,16 @@ $(document).ready(() => {
                         SpreadJsObj.reLoadSheetHeader(self.sheet);
                         $('[name=type-title-contract]').text('本期合同计量金额');
                         $('[name=type-title-qc]').text('本期变更计量金额');
+                        $('#show-qc-minus-jl').parent().hide();
+                        $('#qc-minus-jl').parent().hide();
                     } else {
                         const jlCol = self.spreadSetting.cols.find(function (x) {return x.field === 'jl'});
                         jlCol.title = '本期计量数量';
                         SpreadJsObj.reLoadSheetHeader(self.sheet);
                         $('[name=type-title-contract]').text('本期合同计量数量');
                         $('[name=type-title-qc]').text('本期变更计量数量');
+                        $('#show-qc-minus-jl').parent().show();
+                        $('#qc-minus-jl').parent().show();
                     }
                     if (stage.im_type === imType.bb.value || stage.im_type === imType.bw.value) {
                         $('#show-jldy').parent().show();
@@ -3595,6 +3605,10 @@ $(document).ready(() => {
             $('#show-qc-jl').text(qcJl);
             $('#qc-jl').val(qcJl);
 
+            const qcMinusJl = data && data.qc_minus_jl ? data.qc_minus_jl : '';
+            $('#show-qc-minus-jl').text(qcMinusJl);
+            $('#qc-minus-jl').val(qcMinusJl);
+
             const bglCode = data && data.bgl_code ? data.bgl_code : '';
             $('#show-bgl-code').text(bglCode);
             $('#bgl-code').val(bglCode);

+ 33 - 25
app/public/js/stage_im.js

@@ -24,8 +24,8 @@ const stageIm = (function () {
         keys: ['id', 'tender_id', 'ledger_id'],
         stageId: 'id',
     };
-    gsTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'];
-    gsTreeSetting.calcFields = ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp'];
+    gsTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty'];
+    gsTreeSetting.calcFields = ['deal_tp', 'total_price', 'contract_tp', 'qc_tp', 'qc_minus_qty', 'gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp'];
     gsTreeSetting.calcFun = function (node) {
         if (node.children && node.children.length === 0) {
             node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
@@ -389,10 +389,10 @@ const stageIm = (function () {
         if (im.calc_memo !== undefined && im.calc_memo !== null && im.calc_memo !== '') return;
 
         if (im.leafXmjs && im.leafXmjs.length > 0) {
-            const memo = ['本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit];
+            const memo = ['本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit];
             for (const lx of im.leafXmjs) {
                 for (const p of lx.pos) {
-                    memo.push(p.name + ':' + p.jl + ' ' + im.unit);
+                    memo.push(p.name + ':' + p.jl + (p.qc_minus_jl ? (` (不计价 ${p.qc_minus_jl}) `) : ' ') + im.unit);
                 }
             }
             im.calc_memo = memo.join('\n');
@@ -405,10 +405,10 @@ const stageIm = (function () {
                 if (b.pos && b.pos.length > 0) {
                     memo.push('清单' + (i+1) + ':' + b.b_code + ' ' + b.name);
                     for (const p of b.pos) {
-                        memo.push(p.name + ':' + p.jl + ' ' + b.unit);
+                        memo.push(p.name + ':' + p.jl + (p.qc_minus_jl ? (` (不计价 ${p.qc_minus_jl}) `) : ' ') + b.unit);
                     }
                 } else {
-                    memo.push('清单' + (i+1) + ':' + b.b_code + ' ' + b.name + ':' + (checkZero(b.jl) ? 0 : b.jl) + ' ' + b.unit);
+                    memo.push('清单' + (i+1) + ':' + b.b_code + ' ' + b.name + ':' + (checkZero(b.jl) ? 0 : b.jl) + (b.qc_minus_jl ? (` (不计价 ${b.qc_minus_jl}) `) : ' ') + b.unit);
                 }
             }
             im.calc_memo = memo.join('\n');
@@ -457,7 +457,7 @@ const stageIm = (function () {
         const posRange = gsPos.getLedgerPos(node.id);
         if (!posRange) { return }
         for (const p of posRange) {
-            if (checkZero(p.contract_qty) && checkZero(p.qc_qty)) { continue; }
+            if (checkZero(p.contract_qty) && checkZero(p.qc_qty) && checkZero(p.qc_minus_qty)) { continue; }
             let lp = _.find(gclBills.pos, {name: p.name});
             if (!lp) {
                 lp = {name: p.name};
@@ -466,6 +466,7 @@ const stageIm = (function () {
             lp.jl = ZhCalc.add(lp.jl, p.gather_qty);
             lp.contract_jl = ZhCalc.add(lp.contract_jl, p.contract_qty);
             lp.qc_jl = ZhCalc.add(lp.qc_jl, p.qc_qty);
+            lp.qc_minus_jl = ZhCalc.add(lp.qc_minus_jl, p.qc_minus_qty);
         }
     }
     function recursiveGenerateTzGclBills(node, im) {
@@ -477,7 +478,7 @@ const stageIm = (function () {
                     continue;
                 }
                 if (checkZero(p.contract_qty) && checkZero(p.contract_tp) &&
-                    checkZero(p.qc_qty) && checkZero(p.qc_tp)) {
+                    checkZero(p.qc_qty) && checkZero(p.qc_tp) && checkZero(p.qc_minus_qty)) {
                     continue;
                 }
                 let b = _.find(im.gclBills, {bid: p.id});
@@ -488,6 +489,7 @@ const stageIm = (function () {
                 b.jl = ZhCalc.add(b.jl, p.gather_qty);
                 b.contract_jl = ZhCalc.add(b.contract_jl, p.contract_qty);
                 b.qc_jl = ZhCalc.add(b.qc_jl, p.qc_qty);
+                b.qc_minus_jl = ZhCalc.add(b.qc_minus_jl, p.qc_minus_qty);
                 generateTzPosData(p, b);
             }
         }
@@ -533,23 +535,23 @@ const stageIm = (function () {
             for (const p of posterity) {
                 if (p.children && p.children.length > 0) continue;
                 if (!checkZero(p.contract_qty) || !checkZero(p.contract_tp) ||
-                    !checkZero(p.qc_qty) || !checkZero(p.qc_tp))
+                    !checkZero(p.qc_qty) || !checkZero(p.qc_tp) || !checkZero(p.qc_minus_qty))
                     return true;
                 const pPos = gsPos.getLedgerPos(p.id);
                 if (!pPos || pPos.length === 0) continue;
                 for (const pp of pPos) {
-                    if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
+                    if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty) || !checkZero(pp.qc_minus_qty)) return true;
                 }
             }
             return false;
         } else {
             if (!checkZero(node.contract_qty) || !checkZero(node.contract_tp) ||
-                !checkZero(node.qc_qty) || !checkZero(node.qc_tp))
+                !checkZero(node.qc_qty) || !checkZero(node.qc_tp) || !checkZero(node.qc_minus_qty))
                 return true;
             const pPos = gsPos.getLedgerPos(node.id);
             if (!pPos || pPos.length === 0) return false;
             for (const pp of pPos) {
-                if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
+                if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty) || !checkZero(pp.qc_minus_qty)) return true;
             }
         }
     }
@@ -558,7 +560,7 @@ const stageIm = (function () {
         const pPos = gsPos.getLedgerPos(node.id);
         if (!pPos || pPos.length === 0) return null;
         for (const pp of pPos) {
-            if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return pp;
+            if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty) || !checkZero(pp.qc_minus_qty)) return pp;
         }
     }
 
@@ -587,7 +589,7 @@ const stageIm = (function () {
             const peg = getPegNode(node);
             const im = {
                 lid: node.id, pid: '', code: node.code,
-                jl: node.gather_tp, contract_jl: node.contract_tp, qc_jl: node.qc_tp,
+                jl: node.gather_tp, contract_jl: node.contract_tp, qc_jl: node.qc_tp, qc_minus_jl: 0,
                 //im_code: getNewImCode(),
                 peg: peg ? getPegStr(peg.name) : '', drawing_code: getDrawingCode(node),
                 position: '',
@@ -625,11 +627,13 @@ const stageIm = (function () {
         }
         gcl.contract_jl = ZhCalc.add(gcl.contract_jl, bills.contract_jl);
         gcl.qc_jl = ZhCalc.add(gcl.qc_jl, bills.qc_jl);
+        gcl.qc_minus_jl = ZhCalc.add(gcl.qc_minus_jl, bills.qc_minus_jl);
         gcl.jl = ZhCalc.add(gcl.jl, bills.jl);
     }
     function calculateBwBillsIm(im) {
         im.contract_jl = 0;
         im.qc_jl = 0;
+        im.qc_minus_jl = 0;
         for (const b of im.gclBills) {
             im.contract_jl = ZhCalc.add(im.contract_jl, ZhCalc.mul(b.contract_jl, b.unit_price, decimal.tp));
             im.qc_jl = ZhCalc.add(im.qc_jl, ZhCalc.mul(b.qc_jl, b.unit_price, decimal.tp));
@@ -661,7 +665,7 @@ const stageIm = (function () {
                 const pPos = gsPos.getLedgerPos(p.id);
                 if (pPos && pPos.length > 0) {
                     for (const pp of pPos) {
-                        if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) continue;
+                        if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty) && checkZero(pp.qc_minus_qty)) continue;
                         let im = nodeImData.find(function (d) {
                             return d.lid === node.id && d.pos_name === pp.name;
                         });
@@ -689,7 +693,7 @@ const stageIm = (function () {
                         }
                         addBwBillsGclBills(im, {
                             b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
-                            jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty
+                            jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty, qc_minus_jl: pp.qc_minus_qty,
                         });
 
                         if (pp.drawing_code && im.drawing_code instanceof Array)
@@ -707,11 +711,12 @@ const stageIm = (function () {
 
                     imDefault.contract_jl = ZhCalc.add(imDefault.contract_jl, p.contract_tp);
                     imDefault.qc_jl = ZhCalc.add(imDefault.qc_jl, p.qc_tp);
+                    imDefault.qc_minus_jl = 0;
                     imDefault.used = true;
 
                     addBwBillsGclBills(imDefault, {
                         b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
-                        jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_jl,
+                        jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty, qc_minus_jl: p.qc_qty,
                     });
                 }
             }
@@ -737,7 +742,7 @@ const stageIm = (function () {
         const posRange = gsPos.getLedgerPos(node.id);
         if (!posRange) { return }
         for (const p of posRange) {
-            if (!p.gather_qty || checkZero(p.gather_qty)) { continue; }
+            if (checkZero(p.contract_qty) && checkZero(p.qc_qty) && checkZero(p.qc_minus_qty)) { continue; }
             let lp = _.find(lx.pos, {name: p.name});
             if (!lp) {
                 lp = {name: p.name};
@@ -746,6 +751,7 @@ const stageIm = (function () {
             lp.jl = ZhCalc.add(lp.jl, p.gather_qty);
             lp.contract_jl = ZhCalc.add(lp.contract_jl, p.contract_qty);
             lp.qc_jl = ZhCalc.add(lp.qc_jl, p.qc_qty);
+            lp.qc_minus_jl = ZhCalc.add(lp.qc_minus_jl, p.qc_minus_qty);
         }
     }
     function generateZlLeafXmjData(node, im) {
@@ -766,6 +772,7 @@ const stageIm = (function () {
         lx.jl = ZhCalc.add(lx.jl, node.gather_qty);
         lx.contract_jl = ZhCalc.add(lx.contract_jl, node.contract_qty);
         lx.qc_jl = ZhCalc.add(lx.qc_jl, node.qc_qty);
+        lx.qc_minus_jl = ZhCalc.add(lx.qc_minus_jl, node.qc_minus_qty);
         generateZlPosData(node, lx);
     }
     function generateZlChangeData(node, im) {
@@ -809,7 +816,7 @@ const stageIm = (function () {
                 const peg = getPegNode(node);
                 im = {
                     lid: node.id, pid: '', code: p.b_code, name: p.name, unit: p.unit, unit_price: p[up_field],
-                    jl: 0, contract_jl: 0, qc_jl: 0,
+                    jl: 0, contract_jl: 0, qc_jl: 0, qc_minus_jl: 0,
                     peg: peg ? getPegStr(peg.name) : '',
                     position: '',
                     lIndex: nodeIndex,
@@ -837,6 +844,7 @@ const stageIm = (function () {
             im.jl = ZhCalc.add(im.jl, p.gather_qty);
             im.contract_jl = ZhCalc.add(im.contract_jl, p.contract_qty);
             im.qc_jl = ZhCalc.add(im.qc_jl, p.qc_qty);
+            im.qc_minus_jl = ZhCalc.add(im.qc_minus_jl, p.qc_minus_qty);
         }
     }
 
@@ -851,10 +859,10 @@ const stageIm = (function () {
             if (pPos && pPos.length > 0) {
                 const nodeIndex = gsTree.getNodeIndex(node);
                 for (const pp of pPos) {
-                    if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) { continue }
+                    if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty) && checkZero(pp.qc_minus_qty)) { continue }
                     const im = {
                         lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p[up_field], pid: pp.id,
-                        jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty,
+                        jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty, qc_minus_jl: pp.qc_minus_qty,
                         //im_code: getNewImCode(),
                         bw: bw, jldy: pp.name,
                         peg: CheckPeg(pp.name) ? getPegStr(pp.name) : (peg ? getPegStr(peg.name) : ''),
@@ -867,7 +875,7 @@ const stageIm = (function () {
                         source: [{id: p.ledger_id, code: p.code, b_code: p.b_code}],
                         im_type: imType.bw.value,
                     };
-                    im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
+                    im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                     ImData.push(im);
                     for (const c of changes) {
                         if (c.lid === p.id && c.pid === pp.id && c.qty && c.qty !== 0) {
@@ -876,11 +884,11 @@ const stageIm = (function () {
                     }
                 }
             } else {
-                if (checkZero(p.gather_qty) && checkZero(p.gather_tp)) { continue }
+                if (checkZero(p.gather_qty) && checkZero(p.gather_tp) && checkZero(p.qc_minus_qty)) { continue }
 
                 const im = {
                     lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p[up_field], pid: '',
-                    jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty,
+                    jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty, qc_minus_jl: p.qc_minus_qty,
                     im_code: getNewImCode(),
                     bw: bw,
                     peg: peg ? getPegStr(peg.name) : '',
@@ -893,7 +901,7 @@ const stageIm = (function () {
                     source: [{id: p.ledger_id, code: p.code, b_code: p.b_code}],
                     im_type: imType.bw.value,
                 };
-                im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
+                im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                 ImData.push(im);
                 for (const c of changes) {
                     if (c.lid === p.id && c.pid == -1 && c.qty && c.qty !== 0) {

+ 13 - 6
app/service/change.js

@@ -1190,18 +1190,19 @@ module.exports = app => {
          * @param pos - 查询的部位
          * @return {Promise<*>} - 可用的变更令列表
          */
-        async getValidChanges(tender, stage, bills, pos) {
+        async getValidChanges(tender, stage, data) {
+            const bills = data.bills, pos = data.pos;
             const self = this;
             const getFilterPart = function(field, value) {
                 return value
                     ? field + ' = ' + self.db.escape(value)
                     : self.db.format("(?? = null or ?? = '')", [field, field]);
             };
-            const filter = getFilterPart('cb.code', bills.b_code) +
+            let filter = getFilterPart('cb.code', bills.b_code) +
                 ' And ' + getFilterPart('cb.name', bills.name) +
                 ' And ' + getFilterPart('cb.unit', bills.unit) +
-                ' And cb.`unit_price` = ' + this.db.escape(bills.unit_price) +
-                (pos ? getFilterPart('cb.bwmx', pos.name) : '');
+                ' And cb.`unit_price` = ' + this.db.escape(bills.unit_price);
+            // if (data.pos) filter = filter + ' And ' + getFilterPart('cb.bwmx', pos.name);
             const sql =
                 'SELECT c.cid, c.code, c.name, c.w_code, c.p_code, c.peg, c.org_name, c.org_code, c.new_name, c.new_code,' +
                 '    c.content, c.basis, c.memo, c.type, c.class, c.quality, c.company, c.charge, ' +
@@ -1218,7 +1219,13 @@ module.exports = app => {
                 '  WHERE c.tid = ? And c.status = ? And c.valid And ' + filter +
                 '  ORDER BY c.in_time';
             const sqlParam = [tender.id, stage.order, tender.id, audit.flow.status.checked];
-            const changes = await this.db.query(sql, sqlParam);
+            let changes = await this.db.query(sql, sqlParam);
+            if (data.minus) {
+                changes = changes.filter(c => {
+                    c.bamount = c.b_amount ? parseFloat(c.b_amount) : 0;
+                    return c.bamount < 0;
+                })
+            }
             for (const c of changes) {
                 let sSql = 'SELECT * FROM ' + this.ctx.service.stageChange.tableName + ' WHERE sid = ? and cbid = ?';
                 const sSqlParam = [stage.id, c.cbid];
@@ -1227,7 +1234,7 @@ module.exports = app => {
                     sSqlParam.push(stage.curTimes, stage.curTimes, stage.curOrder);
                 }
                 const stageUsedData = await this.db.query(sSql, sSqlParam);
-                const filter = this.ctx.helper.filterLastestData(stageUsedData, ['pid', 'lid'], 'stimes', 'sorder');
+                const filter = this.ctx.helper.filterLastestData(stageUsedData, ['pid', 'lid', 'no_value'], 'stimes', 'sorder');
                 c.stage_used_amount = this.ctx.helper.sum(filter.map(x => { return x.qty }));
                 const aSql = 'SELECT ca.*, pa.name As u_name, pa.role As u_role ' +
                     '  FROM ?? As ca ' +

+ 4 - 2
app/service/project.js

@@ -11,6 +11,7 @@ const imType = require('../const/tender').imType;
 const defaultFunRela = {
     banOver: true,
     hintOver: true,
+    minusNoValue: false,
     imType: imType.zl.value,
     needGcl: false,
 };
@@ -55,7 +56,8 @@ module.exports = app => {
                     rule = {
                         imType: {type: 'enum', values: [imType.tz.value, imType.zl.value, imType.bb.value, imType.bw.value], required: true},
                         banOver: {type: 'bool', required: true,},
-                        hintOver: {type: 'bool', required: true,}
+                        hintOver: {type: 'bool', required: true,},
+                        minusNoValue: {type: 'bool', required: true,}
                     };
                     break;
                 default:
@@ -162,7 +164,7 @@ module.exports = app => {
             const result = await this.db.update(this.tableName, {
                 id: id, fun_rela: JSON.stringify({
                     banOver: data.banOver, hintOver: data.hintOver,
-                    imType: data.imType, needGcl: data.needGcl,
+                    imType: data.imType, needGcl: data.needGcl, minusNoValue: data.minusNoValue,
                 }),
             });
             return result.affectedRows === 1;

+ 4 - 26
app/service/report_memory.js

@@ -405,20 +405,9 @@ module.exports = app => {
                     preStage = this.ctx.stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
                 }
                 this.ctx.helper.assignRelaData(billsData, [
-                    {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'postil'], prefix: '', relaId: 'lid'},
-                    {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid'}
+                    {data: curStage, fields: ['contract_qty', 'contract_tp', 'contract_expr', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'postil'], prefix: '', relaId: 'lid'},
+                    {data: preStage, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty'], prefix: 'pre_', relaId: 'lid'}
                 ]);
-                if (this._checkFieldsExist(fields, billsFields.final1)) {
-                    const preMinusChange = await this.ctx.service.stageChangeFinal.getPreMinusChange(this.ctx.stage.tid, this.ctx.stage.order);
-                    const changeData = this.ctx.stage.readOnly
-                        ? await this.ctx.service.stageChange.getAuditorAllStageData(this.ctx.tender.id, this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder)
-                        : await this.ctx.service.stageChange.getLastestAllStageData(this.ctx.tender.id, this.ctx.stage.id);
-                    const minusChange = changeData.filter(x => { return x.minus });
-                    this.ctx.helper.assignSumRelaData(billsData, 'id', [
-                        {data: preMinusChange, fields: [{source: 'qty', target: 'pre_minus_qc_qty'}], relaField: 'lid'},
-                        {data: minusChange, fields: [{source: 'qty', target: 'minus_qc_qty'}], relaField: 'lid'},
-                    ]);
-                }
 
                 const billsTree = this._getNewBillsTree();
                 billsTree.loadDatas(billsData);
@@ -483,20 +472,9 @@ module.exports = app => {
                     prePosStage = this.ctx.stage.order > 1 ? await this.ctx.service.stagePosFinal.getFinalData(this.ctx.tender, this.ctx.stage.order - 1) : [];
                 }
                 this.ctx.helper.assignRelaData(posData, [
-                    {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'},
-                    {data: prePosStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
+                    {data: curPosStage, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'contract_expr', 'postil'], prefix: '', relaId: 'pid'},
+                    {data: prePosStage, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty'], prefix: 'pre_', relaId: 'pid'}
                 ]);
-                if (this._checkFieldsExist(fields, posFields.final1)) {
-                    const preMinusChange = await this.ctx.service.stageChangeFinal.getPreMinusChange(this.ctx.stage.tid, this.ctx.stage.order);
-                    const changeData = this.ctx.stage.readOnly
-                        ? await this.ctx.service.stageChange.getAuditorAllStageData(this.ctx.tender.id, this.ctx.stage.id, this.ctx.stage.curTimes, this.ctx.stage.curOrder)
-                        : await this.ctx.service.stageChange.getLastestAllStageData(this.ctx.tender.id, this.ctx.stage.id);
-                    const minusChange = changeData.filter(x => { return x.minus });
-                    this.ctx.helper.assignSumRelaData(posData, 'id', [
-                        {data: preMinusChange, fields: [{source: 'qty', target: 'pre_minus_qc_qty'}], relaField: 'pid'},
-                        {data: minusChange, fields: [{source: 'qty', target: 'minus_qc_qty'}], relaField: 'pid'},
-                    ]);
-                }
                 this.pos.loadDatas(posData);
                 this.pos.calculateAll();
 

+ 3 - 1
app/service/stage_bills.js

@@ -182,6 +182,7 @@ module.exports = app => {
                 d.contract_tp = orgData.contract_tp;
                 d.qc_qty = orgData.qc_qty;
                 d.qc_tp = orgData.qc_tp;
+                d.qc_minus_qty = orgData.qc_minus_qty;
                 d.postil = orgData.postil;
             }
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
@@ -195,6 +196,7 @@ module.exports = app => {
                 d.qc_qty = this.round(insertData.qc_qty, precision.value);
                 d.qc_tp = this.ctx.helper.mul(d.qc_qty, ledgerData.unit_price, info.decimal.tp);
             }
+            if (insertData.qc_minus_qty !== undefined) d.qc_minus_qty = this.round(insertData.qc_minus_qty, precision.value);
             if (insertData.postil) {
                 d.postil = insertData.postil;
             }
@@ -286,7 +288,7 @@ module.exports = app => {
                 posGather.qc_tp = this.ctx.helper.mul(posGather.qc_qty, ledgerBills.unit_price, info.decimal.tp);
             }
             if (stageBills) {
-                if (stageBills.contract_qty === posGather.contract_qty && stageBills.qc_qty === posGather.qc_qty) {
+                if (stageBills.contract_qty === posGather.contract_qty && stageBills.qc_qty === posGather.qc_qty && stageBills.qc_minus_qty === posGather.qc_minus_qty) {
                     return;
                 }
                 if (stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {

+ 5 - 15
app/service/stage_bills_final.js

@@ -77,7 +77,6 @@ module.exports = app => {
             }
             const cur = await this.ctx.service.stageBills.getLastestStageData2(tender.id, stage.id);
             const pre = await this.getFinalData(tender, stage.order - 1);
-            const minusChange = await this.ctx.service.stageChange.getStageMinusChange(stage);
             if ((!cur || cur.length === 0) && (!pre || pre.length === 0)) return;
             for (const c of cur) {
                 delete c.id;
@@ -94,22 +93,13 @@ module.exports = app => {
                     c.contract_tp = this.ctx.helper.add(c.contract_tp, p.contract_tp);
                     c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
                     c.qc_tp = this.ctx.helper.add(c.qc_tp, p.qc_tp);
-                    if (p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
-                        || !this.ctx.helper.checkZero(c.contract_tp)) {
-                        c.used = true;
-                    } else {
-                        const mc = minusChange.find(x => { return x.lid === c.lid && x.qty < 0 });
-                        c.used = !!mc;
-                    }
+                    c.qc_minus_qty = this.ctx.helper.add(c.qc_minus_qty, p.qc_minus_qty);
+                    c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
+                        || !this.ctx.helper.checkZero(c.contract_tp) || ! this.ctx.helper.checkZero(c.qc_minus_qty);
                     pre.splice(pre.indexOf(p), 1);
                 } else {
-                    if (!this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
-                        || !this.ctx.helper.checkZero(c.contract_tp)) {
-                        c.used = true;
-                    } else {
-                        const mc = minusChange.find(x => { return x.lid === c.lid && x.qty < 0 });
-                        c.used = !!mc;
-                    }
+                    c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)
+                        || !this.ctx.helper.checkZero(c.contract_tp) || ! this.ctx.helper.checkZero(c.qc_minus_qty);
                 }
             }
 

+ 42 - 37
app/service/stage_change.js

@@ -36,22 +36,24 @@ module.exports = app => {
          * @param {Number} pid - 部位明细id
          * @return {Promise<*>}
          */
-        async getLastestStageData(tid, sid, lid, pid) {
+        async getLastestStageData(tid, sid, lid, pid, noValue) {
+            const filter = noValue !== undefined ? 'And no_value = ?' : '';
             const sql = 'SELECT c.*,' +
                 '  oc.p_code As c_code, oc.new_code As c_new_code' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
-                '      WHERE tid = ? And sid = ? And lid = ? And pid = ?' +
-                '      GROUP By `lid`, `pid`, `cid`, `cbid`' +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
+                '      WHERE tid = ? And sid = ? And lid = ? And pid = ?' + filter +
+                '      GROUP By `lid`, `pid`, `cid`, `cbid`, `no_value`' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
                 '  ON c.cbid = ocb.id' +
                 '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid, lid, pid ? pid : -1];
+            if (noValue !== undefined) sqlParam.push(noValue);
             return await this.db.query(sql, sqlParam);
         }
 
@@ -65,22 +67,24 @@ module.exports = app => {
          * @param {Number} pid - 部位明细id
          * @return {Promise<*>}
          */
-        async getAuditorStageData(tid, sid, times, order, lid, pid) {
+        async getAuditorStageData(tid, sid, times, order, lid, pid, noValue) {
+            const filter = noValue !== undefined ? 'And no_value = ?' : '';
             const sql = 'SELECT c.*,' +
                 '  oc.p_code As c_code, oc.new_code As c_new_code, oc.quality, ocb.code as b_code, ocb.name, ocb.unit' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
-                '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?)) And lid = ? And pid = ?' +
-                '      GROUP By `lid`, `pid`, cid, cbid' +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
+                '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?)) And lid = ? And pid = ?' + filter +
+                '      GROUP By `lid`, `pid`, cid, cbid, no_value' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
                 '  ON c.cbid = ocb.id' +
                 '  WHERE not ISNULL(ocb.id)';
             const sqlParam = [tid, sid, times, times, order, lid, pid ? pid : -1];
+            if (noValue !== undefined) sqlParam.push(noValue);
             return await this.db.query(sql, sqlParam);
         }
 
@@ -89,11 +93,11 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code, oc.quality, ocb.code as b_code, ocb.name, ocb.unit' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ?' +
-                '      GROUP By `lid`, `pid`, cid, cbid' +
+                '      GROUP By `lid`, `pid`, cid, cbid, no_value' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
@@ -108,11 +112,11 @@ module.exports = app => {
                 '  oc.p_code As c_code, oc.new_code As c_new_code, oc.quality, ocb.code as b_code, ocb.name, ocb.unit' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  INNER JOIN ( ' +
-                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid` From ' + this.tableName +
+                '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `progress`, `lid`, `pid`, `sid`, `cid`, `cbid`, `no_value` From ' + this.tableName +
                 '      WHERE tid = ? And sid = ? And (`stimes` < ? OR (`stimes` = ? AND `sorder` <= ?))' +
-                '      GROUP By `lid`, `pid`, cid, cbid' +
+                '      GROUP By `lid`, `pid`, cid, cbid, no_value' +
                 '  ) As m ' +
-                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid`' +
+                '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.progress And c.lid = m.lid And c.pid = m.pid And c.`sid` = m.`sid` And c.`cid` = m.`cid` And c.`cbid` = m.`cbid` And c.`no_value` = m.`no_value`' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' As oc' +
                 '  ON c.cid = oc.cid' +
                 '  LEFT JOIN ' + this.ctx.service.changeAuditList.tableName + ' As ocb' +
@@ -129,15 +133,15 @@ module.exports = app => {
          * @param {Array} changes - 调用的变更令
          * @return {Promise<void>}
          */
-        async billsChange(bills, changes) {
+        async billsChange(bills, noValue, changes) {
             const self = this;
-            function getNewChange(cid, cbid, times, order, qty, minus) {
+            function getNewChange(cid, cbid, times, order, qty, minus, no_value) {
                 return {
                     tid: self.ctx.tender.id, sid: self.ctx.stage.id,
                     lid: bills.id, pid: -1,
                     cid, cbid,
                     stimes: times, sorder: order,
-                    qty, minus
+                    qty, minus, no_value,
                 };
             }
             const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(bills.id);
@@ -146,7 +150,7 @@ module.exports = app => {
             }
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerBills.unit);
             // 获取原变更令
-            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, bills.id, -1);
+            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, bills.id, -1, noValue);
             // 获取更新数据
             const updateChanges = [],
                 newChanges = [];
@@ -155,7 +159,7 @@ module.exports = app => {
                 const nc = this._.find(changes, { cid: oc.cid, cbid: oc.cbid });
                 if (!nc || nc.qty !== oc.qty) {
                     const qty = nc ? this.round(nc.qty, precision.value) : null;
-                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus);
+                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus, noValue);
                     billsQty = this.ctx.helper.add(billsQty, change.qty);
                     if (oc.stimes === this.ctx.stage.curTimes && oc.sorder === this.ctx.stage.curOrder) {
                         change.id = oc.id;
@@ -170,7 +174,7 @@ module.exports = app => {
             for (const c of changes) {
                 const nc = this._.find(oldChanges, { cid: c.cid, cbid: c.cbid });
                 if (!nc) {
-                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus);
+                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus, noValue);
                     billsQty = this.ctx.helper.add(billsQty, change.qty);
                     newChanges.push(change);
                 }
@@ -185,7 +189,8 @@ module.exports = app => {
                     await transaction.update(this.tableName, c);
                 }
                 const stageBills = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, bills.id);
-                await this.ctx.service.stageBills.updateStageBillsQty(transaction, ledgerBills, stageBills, { qc_qty: billsQty });
+                const sbUpdate = noValue ? {qc_minus_qty: billsQty} : {qc_qty: billsQty};
+                await this.ctx.service.stageBills.updateStageBillsQty(transaction, ledgerBills, stageBills, sbUpdate);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -202,15 +207,15 @@ module.exports = app => {
          * @param {Array} changes - 调用的变更令
          * @return {Promise<{}>}
          */
-        async posChange(pos, changes) {
+        async posChange(pos, noValue, changes) {
             const self = this;
-            function getNewChange(cid, cbid, times, order, qty, minus) {
+            function getNewChange(cid, cbid, times, order, qty, minus, no_value) {
                 return {
                     tid: self.ctx.tender.id, sid: self.ctx.stage.id,
                     lid: pos.lid, pid: pos.id,
                     cid, cbid,
                     stimes: times, sorder: order,
-                    qty, minus
+                    qty, minus, no_value,
                 };
             }
             const ledgerBills = await this.ctx.service.ledger.getCompleteDataById(pos.lid);
@@ -219,7 +224,7 @@ module.exports = app => {
             }
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerBills.unit);
             // 获取原变更令
-            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.lid, pos.id);
+            const oldChanges = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.lid, pos.id, noValue);
             const updateChanges = [],
                 newChanges = [];
             let posQty = 0;
@@ -227,7 +232,7 @@ module.exports = app => {
                 const nc = this._.find(changes, { cid: oc.cid, cbid: oc.cbid });
                 if (!nc || nc.qty !== oc.qty) {
                     const qty = nc ? this.round(nc.qty, precision.value) : null;
-                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus);
+                    const change = getNewChange(oc.cid, oc.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, qty, nc ? nc.minus : oc.minus, noValue);
                     posQty = this.ctx.helper.add(posQty, change.qty);
                     if (oc.stimes === this.ctx.stage.curTimes && oc.sorder === this.ctx.stage.curOrder) {
                         change.id = oc.id;
@@ -242,7 +247,7 @@ module.exports = app => {
             for (const c of changes) {
                 const nc = this._.find(oldChanges, { cid: c.cid, cbid: c.cbid });
                 if (!nc) {
-                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus);
+                    const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus, noValue);
                     posQty = this.ctx.helper.add(posQty, change.qty);
                     newChanges.push(change);
                 }
@@ -252,7 +257,7 @@ module.exports = app => {
             try {
                 if (newChanges.length > 0) await transaction.insert(this.tableName, newChanges);
                 if (updateChanges.length > 0) await transaction.updateRows(this.tableName, updateChanges);
-                await this.ctx.service.stagePos.updateChangeQuantity(transaction, pos, posQty);
+                await this.ctx.service.stagePos.updateChangeQuantity(transaction, pos, posQty, noValue);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -292,7 +297,7 @@ module.exports = app => {
                 const pre = await this.db.query(preSql, [tid, cid, this.ctx.stage.order]);
                 const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid = ?';
                 const curAll = await this.db.query(sql, [this.ctx.stage.id]);
-                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
                 return [...pre, ...cur];
             }
         }
@@ -317,7 +322,7 @@ module.exports = app => {
                 const pre = await this.db.query(preSql, [tid, cid, stage.order]);
                 const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid = ? and cid = ?';
                 const curAll = await this.db.query(sql, [stage.id, cid]);
-                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
                 return [...pre, ...cur];
             }
         }
@@ -338,7 +343,7 @@ module.exports = app => {
                         '  INNER JOIN ( ' +
                         '    SELECT MAX(`stimes` * ' + timesLen + ' + `sorder`) As `flow`, `lid`, `pid`, `cbid`, `sid` From ' + this.tableName +
                         '      WHERE sid = ? And cid = ?' +
-                        '      GROUP By `lid`, `pid`, `cbid`' +
+                        '      GROUP By `lid`, `pid`, `cbid`, `no_value`' +
                         '  ) As m ' +
                         '  ON (c.stimes * ' + timesLen + ' + c.sorder) = m.flow And c.lid = m.lid And c.pid = m.pid And c.cbid = m.cbid And c.sid = m.sid' +
                         '  LEFT JOIN ' + this.ctx.service.ledger.tableName + ' As l ON c.lid = l.id' +
@@ -355,13 +360,13 @@ module.exports = app => {
         async getStageUsedChangeId(sid) {
             const sql = 'SELECT lid, pid, cid, cbid, qty, stimes, sorder FROM ' + this.tableName + ' WHERE sid = ?';
             const curAll = await this.db.query(sql, [sid]);
-            const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+            const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid'], 'stimes', 'sorder');
             return this._.map(this._.filter(cur, 'qty'), 'cid');
         }
 
         async getFinalStageData(tid, sid) {
             const data = await this.getAllDataByCondition({ where: { tid, sid } });
-            return this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+            return this.ctx.helper.filterLastestData(data, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
         }
 
         async getSumLoadFinalData(sid) {
@@ -370,7 +375,7 @@ module.exports = app => {
                 '  Left Join ' + this.ctx.service.change.tableName + ' c ON cf.cid = c.cid' +
                 '  Where cf.sid = ?';
             const result = await this.db.query(sql, [sid]);
-            return this.ctx.helper.filterLastestData(result, ['lid', 'pid', 'cbid'], 'stimes', 'sorder');
+            return this.ctx.helper.filterLastestData(result, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
         }
 
         async _getTender(stage) {
@@ -425,7 +430,7 @@ module.exports = app => {
                 const pre = await this.db.query(preSql, [stage.tid, stage.order]);
                 const sql = 'SELECT * FROM ' + this.tableName + ' WHERE sid = ? AND (stimes * 100 + sorder) <= (? * 100 + ?)';
                 const curAll = await this.db.query(sql, [stage.id, stage.curTimes, stage.curOrder]);
-                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cid', 'cbid'], 'stimes', 'sorder');
+                const cur = this.ctx.helper.filterLastestData(curAll, ['lid', 'pid', 'cbid', 'no_value'], 'stimes', 'sorder');
                 return [...pre, ...cur];
             }
         }

+ 1 - 13
app/service/stage_change_final.js

@@ -64,7 +64,7 @@ module.exports = app => {
                 data.push({
                     tid: c.tid, sid: c.sid, sorder: stage.order,
                     lid: c.lid, pid: c.pid, cid: c.cid, cbid: c.cbid,
-                    qty: c.qty, minus: c.minus,
+                    qty: c.qty, minus: c.minus, no_value: c.no_value,
                 });
             }
             if (data.length > 0) await transaction.insert(this.tableName, data);
@@ -101,18 +101,6 @@ module.exports = app => {
             const usedQty = await this.db.queryOne('Select SUM(qty) as qty FROM ' + this.tableName + ' WHERE cbid = ?', [cbid]);
             return usedQty ? this.ctx.helper.sub(qty, usedQty.qty) : qty;
         }
-
-        async getPreMinusChange(tid, sorder) {
-            const sql = 'SELECT lid, pid, SUM(qty) as qty FROM ' + this.tableName + ' WHERE tid = ? and sorder < ? and minus GROUP BY lid, pid';
-            const data = await this.db.query(sql, [tid, sorder]);
-            return data;
-        }
-
-        async getMinusChange(tid) {
-            const sql = 'SELECT lid, pid, SUM(qty) as qty FROM ' + this.tableName + ' WHERE tid = ? GROUP BY lid, pid';
-            const data = await this.db.query(sql, [tid]);
-            return data;
-        }
     }
 
     return StageChangeFinal;

+ 8 - 7
app/service/stage_pos.js

@@ -108,7 +108,7 @@ module.exports = app => {
         }
         async getLastestStageData2(tid, sid, where) {
             const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, postil, `times`, `order`, `contract_expr`' +
+            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, qc_minus_qty, postil, `times`, `order`, `contract_expr`' +
                 '  FROM ' + this.departTableName(tid) +
                 '  WHERE tid = ? And sid = ? ' + filterSql;
             const sqlParam = [tid, sid];
@@ -117,7 +117,7 @@ module.exports = app => {
         }
         async getAuditorStageData2(tid, sid, times, order, where) {
             const filterSql = this._getPosFilterSql(where);
-            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, postil, `times`, `order`, `contract_expr`' +
+            const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, qc_minus_qty, postil, `times`, `order`, `contract_expr`' +
                 '  FROM ' + this.departTableName(tid) +
                 '  WHERE tid = ? And sid = ? And (`times` < ? OR (`times` = ? AND `order` <= ?)) ' + filterSql;
             const sqlParam = [tid, sid, times, times, order];
@@ -545,7 +545,7 @@ module.exports = app => {
             }
         }
 
-        async updateChangeQuantity(transaction, pos, qty) {
+        async updateChangeQuantity(transaction, pos, qty, noValue) {
             let orgPos = await this.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id, {pid: pos.id});
             if (orgPos.length > 1) {
                 throw '数据错误';
@@ -553,7 +553,7 @@ module.exports = app => {
                 orgPos = orgPos[0];
             }
             if (orgPos && orgPos.times === this.ctx.stage.curTimes && orgPos.order === this.ctx.stage.curOrder) {
-                await transaction.update(this.tableName, {id: orgPos.id, qc_qty: qty});
+                await transaction.update(this.tableName, noValue ? {id: orgPos.id, qc_minus_qty: qty} : {id: orgPos.id, qc_qty: qty});
             } else {
                 await transaction.insert(this.tableName, {
                     tid: this.ctx.tender.id,
@@ -564,7 +564,8 @@ module.exports = app => {
                     times: this.ctx.stage.curTimes,
                     order: this.ctx.stage.curOrder,
                     contract_qty: orgPos ? orgPos.contract_qty : 0,
-                    qc_qty: qty,
+                    qc_qty: !noValue ? qty : (orgPos ? orgPos.qc_qty : 0),
+                    qc_minus_qty: noValue ? qty : (orgPos ? orgPos.qc_minus_qty : 0),
                 });
             }
             await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, pos.lid, transaction);
@@ -579,8 +580,8 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getPosGather(tid, sid, lid, transaction) {
-            const calcQtySql = 'SELECT SUM(`contract_qty`) As `contract_qty`, SUM(`qc_qty`) As `qc_qty` FROM (' +
-                '  SELECT `contract_qty`, `qc_qty` FROM ' + this.ctx.service.stagePos.tableName + ' As Pos ' +
+            const calcQtySql = 'SELECT SUM(`contract_qty`) As `contract_qty`, SUM(`qc_qty`) As `qc_qty`, SUM(`qc_minus_qty`) AS `qc_minus_qty` FROM (' +
+                '  SELECT `contract_qty`, `qc_qty`, `qc_minus_qty` FROM ' + this.ctx.service.stagePos.tableName + ' As Pos ' +
                 '    INNER JOIN (' +
                 '      SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `pid` ' +
                 '        FROM ' + this.ctx.service.stagePos.tableName +

+ 3 - 14
app/service/stage_pos_final.js

@@ -59,7 +59,6 @@ module.exports = app => {
             }
             const cur = await this.ctx.service.stagePos.getLastestStageData2(tender.id, stage.id);
             const pre = stage.order > 1 ? await this.getFinalData(tender, stage.order - 1) : [];
-            const minusChange = await this.ctx.service.stageChange.getStageMinusChange(stage);
             if ((!cur || cur.length === 0) && (!pre || pre.length === 0)) return;
             for (const c of cur) {
                 delete c.id;
@@ -74,27 +73,17 @@ module.exports = app => {
                 if (p) {
                     c.contract_qty = this.ctx.helper.add(c.contract_qty, p.contract_qty);
                     c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
-                    c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
+                    c.qc_minus_qty = this.ctx.helper.add(c.qc_minus_qty, p.qc_minus_qty);
+                    c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty) || !this.ctx.helper.checkZero(c.qc_minus_qty);
                     pre.splice(pre.indexOf(p), 1);
                 } else {
-                    if (!this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty)) {
-                        c.used = true;
-                    } else {
-                        const mc = minusChange.find(x => { return x.pid === c.pid && x.qty < 0});
-                        c.used = !!mc;
-                    }
+                    c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty) || !this.ctx.helper.checkZero(c.qc_minus_qty);
                 }
             }
             for (const p of pre) {
                 if (p.id !== undefined) delete p.id;
                 p.sid = stage.id;
                 p.sorder = stage.order;
-                if (p.used || !this.ctx.helper.checkZero(p.contract_qty) || !this.ctx.helper.checkZero(p.qc_qty)) {
-                    p.used = true;
-                } else {
-                    const mc = minusChange.find(x => { return x.pid === p.pid && x.qty < 0});
-                    p.used = !!mc;
-                }
             }
             await transaction.insert(this.tableName, cur ? cur.concat(pre) : pre);
         }

+ 14 - 0
app/view/setting/fun.ejs

@@ -29,6 +29,19 @@
                         </div>
                         <div class="card mb-3">
                             <div class="card-body">
+                                <h5 class="card-title">负变更</h5>
+                                <div class="form-group mb-4">
+                                    <div>
+                                        <div class="form-check form-check-inline">
+                                            <input class="form-check-input" type="checkbox" id="minusNoValue" name="minusNoValue" <% if (funRela.minusNoValue) { %>checked<% } %> onchange="updateSetting();">
+                                            <label class="form-check-label" for="minusNoValue">计量不计价</label>
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="card mb-3">
+                            <div class="card-body">
                                 <h5 class="card-title">中间计量模式设置</h5>
                                 <div class="form-group mb-4">
                                     <div>
@@ -135,6 +148,7 @@
             imType: parseInt($('[name=im_type]:checked').val()),
             banOver: $('[name=ban_over]')[0].checked,
             hintOver: $('#hint_over')[0].checked,
+            minusNoValue: $('[name=minusNoValue]')[0].checked,
             needGcl: $('#need_gcl')[0].checked,
             openChangeProject: $('#openChangeProject')[0].checked,
             openChangeApply: $('#openChangeApply')[0].checked,

+ 11 - 0
app/view/stage/index.ejs

@@ -151,6 +151,9 @@
                                 <tbody>
                                 <tr><th width="120" name="type-title-contract">本期合同计量数量</th><td id="show-contract-jl"></td></tr>
                                 <tr><th name="type-title-qc">本期变更计量数量</th><td id="show-qc-jl"></td></tr>
+                                <% if (minusNoValue) { %>
+                                <tr><th name="type-title-qc-minus">本期不计价变更数量</th><td id="show-qc-minus-jl"></td></tr>
+                                <% } %>
                                 <tr><th>变更令号</th><td id="show-bgl-code"></td></tr>
                                 <tr><th>变更图号</th><td id="show-bgl-drawing-code"></td></tr>
                                 <tr><th>部位</th><td id="show-bw-name"></td></tr>
@@ -180,6 +183,14 @@
                                     </div>
                                     <input type="text" class="form-control" value="" id="qc-jl" readonly="">
                                 </div>
+                                <% if (minusNoValue) { %>
+                                <div class="input-group input-group-sm mb-2">
+                                    <div class="input-group-prepend">
+                                        <span class="input-group-text" name="type-title-qc-minus">本期不计价变更数量</span>
+                                    </div>
+                                    <input type="text" class="form-control" value="" id="qc-minus-jl" readonly="">
+                                </div>
+                                <% } %>
                                 <div class="input-group input-group-sm mb-2">
                                     <div class="input-group-prepend">
                                         <span class="input-group-text">变更令号</span>

+ 10 - 0
app/view/tender/detail_modal.ejs

@@ -1806,6 +1806,12 @@
                 </div>
                 <div class="form-group">
                     <div class="custom-control custom-checkbox mb-2">
+                        <input type="checkbox" class="custom-control-input" id="sc_minusNoValue" checked="">
+                        <label class="custom-control-label" for="sc_minusNoValue">计量台账-负变更-计量不计价</label>
+                    </div>
+                </div>
+                <div class="form-group">
+                    <div class="custom-control custom-checkbox mb-2">
                         <input type="checkbox" class="custom-control-input" id="sr_show" checked="">
                         <label class="custom-control-label" for="sr_show">关联台账</label>
                     </div>
@@ -1856,6 +1862,7 @@
 
     const loadFunRelaProperty = function () {
         $('#sl_ignoreParent')[0].checked = property.fun_rela.sum_load.ignoreParent;
+        $('#sc_minusNoValue')[0].checked = property.fun_rela.stage_change.minusNoValue;
         $('#sr_show')[0].checked = property.fun_rela.stage_rela.show;
         $('#hint_over')[0].checked = property.fun_rela.hintOver;
     };
@@ -1870,6 +1877,9 @@
                 sum_load: {
                     ignoreParent: $('#sl_ignoreParent')[0].checked,
                 },
+                stage_change: {
+                    minusNoValue: $('#sc_minusNoValue')[0].checked,
+                },
                 stage_rela: {
                     show: $('#sr_show')[0].checked,
                 }