From 16ab2673285119a38a78f635c0b74384b423c55e Mon Sep 17 00:00:00 2001 From: lkk <364857242@qq.com> Date: 星期二, 29 四月 2025 17:12:50 +0800 Subject: [PATCH] 1 --- src/views/system/package/index.vue | 87 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 85 insertions(+), 2 deletions(-) diff --git a/src/views/system/package/index.vue b/src/views/system/package/index.vue index 020d483..7a4c5e5 100644 --- a/src/views/system/package/index.vue +++ b/src/views/system/package/index.vue @@ -118,8 +118,12 @@ <el-form-item label="鎶樻墸"> <el-input-number style="width: 150px" v-model="youhui" :precision="2" :step="0.1" :max="10" :min="0.1" @change="debounceNumberChange" :debounce="3000"></el-input-number> </el-form-item> - <el-form-item label="鐜颁环" prop="xianprice"> + <!-- <el-form-item label="鐜颁环" prop="xianprice"> <el-input v-model="form.xianprice" placeholder="鐜颁环" clearable style="width: 140px" @input="changeXianjia" @blur="numberChangeXianPrice(youhui, youhui)" type="number" :debounce="3000" min="0"/> + </el-form-item> --> + <el-form-item label="鐜颁环" prop="xianprice"> + <el-input v-model="form.xianprice" placeholder="鐜颁环" clearable style="width: 140px" @input="changeXianjia" + type="number" :debounce="3000" min="0"/> </el-form-item> <el-form-item label="鍏抽敭瀛�" prop="keywords"> <el-select multiple v-model="form.keywords" placeholder="璇烽�夋嫨鍏抽敭瀛�" style="width: 160px" @change="sel" filterable clearable> @@ -777,7 +781,7 @@ this.DataList = this.DataList.filter((item) => item.proParentId !== row.proParentId); this.TotalPrice1 = this.DataList.reduce((sum, item) => sum + item.priceOrd, 0); }, - submitForm() { + /* submitForm() { this.form.limits = this.youhui; this.form.price = this.pics; this.form.priceNow = this.form.xianprice; @@ -813,6 +817,85 @@ this.open = false; this.getList(); }); + }, */ + submitForm() { + // 妫�鏌ョ幇浠锋槸鍚﹀彂鐢熷彉鍖� + if (this.form.xianprice !== this.lastXianPrice) { + this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", { + confirmButtonText: "纭畾", + cancelButtonText: "鍙栨秷", + type: "warning", + }).then(() => { + // 鏇存柊鎵�鏈夊瓙椤圭殑鎶樻墸 + this.youhui = (Math.floor((this.form.xianprice / this.pics) * 100) / 100) * 10; + let totalYsprice = new Big(0); + this.DataList.forEach((item) => { + item.limits = this.youhui; + const ordPrice = new Big(item.priceOrd); + const discount = new Big(item.limits); + const result = ordPrice.times(discount.div(10)); + item.priceNow = result.toNumber(); + totalYsprice = totalYsprice.plus(new Big(item.priceNow)); + }); + + if (!totalYsprice.eq(this.form.xianprice)) { + const diff = new Big(this.form.xianprice).minus(totalYsprice); + if (this.DataList.length > 0) { + const lastItem = this.DataList[this.DataList.length - 1]; + const newYsPrice = new Big(lastItem.priceNow).plus(diff).toNumber(); + this.$set(this.DataList[this.DataList.length - 1], "priceNow", newYsPrice); + } + } + + // 淇濆瓨鏁版嵁 + return this.saveData(); + }).catch(() => { + // 鐢ㄦ埛鍙栨秷鎿嶄綔锛屾仮澶嶅師鏉ョ殑鐜颁环 + this.form.xianprice = this.lastXianPrice; + }); + } else { + // 鐜颁环娌℃湁鍙樺寲锛岀洿鎺ヤ繚瀛� + this.saveData(); + } + }, + // 鏂板涓�涓柟娉曞鐞嗕繚瀛橀�昏緫 + saveData() { + this.form.limits = this.youhui; + this.form.price = this.pics; + this.form.priceNow = this.form.xianprice; + if (this.keys) { + this.form.keywords = this.keys; + } + let packageProjects = []; + this.DataList.forEach((item) => { + packageProjects.push({ + proName: item.proName, + proId: item.proId, + priceNow: item.priceNow, + limits: item.limits, + priceOrd: item.priceOrd, + }); + }); + let data = { + pacName: this.form.pacName, + limits: this.form.limits, + pacStatus: this.form.pacStatus, + packageProjects: packageProjects, + newPrice: this.form.xianprice, + price: this.pics, + pacId: this.form.pacId || null, + isOnSale: this.form.isOnSale, + sort: this.form.sort, + retailPrice: this.form.retailPrice, + tjCategory: this.form.tjCategory, + pacRemark: this.form.pacRemark, + detail: this.form.detail, + }; + + return saveOreditTjPacNew(data).then((res) => { + this.open = false; + this.getList(); + }); }, handleDelete(row) { const pacIds = row.pacId || this.ids; -- Gitblit v1.8.0