Jelajahi Sumber

修复控制和展示

laiguoran 4 tahun lalu
induk
melakukan
6f9e85dd34

+ 33 - 7
app/public/js/change_information_approval.js

@@ -7,6 +7,15 @@
  * @date 2018/11/22
  * @version
  */
+
+function getPasteHint (str, row = '') {
+    let returnObj = str;
+    if (row) {
+        returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
+    }
+    return returnObj;
+}
+
 $(document).ready(() => {
     const changeSpreadSetting = {
         cols: [
@@ -181,10 +190,17 @@ $(document).ready(() => {
                         return;
                     }
                     validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
+                    // 判断是否大于等于限制值,否则无法更改
+                    const usedInfo = _.find(changeUsedData, { id: select.id });
+                    if (usedInfo && validText < usedInfo.used_qty) {
+                        toastr.error('清单变更数值必须大于等于已调用值');
+                        SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                        changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
+                        return;
+                    }
                 }
                 select[col.field] = validText;
                 select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
-                console.log(select);
 
                 const data = {
                     id: select.id,
@@ -206,10 +222,11 @@ $(document).ready(() => {
             }
         },
         clipboardPasted(e, info) {
-            // const hint = {
-            //     cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
-            //     numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
-            // };
+            const hint = {
+                cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
+                numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
+                qtyError: {type: 'error', msg: '变更数值必须大于等于已调用值'},
+            };
             const range = info.cellRange;
             const sortData = info.sheet.zh_data || [];
             // console.log(info, range);
@@ -261,6 +278,15 @@ $(document).ready(() => {
                             continue;
                         }
                         validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
+                        // 判断是否大于等于限制值,否则无法更改
+                        const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
+                        if (usedInfo && validText < usedInfo.used_qty) {
+                            toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
+                            SpreadJsObj.reLoadRowData(info.sheet, curRow);
+                            changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
+                            bPaste = false;
+                            continue;
+                        }
                     }
                     // cLData[colSetting.field] = validText;
                     sortData[curRow][colSetting.field] = validText;
@@ -270,11 +296,11 @@ $(document).ready(() => {
                     data.push(cLData);
                     // rowData.push(curRow);
                 } else {
-                    SpreadJsObj.reLoadRowData(info.sheet, curRow);
+                    // SpreadJsObj.reLoadRowData(info.sheet, curRow);
                 }
             }
             if (data.length === 0) {
-                SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
+                // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
                 return;
             }
             console.log(data);

+ 17 - 0
app/public/js/change_information_set.js

@@ -83,6 +83,14 @@ $.event.special.valuechange = {
         }
     }
 };
+function getPasteHint (str, row = '') {
+    let returnObj = str;
+    if (row) {
+        returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
+    }
+    return returnObj;
+}
+
 $(document).ready(() => {
     const changeSpreadSetting = {
         cols: [
@@ -354,6 +362,15 @@ $(document).ready(() => {
                         } else {
                             validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
                         }
+                        if(colSetting.field === 'camount') {
+                            // 判断是否大于等于限制值,否则无法更改
+                            const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
+                            if (usedInfo && validText < usedInfo.used_qty) {
+                                toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.used_qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.used_qty);
+                                bPaste = false;
+                                continue;
+                            }
+                        }
                     }
                     let unitdecimal = validText;
                     if (colSetting.field === 'unit') {

+ 1 - 0
app/view/change/information.ejs

@@ -454,6 +454,7 @@
     const auditList2 = JSON.parse(unescape('<%- escape(JSON.stringify(auditList2)) %>'));
     const aidList = _.map(auditList2, 'uid');
     aidList.splice(0, 1);
+    let changeUsedData = JSON.parse(unescape('<%- escape(JSON.stringify(changeUsedData)) %>'));
 </script>
 <script src="/public/js/change_information_approval.js"></script>
 <% } %>