lichao 3 лет назад
Родитель
Сommit
24fbcb331c

+ 97 - 2
src/views/financialManagement/paymentSettle/paymentSettleDetailsPage.vue

@@ -120,6 +120,16 @@
             ></el-input>
             <span v-else>{{ row.thisAmount }}</span>
           </template>
+          <template slot="caseOverPayment">
+            <el-input
+              placeholder="请输入"
+              clearable
+              v-model="form.caseOverPayment"
+              @change="caseOverPaymentChange"
+              v-input-limit="2"
+              :disabled="dataList.length == 0"
+            ></el-input>
+          </template>
         </avue-crud>
       </basic-container>
       <el-dialog
@@ -153,6 +163,8 @@
   import  billDetail from "@/components/bill/billDetailList";
   import { getlistBankBy } from "@/api/financialManagement/paymentRequest";
   import _ from "lodash";
+  import {getUserInfo} from "@/api/system/user";
+  import {getCorpDetail} from "@/api/maintenance/overpayment";
 
   export default {
     name: "paymentDetailsPage",
@@ -279,6 +291,33 @@
               ]
             },
             {
+              label: '使用溢付款',
+              prop: 'caseOverPayment',
+              display: false,
+              span: 8,
+              rules: [
+                {
+                  pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
+                  message: ' ',
+                  trigger: 'blur'
+                }
+              ]
+            },
+            {
+              label: '溢付款余额',
+              prop: 'overPayment',
+              display: false,
+              disabled: true,
+              span: 8,
+              rules: [
+                {
+                  pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
+                  message: ' ',
+                  trigger: 'blur'
+                }
+              ]
+            },
+            {
               label: '付款日期',
               prop: 'settlementDate',
               format:"yyyy-MM-dd",
@@ -345,12 +384,31 @@
         //顶部from数据
         oldForm:{},
         oldDataList:[],
+        category: '',
+        allAmount: 0,
       }
     },
     components:{
       billDetail
     },
     created() {
+      // 人民币金额默认为0
+      this.$set(this.form,"amount", 0)
+      getUserInfo().then(res=>{
+        this.category = res.data.data.billType
+        if (this.category == 2) {
+          this.$set(this.form,"overPayment", 0)
+          this.$set(this.form,"caseOverPayment", 0)
+          this.option.column.forEach(item => {
+            if (item.prop == 'caseOverPayment' || item.prop == 'overPayment') {
+              item.display = true
+            }
+            if (item.prop == 'foreignAmount') {
+              item.display = false
+            }
+          })
+        }
+      })
       //币别
       this.getWorkDicts("currency").then(res =>{
         this.currencyDic = res.data.data
@@ -396,6 +454,12 @@
         getlistBankBy(corpValue.id).then(res =>{
           this.$set(this.form,"bankList",res.data)
         })
+        // 溢付款余额获取
+        if (this.category == 2) {
+          getCorpDetail({corpId:corpValue.id}).then(res => {
+            this.form.overPayment = res.data.data? res.data.data.balanceOverpaymen: 0
+          })
+        }
       },
       //选择卡号
       accountNoChange(value){
@@ -465,6 +529,23 @@
               this.buttonLoading = true
               this.form.billNo = this.dataList.map(item =>{return item.billNo}).join(",")
 
+              if (this.category == 2 && this.financeDisabled) {
+                this.allAmount = 0;
+                this.form.amount = this.form.amount? this.form.amount: 0
+                this.dataList.forEach(e => {
+                  this.allAmount = Number(this.allAmount) + Number(e.thisAmount)
+                })
+                if (this.allAmount == 0 && this.form.amount == 0) {
+                  return this.$message.error('人民币金额不能为空')
+                } else if (Number(this.allAmount) > 0 && (Number(this.form.amount) > Number(this.allAmount))) {
+                  this.form.caseOverPayment = 0;
+                } else if (Number(this.allAmount) > 0 && (Number(this.form.amount) < Number(this.allAmount))) {
+                  this.form.caseOverPayment = Number(this.allAmount) - Number(this.form.amount)
+                  if (Number(this.form.caseOverPayment) > Number(this.form.overPayment)) {
+                    return this.$message.error('溢付款余额不足,无法付费')
+                  }
+                }
+              }
               const params = {
                 ...this.form,
                 billType:"付费",
@@ -520,9 +601,16 @@
             })
           }})
       },
-      afterEcho(data){
+      async afterEcho(data){
         this.form = data;
-        this.oldForm = Object.assign({},data);
+        if (this.category == 2) {
+          await getCorpDetail({corpId: this.form.corpId}).then(res => {
+            if (Number(this.form.overPayment) != (res.data.data? res.data.data.balanceOverpaymen: '0.00')) {
+              this.form.overPayment = res.data.data? res.data.data.balanceOverpaymen: '0.00'
+            }
+          })
+        }
+        this.oldForm = Object.assign({},this.form);
         this.financeDisabled =  this.form.financeStatus == "待结算"?true:false;
         //审核状态为空时  说明为新单进来
         if(this.financeDisabled){
@@ -587,6 +675,13 @@
           this.$emit("goBack");
         }
       },
+      // 溢付款更改时
+      caseOverPaymentChange() {
+        if (Number(this.form.caseOverPayment) > Number(this.form.overPayment)) {
+          this.form.caseOverPayment = 0;
+          return this.$message.error('本次使用的溢付款不能超过总溢付款')
+        }
+      },
     }
   }
 </script>