From 9bf8ea5b40a41425148ca99f012c76bbdb44daf2 Mon Sep 17 00:00:00 2001 From: wwl <xchao828@163.com> Date: 星期一, 06 一月 2025 13:31:54 +0800 Subject: [PATCH] z --- src/views/system/comp/index.vue | 69 +++++++++++++++++++--------------- 1 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/views/system/comp/index.vue b/src/views/system/comp/index.vue index 8afc583..9c97373 100644 --- a/src/views/system/comp/index.vue +++ b/src/views/system/comp/index.vue @@ -1093,44 +1093,53 @@ } }, resetright() { - this.queryParams.price = 0; - this.queryParams.xianprice = 0; // 鍒濆鍖栫幇浠� - this.youhui = 0; // 鍒濆鍖栦紭鎯� + if (this.dataList.length == 0) { + return; // 濡傛灉鏁版嵁鍒楄〃涓虹┖锛岀洿鎺ヨ繑鍥� + } else { + this.queryParams.price = 0; // 鍒濆鍖栨�讳环 + this.queryParams.xianprice = 0; // 鍒濆鍖栫幇浠� + this.youhui = 0; // 鍒濆鍖栦紭鎯� - const newItemsToAdd = []; + const newItemsToAdd = []; // 鐢ㄤ簬瀛樺偍鏂伴渶瑕佹坊鍔犵殑椤圭洰 - this.dataList.forEach((item) => { - this.$refs.tre.toggleRowSelection(item, false); - // 浣跨敤 $set 纭繚鍝嶅簲鎬� - this.$set(item, 'limits', 10); - this.$set(item, 'ysPrice', item.proPrice); + this.dataList.forEach((item) => { + this.$refs.tre.toggleRowSelection(item, false); // 鍙栨秷閫変腑鐘舵�� + // 浣跨敤 $set 纭繚鍝嶅簲鎬� + this.$set(item, 'limits', 10); // 璁剧疆闄愬埗鏁伴噺 + this.$set(item, 'ysPrice', item.proPrice); // 璁剧疆鐜颁环涓哄師浠� - // 妫�鏌ユ槸鍚﹀凡缁忓瓨鍦ㄧ浉鍚岀殑椤圭洰 - const existingItem = this.OnenewpacName.find(existing => existing.proId === item.proId); - if (!existingItem) { - newItemsToAdd.push(item); - this.updateProPrice(item); // 鏇存柊鍗曚釜椤圭洰鐨勪环鏍� - } - }); + // 妫�鏌ユ槸鍚﹀凡缁忓瓨鍦ㄧ浉鍚岀殑椤圭洰 + const existingItem = this.OnenewpacName.find(existing => existing.proId === item.proId); + if (!existingItem) { + newItemsToAdd.push(item); // 濡傛灉涓嶅瓨鍦ㄧ浉鍚岄」鐩紝鍒欐坊鍔犲埌鏂版暟缁� + this.updateProPrice(item); // 鏇存柊鍗曚釜椤圭洰鐨勪环鏍� + } + }); - // 娣诲姞鏂伴」鐩埌 OnenewpacName - this.OnenewpacName.push(...newItemsToAdd); + // 娣诲姞鏂伴」鐩埌 OnenewpacName + this.OnenewpacName.push(...newItemsToAdd); - // 鍒犻櫎閲嶅椤圭洰锛岃繖閲屾垜浠彧闇�澶勭悊鏂版坊鍔犵殑椤圭洰鍜屽師鏈夐」鐩箣闂寸殑閲嶅 - for (let i = this.OnenewpacName.length - newItemsToAdd.length; i < this.OnenewpacName.length - 1; i++) { - for (let j = i + 1; j < this.OnenewpacName.length; j++) { - if (this.OnenewpacName[i].proId === this.OnenewpacName[j].proId) { - this.OnenewpacName.splice(j, 1); - j--; - } + // 鍒犻櫎閲嶅椤圭洰锛岃繖閲屾垜浠彧闇�澶勭悊鏂版坊鍔犵殑椤圭洰鍜屽師鏈夐」鐩箣闂寸殑閲嶅 + for (let i = this.OnenewpacName.length - newItemsToAdd.length; i < this.OnenewpacName.length - 1; i++) { + for (let j = i + 1; j < this.OnenewpacName.length; j++) { + if (this.OnenewpacName[i].proId === this.OnenewpacName[j].proId) { + this.OnenewpacName.splice(j, 1); // 鍒犻櫎閲嶅鐨勯」鐩� + j--; // 鍥犱负鍒犻櫎浜嗕竴涓厓绱狅紝褰撳墠鐨刯瑕佸噺1 } } + } + this.queryParams.price = 0 + this.queryParams.xianprice = 0 + // 閲嶆柊璁$畻鎬讳环鍜岀幇浠� + this.OnenewpacName.forEach((item) => { + this.queryParams.price += item.proPrice; // 绱姞鍘熶环 + this.queryParams.xianprice += item.ysPrice || 0; // 绱姞鐜颁环锛屽鏋測sPrice涓簎ndefined鍒欑疮鍔�0 + }); - this.OnenewpacName.forEach((item) => { - this.queryParams.price += item.proPrice; - this.queryParams.xianprice += item.ysPrice || 0; // 纭繚ysPrice瀛樺湪 - }) - }, + // 璁$畻浼樻儬锛岃繖閲屽亣璁句紭鎯犳槸鐜颁环涓庡師浠风殑宸鐧惧垎姣� + this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10; + } +}, handledbelete(row) { this.queryParams.price = 0; this.queryParams.xianprice = 0; // 鍒濆鍖栫幇浠� -- Gitblit v1.8.0