src/views/system/comp/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/system/tijian/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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)); 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;