From 1ac61011eb11a7d66f399abe1cf8b6b6fa2f9071 Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期三, 12 三月 2025 15:25:05 +0800
Subject: [PATCH] 1

---
 src/views/system/package/index.vue |  272 +++++++++--------------------------------------------
 1 files changed, 49 insertions(+), 223 deletions(-)

diff --git a/src/views/system/package/index.vue b/src/views/system/package/index.vue
index 839dfd1..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
         >
@@ -698,7 +698,10 @@
                 </template> 
               </el-table-column>-->
             </el-table>
-            <!-- <h3 style="font-weight: 600">鍚堣锛歿{ pics }}鍏�</h3> -->
+            <!-- 娣诲姞椤圭洰鎬绘暟鏄剧ず -->
+            <div style="margin-top: 10px; text-align: right;font-size: 14px">
+              鍏辫 <span style="font-weight: bold;">{{ DataList.length }}</span> 鏉¢」鐩�
+            </div>
           </div>
         </el-col>
       </el-row>
@@ -1065,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();
       });
     },
@@ -1302,68 +1292,6 @@
       });
       this.loading = false;
     },
-    // getDataList() {
-    //   this.loading = true;
-
-    //   getProParentIdDxList(this.queryParams).then((response) => {
-    //     this.Treedata = response.data.list;
-    //     /*  if (this.form.tjProjectList) {
-    //       this.form.tjProjectList.forEach((item) => {
-    //         this.Treedata.forEach((item1) => {
-    //           if (item.proId == item1.proId) {
-    //             this.checkedkey.push(item1.proId);
-
-    //             this.DataList.push(item1);
-
-    //             this.DataList.forEach((item1) => {
-    //               item1.limits = 10;
-    //               if (item1.limits > 10) {
-    //                 item1.limits = 10; // 寮哄埗灏嗗�艰缃负鏈�澶у��
-    //               } else if (item1.limits < 0) {
-    //                 item1.limits = 0; // 寮哄埗灏嗗�艰缃负鏈�灏忓��
-    //               }
-    //               this.updateProPrice(item1); // 鏇存柊浠锋牸鎴栧叾浠栭�昏緫
-    //             });
-
-    //           }
-    //         });
-    //       });
-    //     }  */ /* else {
-    //       this.checkedkey.push(this.Treedata[0].proId);
-    //       let proId = this.Treedata[0].proId;
-    //       this.TreedataList = this.Treedata.filter(
-    //         (item) => item.proId == proId
-    //       ); */
-
-    //     // 灏嗙涓�涓」鐩坊鍔犲埌 DataList
-    //     // this.TreedataList.forEach((item) => {
-    //     //   this.checkedListkey.push(item.proId);
-    //     //   this.DataList.push(item);
-    //     // });
-    //     /*  getProSonDxList(proId).then((res) => {
-    //         this.TreedataList = res.data.list;
-    //         this.TreedataList.forEach((item) => {
-    //           item.disabled = true;
-    //           this.checkedListkey.push(item.proId);
-    //           this.DataList.push(item);
-    //           this.DataList.forEach((item) => {
-    //             item.propinName = this.Treedata[0].proName;
-    //             item.propinPrice = this.Treedata[0].proPrice;
-    //           });
-    //           this.pics = 0;
-    //           this.DataList.forEach((item) => {
-    //             this.pics += item.proPrice;
-    //           });
-    //         });
-    //       }); */
-    //     // }
-    //     this.pics = this.DataList.reduce(
-    //       (total, item) => total + item.priceOrd,
-    //       0
-    //     );
-    //     this.loading = false;
-    //   });
-    // },
     handleFilterInput() {
       this.queryParams1.page = 1; // 鎼滅储鏃堕噸缃负绗竴椤�
       this.getDataList(); // 璋冪敤鎺ュ彛鑾峰彇鏁版嵁
@@ -1382,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() {
@@ -1433,7 +1362,6 @@
           }
         }
       }
-      return this.DataList;
     },
 
     // 鐐瑰嚮鑾峰彇姣忎釜鏍戣妭鐐�
@@ -1531,71 +1459,6 @@
         this.getList();
       });
     },
-    /* submitForm() {
-      if (this.form.pacName) {
-        this.form.tjProjectList = [];
-        if (this.DataList.length != 0) {
-          this.treeList = JSON.parse(JSON.stringify(this.DataList));
-          for (var i = 0; i < this.treeList.length; i++) {
-            for (var j = i + 1; j < this.treeList.length; j++) {
-              if (
-                this.treeList[i].proParentId == this.treeList[j].proParentId
-              ) {
-                this.treeList.splice(j, 1);
-                j--;
-              }
-            }
-          }
-          this.treeList.forEach((item) => {
-            this.form.tjProjectList.push({
-              // id: 0,
-              proName: item.propinName,
-              // allSonProName: item.proName + ",",
-              proPrice: item.propinPrice,
-              priceNow: item.propinPrice,
-              proId: item.proParentId,
-            });
-          });
-        }
-        this.$refs["form"].validate((valid) => {
-          if (valid) {
-            if (this.form.pacId != null) {
-              // if (this.form.pacStatus === "鍚敤") {
-              //   this.form.pacStatus = 0;
-              // } else {
-              //   this.form.pacStatus = 1;
-              // }
-              if (this.keys) {
-                this.form.keywords = this.keys;
-              } else {
-                this.form.keywords = this.form.keywords.toString();
-              }
-
-              updatePackage(this.form).then((response) => {
-                this.$modal.msgSuccess("淇敼鎴愬姛");
-                this.open = false;
-                this.getList();
-              });
-            } else {
-              this.form.keywords = this.keys;
-              // if (this.form.pacStatus === "鍚敤") {
-              //   this.form.pacStatus = 0;
-              // } else {
-              //   this.form.pacStatus = 1;
-              // }
-              // return;
-              addPackage(this.form).then((response) => {
-                this.$modal.msgSuccess("鏂板鎴愬姛");
-                this.open = false;
-                this.getList();
-              });
-            }
-          }
-        });
-      } else {
-        Message.warning("璇峰厛濉啓濂楅鍚嶇О");
-      }
-    }, */
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const pacIds = row.pacId || this.ids;
@@ -1627,43 +1490,6 @@
         `package_${new Date().getTime()}.xlsx`
       );
     },
-    // 濂楅璇︽儏
-    // handleSeach(row) {
-    //   this.Seachopen = true;
-    //   this.loading = true;
-    //   const pacId = row.pacId;
-    //   this.pacId = row.pacId
-    //   let data = {
-    //     pacId: pacId,
-    //   };
-    //   getAllPackage(data).then((response) => {
-    //     this.allpackageList = response.data.tjProjectList;
-    //     this.loading = false;
-    //     let arr = [];
-    //     this.allpackageList.forEach((item) => {
-    //       arr.push(item.proName);
-    //     });
-    //     this.newproName = arr;
-    //   });
-
-    //   getAllPackageList().then((response) => {
-    //     this.allList = response.data;
-    //     this.loading = false;
-    //   });
-    // },
-    // // 鍏ㄩ��
-    // handleCheckAllChange(val) {
-    //   this.newproName = val ? this.allList : [];
-    //   this.isIndeterminate = false;
-    // },
-
-    // handleCheckedCitiesChange(value) {
-    //   let checkedCount = value.length;
-    //   this.checkAll = checkedCount === this.allList.length;
-    //   this.isIndeterminate =
-    //     checkedCount > 0 && checkedCount < this.allList.length;
-    // },
-
     submitcheckbox() {
       let _this = this;
       let proIds = [];

--
Gitblit v1.8.0