From 20597e952095f7183e9a0e344bb1505420616dc9 Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期六, 11 一月 2025 18:09:01 +0800
Subject: [PATCH] 222

---
 src/views/system/tijian/index.vue |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/src/views/system/tijian/index.vue b/src/views/system/tijian/index.vue
index 7ab21ed..dd2b83c 100644
--- a/src/views/system/tijian/index.vue
+++ b/src/views/system/tijian/index.vue
@@ -495,10 +495,11 @@
               <el-form-item label="浼樻儬">
                 <!-- {{ discount }} -->
                 <el-input-number ref="inputNumber" style="width: 150px" v-model="discount" :precision="1" :step="0.1"
-                  :max="10" :min="0" @change="numberChange" :disabled="isfalse"></el-input-number>
+                  :max="10" :min="0" @change="debounceNumberChange" :disabled="isfalse"></el-input-number>
               </el-form-item>
               <el-form-item label="瀹炴敹閲戦">
-                <el-input placeholder="瀹炴敹閲戦" v-model="TotalPrice" style="width: 206px"></el-input>
+                <el-input placeholder="瀹炴敹閲戦" v-model="TotalPrice" style="width: 206px"
+                  @input="changeXianjia" @blur="numberChangeXianPrice(discount, discount)"/>
               </el-form-item>
               <br />
 
@@ -654,7 +655,7 @@
               </el-form-item>
               <el-form-item label="浼樻儬">
                 <el-input-number style="width: 140px" v-model="discount" :precision="1" :step="0.1" :max="10" :min="0"
-                  @change="numberChange" :disabled="isfalse"></el-input-number>
+                  @change="debounceNumberChange" :disabled="isfalse"></el-input-number>
               </el-form-item>
               <el-form-item label="瀹炴敹閲戦">
                 <el-input v-model="formInline.paidIn" placeholder="瀹炰粯" style="width: 94px">
@@ -1072,7 +1073,20 @@
   mounted() { },
 
   methods: {
+    debounceNumberChange(currentValue, oldValue) {
+      clearTimeout(this.debounceTimer);
+      this.debounceTimer = setTimeout(() => {
+        this.numberChange(currentValue, oldValue);
+      }, 300);
+    },
+    changeXianjia() {
+      // 鍘熷鎶樻墸鐜囪绠�
+      if (this.TotalPrice1 !== 0) {
+        this.discount =
+(Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
+      }
 
+    },
     clear() {
       this.form.firmId = "";
     },
@@ -1592,7 +1606,40 @@
           this.discount = oldValue;
         });
     },
-
+    numberChangeXianPrice(currentValue, oldValue) {
+      this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          this.discount = currentValue;
+          if (this.discount < this.getInfodis) {
+            this.discount = this.getInfodis;
+          }
+          let totalYsprice = new Big(0)
+          this.tableData1.forEach((item) => {
+            item.discount = this.discount;
+            const ordPrice = new Big(item.ordPrice);
+            const discount = new Big(item.discount);
+            const result = ordPrice.times(discount.div(10))
+            item.nowPrice = result.toNumber();
+            totalYsprice = totalYsprice.plus(new Big(item.nowPrice));
+          })
+          if (!totalYsprice.eq(this.TotalPrice)) {
+            const diff = new Big(this.TotalPrice).minus(totalYsprice);
+            if (this.tableData1.length > 0) {
+              const lastItem = this.tableData1[this.tableData1.length - 1]
+              const newYsPrice = new Big(lastItem.nowPrice).plus(diff).toNumber()
+              console.log("hhh", this.tableData1[this.tableData1.length - 1].nowPrice,newYsPrice)
+              this.$set(this.tableData1[this.tableData1.length - 1], 'nowPrice', newYsPrice)
+            }
+          }
+        })
+        .catch(() => {
+          this.discount = oldValue;
+        });
+    },
     /** 鐧昏鎻愪氦鎸夐挳 */
     submitForm() {
       let _this = this;

--
Gitblit v1.8.0