ZaiZai hai 1 ano
pai
achega
8fecb2f92b
Modificáronse 1 ficheiros con 25 adicións e 12 borrados
  1. 25 12
      src/views/alter/admin/components/order/addModal.vue

+ 25 - 12
src/views/alter/admin/components/order/addModal.vue

@@ -120,7 +120,7 @@
                                     <el-table-column prop="contractTotal" label="变更前" />
                                     <el-table-column prop="currentChangeTotal" label="变更增减">
                                         <template #default="{ row }">
-                                            <hc-table-input v-model="row.currentChangeTotal" @blur="currentChangeTotalBlur($event, row)" />
+                                            <hc-table-input v-model="row.currentChangeTotal" @blur="currentChangeTotalBlur(row)" />
                                         </template>
                                     </el-table-column>
                                     <el-table-column prop="changeTotal" label="变更后" />
@@ -357,33 +357,46 @@ const changeNodeFinish = (data) => {
 }
 
 //变更清单增减
-const currentChangeTotalBlur = (event, row) => {
-    //计算数量
+const currentChangeTotalBlur = (row) => {
     const changeNum = (BigNumber(row.contractTotal).plus(row.currentChangeTotal)).toNumber()
     if (changeNum < 0) {
         window.$message.warning('变更增减数量不能小于变更前数量')
-        row.currentChangeTotal = '-' + row.contractTotal
+        const contract = '-' + row.contractTotal
+        nextTick(() => {
+            //计算金额
+            row.currentChangeMoney = (BigNumber(contract).multipliedBy(row.currentPrice)).toNumber()
+            row.changeMoney = 0
+
+            //设置数量
+            row.currentChangeTotal = contract
+            row.changeTotal = 0
+        })
+    } else {
+        nextTick(() => {
+            //设置数量
+            row.changeTotal = changeNum
+            //计算金额
+            row.currentChangeMoney = (BigNumber(row.currentChangeTotal).multipliedBy(row.currentPrice)).toNumber()
+            row.changeMoney = (BigNumber(changeNum).multipliedBy(row.currentPrice)).toNumber()
+        })
     }
-    row.changeTotal = changeNum
-
-    //计算金额
-    row.currentChangeMoney = (BigNumber(row.currentChangeTotal).multipliedBy(row.currentPrice)).toNumber()
-    row.changeMoney = (BigNumber(changeNum).multipliedBy(row.currentPrice)).toNumber()
     getFormList()
 }
 
 //获取变更清单总额
 const getFormList = () => {
-    let total = 0, table = deepClone(tableData.value)
+    let total = 0, table = tableData.value
     for (let i = 0; i < table.length; i++) {
         const item = table[i]
+        if (!isArray(item.formList)) {
+            item.formList = []
+        }
         for (let j = 0; j < item.formList.length; j++) {
             const form = item.formList[j]
             total = (BigNumber(total).plus(form.currentChangeMoney)).toNumber()
         }
     }
-    tableData.value = []
-    tableData.value = table
+    baseForm.value.changeMoney = total
 }