Kaynağa Gözat

配件销售单里的付款

caojunjie 2 yıl önce
ebeveyn
işleme
6fe0d5bf2f
1 değiştirilmiş dosya ile 65 ekleme ve 21 silme
  1. 65 21
      src/views/salesOrder/detailsPage.vue

+ 65 - 21
src/views/salesOrder/detailsPage.vue

@@ -57,9 +57,9 @@
       <trade-card title="商品信息" v-loading="loadingBtn">
         <avue-form ref="option2form" class="trading-form" v-model="form" :option="option2">
           <template slot="thisUsedProfit">
-            <el-input-number v-model="form.thisUsedProfit" :disabled="detailData.status == 1 || mebertype"
+            <el-input-number v-model="jsthisUsedProfit" disabled
               placeholder="请输入" size="small" :controls="false" style="width:100%;"
-                             @change="thisUsedchange" ></el-input-number>
+                              ></el-input-number>
               <!--@change="amountChange"-->
           </template>
             <template slot="memberBalance">
@@ -159,13 +159,22 @@
           :close-on-press-escape="false"
           v-dialog-drag
           width="35%"
+          v-loading="loadingBtn"
           :before-close="paymentClose">
           <div>
-              <div style="font-size: 16px">订单金额为{{zhifdingdan}}</div>
+              <div style="font-size: 16px">应收金额为{{zhifdingdan}}</div>
+
+              <div style="display: flex;align-items: center;margin-top: 20px">
+                  <div style="margin-right: 10px;width: 90px;text-align: right">优惠金额:</div>
+                  <el-input style="width: 200px;" type="number" v-model="form.thisUsedProfit" :disabled="jsthisUsedProfit != 0"
+                                   placeholder="请输入" size="small" :controls="false"
+                                   @change="thisUsedchange" >
+                  </el-input>
+              </div>
               <div style="display: flex;align-items: center;margin-top: 20px">
                   <div style="margin-right: 10px;width: 90px;text-align: right">会员卡金额:</div>
                   <div style="display: flex">
-                      <el-input style="width: 200px;" v-model="form.memberAmout" size="small" placeholder="请输入会员卡金额"
+                      <el-input style="width: 200px;" type="number" v-model="form.memberAmout" size="small" placeholder="请输入会员卡金额"
                                 @change="memberchange"></el-input>
                       <span style="margin-left: 10px;border: 1px solid #E4E7ED;padding: 6px;border-radius: 4px">
                           余额:{{balanceAmounts}}
@@ -175,7 +184,8 @@
               <div style="display: flex;align-items: center;margin-top: 20px">
                   <div style="margin-right: 10px;width: 90px;text-align: right">收款金额:</div>
                   <div>
-                      <el-input style="width: 200px;" v-model="form.currentAmount" size="small" placeholder="请输入支付金额"
+                      <el-input style="width: 200px;" type="number" v-model="form.currentAmount" size="small" placeholder="请输入支付金额"
+                                @change="currentchange"
                        ></el-input>
                   </div>
               </div>
@@ -194,7 +204,7 @@
               </div>
           </div>
           <span slot="footer" style="text-align: left" class="dialog-footer">
-              <el-button @click="paymentVisible = false">取 消</el-button>
+              <el-button @click="paymentClose">取 消</el-button>
               <el-button type="primary" @click="querenfun">确 定</el-button>
           </span>
       </el-dialog>
@@ -226,7 +236,8 @@ export default {
   name: "index",
   data() {
     return {
-        mebertype:false,
+        jsthisUsedProfit:0,
+        jsdebitAmount:0,
         // 收款账户
         accountdata:[],
         // 付款的弹窗开启和关闭
@@ -561,7 +572,6 @@ export default {
       optionList
     );
     if (this.detailData.id) {
-        this.mebertype = true
       this.getDetail(this.detailData.id);
     }
     if (this.detailData.status == 1) {
@@ -595,9 +605,9 @@ export default {
                   this.form.thisUsedProfit = 0
               })
           }
-          if (Number(this.form.thisUsedProfit) > Number(this.form.orderAmount)) {
+          if (Number(this.form.thisUsedProfit) >= Number(this.form.orderAmount)) {
               this.$nextTick(()=>{
-                  this.form.thisUsedProfit = Number(this.form.orderAmount)
+                  this.form.thisUsedProfit = Number(this.form.orderAmount) - 1
                   // this.form.memberBalance = 0
                   this.form.currentAmount = 0
               })
@@ -613,9 +623,13 @@ export default {
           }
 
           this.$nextTick(()=>{
-              console.log(sum - this.form.thisUsedProfit)
-              this.form.currentAmount = sum - this.form.thisUsedProfit
-              this.form.debitAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
+              // console.log(sum - this.form.thisUsedProfit)
+              this.form.settlmentAmount = this.form.settlmentAmount?this.form.settlmentAmount:0
+              this.$set(this.form,'currentAmount',sum - this.form.thisUsedProfit - this.form.settlmentAmount)
+              // this.form.currentAmount = sum - this.form.thisUsedProfit
+              this.form.debitAmount = subtract(this.form.orderAmount, this.form.thisUsedProfit)
+              this.zhifdingdan = Number(this.form.debitAmount) - Number(this.form.settlmentAmount)
+              console.log(this.zhifdingdan,628)
           })
       },
       // 会员卡金额的监听
@@ -638,7 +652,8 @@ export default {
                   this.form.memberAmout = Number(this.balanceAmounts)
               })
           }
-          let sum = Number(this.form.orderAmount) - Number(this.form.thisUsedProfit)
+          this.form.settlmentAmount = this.form.settlmentAmount?this.form.settlmentAmount:0
+          let sum = Number(this.form.orderAmount) - Number(this.form.thisUsedProfit) - Number(this.form.settlmentAmount)
           if (this.form.memberAmout > sum) {
               this.$nextTick(()=>{
                   this.form.memberAmout = sum
@@ -646,9 +661,21 @@ export default {
           }
           this.$nextTick(()=>{
               console.log(sum - this.form.memberAmout)
-              this.form.currentAmount = (sum - this.form.memberAmout).toFixed(2)
+              this.$set(this.form,'currentAmount',(sum - this.form.memberAmout).toFixed(2))
+              // this.form.currentAmount = (sum - this.form.memberAmout).toFixed(2)
           })
       },
+      // 本次金额监听
+      currentchange(){
+          if (this.form.currentAmount < 0) {
+              this.form.currentAmount = 0
+          }
+          this.form.memberAmout = this.form.memberAmout?this.form.memberAmout:0
+          if ((this.form.currentAmount + this.form.memberAmout) > this.zhifdingdan) {
+              this.form.currentAmount = this.zhifdingdan
+              this.form.memberAmout = 0
+          }
+      },
       // 收款点击事件
       clickPayment(){
           // // 和删除一样的接口 显示要收款的现金
@@ -675,15 +702,22 @@ export default {
           });
           this.zhifdingdan = Number(this.form.debitAmount) - Number(this.form.settlmentAmount)
           this.form.memberAmout = this.form.memberAmout?this.form.memberAmout:0
+          this.form.currentAmount = this.form.currentAmount?this.form.currentAmount:0
           this.paymentVisible = true
       },
       // 收款弹窗的确认
       querenfun(){
-          if(this.form.currentAmount < 0){
-              return this.$message.error('支付金额不能负数');
-          }
-          if (this.form.memberAmout < 0) {
-              return this.$message.error('会员卡金额不能为负数');
+          // if(this.form.currentAmount < 0){
+          //     return this.$message.error('支付金额不能负数');
+          // }
+          // if (this.form.memberAmout < 0) {
+          //     return this.$message.error('会员卡金额不能为负数');
+          // }
+          // 判断本次收款和会员卡收款不能为空
+          if (!this.form.currentAmount || this.form.currentAmount == 0) {
+              if (!this.form.memberAmout || this.form.memberAmout == 0) {
+                  this.$message.error('本次收款金额或会员卡金额不能为空或零');
+              }
           }
           let balance = Number(this.form.debitAmount) - Number(this.form.settlmentAmount)
           if(this.form.currentAmount > balance){
@@ -693,14 +727,20 @@ export default {
               ...this.form,
               orderFilesList: this.orderFilesList
           }
+          this.loadingBtn = true
           collectPayment(form).then(res=>{
               this.$message.success('收款成功');
               this.paymentVisible = false
+              this.loadingBtn = false
               this.getDetail(this.detailData.id);
           })
       },
       // // 付款弹窗的关闭
       paymentClose(){
+          this.$set(this.form,'memberAmout',0)
+          this.$set(this.form,'currentAmount',0)
+          this.$set(this.form,'thisUsedProfit',this.jsthisUsedProfit)
+          this.$set(this.form,'debitAmount',this.jsdebitAmount)
           this.paymentVisible = false
       },
     //打开审核
@@ -798,8 +838,12 @@ export default {
       getDetails({ id: id })
         .then(res => {
           this.form = res.data.data;
-          // // 深拷贝会员卡金额
+          // // 深拷贝优惠金额
           // this.jsonmemberBalance = JSON.parse(JSON.stringify(this.form.memberBalance))
+            this.jsthisUsedProfit = JSON.parse(JSON.stringify(this.form.thisUsedProfit))
+            // 深拷贝应收金额
+            this.jsdebitAmount = JSON.parse(JSON.stringify(this.form.debitAmount))
+
           this.data = res.data.data.orderItemsList;
           this.settlementList = res.data.data.settlementList;
           this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];