Procházet zdrojové kódy

中间计量相关

MaiXinRong před 5 roky
rodič
revize
122c6bfeaa

+ 7 - 2
app/lib/ledger.js

@@ -157,14 +157,19 @@ class baseTree {
      * @returns {Array}
      */
     getPosterity (node) {
+        let posterity;
         if (node.full_path !== '') {
             const reg = new RegExp('^' + node.full_path + '-');
-            return this.datas.filter(function (x) {
+            posterity = this.datas.filter(function (x) {
                 return reg.test(x.full_path);
             });
         } else {
-            return this._recursiveGetPosterity(node);
+            posterity = this._recursiveGetPosterity(node);
         }
+        posterity.sort(function (x, y) {
+            return self.getNodeIndex(x) - self.getNodeIndex(y);
+        });
+        return posterity;
     };
 
     /**

+ 11 - 9
app/lib/stage_im.js

@@ -61,7 +61,7 @@ class StageIm {
         this.ImData = [];
         this.ImBillsData = [];
         //
-        this.imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position'];
+        this.imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position', 'jldy'];
         this.splitChar = '-';
     }
 
@@ -255,8 +255,9 @@ class StageIm {
                 (!im.pos_name || im.pos_name === d.pos_name);
         });
         if (cd) {
+            im.custom_define = cd.custom_define ? cd.custom_define.split(',') : this.imFields;
             this._.assignInWith(im, cd, function(oV, sV, key) {
-                return self.imFields.indexOf(key) > -1 && sV !== undefined && sV !== null ? sV : oV;
+                return im.custom_define.indexOf(key) > -1 && sV !== undefined && sV !== null ? sV : oV;
             });
         }
     }
@@ -273,6 +274,10 @@ class StageIm {
             }
             im.calc_memo = memo.join('\n');
         } else if (im.gclBills && im.gclBills.length > 0) {
+            const self = this;
+            im.gclBills.sort(function (x, y) {
+                return self.ctx.helper.compareCode(x.b_code, y.b_code);
+            });
             const memo = [];
             for (const [i, b] of im.gclBills.entries()) {
                 if (b.pos && b.pos.length > 0) {
@@ -524,8 +529,8 @@ class StageIm {
                         }
                     }
 
-                    if (pp.drawing_code) im.drawing_code.push(pp.drawing_code);
-                    if (pp.position) im.position.push(pp.position);
+                    if (pp.drawing_code instanceof Array) im.drawing_code.push(pp.drawing_code);
+                    if (pp.position instanceof Array) im.position.push(pp.position);
                 }
             } else {
                 for (const c of changes) {
@@ -539,9 +544,6 @@ class StageIm {
 
                 this._addBwBillsGclBills(imDefault, {
                     b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
-                    // jl: p.gather_qty ? p.gather_qty : p.gather_tp,
-                    // contract_jl: p.contract_qty ? p.contract_qty : p.contract_tp,
-                    // qc_jl: p.qc_qty ? p.qc_qty : p.tp,
                     jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_jl,
                 });
             }
@@ -552,8 +554,8 @@ class StageIm {
         }
         for (const im of nodeImData) {
             this._calculateBwBillsIm(im);
-            im.drawing_code = im.drawing_code.join(mergeChar);
-            im.position = im.position.join(mergeChar);
+            im.drawing_code = this.ctx.helper._.uniq(im.drawing_code).join(mergeChar);
+            im.position = this.ctx.helper._.uniq(im.position).join(mergeChar);
             ImData.push(im);
         }
     }

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

@@ -23,6 +23,7 @@ const invalidFields = {
     posCalc: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp'],
     posXmj: ['code'],
 };
+const exprField = ['sgfh_qty', 'sgfh_tp', 'sjcl_qty'];
 function transExpr(expr) {
     return expr.replace('=', '').replace('%', '/100');
 }
@@ -427,6 +428,9 @@ $(document).ready(function() {
          * @param {Object} e
          * @param {Object} info
          */
+        _setExpr: function (field, text, data) {
+
+        },
         editEnded: function (e, info) {
             if (info.sheet.zh_setting) {
                 const col = info.sheet.zh_setting.cols[info.col];
@@ -475,6 +479,7 @@ $(document).ready(function() {
                         } else {
                             try {
                                 data[col.field] = math.evaluate(transExpr(newValue));
+                                if (exprField.indexOf(col.field) >= 0) data[col.field + '']
                             } catch(err) {
                                 toastr.error('输入的表达式非法');
                                 SpreadJsObj.reLoadRowData(info.sheet, info.row);

+ 8 - 2
app/public/js/path_tree.js

@@ -455,14 +455,20 @@ const createNewPathTree = function (type, setting) {
          * @returns {Array}
          */
         getPosterity(node) {
+            const self = this;
+            let posterity;
             if (node.full_path !== '') {
                 const reg = new RegExp('^' + node.full_path + '-');
-                return this.datas.filter(function (x) {
+                posterity = this.datas.filter(function (x) {
                     return reg.test(x.full_path);
                 });
             } else {
-                return this._recursiveGetPosterity(node);
+                posterity = this._recursiveGetPosterity(node);
             }
+            posterity.sort(function (x, y) {
+                return self.getNodeIndex(x) - self.getNodeIndex(y);
+            });
+            return posterity;
         };
         /**
          * 查询node是否是父节点的最后一个子节点

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

@@ -1778,6 +1778,11 @@ $(document).ready(() => {
                                 updateData.unit_price = data.unit_price;
                                 updateData.pos_name = data.pos_name;
                             }
+                            if (data.custom_define.indexOf('doc_code') === -1) {
+                                updateData.custom_define = data.custom_define;
+                                updateData.custom_define.push('doc_code');
+                                updateData.custom_define = updateData.custom_define.join(',');
+                            }
                             updateData.doc_code = info.editingText === null ? '' : info.editingText;
                             postData(window.location.pathname + '/detail/save', updateData, function (result) {
                                 stageIm.loadUpdateDetailData(result);
@@ -1818,6 +1823,11 @@ $(document).ready(() => {
                                     updateData.unit_price = data.unit_price;
                                     updateData.pos_name = data.pos_name;
                                 }
+                                if (data.custom_define.indexOf('doc_code') === -1) {
+                                    updateData.custom_define = data.custom_define;
+                                    updateData.custom_define.push('doc_code');
+                                    updateData.custom_define = updateData.custom_define.join(',');
+                                }
                                 updateData.doc_code = info.sheet.getText(curRow, info.cellRange.col).replace('\n', '');
                                 datas.push(updateData);
                             }
@@ -1844,6 +1854,7 @@ $(document).ready(() => {
                                     const updateData = {lid: data.lid};
                                     if (data.uuid) {
                                         updateData.uuid = data.uuid;
+                                        updateData.custom_define = data.custom_define;
                                         updateData.doc_code = '';
                                         datas.push(updateData);
                                     }
@@ -1889,6 +1900,11 @@ $(document).ready(() => {
                             } else {
                                 updateData.doc_code = text.replace('\n', '');
                             }
+                            if (data.custom_define.indexOf('doc_code') === -1) {
+                                updateData.custom_define = data.custom_define;
+                                updateData.custom_define.push('doc_code');
+                                updateData.custom_define = updateData.custom_define.join(',');
+                            }
                             datas.push(updateData);
                         }
                     }
@@ -2071,7 +2087,7 @@ $(document).ready(() => {
                         defaultRowHeight: 21,
                         headerFont: '12px 微软雅黑',
                         font: '12px 微软雅黑',
-                    }
+                    };
                     sjsSettingObj.setFxTreeStyle(setting, sjsSettingObj.FxTreeStyle.jz);
                     SpreadJsObj.initSheet(self.gsSpread.getActiveSheet(), setting);
                     self.gsSpread.bind(spreadNS.Events.ButtonClicked, function (e, info) {
@@ -2209,9 +2225,11 @@ $(document).ready(() => {
                     if (!org[field]) {
                         if (newValue !== '') {
                             update[field] = newValue;
+                            if (data.custom_define.indexOf(field) === -1) update.custom_define.push(field);
                         }
                     } else if (newValue !== org[field]){
                         update[field] = newValue;
+                        if (data.custom_define.indexOf(field) === -1) update.custom_define.push(field);
                     }
                 }
 
@@ -2219,19 +2237,30 @@ $(document).ready(() => {
                 const updateData = {lid: data.lid, pid: data.pid};
                 if (data.uuid) {
                     updateData.uuid = data.uuid;
+                    updateData.custom_define = data.custom_define;
                 } else {
                     updateData.code = data.code;
                     updateData.name = data.name;
                     updateData.unit = data.unit;
                     updateData.unit_price = data.unit_price;
                     updateData.pos_name = data.pos_name;
-                }
-                updateData.bw = $('#bw-name').val();
-                updateData.peg = $('#peg').val();
-                updateData.xm = $('#xm-name').val();
-                updateData.position = $('#position').val();
-                updateData.drawing_code = $('#drawing-code').val();
-                updateData.calc_memo = $('#calc-memo').val();
+                    updateData.custom_define = [];
+                }
+                check('bw', $('#bw-name'), data, updateData);
+                check('peg', $('#peg'), data, updateData);
+                check('xm', $('#xm'), data, updateData);
+                check('position', $('#position'), data, updateData);
+                check('jldy', $('#jldy'), data, updateData);
+                check('drawing_code', $('#drawing_code'), data, updateData);
+                check('calc-memo', $('#calc-memo'), data, updateData);
+                updateData.custom_define = updateData.custom_define.join(',');
+                // updateData.bw = $('#bw-name').val();
+                // updateData.peg = $('#peg').val();
+                // updateData.xm = $('#xm-name').val();
+                // updateData.position = $('#position').val();
+                // updateData.jldy = $('#jldy').val();
+                // updateData.drawing_code = $('#drawing-code').val();
+                // updateData.calc_memo = $('#calc-memo').val();
                 postData(window.location.pathname + '/detail/save', updateData, function (result) {
                     stageIm.loadUpdateDetailData(result);
                     self.reLoadDetailData();
@@ -2378,6 +2407,11 @@ $(document).ready(() => {
                         updateData.unit_price = data.unit_price;
                         updateData.pos_name = data.pos_name;
                     }
+                    if (data.custom_define.indexOf('calc_img') === -1) {
+                        updateData.custom_define = data.custom_define;
+                        updateData.custom_define.push('calc_img');
+                        updateData.custom_define = updateData.custom_define.join(',');
+                    }
                     updateData.img = canvas.toDataURL('image/png');
                     updateData.imgInfo = itemInfo;
                     postData(window.location.pathname + '/detail/merge-img', updateData, function (result) {

+ 18 - 9
app/public/js/stage_im.js

@@ -9,7 +9,7 @@
  */
 
 const stageIm = (function () {
-    const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position'];
+    const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position', 'jldy'];
     const splitChar = '-';
     const mergeChar = ';';
     let stage, imType, decimal, details, changes, ImData, pre;
@@ -265,8 +265,9 @@ const stageIm = (function () {
                 (!im.pos_name || im.pos_name === d.pos_name);
         });
         if (cd) {
+            im.custom_define = cd.custom_define ? cd.custom_define.split(',') : imFields;
             _.assignInWith(im, cd, function (oV, sV, key) {
-                return (imFields.indexOf(key) > -1 && sV !== undefined && sV !== null) ? sV : oV;
+                return (im.custom_define.indexOf(key) > -1 && sV !== undefined && sV !== null) ? sV : oV;
             });
         }
     }
@@ -283,6 +284,9 @@ const stageIm = (function () {
             }
             im.calc_memo = memo.join('\n');
         } else if (im.gclBills && im.gclBills.length > 0) {
+            im.gclBills.sort(function (x, y) {
+                return compareCode(x.b_code, y.b_code);
+            });
             const memo = [];
             for (const [i, b] of im.gclBills.entries()) {
                 if (b.pos && b.pos.length > 0) {
@@ -428,6 +432,7 @@ const stageIm = (function () {
                 peg: peg ? getPegStr(peg.name) : '', drawing_code: getDrawingCode(node),
                 position: '',
                 lIndex: nodeIndex,
+                custom_define: [],
             };
             if (stage.im_gather && node.check) {
                 im.bw = getZlGatherBw(node, peg);
@@ -484,6 +489,7 @@ const stageIm = (function () {
                 lIndex: nodeIndex,
                 bw: bw, jldy: node.name,
                 changes: [], gclBills: [],
+                custom_define: [],
             };
             checkCustomDetail(imDefault);
             for (const p of posterity) {
@@ -506,6 +512,7 @@ const stageIm = (function () {
                                 lIndex: nodeIndex,
                                 bw: bw, jldy: pp.name,
                                 changes: [], gclBills: [],
+                                custom_define: [],
                             };
                             nodeImData.push(im);
                             checkCustomDetail(im);
@@ -521,8 +528,10 @@ const stageIm = (function () {
                             jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty
                         });
 
-                        if (pp.drawing_code) im.drawing_code.push(pp.drawing_code);
-                        if (pp.position) im.position.push(pp.position);
+                        if (pp.drawing_code instanceof Array)
+                            im.drawing_code.push(pp.drawing_code);
+                        if (pp.position instanceof Array)
+                            im.position.push(pp.position);
                     }
                 } else {
                     for (const c of changes) {
@@ -536,9 +545,6 @@ const stageIm = (function () {
 
                     addBwBillsGclBills(imDefault, {
                         b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
-                        // jl: p.gather_qty ? p.gather_qty : p.gather_tp,
-                        // contract_jl: p.contract_qty ? p.contract_qty : p.contract_tp,
-                        // qc_jl: p.qc_qty ? p.qc_qty : p.tp,
                         jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_jl,
                     });
                 }
@@ -549,8 +555,8 @@ const stageIm = (function () {
             }
             for (const im of nodeImData) {
                 calculateBwBillsIm(im);
-                im.drawing_code = im.drawing_code.join(mergeChar);
-                im.position = im.position.join(mergeChar);
+                im.drawing_code = _.uniq(im.drawing_code).join(mergeChar);
+                im.position = _.uniq(im.position).join(mergeChar);
                 ImData.push(im);
             }
         }
@@ -644,6 +650,7 @@ const stageIm = (function () {
                     peg: peg ? getPegStr(peg.name) : '',
                     position: '',
                     lIndex: nodeIndex,
+                    custom_define: [],
                 };
                 if (stage.im_gather && node.check) {
                     im.bw = getZlGatherBw(node, peg);
@@ -691,6 +698,7 @@ const stageIm = (function () {
                         changes: [],
                         position: pp.position,
                         lIndex: nodeIndex,
+                        custom_define: [],
                     };
                     im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
                     checkCustomDetail(im);
@@ -717,6 +725,7 @@ const stageIm = (function () {
                     changes: [],
                     position: '',
                     lIndex: gsTree.getNodeIndex(node),
+                    custom_define: [],
                 };
                 im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
                 checkCustomDetail(im);

+ 25 - 1
sql/update.sql

@@ -5,4 +5,28 @@ UPDATE `zh_stage_pay` sp
   WHERE (sp.`start_stage_order` < s.`order` OR ((not IsNULL(sp.pre_tp)) AND sp.pre_tp) AND sp.`pre_used` = 0 AND p.`ptype` = 1;
 
 ALTER TABLE `zh_stage_detail`
-ADD COLUMN `pos_name`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '计量单元名称' AFTER `position`;
+ADD COLUMN `pos_name`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '计量单元名称' AFTER `position`;
+
+ALTER TABLE `zh_formula`
+MODIFY COLUMN `sid`  int(11) NOT NULL DEFAULT -1 COMMENT '期id' AFTER `tid`,
+MODIFY COLUMN `rid`  varchar(50) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '' COMMENT '修订id' AFTER `sid`,
+MODIFY COLUMN `formula`  varchar(1000) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '表达式' AFTER `table_field`,
+ADD COLUMN `valid`  tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否可用' AFTER `formula`;
+
+ALTER TABLE `zh_stage_detail`
+ADD COLUMN `custom_define`  varchar(1000) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '修改过的字段' AFTER `pos_name`;
+
+ALTER TABLE `zh_ledger`
+MODIFY COLUMN `sgfh_qty`  decimal(24,8) NULL DEFAULT NULL COMMENT '施工复核 - 数量' AFTER `deal_tp`,
+MODIFY COLUMN `sgfh_tp`  decimal(24,8) NULL DEFAULT NULL COMMENT '施工复核 - 金额' AFTER `sgfh_qty`,
+ADD COLUMN `sgfh_expr`  varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '施工复核-公式' AFTER `is_tp`,
+ADD COLUMN `sjcl_expr`  varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '设计错漏-公式' AFTER `sgfh_expr`,
+ADD COLUMN `qtcl_expr`  varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '其他错漏-公式' AFTER `sjcl_qty`;
+
+
+ALTER TABLE `zh_revise_bills`
+MODIFY COLUMN `sgfh_qty`  decimal(24,8) NULL DEFAULT NULL COMMENT '施工复核 - 数量' AFTER `deal_tp`,
+MODIFY COLUMN `sgfh_tp`  decimal(24,8) NULL DEFAULT NULL COMMENT '施工复核 - 金额' AFTER `sgfh_qty`,
+ADD COLUMN `sgfh_expr`  varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '施工复核-公式' AFTER `is_tp`,
+ADD COLUMN `sjcl_expr`  varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '设计错漏-公式' AFTER `sgfh_expr`,
+ADD COLUMN `qtcl_expr`  varchar(255) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT '' COMMENT '其他错漏-公式' AFTER `sjcl_qty`;