From 09d95b97911084ff55d01c4122e7548c1923c012 Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期三, 08 一月 2025 15:16:20 +0800
Subject: [PATCH] 体检费用

---
 src/views/system/package/index.vue |  253 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 235 insertions(+), 18 deletions(-)

diff --git a/src/views/system/package/index.vue b/src/views/system/package/index.vue
index 4c7277b..771a55a 100644
--- a/src/views/system/package/index.vue
+++ b/src/views/system/package/index.vue
@@ -425,11 +425,32 @@
             style="width: 150px"
           />
         </el-form-item>
-        <el-form-item label="鍘熶环" prop="counterPrice">
+        <el-form-item label="鍘熶环" prop="pics">
           <el-input
-            v-model="form.counterPrice"
+            v-model="pics"
             placeholder="璇疯緭鍏ュ師浠�"
             style="width: 150px"
+          />
+        </el-form-item>
+        <el-form-item label="鎶樻墸">
+          <el-input-number
+            ref="inputNumber"
+            style="width: 150px"
+            v-model="youhui"
+            :precision="2"
+            :step="0.1"
+            :max="10"
+            :min="1"
+            @change="numberChange"
+          ></el-input-number>
+        </el-form-item>
+        <el-form-item label="浼樻儬浠�">
+          <el-input
+            ref="inputName"
+            v-model="form.xianprice"
+            placeholder="浼樻儬浠�"
+            clearable
+            style="width: 140px"
           />
         </el-form-item>
         <el-form-item label="浣撴绫诲埆" prop="tjCategory">
@@ -541,7 +562,7 @@
             </el-tree>
           </div>
         </el-col>
-       <!--  <el-col :span="6">
+        <!--  <el-col :span="6">
           <div
             style="text-align: center; margin-bottom: 10px; margin-top: 10px"
           >
@@ -567,20 +588,44 @@
         <el-col :span="11">
           <div class="grid-content bg-purple">
             <div
-              style="text-align: center; margin-bottom: 10px; margin-top: 10px; margin-left: 16%;"
+              style="
+                text-align: center;
+                margin-bottom: 10px;
+                margin-top: 10px;
+                margin-left: 16%;
+              "
             >
               宸查�夐」鐩垪琛�
             </div>
             <el-table
               :data="DataList"
               border
-              style="width: 80%; margin-left: 18%;"
+              style="width: 80%; margin-left: 18%"
               height="400"
               :span-method="objectSpanMethod"
             >
-              <el-table-column prop="propinName" label="妫�鏌ラ」鐩�" >
+              <el-table-column prop="proName" label="妫�鏌ラ」鐩�">
               </el-table-column>
-              <el-table-column prop="proPrice" label="鍘熶环" align="center" >
+
+              <el-table-column prop="proPrice" label="鍘熶环" align="center">
+              </el-table-column>
+              <el-table-column label="鎶樻墸">
+                <template slot-scope="scope">
+                  <!-- 鍙緭鍏ョ函鏁板瓧鎶樻墸 -->
+                  <el-input
+                    v-model.number="scope.row.limits"
+                    @input="calculateDiscount(scope.row)"
+                    placeholder="杈撳叆鎶樻墸"
+                    size="small"
+                    type="number"
+                    min="0"
+                    step="0.1"
+                    max="10"
+                  >
+                  </el-input>
+                </template>
+              </el-table-column>
+              <el-table-column prop="priceNow" label="浼樻儬浠�" align="center">
               </el-table-column>
               <!-- <el-table-column prop="proName" label="鏄庣粏椤圭洰" width="260px">
               </el-table-column> -->
@@ -603,7 +648,7 @@
                 </template> 
               </el-table-column>-->
             </el-table>
-            <h3 style="font-weight: 600">鍚堣锛歿{ pics }}鍏�</h3>
+            <!-- <h3 style="font-weight: 600">鍚堣锛歿{ pics }}鍏�</h3> -->
           </div>
         </el-col>
       </el-row>
@@ -652,8 +697,10 @@
   getAllList,
   updateProject,
   getPacTjProjectList,
+  saveOreditTjPacNew,
 } from "@/api/system/package";
 import { Message } from "element-ui";
+import Big from "big.js";
 export default {
   name: "Package",
   dicts: ["sys_normal_disable", "sys_yes_no", "dict_tjtype"],
@@ -675,6 +722,7 @@
       DataList: [],
       list1: true,
       activeName: "1",
+      num: 1,
       checkedObj: {},
       dataObj: {},
       Treedata: [],
@@ -733,8 +781,13 @@
         pacRemark: null,
       },
       // 琛ㄥ崟鍙傛暟
-      form: {},
+      form: {
+        xianprice: null, // 浼樻儬浠�
+        counterPrice: null, //鍘熶环
+        limits: 10,
+      },
       forms: {},
+      youhui: 10,
       // 琛ㄥ崟鏍¢獙
       rules: {
         deleted: [
@@ -770,6 +823,7 @@
       this.$refs.tree.filter(val);
     },
   },
+
   created() {
     this.getList();
     this.getKeyword();
@@ -782,9 +836,9 @@
     filterNode(value, data) {
       if (!value) return true;
       // return data.proName.indexOf(value) !== -1;
-      if(data.proName.indexOf(value) !== -1){
+      if (data.proName.indexOf(value) !== -1) {
         return data.proName.indexOf(value) !== -1;
-      }else{
+      } else {
         return data.proEngName.indexOf(value) !== -1;
       }
     },
@@ -1055,7 +1109,55 @@
 
       return this.form.tjProjectList;
     },
-    //  // 榛樿鎺ュ彈鍥涗釜鍊� { 褰撳墠琛岀殑鍊�, 褰撳墠鍒楃殑鍊�, 琛岀殑涓嬫爣, 鍒楃殑涓嬫爣 }
+
+    numberChange(currentValue, oldValue) {
+      this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          this.youhui = currentValue;
+          /*    if (this.youhui < 10) {
+            this.youhui = 10;
+            // this.$modal.msgError(`璇ヤ汉鍛樻渶楂樹紭鎯犳潈闄愪负${this.getInfodis}鎶榒);
+          } */
+          this.DataList.forEach((item) => {
+            item.limits = this.youhui;
+            const proPrice = new Big(item.proPrice);
+            const limits = new Big(item.limits);
+            const result = proPrice.times(limits.div(10));
+            item.priceNow = result.toNumber();
+            this.form.xianprice = this.DataList.reduce((sum, item) => {
+              return sum.plus(new Big(item.priceNow || "0"));
+            }, new Big(0));
+          });
+        })
+        .catch(() => {
+          this.youhui = oldValue;
+        });
+    },
+
+    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.priceNow = result.toNumber();
+      this.form.xianprice = this.DataList.reduce((sum, item) => {
+        return sum.plus(new Big(item.priceNow || "0"));
+      }, new Big(0)).toNumber();
+      this.youhui =
+        (Math.floor((this.form.xianprice / this.pics) * 100) / 100) * 10;
+    },
+    calculateDiscount(row) {
+      if (row.limits > 10) {
+        row.limits = 10; // 寮哄埗灏嗗�艰缃负鏈�澶у��
+      } else if (row.limits < 0) {
+        row.limits = 0; // 寮哄埗灏嗗�艰缃负鏈�灏忓��
+      }
+      this.updateProPrice(row); // 鏇存柊浠锋牸鎴栧叾浠栭�昏緫
+    },
+    // 榛樿鎺ュ彈鍥涗釜鍊� { 褰撳墠琛岀殑鍊�, 褰撳墠鍒楃殑鍊�, 琛岀殑涓嬫爣, 鍒楃殑涓嬫爣 }
     objectSpanMethod({ row, column, rowIndex, columnIndex }) {
       let fields = ["propinName"];
       let cellValue = row[column.property];
@@ -1092,7 +1194,19 @@
             this.Treedata.forEach((item1) => {
               if (item.proId == item1.proId) {
                 this.checkedkey.push(item1.proId);
-                let proId = 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); // 鏇存柊浠锋牸鎴栧叾浠栭�昏緫
+                });
+
+                /* let proId = item1.proId;
                 getProSonDxList(proId).then((res) => {
                   this.TreedataList = res.data.list;
                   this.TreedataList.forEach((item2) => {
@@ -1112,14 +1226,23 @@
                       });
                     }
                   });
-                });
+                }); */
               }
             });
           });
         } else {
           this.checkedkey.push(this.Treedata[0].proId);
           let proId = this.Treedata[0].proId;
-          getProSonDxList(proId).then((res) => {
+          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;
@@ -1134,12 +1257,60 @@
                 this.pics += item.proPrice;
               });
             });
-          });
+          }); */
         }
+        this.pics = this.DataList.reduce(
+          (total, item) => total + item.proPrice,
+          0
+        );
         this.loading = false;
       });
     },
+
     handleCurrentChecked(data, checked, checkedNodes) {
+      this.dataObj = data;
+      this.checkedObj = checked;
+
+      if (checked == true) {
+        // 灏嗛�変腑鐨勯」鐩坊鍔犲埌 DataList
+        this.checkedListkey.push(data.proId);
+        this.DataList.push({
+          proId: data.proId,
+          proName: data.proName,
+          proPrice: data.proPrice, // 鍘熶环
+          limits: 10, // 榛樿鎶樻墸锛�100%锛�
+          priceNow: data.proPrice, // 榛樿浼樻儬浠蜂笌鍘熶环鐩稿悓
+        });
+
+        // 閲嶆柊璁$畻鎬讳环
+        this.pics = 0;
+        this.TotalPrice1 = 0;
+        this.DataList.forEach((item) => {
+          this.pics += item.proPrice;
+          this.form.counterPrice += item.proPrice;
+          this.TotalPrice1 += item.proPrice; // 鍙互鏍规嵁闇�瑕佹敼鎴愪紭鎯犱环 `priceNow`
+        });
+      } else if (checked == false) {
+        // 浠� DataList 涓Щ闄ゅ彇娑堥�変腑鐨勯」鐩�
+        let index = this.DataList.findIndex(
+          (item) => item.proId === data.proId
+        );
+        if (index !== -1) {
+          this.DataList.splice(index, 1);
+        }
+
+        // 閲嶆柊璁$畻鎬讳环
+        this.pics = 0;
+        this.TotalPrice1 = 0;
+        this.DataList.forEach((item) => {
+          this.pics += item.proPrice;
+          this.form.counterPrice += item.proPrice;
+          this.TotalPrice1 += item.proPrice; // 鍙互鏍规嵁闇�瑕佹敼鎴愪紭鎯犱环 `priceNow`
+        });
+      }
+    },
+
+    /* handleCurrentChecked(data, checked, checkedNodes) {
       this.dataObj = data;
       this.checkedObj = checked;
       if (checked == true) {
@@ -1190,7 +1361,7 @@
           });
         });
       }
-    },
+    }, */
 
     spliceData() {
       for (var i = 0; i < this.DataList.length; i++) {
@@ -1256,6 +1427,52 @@
 
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
+      console.log(this.form, 999);
+      this.form.limits = this.youhui;
+      this.form.price = this.pics;
+      this.form.priceNow = this.queryParams.xianprice;
+
+      if (this.keys) {
+        this.form.keywords = this.keys; // 濡傛灉鏈� this.keys锛屽垯鐩存帴璧嬪��
+      } else {
+        this.form.keywords = this.form.keywords.toString(); // 濡傛灉娌℃湁锛屽垯灏� this.form.keywords 杞垚瀛楃涓�
+      }
+
+      let packageProjects = []; // 瀹氫箟涓�涓┖鏁扮粍
+
+      this.DataList.forEach((item) => {
+        packageProjects.push({
+          proName: item.proName,
+          proId: item.proId,
+          priceNow: item.priceNow,
+          limits: item.limits,
+          priceOrd: item.proPrice,
+        });
+      });
+      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,
+        keywords: this.form.keywords,
+        sort: this.form.sort,
+        retailPrice: this.form.retailPrice,
+        tjCategory: this.form.tjCategory,
+        pacRemark: this.form.pacRemark,
+        detail: this.form.detail,
+      };
+
+      saveOreditTjPacNew(data).then((res) => {
+        console.log(res, 555);
+        this.open = false;
+        this.getList();
+      });
+    },
+    /* submitForm() {
       if (this.form.pacName) {
         this.form.tjProjectList = [];
         if (this.DataList.length != 0) {
@@ -1319,7 +1536,7 @@
       } else {
         Message.warning("璇峰厛濉啓濂楅鍚嶇О");
       }
-    },
+    }, */
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const pacIds = row.pacId || this.ids;

--
Gitblit v1.8.0