Explorar o código

1. 计算模板,转换计算代号相关
2. 计量单元,复制粘贴计算1问题

MaiXinRong hai 2 semanas
pai
achega
c40c13787b

+ 6 - 0
app/lib/rm/tender.js

@@ -140,6 +140,12 @@ class rptMemPaymentSafe extends RptMemBase {
                 return materialSource.getMaterialPos(params.tender_id, params.material_order, fields);
             case 'mem_material_stage':
                 return materialSource.getMaterialStage(params.tender_id, params.material_order, fields);
+            case 'mem_material_exponent':
+                return materialSource.getMaterialExponent(params.tender_id, params.material_order, fields);
+            case 'mem_material_exponent_node':
+                return materialSource.getMaterialExponentNode(params.tender_id, params.material_order, fields);
+            case 'mem_material_exponent_shard':
+                return materialSource.getMaterialExponentShard(params.tender_id, params.material_order, fields);
             case 'mem_stage_sum_bills':
                 return service.rptStageSumMemory.getStageSumBills(params.tender_id, fields,
                     customDefine.stage_select, customSelect ? customSelect.stage_select : null);

+ 37 - 0
app/lib/rm/tender_material.js

@@ -446,6 +446,43 @@ class ReportMemoryMaterial {
             }];
         }
     }
+
+    async getMaterialExponent(tender_id, material_order, fields) {
+        const material = await this.ctx.service.material.getDataByCondition({tid: tender_id, order: material_order});
+        if (!material) return [];
+
+        const materials = await this.ctx.service.material.getAllDataByCondition({
+            where: {tid: this.ctx.material.tid},
+            orders: [['order', 'desc']],
+        });
+        if (materials.length === 0) return [];
+
+        let result;
+        if (materials[0].order === material.order) {
+            result = await this.ctx.service.materialExponent.getAllDataByCondition({
+                where: { tid: material.tid }
+            });
+        } else {
+            const sql = 'SELECT me.id, me.tid, me.mid, me.type, me.symbol, me.symbol_desc, me.code, me.remark, me.in_time,' +
+                '    meh.type, meh.weight_num, meh.basic_price, meh.basic_times, meh.m_price, meh.calc_num, meh.is_summary' +
+                '  FROM ' + this.ctx.service.materialExponentHistory.tableName + ' meh ' +
+                '  LEFT JOIN ' + this.ctx.service.materialExponent.tableName + ' me ON meh.me_id = me.id ' +
+                '  WHERE meh.tid = ? And meh.mid = ?'+
+                '  ORDER By me.id';
+            result = await this.ctx.app.mysql.query(sql, [material.tid, material.id]);
+        }
+        return result;
+    }
+    async getMaterialExponentNode(tender_id, material_order, fields) {
+        const material = await this.ctx.service.material.getDataByCondition({tid: tender_id, order: material_order});
+        if (!material) return [];
+        return this.ctx.service.materialExponentNode.getAllDataByCondition({ where: { mid: material.id } });
+    }
+    async getMaterialExponentShard(tender_id, material_order, fields) {
+        const material = await this.ctx.service.material.getDataByCondition({tid: tender_id, order: material_order});
+        if (!material) return [];
+        return this.ctx.service.materialExponentNode.getAllDataByCondition({ where: { mid: material.id } });
+    }
 }
 
 module.exports = ReportMemoryMaterial;

+ 3 - 1
app/public/js/cost_tmpl.js

@@ -128,6 +128,8 @@ $(document).ready(() => {
                 const typeInfo = validColInfo.find(x => { return x.key === data.type; });
                 return typeInfo.name || '';
             };
+            const numCol = validColInfo.find(x => { return x.key === 'num'; });
+            const validCalcCode = numCol.fields.map(x => { return x.replace('num_', '').toUpperCase(); });
             this.spreadSetting = {
                 cols: [
                     { title: '类型', colSpan: '1', rowSpan: '1', field: 'type', hAlign: 1, width: 80, formatter: '@', readOnly: true, getValue: getTypeValue },
@@ -136,7 +138,7 @@ $(document).ready(() => {
                     // { title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 60, cellType: 'unit' },
                     {
                         title: '计算代号', colSpan: '1', rowSpan: '1', field: 'calc_code', hAlign: 1, width: 80, cellType: 'customizeCombo',
-                        comboItems: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'],
+                        comboItems: validCalcCode,
                     },
                     { title: '小数位数', colSpan: '1', rowSpan: '1', field: 'decimal', hAlign: 1, width: 60, type: 'Number' },
                     { title: '期数据', colSpan: '1', rowSpan: '1', field: 'sum', hAlign: 1, width: 60, readOnly: true, cellType: 'signalCheckbox', show: function(data) {

+ 2 - 2
app/public/js/ledger.js

@@ -2927,8 +2927,8 @@ $(document).ready(function() {
                         if (colSetting.type === 'Number') {
                             const exprInfo = getExprInfo(colSetting.field);
                             const num = _.toNumber(posData[colSetting.field]);
-                            if (num) {
-                                posData[colSetting.field] = num;
+                            if (_.isNumber(num)) {
+                                posData[colSetting.field] = _.isFinite(num) ? num : 0;
                                 if (exprInfo) posData[exprInfo.expr] = '';
                                 bPaste = true;
                             } else {

+ 4 - 2
app/public/js/pos_calc_tmpl.js

@@ -540,16 +540,18 @@ $(document).ready(() => {
                 const typeInfo = validColInfo.find(x => { return x.key === data.type; });
                 return typeInfo.name || '';
             };
+            const numCol = validColInfo.find(x => { return x.key === 'num'; });
+            const validCalcCode = numCol.fields.map(x => { return x.replace('num_', '').toUpperCase(); });
             this.spreadSetting = {
                 cols: [
                     { title: '类型', colSpan: '1', rowSpan: '1', field: 'type', hAlign: 1, width: 80, formatter: '@', readOnly: true, getValue: getTypeValue },
                     { title: '列名', colSpan: '1', rowSpan: '1', field: 'title', hAlign: 0, width: 130, formatter: '@' },
                     { title: '列宽', colSpan: '1', rowSpan: '1', field: 'width', hAlign: 1, width: 70, type: 'Number' },
                     { title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 60, cellType: 'unit' },
-                    { title: '计算代号', colSpan: '1', rowSpan: '1', field: 'calc_code', hAlign: 1, width: 80, cellType: 'customizeCombo', comboItems: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'], },
+                    { title: '计算代号', colSpan: '1', rowSpan: '1', field: 'calc_code', hAlign: 1, width: 80, cellType: 'customizeCombo', comboItems: validCalcCode, },
                     { title: '小数位数', colSpan: '1', rowSpan: '1', field: 'decimal', hAlign: 1, width: 60, type: 'Number' },
                     { title: '规格类型', colSpan: '1', rowSpan: '1', field: 'spec_set', hAlign: 1, width: 80, cellType: 'customizeCombo', cellTypeKey: 'spec', comboItems: specList, },
-                    { title: '关联列代号', colSpan: '1', rowSpan: '1', field: 'rela_col', hAlign: 1, width: 80, cellType: 'customizeCombo', comboItems: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'], },
+                    { title: '关联列代号', colSpan: '1', rowSpan: '1', field: 'rela_col', hAlign: 1, width: 80, cellType: 'customizeCombo', comboItems: validCalcCode, },
                     { title: '计算公式', colSpan: '1', rowSpan: '1', field: 'expr', hAlign: 0, width: 250 },
                 ],
                 emptyRows: 0,

+ 1 - 1
app/service/calc_tmpl.js

@@ -520,7 +520,7 @@ module.exports = app => {
             if (!org || org.pid !== this.ctx.session.sessionProject.id) throw '复制的模板不存在,请刷新后重试';
 
             await this.getProjectCalcTmplSet();
-            const count = await this.count({pid: this.ctx.session.sessionProject.id, type});
+            const count = await this.count({pid: this.ctx.session.sessionProject.id, type: org.type});
             if (count >= this.projectSet[org.type].validCount) throw '已达模板使用上限';
 
             const insertData = {

+ 12 - 0
app/service/report.js

@@ -293,6 +293,18 @@ module.exports = app => {
                             runnableRst.push(materialSource.getMaterialStage(params.tender_id, params.material_order, memFieldKeys[filter]));
                             runnableKey.push(filter);
                             break;
+                        case 'mem_material_exponent':
+                            runnableRst.push(materialSource.getMaterialExponent(params.tender_id, params.material_order, memFieldKeys[filter]));
+                            runnableKey.push(filter);
+                            break;
+                        case 'mem_material_exponent_node':
+                            runnableRst.push(materialSource.getMaterialExponentNode(params.tender_id, params.material_order, memFieldKeys[filter]));
+                            runnableKey.push(filter);
+                            break;
+                        case 'mem_material_exponent_shard':
+                            runnableRst.push(materialSource.getMaterialExponentShard(params.tender_id, params.material_order, memFieldKeys[filter]));
+                            runnableKey.push(filter);
+                            break;
                         case 'mem_stage_sum_bills':
                             runnableRst.push(service.rptStageSumMemory.getStageSumBills(params.tender_id, memFieldKeys[filter],
                                 customDefine.stage_select, customSelect ? customSelect.stage_select : null));