Browse Source

计量上限值限制填写数值

ellisran 1 year ago
parent
commit
f87ef812ec

+ 4 - 1
app/controller/change_controller.js

@@ -722,7 +722,10 @@ module.exports = app => {
                                 id: cl.id,
                             };
                             if (useChangeUsedData.length > 0 && ctx.helper._.findIndex(useChangeUsedData, { cbid: cl.id }) !== -1) {
-                                if (cl.delimit < renderData.deLimit) {
+                                // 获取比例值
+                                const uc = ctx.helper._.find(useChangeUsedData, { cbid: cl.id });
+                                const minLimit = Math.ceil(ctx.helper.div(uc.qty, cl.camount) * 100);
+                                if (minLimit < renderData.deLimit) {
                                     one.delimit = renderData.deLimit;
                                     cl.delimit = renderData.deLimit;
                                 }

+ 43 - 6
app/public/js/change_information_set.js

@@ -101,7 +101,7 @@ $(document).ready(() => {
             {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit2', getValue: 'getValue.unit_price'},
             {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit2'},
             {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: false},
-            {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, formatter: '@', readOnly: false, visible: openChangeState},
+            {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, type: 'Number', readOnly: false, visible: openChangeState},
             {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.oamount'},
             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
             {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: false, getValue: 'getValue.camount'},
@@ -528,6 +528,25 @@ $(document).ready(() => {
                     } else {
                         validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
                     }
+                    if (col.field === 'delimit') {
+                        const reg = /^(\d{1,2}|100)$/;
+                        if (!(_.isNumber(validText) && reg.test(validText))) {
+                            toastr.error('计量上限默认值只能输入0-100之间的整数');
+                            SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                            return;
+                        }
+                        // 需要判断是否已调用,已调用的则不能低于原有值大小
+                        const usedInfo = _.find(changeUsedData, { cbid: select.id });
+                        if (usedInfo && usedInfo.qty) {
+                            const minLimit = Math.ceil(ZhCalc.div(usedInfo.qty, select.camount) * 100);
+                            console.log(usedInfo.qty, minLimit);
+                            if (validText < minLimit) {
+                                toastr.error('计量上限值至少大于等于 ' + minLimit);
+                                SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                                return;
+                            }
+                        }
+                    }
                 }
                 if (col.field === 'unit') {
                     select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
@@ -558,7 +577,7 @@ $(document).ready(() => {
             };
             const range = info.cellRange;
             const sortData = info.sheet.zh_data || [];
-            if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
+            if (range.row + range.rowCount > sortData.length) {
                 toastMessageUniq(hint.cellError);
                 // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
                 SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
@@ -566,7 +585,7 @@ $(document).ready(() => {
                 changeSpreadObj.makeSjsFooter();
                 return;
             }
-            if (sortData.length > 0 && range.col + range.colCount > 10) {
+            if (sortData.length > 0 && range.col + range.colCount > 14) {
                 toastMessageUniq(hint.cellError);
                 SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
                 SpreadJsObj.reLoadSheetData(changeSpreadSheet);
@@ -582,7 +601,7 @@ $(document).ready(() => {
                 const curRow = range.row + iRow;
                 // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
                 const cLData = { id: sortData[curRow].id };
-                const hintRow = range.rowCount > 1 ? curRow : '';
+                const hintRow = range.rowCount >= 1 ? curRow : '';
                 let sameCol = 0;
                 for (let iCol = 0; iCol < range.colCount; iCol++) {
                     const curCol = range.col + iCol;
@@ -632,11 +651,11 @@ $(document).ready(() => {
                         // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
                         const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
                         if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
-                            toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
+                            toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
                             bPaste = false;
                             continue;
                         } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
-                            toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
+                            toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
                             bPaste = false;
                             continue;
                         }
@@ -654,6 +673,24 @@ $(document).ready(() => {
                         } else {
                             validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
                         }
+                        if (colSetting.field === 'delimit') {
+                            const reg = /^(\d{1,2}|100)$/;
+                            if (!(_.isNumber(validText) && reg.test(validText))) {
+                                toastr.error('清单第' + (hintRow+1) + '行计量上限默认值只能粘贴0-100之间的整数');
+                                bPaste = false;
+                                continue;
+                            }
+                            // 需要判断是否已调用,已调用的则不能低于原有值大小
+                            const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
+                            if (usedInfo && usedInfo.qty) {
+                                const minLimit = Math.ceil(ZhCalc.div(usedInfo.qty, sortData[curRow].camount) * 100);
+                                if (validText < minLimit) {
+                                    toastr.error('清单第' + (hintRow+1) + '行计量上限值至少大于等于 ' + minLimit);
+                                    bPaste = false;
+                                    continue;
+                                }
+                            }
+                        }
                     }
                     let unitdecimal = validText;
                     if (colSetting.field === 'unit') {

+ 4 - 1
app/service/change.js

@@ -719,7 +719,10 @@ module.exports = app => {
                             id: cl.id,
                         };
                         if (useChangeUsedData.length > 0 && this._.findIndex(useChangeUsedData, { cbid: cl.id }) !== -1) {
-                            if (cl.delimit < delimit) {
+                            // 获取比例值
+                            const uc = this._.find(useChangeUsedData, { cbid: cl.id });
+                            const minLimit = Math.ceil(this.ctx.helper.div(uc.qty, cl.camount) * 100);
+                            if (minLimit < delimit) {
                                 one.delimit = delimit;
                                 cl.delimit = delimit;
                             }

+ 1 - 1
app/view/setting/fun.ejs

@@ -438,7 +438,7 @@
             // 变更令状态功能-设置计量调用上限
             const change_state = [];
             let flag = false;
-            const reg = /^[1-9]\d{0,2}$|^0|^100$/;
+            const reg = /^(\d{1,2}|100)$/;
             $('#change_state_table tr').each(function () {
                 const one_state = _.find(changeState, { order: parseInt($(this).attr('data-order'))});
                 const value = parseFloat($(this).find('input[type="number"]').val());