Browse Source

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

laiguoran 3 years atrás
parent
commit
4fdde5aa0d
5 changed files with 112 additions and 18 deletions
  1. 42 16
      app/lib/stage_im.js
  2. 5 0
      app/public/js/stage.js
  3. 62 1
      app/public/js/stage_im.js
  4. 1 1
      app/service/stage_rela.js
  5. 2 0
      sql/update.sql

+ 42 - 16
app/lib/stage_im.js

@@ -310,23 +310,49 @@ class StageIm {
 
     _checkCustomDetail(im) {
         const self = this;
-        const cd = this._.find(this.details, function(d) {
-            return im.lid === d.lid &&
-                (!im.code || im.code === d.code) &&
-                (!im.name || im.name === d.name) &&
-                (!im.unit || im.unit === d.unit) &&
-                self.ctx.helper.checkZero(self.ctx.helper.sub(im.unit_price, d.unit_price)) &&
-                (!im.pid || im.pid === d.pid) &&
-                (!im.pos_name || im.pos_name === d.pos_name);
-        });
+        let cd;
+        switch (this.stage.im_type) {
+            case imType.tz.value:
+                cd = this._.find(this.details, function (d) {
+                    return im.lid === d.lid &&
+                        (!im.code || im.code === d.code) &&
+                        (!im.name || im.name === d.name) &&
+                        (!im.unit || im.unit === d.unit) &&
+                        (!im.pid || im.pid === d.pid) &&
+                        (!im.pos_name || im.pos_name === d.pos_name);
+                });
+            case imType.zl.value:
+                cd = this._.find(this.details, function (d) {
+                    return im.lid === d.lid &&
+                        (!im.code || im.code === d.code) &&
+                        (!im.name || im.name === d.name) &&
+                        (!im.unit || im.unit === d.unit) &&
+                        self.ctx.helper.checkZero(self.ctx.helper.sub(im.unit_price, d.unit_price)) &&
+                        (!im.pid || im.pid === d.pid) &&
+                        (!im.pos_name || im.pos_name === d.pos_name);
+                });
+            case imType.bw.value:
+                cd = this._.find(this.details, function (d) {
+                    return im.lid === d.lid &&
+                        (!im.code || im.code === d.code) &&
+                        (!im.name || im.name === d.name) &&
+                        (!im.unit || im.unit === d.unit) &&
+                        self.ctx.helper.checkZero(self.ctx.helper.sub(im.unit_price, d.unit_price)) &&
+                        (!im.pid || im.pid === d.pid) &&
+                        (!im.pos_name || im.pos_name === d.pos_name);
+                });
+            case imType.bb.value:
+                cd = this._.find(this.details, function (d) {
+                    return im.lid === d.lid &&
+                        (!im.name || im.name === d.name) &&
+                        (!im.unit || im.unit === d.unit) &&
+                        (!im.pid || im.pid === d.pid) &&
+                        (!im.pos_name || im.pos_name === d.pos_name);
+                });
+        }
         if (cd) {
-            im.custom_define = im.custom_define !== null
-                ? (cd.custom_define ? cd.custom_define.split(',') : [])
-                : this.imFields;
-            this._.assignInWith(im, cd, function(oV, sV, key) {
-                return im.custom_define.indexOf(key) > -1 ? sV : oV;
-            });
-            if (im.code === '101-1-b') console.log(im.calc_memo);
+            im.custom_define = im.custom_define !== null ? (cd.custom_define ? cd.custom_define.split(',') : []) : this.imFields;
+            this._.assignInWith(im, cd, function(oV, sV, key) { return im.custom_define.indexOf(key) > -1 ? sV : oV; });
         }
     }
 

+ 5 - 0
app/public/js/stage.js

@@ -2521,6 +2521,7 @@ $(document).ready(() => {
                                 updateData.unit_price = data.unit_price;
                                 updateData.pid = data.pid;
                                 updateData.pos_name = data.pos_name;
+                                updateData.im_type = data.im_type;
                             }
                             if (data.custom_define.indexOf('doc_code') === -1) {
                                 updateData.custom_define = data.custom_define;
@@ -2567,6 +2568,7 @@ $(document).ready(() => {
                                     updateData.unit_price = data.unit_price;
                                     updateData.pid = data.pid;
                                     updateData.pos_name = data.pos_name;
+                                    updateData.im_type = data.im_type;
                                 }
                                 if (data.custom_define.indexOf('doc_code') === -1) {
                                     updateData.custom_define = data.custom_define;
@@ -2639,6 +2641,7 @@ $(document).ready(() => {
                                 updateData.unit_price = data.unit_price;
                                 updateData.pid = data.pid;
                                 updateData.pos_name = data.pos_name;
+                                updateData.im_type = data.im_type;
                             }
                             if (regRst) {
                                 updateData.doc_code = text.substr(0, regRst.index) + (parseInt(regRst[0]) + iRow + 1);
@@ -3050,6 +3053,7 @@ $(document).ready(() => {
                     updateData.unit_price = data.unit_price;
                     updateData.pid = data.pid;
                     updateData.pos_name = data.pos_name;
+                    updateData.im_type = data.im_type;
                     updateData.custom_define = [];
                 }
                 let infoUpdate = false;
@@ -3261,6 +3265,7 @@ $(document).ready(() => {
                     updateData.unit_price = data.unit_price;
                     updateData.pid = data.pid;
                     updateData.pos_name = data.pos_name;
+                    updateData.im_type = data.im_type;
                 }
                 if (items.length > 0) {
                     const itemInfo = [];

+ 62 - 1
app/public/js/stage_im.js

@@ -275,6 +275,56 @@ const stageIm = (function () {
         im.calc_img_remark = detail.calc_img_remark;
     }
 
+    function checkTzCustomDetail(im) {
+        const cd = _.find(details, function (d) {
+            return im.lid === d.lid &&
+                (!im.code || im.code === d.code) &&
+                (!im.name || im.name === d.name) &&
+                (!im.unit || im.unit === d.unit) &&
+                (!im.pid || im.pid === d.pid) &&
+                (!im.pos_name || im.pos_name === d.pos_name);
+        });
+        if (cd) loadCustomDetail(im, cd);
+    }
+
+    function checkZlCustomDetail(im) {
+        const cd = _.find(details, function (d) {
+            return im.lid === d.lid &&
+                (!im.code || im.code === d.code) &&
+                (!im.name || im.name === d.name) &&
+                (!im.unit || im.unit === d.unit) &&
+                checkZero(ZhCalc.sub(im.unit_price, d.unit_price)) &&
+                (!im.pid || im.pid === d.pid) &&
+                (!im.pos_name || im.pos_name === d.pos_name);
+        });
+        if (cd) loadCustomDetail(im, cd);
+    }
+
+    function checkBwCustomDetail(im) {
+        const cd = _.find(details, function (d) {
+            return im.lid === d.lid &&
+                (!im.code || im.code === d.code) &&
+                (!im.name || im.name === d.name) &&
+                (!im.unit || im.unit === d.unit) &&
+                checkZero(ZhCalc.sub(im.unit_price, d.unit_price)) &&
+                (!im.pid || im.pid === d.pid) &&
+                (!im.pos_name || im.pos_name === d.pos_name);
+        });
+        if (cd) loadCustomDetail(im, cd);
+    }
+
+
+    function checkBbCustomDetail(im) {
+        const cd = _.find(details, function (d) {
+            return im.lid === d.lid &&
+                (!im.name || im.name === d.name) &&
+                (!im.unit || im.unit === d.unit) &&
+                (!im.pid || im.pid === d.pid) &&
+                (!im.pos_name || im.pos_name === d.pos_name);
+        });
+        if (cd) loadCustomDetail(im, cd);
+    }
+
     function checkCustomDetail(im) {
         const cd = _.find(details, function (d) {
             return im.lid === d.lid &&
@@ -502,6 +552,7 @@ const stageIm = (function () {
                 lIndex: nodeIndex,
                 custom_define: [],
                 source: [{id: node.ledger_id, code: node.code, b_code: node.b_code}],
+                im_type: imType.zl.value,
             };
             if (stage.im_gather && node.check) {
                 im.bw = getZlGatherBw(node, peg);
@@ -559,6 +610,7 @@ const stageIm = (function () {
                 changes: [], gclBills: [],
                 custom_define: [],
                 source: [{id: node.ledger_id, code: node.code, b_code: node.b_code}],
+                im_type: imType.bb.value,
             };
             for (const p of posterity) {
                 if (p.children && p.children.length > 0) continue;
@@ -582,6 +634,7 @@ const stageIm = (function () {
                                 changes: [], gclBills: [],
                                 custom_define: [],
                                 source: [],
+                                im_type: imType.bb.value,
                             };
                             nodeImData.push(im);
                         }
@@ -724,6 +777,7 @@ const stageIm = (function () {
                     lIndex: nodeIndex,
                     custom_define: [],
                     source: [],
+                    im_type: imType.zl.value,
                 };
                 if (stage.im_gather && node.check) {
                     im.bw = getZlGatherBw(node, peg);
@@ -773,6 +827,7 @@ const stageIm = (function () {
                         lIndex: nodeIndex,
                         custom_define: [],
                         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;
                     ImData.push(im);
@@ -800,6 +855,7 @@ const stageIm = (function () {
                     lIndex: gsTree.getNodeIndex(node),
                     custom_define: [],
                     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;
                 ImData.push(im);
@@ -859,7 +915,12 @@ const stageIm = (function () {
             }
             getCalcMemo(im);
             getChangeInfo(im);
-            checkCustomDetail(im);
+            switch (stage.im_type) {
+                case imType.tz.value: checkTzCustomDetail(im);
+                case imType.zl.value: checkZlCustomDetail(im);
+                case imType.bw.value: checkBwCustomDetail(im);
+                case imType.bb.value: checkBbCustomDetail(im);
+            }
         }
     }
 

+ 1 - 1
app/service/stage_rela.js

@@ -480,7 +480,7 @@ module.exports = app => {
                 await conn.delete(this.ctx.service.stageRelaPosFinal.tableName, {sid: rela.sid, rela_tid: rela.rela_tid});
                 await conn.delete(this.ctx.service.stageRelaIm.tableName, {sid: rela.sid, rela_tid: rela.rela_tid});
                 await conn.delete(this.ctx.service.stageRelaImBills.tableName, {sid: rela.sid, rela_tid: rela.rela_tid});
-                await conn.update(this.ctx.service.stage.tableName, { id: this.ctx.stage.id, check_calc: 1 });
+                // await conn.update(this.ctx.service.stage.tableName, { id: this.ctx.stage.id, check_calc: 1 });
                 await conn.commit();
             } catch (err) {
                 await conn.rollback();

+ 2 - 0
sql/update.sql

@@ -167,3 +167,5 @@ CREATE TABLE `zh_stage_shoufang_attachment`  (
   INDEX `sid`(`sid`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT = '收方单附件表';
 
+ALTER TABLE `zh_stage_detail`
+ADD COLUMN `im_type`  tinyint(1) UNSIGNED NULL COMMENT '中间计量模式' AFTER `calc_img_remark`;