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 +++++++++++++++++++++++++-- src/views/system/comp/index.vue | 39 +++++++++++-------- 2 files changed, 73 insertions(+), 21 deletions(-) diff --git a/src/views/system/comp/index.vue b/src/views/system/comp/index.vue index e835cee..ee61488 100644 --- a/src/views/system/comp/index.vue +++ b/src/views/system/comp/index.vue @@ -170,10 +170,6 @@ <el-form-item label="鍘熶环" prop="price"> <el-input v-model="forms.price" placeholder="璇疯緭鍏ュ師浠�" style="width: 130px" /> </el-form-item> - <!-- <el-form-item label="鎶樻墸" prop="limits"> - <el-input v-model="forms.limits" placeholder="璇疯緭鍏ユ姌鎵�" style="width: 130px" @change="numberChange" /> - </el-form-item> --> - <el-form-item label="浼樻儬浠�" prop="ysPrice"> <el-input v-model="forms.ysPrice" placeholder="璇疯緭鍏ュ簲鏀�" style="width: 120px" /> </el-form-item> @@ -358,7 +354,7 @@ <el-table-column label="鎶樻墸" width="151"> <template slot-scope="scope"> <!-- 鍙緭鍏ョ函鏁板瓧鎶樻墸 --> - <el-input-number v-model.number="scope.row.limits" + <el-input-number v-model.number="scope.row.limits" @input="validateDiscount(scope.row)" placeholder="杈撳叆鎶樻墸" size="small" type="number" :min="0" :step="0.1" :precision="1" :max="20"> </el-input-number> </template> @@ -804,6 +800,26 @@ this.getList(); }, methods: { + validateDiscount(row) { + if (row.limits > 10) { + row.limits = 10; // 寮哄埗灏嗗�艰缃负鏈�澶у�� + } else if (row.limits < 0) { + row.limits = 0; // 寮哄埗灏嗗�艰缃负鏈�灏忓�� + } + this.updateProPrice(row); // 鏇存柊浠锋牸鎴栧叾浠栭�昏緫 + }, + updateProPrice(row) { + console.log('1234') + const proPrice = new Big(row.proPrice); + + const limits = new Big(row.limits); + const result = proPrice.times(limits.div(10)); // ordPrice * (discount / 10) + row.ysPrice = result.toNumber(); + this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => { + return sum.plus(new Big(item.ysPrice || '0')); + }, new Big(0)).toNumber(); + this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10 + }, debounceNumberChange(currentValue, oldValue) { clearTimeout(this.debounceTimer); this.debounceTimer = setTimeout(() => { @@ -819,17 +835,7 @@ } }, - updateProPrice(row) { - const proPrice = new Big(row.proPrice); - - const limits = new Big(row.limits); - const result = proPrice.times(limits.div(10)); // ordPrice * (discount / 10) - row.ysPrice = result.toNumber(); - // this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => { - // return sum.plus(new Big(item.ysPrice || '0')); - // }, new Big(0)).toNumber(); - this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10 - }, + getList() { this.$nextTick(() => { this.$refs.inputName.focus(); @@ -1008,7 +1014,6 @@ const limits = new Big(item.limits); const result = proPrice.times(limits.div(10)); // ordPrice * (discount / 10) item.ysPrice = result.toNumber(); - console.log("numberChange") this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => { return sum.plus(new Big(item.ysPrice || '0')); }, new Big(0)); 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