From 2865369d52bed1a3ac334a4c82a70babab93a96f Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期一, 03 三月 2025 14:08:28 +0800
Subject: [PATCH] 1

---
 src/views/system/package/index.vue |  103 ++++++++++++++++++++++-----------------------------
 1 files changed, 45 insertions(+), 58 deletions(-)

diff --git a/src/views/system/package/index.vue b/src/views/system/package/index.vue
index 2af9a0f..8a46b9a 100644
--- a/src/views/system/package/index.vue
+++ b/src/views/system/package/index.vue
@@ -71,7 +71,7 @@
           icon="el-icon-edit"
           size="mini"
           :disabled="single"
-          @click="handleUp"
+          @click="handleUpdate"
           v-hasPermi="['system:package:edit']"
           >淇敼</el-button
         >
@@ -1068,56 +1068,43 @@
         });
     },
 
-    handleUp() {
-      this.title = "浣撴濂楅淇℃伅缁存姢";
-      this.open = true;
-      // getPacTjProjectList().then((response) => {
-      //   this.allList = response.data;
-      //   this.loading = false;
-      // });
-      getPacInFo(this.forms.pacId).then((response) => {
-        this.form = response.data;
-        console.log(this.form, 2233);
-
-        this.form.keywords = this.form.keywords.slice(0, -1);
-        this.form.keywords = this.form.keywords.split(",");
-        // this.DataList = [];
-
-        // this.pics = 0;
-        this.DataList = [];
-        this.checkedkey = [];
-        this.checkedListkey = [];
-        this.DataList = response.data.packageProjects;
-        this.DataList.forEach((item) => {
-          this.checkedkey.push(item.proId);
-          this.checkedListkey.push(item.proId);
-        });
-
-        // 鑾峰彇鏂扮殑鏁版嵁鍒楄〃锛堝鏋滈渶瑕侊級
-        this.getDataList();
-      });
-    },
-
     /** 淇敼鎸夐挳鎿嶄綔 */
     handleUpdate(row) {
       this.title = "浣撴濂楅淇℃伅缁存姢";
       this.open = true;
+      // 閲嶇疆鏁版嵁
+      this.DataList = [];
+      this.checkedkey = [];
+      this.checkedListkey = [];
+      this.checkedNodes = []; // 娣诲姞杩欒锛岄噸缃�変腑鑺傜偣
+
       getPacInFo(row.pacId).then((response) => {
         this.form = response.data;
-        console.log(this.form, 445);
+        
+        // 澶勭悊鍏抽敭瀛�
+        if (this.form.keywords) {
+          this.form.keywords = this.form.keywords.slice(0, -1);
+          this.form.keywords = this.form.keywords.split(",");
+        }
 
-        this.form.keywords = this.form.keywords.slice(0, -1);
-        this.form.keywords = this.form.keywords.split(",");
-        this.DataList = [];
-        this.checkedkey = [];
-        this.checkedListkey = [];
-        this.DataList = response.data.packageProjects;
-        this.DataList.forEach((item) => {
-          this.checkedkey.push(item.proId);
-          this.checkedListkey.push(item.proId);
-        });
+        // 澶勭悊椤圭洰鏁版嵁
+        if (response.data.packageProjects && response.data.packageProjects.length > 0) {
+          this.DataList = response.data.packageProjects;
+          
+          // 鏇存柊閫変腑鐘舵��
+          this.DataList.forEach((item) => {
+            this.checkedkey.push(item.proId);
+            this.checkedListkey.push(item.proId);
+            this.checkedNodes.push(item.proId); // 娣诲姞鍒伴�変腑鑺傜偣鏁扮粍
+          });
 
-        // 鑾峰彇鏂扮殑鏁版嵁鍒楄〃锛堝鏋滈渶瑕侊級
+          // 璁$畻鎬讳环鍜屾姌鎵�
+          this.pics = this.DataList.reduce((total, item) => total + item.priceOrd, 0);
+          this.form.xianprice = this.DataList.reduce((total, item) => total + item.priceNow, 0);
+          this.youhui = this.DataList[0]?.limits || 10;
+        }
+
+        // 鑾峰彇鏂扮殑鏁版嵁鍒楄〃
         this.getDataList();
       });
     },
@@ -1323,33 +1310,34 @@
 
     handleCurrentChecked(data, checked, indeterminate) {
       if (checked) {
-        // 濡傛灉宸查�夊垪琛ㄤ腑涓嶅瓨鍦ㄦ椤圭洰锛屽垯娣诲姞
-        if (!this.DataList.some((item) => item.proId === data.proId)) {
+        // 妫�鏌ユ槸鍚﹀凡瀛樺湪
+        if (!this.DataList.some(item => item.proId === data.proId)) {
+          // 娣诲姞鏂伴」鐩椂浣跨敤涓庡凡鏈夐」鐩浉鍚岀殑鎶樻墸鐜�
+          const currentDiscount = this.DataList.length > 0 ? this.DataList[0].limits : 10;
+          const priceNow = new Big(data.proPrice).times(new Big(currentDiscount).div(10)).toNumber();
+          
           this.DataList.push({
             proId: data.proId,
             proName: data.proName,
             priceOrd: data.proPrice,
-            limits: 10,
-            priceNow: data.proPrice,
+            limits: currentDiscount,
+            priceNow: priceNow
           });
-        }
-        // 娣诲姞鍒� checkedNodes 鏁扮粍
-        if (!this.checkedNodes.includes(data.proId)) {
-          this.checkedNodes.push(data.proId);
+          
+          if (!this.checkedNodes.includes(data.proId)) {
+            this.checkedNodes.push(data.proId);
+          }
         }
       } else {
-        // 鍙栨秷閫変腑鏃讹紝浠嶥ataList涓Щ闄�
-        this.DataList = this.DataList.filter(
-          (item) => item.proId !== data.proId
-        );
-        // 浠� checkedNodes 涓Щ闄�
+        // 绉婚櫎椤圭洰
+        this.DataList = this.DataList.filter(item => item.proId !== data.proId);
         const index = this.checkedNodes.indexOf(data.proId);
         if (index > -1) {
           this.checkedNodes.splice(index, 1);
         }
       }
 
-      // 鏇存柊浼樻儬浠峰拰鎬讳环
+      // 鏇存柊鎬讳环鍜屾姌鎵�
       this.updateTotalPrice();
     },
     updateTotalPrice() {
@@ -1374,7 +1362,6 @@
           }
         }
       }
-      return this.DataList;
     },
 
     // 鐐瑰嚮鑾峰彇姣忎釜鏍戣妭鐐�

--
Gitblit v1.8.0