瀏覽代碼

负变更-计量不计价,显示设置,计量台账调用

MaiXinRong 3 年之前
父節點
當前提交
0335327bb1

+ 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,
         },

+ 24 - 12
app/controller/stage_controller.js

@@ -88,13 +88,18 @@ 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;
+                });
+            }
             const tender = this.ctx.tender,
                 stage = this.ctx.stage;
             const stageSetting = tender.data.measure_type === measureType.tz.value
@@ -116,6 +121,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 +177,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,9 +203,9 @@ 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.hintOver = projectFunInfo.hintOver && ctx.tender.info.fun_rela.hintOver;
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
+                console.log(2, renderData.ledgerSpread.cols.find(x => { return x.field === 'qc_minus_qty'}));
                 await this.layout('stage/index.ejs', renderData, 'stage/modal.ejs');
             } catch (err) {
                 this.log(err);
@@ -231,11 +241,13 @@ module.exports = app => {
             if (this.ctx.session.sessionProject.dagl) ledgerColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
             if (tender.data.measure_type === measureType.gcl.value) ledgerColumn.push('deal_qty', 'deal_tp');
             if (tender.info.display.ledger.dgnQty) ledgerColumn.push('dgn_qty1', 'dgn_qty2');
+            if (tender.info.fun_rela.stage_change.minusNoValue) ledgerColumn.push('qc_minus_qty');
 
             const posColumn = ['id', 'tid', 'lid', 'name', 'position', 'porder', 'quantity', 'add_stage_order', 'drawing_code'];
             if (tender.info.display.stage.realComplete) posColumn.push('real_qty');
             if (this.ctx.session.sessionProject.gxby) posColumn.push('gxby_status', 'gxby_url', 'gxby_limit');
             if (this.ctx.session.sessionProject.dagl) posColumn.push('dagl_status', 'dagl_url', 'dagl_limit');
+            if (tender.info.fun_rela.stage_change.minusNoValue) posColumn.push('qc_minus_qty');
             for (const field of sjsRela.ledgerCol) {
                 if (field.show) {
                     ledgerColumn.push(field.field);
@@ -268,8 +280,8 @@ module.exports = app => {
             this.ctx.helper.assignRelaData(ledgerData, [
                 { 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', 'postil'], prefix: '', relaId: 'lid' },
-                { data: preStageData, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'used'], prefix: 'pre_', 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' },
             ]);
             return ledgerData;
         }
@@ -294,8 +306,8 @@ 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, [
-                { 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' },
             ]);
             return posData;
         }
@@ -439,8 +451,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) {
@@ -500,7 +512,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);
@@ -525,12 +537,12 @@ module.exports = app => {
                 }
                 let result, minus, posMinus;
                 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};
 })();

+ 30 - 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);
                     }
                 }

+ 11 - 4
app/service/change.js

@@ -1190,7 +1190,8 @@ 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
@@ -1201,7 +1202,7 @@ module.exports = app => {
                 ' 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) : '');
+                (pos ? ' 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 ' +

+ 3 - 1
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:

+ 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.getDataById(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.getDataById(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="ban_over" 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,

+ 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,
                 }

+ 132 - 0
sql/update.sql

@@ -5,3 +5,135 @@ ADD COLUMN `pos_count`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计量单
 UPDATE `zh_tender` SET `had_map`=3 WHERE `had_map`=1;
 
 ALTER TABLE `zh_tender` ADD `map_pic` VARCHAR(255) NULL DEFAULT NULL COMMENT '静态图片地址' AFTER `had_map`;
+
+ALTER TABLE `zh_stage_bills_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+
+ALTER TABLE `zh_stage_bills_final_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+ALTER TABLE `zh_stage_bills_final_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_tp`;
+
+ALTER TABLE `zh_stage_pos_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_10`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_11`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_12`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_13`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_14`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_15`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_16`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_17`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_18`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_19`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+
+
+ALTER TABLE `zh_stage_pos_final_0`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_1`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_2`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_3`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_4`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_5`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_6`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_7`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_8`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_9`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_10`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_11`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_12`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_13`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_14`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_15`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_16`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_17`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_18`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+ALTER TABLE `zh_stage_pos_final_19`
+ADD COLUMN `qc_minus_qty`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '计量不计价变更' AFTER `qc_qty`;
+
+ALTER TABLE `zh_stage_change`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否不计价' AFTER `minus`;
+ALTER TABLE `zh_stage_change_final`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否不计价' AFTER `minus`;
+ALTER TABLE `zh_stage_detail`
+ADD COLUMN `no_value`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '计量不计价' AFTER `unit_price`;