Browse Source

变更令

ZaiZai 1 year ago
parent
commit
cf40288503
1 changed files with 13 additions and 9 deletions
  1. 13 9
      src/views/alter/admin/components/order/addModal.vue

+ 13 - 9
src/views/alter/admin/components/order/addModal.vue

@@ -164,7 +164,7 @@
 <script setup>
 import { nextTick, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
-import { getDictionaryData } from '~uti/tools'
+import { getDictionaryData, isNumberReg } from '~uti/tools'
 import { arrToKey, formValidate, getArrValue, getObjValue, isArray, isNullES } from 'js-fast-way'
 import ChangeRequest from './changeRequest.vue'
 import unitApi from '~api/project/debit/contract/unit'
@@ -369,29 +369,33 @@ const changeNodeFinish = (data) => {
 
 //变更清单增减
 const currentChangeTotalBlur = (row) => {
-    const changeNum = (BigNumber(row.contractTotal).plus(row.currentChangeTotal)).toString()
+    //如果为空
+    let val = row.currentChangeTotal
+    const isMeter = isNumberReg(val)
+    if (isNullES(val) || !isMeter) {
+        val = 0
+    }
+    const changeNum = (BigNumber(row.contractTotal).plus(val)).toString()
     if (changeNum < 0) {
         window.$message.warning('变更增减数量不能小于变更前数量')
         const contract = '-' + row.contractTotal
         nextTick(() => {
-            //计算金额
-            row.currentChangeMoney = (BigNumber(contract).multipliedBy(row.currentPrice)).toString()
-            row.changeMoney = 0
-
             //设置数量
             row.currentChangeTotal = contract
             row.changeTotal = 0
-
+            //计算金额
+            row.currentChangeMoney = (BigNumber(contract).multipliedBy(row.currentPrice)).toString()
+            row.changeMoney = 0
             getFormList()
         })
     } else {
         nextTick(() => {
             //设置数量
             row.changeTotal = changeNum
+            row.currentChangeTotal = val
             //计算金额
-            row.currentChangeMoney = (BigNumber(row.currentChangeTotal).multipliedBy(row.currentPrice)).toString()
+            row.currentChangeMoney = (BigNumber(val).multipliedBy(row.currentPrice)).toString()
             row.changeMoney = (BigNumber(changeNum).multipliedBy(row.currentPrice)).toString()
-
             getFormList()
         })
     }