Преглед изворни кода

更改加权系数独立设置

ellisran пре 2 месеци
родитељ
комит
28089b73e2

+ 5 - 3
app/public/js/material_exponent.js

@@ -336,7 +336,7 @@ $(document).ready(() => {
                 // 未改变值则不提交
                 let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
                 const orgValue = select[col.field];
-                if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
+                if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     return;
                 }
@@ -379,7 +379,8 @@ $(document).ready(() => {
                         validText = ZhCalc.round(num, 3);
                         num = ZhCalc.round(num, 3);
                     }
-                    const total_weight = showStageExponent || exponent_nodes ? ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(materialExponentShardData, 'weight_num')), parseFloat(orgValue)), num) : ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(materialExponentData, 'weight_num')), parseFloat(orgValue)), num);
+                    const weight_datas = showStageExponent || exponent_nodes ? _.filter(materialExponentShardData, { ms_id: parseInt($('#myTab').find('.active').attr('data-msid')) || null, mn_id: parseInt($('#myTab2').find('.active').attr('data-mnid')) || null }) : materialExponentData;
+                    const total_weight = ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(weight_datas, 'weight_num')), parseFloat(orgValue)), num);
                     if (total_weight > 1) {
                         toastr.error('加权系数总和不能大于1');
                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -591,7 +592,8 @@ $(document).ready(() => {
                             validText = ZhCalc.round(num, 3);
                             num = ZhCalc.round(num, 3);
                         }
-                        const total_weight = showStageExponent || exponent_nodes ? ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(materialExponentShardData, 'weight_num')), parseFloat(orgValue)), num) : ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(materialExponentData, 'weight_num')), parseFloat(orgValue)), num);
+                        const weight_datas = showStageExponent || exponent_nodes ? _.filter(materialExponentShardData, { ms_id: parseInt($('#myTab').find('.active').attr('data-msid')) || null, mn_id: parseInt($('#myTab2').find('.active').attr('data-mnid')) || null }) : materialExponentData;
+                        const total_weight = ZhCalc.add(ZhCalc.sub(ZhCalc.sum(_.map(weight_datas, 'weight_num')), parseFloat(orgValue)), num);
                         if (total_weight > 1) {
                             toastMessageUniq(getPasteHint(hint.weightNumberCan, hintRow));
                             bPaste = false;

+ 0 - 1
app/service/material_exponent.js

@@ -330,7 +330,6 @@ module.exports = app => {
             if (ms_id !== null) mesCondition.ms_id = ms_id;
             if (mn_id !== null) mesCondition.mn_id = mn_id;
             const mesList = await transaction.select(this.ctx.service.materialExponentShard.tableName, { where: mesCondition });
-            console.log(mesList);
             const materialExponentColArray = ['symbol', 'symbol_desc', 'code', 'basic_price', 'is_summary', 'basic_times'];
             const materialExponentShardColArray = ['weight_num', 'm_price', 'remark'];
             const updateCalcArray = ['weight_num', 'basic_price', 'm_price', 'is_summary'];

+ 1 - 1
app/service/material_exponent_shard.js

@@ -77,7 +77,7 @@ module.exports = app => {
                 if (data[nu] !== undefined && mesInfo[nu] !== data[nu]) updateData[nu] = data[nu];
             }
             await transaction.update(this.tableName, updateData);
-            if (updateData.m_price !== undefined || needCalc) {
+            if (updateData.m_price !== undefined || updateData.weight_num !== undefined || needCalc) {
                 const mnInfo = mn_id ? await transaction.get(this.ctx.service.materialExponentNode.tableName, { mid: this.ctx.material.id, id: mn_id }) : null;
                 const msInfo = ms_id && !mn_id ? await transaction.get(this.ctx.service.materialStage.tableName, { mid: this.ctx.material.id, id: ms_id }) : null;
                 const ex_calc = mnInfo ? JSON.parse(mnInfo.ex_calc) : msInfo ? JSON.parse(msInfo.ex_calc) : materialConst.ex_calc;