duy 1 год назад
Родитель
Сommit
56478e18c7
1 измененных файлов с 26 добавлено и 58 удалено
  1. 26 58
      src/views/debit-pay/admin/components/middlepay/addModal.vue

+ 26 - 58
src/views/debit-pay/admin/components/middlepay/addModal.vue

@@ -291,13 +291,12 @@ if (containsField) {
 } else {
   isRelationData.value = false
   addTableData.value.forEach((ele)=>{
-    ele.upPayRatio = ele.oldupPayRatio || 0
+    ele.upPayRatio = ele.oldupPayRatio || '0.00'
   })
 }
-// 判断数组中是否存在某个对象的 upPayRatio 字段值为 100
-const hasValue100 = addTableData.value.some(obj => obj.upPayRatio === 100)
 nextTick(()=>{
-    if (hasValue100 && (isComparedRaVal.value === 1 )) {
+    console.log(isComparedRaVal.value, 'isComparedRaVal.value ')
+    if (isComparedRaVal.value === 1 ) {
         window.$message.warning('累计计量金额超出支付比列,如需计量100%,请完成关联对应的质保资料')
     }
 })
@@ -474,7 +473,6 @@ const currentMeterTotalBlur = (row) => {
     }
     //计算本期计量金额
     nextTick(() => {
-     
         row.currentMeterTotal = currentMeterTotal
         row.currentMeterMoney = (BigNumber(currentMeterTotal).multipliedBy(row.currentPrice)).toString()
         row.allMeterTotal = (BigNumber(currentMeterTotal).plus(row.otherMeterTotal)).toString()
@@ -487,34 +485,7 @@ const currentMeterTotalBlur = (row) => {
         //计算本期支付比例
         //本期支 付比例=本期计量数量/变更后数量
         row.payRatio = BigNumber(currentMeterTotal).dividedBy(row.changeTotal).toString() * 100
-
-        // 每次填写完 本期计量数量或者支付比例后
-        // 就去对比:本期支付比例+其他期支付比例
-        //             是否大于最大支付比例
-        // 如果大于,则提示
-
-           let payRatio = new BigNumber(row.payRatio )//本期支付比例
-           let upPayRatio = new BigNumber(row.upPayRatio )//最大支付比例
-           let otherPayRatio = new BigNumber(row.otherPayRatio )//其他期支付比例
-           let result = BigNumber(payRatio).plus(otherPayRatio)//本期支付比例+其他期支付比例
-           const isComparedRa = result.comparedTo(upPayRatio)
-           console.log(isComparedRa, 'isCompared3333333')
-           isComparedRaVal.value = isComparedRa
-               // //a 大于 b = 1,a 等于 b = 0,a 小于 b = -1, a 或 b 的值异常时 = null
-        if (isComparedRa === 1 ) {
-            isCanSave.value = true
-          
-           window.$message.warning('累计计量金额超出支付比列,如需计量100%,请完成关联对应的质保资料')
-            // return '--el-table-tr-bg-color: #fe0000; --el-table-row-hover-bg-color: #fe0000; color: white;'
-            
-        
-        } else {
-            isCanSave.value = false
-           
-        }
-
-
-     
+        compareRowUnpayRatio(row, 1)
 
     })
 }
@@ -530,12 +501,8 @@ const containChangeTotalBlur = (row) => {
         row.containChangeTotal = val
     })
 }
-const unPayRatioBlur = (row)=>{
-    nextTick(()=>{
-        console.log(row, 'rowzhifubili')
-        
-
-        // 计算方式:
+const compareRowUnpayRatio = (row, type)=>{
+          // 计算方式:
         //本期支 付比例=本期计量数量/变更后数量
         //本期支付比例=本期计量数量/变更后数量
         //本期计量数量=本期支付比例*变更后数量
@@ -546,31 +513,39 @@ const unPayRatioBlur = (row)=>{
         // 就去对比:本期支付比例+其他期支付比例
         //             是否大于最大支付比例
         // 如果大于,则提示
-           let changeTotal = new BigNumber(row.changeTotal )//变更后数量
            let payRatio = new BigNumber(row.payRatio )//本期支付比例
            let upPayRatio = new BigNumber(row.upPayRatio )//最大支付比例
            let otherPayRatio = new BigNumber(row.otherPayRatio )//其他期支付比例
            let result = BigNumber(payRatio).plus(otherPayRatio)//本期支付比例+其他期支付比例
-             // 本期计量数量=本期支付比例*变更后数量
-            row.currentMeterTotal = (payRatio.dividedBy(100).multipliedBy(changeTotal)).toString()
-            row.currentMeterMoney = (BigNumber(row.currentMeterTotal).multipliedBy(row.currentPrice)).toString()//本期计量金额额
-            row.allMeterTotal = (BigNumber(row.currentMeterTotal).plus(row.otherMeterTotal)).toString()
            const isComparedRa = result.comparedTo(upPayRatio)
            isComparedRaVal.value = isComparedRa
           
             if (isComparedRa === 1 ) {
                 isCanSave.value = true
-                window.$message.warning('累计计量金额超出支付比列,如需计量100%,请完成关联对应的质保资料')
-            // return '--el-table-tr-bg-color: #fe0000; --el-table-row-hover-bg-color: #fe0000; color: white;'
-            
+                if (type === 1) {
+                    window.$message.warning('累计计量金额超出支付比列,如需计量100%,请完成关联对应的质保资料')
+                } else if (type === 2) {
+                    return isComparedRa
+                }
         
         } else {
             isCanSave.value = false
            
         }
+}
+const unPayRatioBlur = (row)=>{
+    nextTick(()=>{
+        console.log(row, 'rowzhifubili')
+        let payRatio = new BigNumber(row.payRatio )//本期支付比例
+        let changeTotal = new BigNumber(row.changeTotal )//变更后数量
+        // 本期计量数量=本期支付比例*变更后数量
+        row.currentMeterTotal = (payRatio.dividedBy(100).multipliedBy(changeTotal)).toString()
+        row.currentMeterMoney = (BigNumber(row.currentMeterTotal).multipliedBy(row.currentPrice)).toString()//本期计量金额额
+        row.allMeterTotal = (BigNumber(row.currentMeterTotal).plus(row.otherMeterTotal)).toString()
+         // 就去对比:本期支付比例+其他期支付比例
+        //   是否大于最大支付比例
+        compareRowUnpayRatio(row, 1)
          
-      
-      
         //计算总计量金额
         let meterMoney = 0, table = addTableData.value
         for (let i = 0; i < table.length; i++) {
@@ -586,17 +561,10 @@ const unPayRatioBlur = (row)=>{
 const isCanSave = ref(false)
 
 const addTableRowStyle = ({ row }) => {
-
+    console.log(row, 'xuan')
     //本期支付比例+其他期支付比例
      //  是否大于最大支付比例
-           let payRatio = new BigNumber(row.payRatio )//本期支付比例
-           let upPayRatio = new BigNumber(row.upPayRatio )//最大支付比例
-           let otherPayRatio = new BigNumber(row.otherPayRatio )//其他期支付比例
-           let result = BigNumber(payRatio).plus(otherPayRatio)//本期支付比例+其他期支付比例
-
-           const isComparedRa = result.comparedTo(upPayRatio)
-           isComparedRaVal.value = isComparedRa
-               // //a 大于 b = 1,a 等于 b = 0,a 小于 b = -1, a 或 b 的值异常时 = null
+      const isComparedRa = compareRowUnpayRatio(row, 2)
         if (isComparedRa === 1 ) {
             isCanSave.value = true