From 84a9297d616a8db97330e3daa6b92974bb738fa5 Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期一, 28 七月 2025 16:38:30 +0800
Subject: [PATCH] 1

---
 src/views/hosp/order/index.vue |  267 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 241 insertions(+), 26 deletions(-)

diff --git a/src/views/hosp/order/index.vue b/src/views/hosp/order/index.vue
index e883655..305352e 100644
--- a/src/views/hosp/order/index.vue
+++ b/src/views/hosp/order/index.vue
@@ -75,7 +75,7 @@
             v-hasPermi="['hosp:order:export']">瀵煎嚭</el-button>
         </el-col>
 
-       
+
         <el-col :span="1.5">
           <el-button type="primary" size="mini" @click="handleProject1" :disabled="single"
             v-hasPermi="['hosp:order:export']">琛ュ綍椤圭洰</el-button>
@@ -97,16 +97,17 @@
           <el-button type="primary" size="mini" @click="budadzd" :disabled="single"
             v-hasPermi="['hosp:order:export']">鎵撳嵃琛ュ綍鍗�</el-button>
         </el-col>
-         <el-col :span="1.5">
-          <el-button style="background-color:#E6A23C;color:#fff"
-           size="mini" @click="handleRevoke" :disabled="single">鎾ら攢绛惧埌</el-button>
+        <el-col :span="1.5">
+          <el-button style="background-color:#E6A23C;color:#fff" size="mini" @click="handleRevoke"
+            :disabled="single">鎾ら攢绛惧埌</el-button>
         </el-col>
         <el-col :span="1.5">
           <el-button style="background-color:#E6A23C;color:#fff" size="mini" @click="ForceChexiao" :disabled="single"
             v-hasPermi="['qzcx']">寮哄埗鎾ら攢</el-button>
         </el-col>
         <el-col :span="1.5">
-          <el-button style="background-color:#E6A23C;color:#fff" size="mini" @click="ResumeAppointment" :disabled="multiple">鎭㈠棰勭害</el-button>
+          <el-button style="background-color:#E6A23C;color:#fff" size="mini" @click="ResumeAppointment"
+            :disabled="multiple">鎭㈠棰勭害</el-button>
         </el-col>
         <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
       </el-row>
@@ -197,8 +198,8 @@
             <template slot-scope="scope">
               <el-button size="mini" type="text" icon="el-icon-document" @click="handleUpdate(scope.row)"
                 v-hasPermi="['hosp:order:edit']" title="璁㈠崟娴佹按"></el-button>
-              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleProject(scope.row)"
-                v-hasPermi="['hosp:order:edit']" title="琛ュ綍椤圭洰"></el-button>
+              <!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleProject(scope.row)"
+                v-hasPermi="['hosp:order:edit']" title="琛ュ綍椤圭洰"></el-button> -->
               <!-- <el-button type="text" size="mini" class="btn" icon="el-icon-download" title="涓嬭浇瀵艰瘖鍗�" @click="
               daoZhenDan,
               LoadFileImg(scope.row);
@@ -225,8 +226,8 @@
               @click="viewReport(scope.row)"
             ></el-button> -->
 
-              <el-button type="text" size="mini" class="btn" icon="el-icon-download" title="瀵艰瘖鍗�"
-                @click="handleReport(scope.row)"></el-button>
+              <!-- <el-button type="text" size="mini" class="btn" icon="el-icon-download" title="瀵艰瘖鍗�"
+                @click="handleReport(scope.row)"></el-button> -->
 
               <!-- <button @click="downLoadFileImg(scope.row)">鏌ョ湅鎶ュ憡</button> -->
             </template>
@@ -474,6 +475,7 @@
               <el-table-column prop="proPrice" label="鍘熶环" width="56px">
               </el-table-column>
 
+
               <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width" width="50px">
                 <template slot-scope="scope">
                   <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDel(scope.row)"
@@ -534,7 +536,7 @@
       </el-dialog>
 
       <!-- 娣诲姞琛ュ綍椤圭洰 -->
-      <el-dialog :title="title" :visible.sync="Projectopen1" width="1100px" style="height: 860px" append-to-body
+      <el-dialog :title="title" :visible.sync="Projectopen1" width="1200px" style="height: 860px" append-to-body
         :close-on-click-modal="false">
         <div class="box">
           <div class="box1">
@@ -586,13 +588,26 @@
             </div>
             <el-table :data="DataList3" border style="width: 100%; table-layout: fixed" height="560"
               :span-method="objectspanmethod">
-              <el-table-column prop="propinName" label="妫�鏌ラ」鐩�" width="200px" :show-overflow-tooltip="true">
+              <el-table-column prop="propinName" label="妫�鏌ラ」鐩�" width="160px" :show-overflow-tooltip="true">
               </el-table-column>
-              <el-table-column prop="proName" label="鏄庣粏椤圭洰" width="200px" :show-overflow-tooltip="true">
+              <el-table-column prop="proName" label="鏄庣粏椤圭洰" width="160px" :show-overflow-tooltip="true">
               </el-table-column>
               <el-table-column prop="sl" label="鏁伴噺" width="56px">
               </el-table-column>
               <el-table-column prop="proPrice" label="鍘熶环" width="56px">
+              </el-table-column>
+              <el-table-column label="鎶樻墸" width="150px">
+                <template slot-scope="scope">
+                  <!-- @input="validateDiscount(scope.row)" -->
+                  <el-input-number v-model.number="scope.row.discount" @change="handleManualChange(scope.row)"
+                    placeholder="杈撳叆鎶樻墸" size="small" type="number" :precision="1" :step="0.1" :max="10" :min="0">
+                  </el-input-number>
+                </template>
+              </el-table-column>
+              <el-table-column prop="nowPrice" label="鐜颁环">
+                <template slot-scope="scope">
+                  {{ scope.row.nowPrice ? scope.row.nowPrice.toFixed(2) : scope.row.nowPrice }}
+                </template>
               </el-table-column>
 
               <el-table-column label="鎿嶄綔" align="center" class-name="small-padding fixed-width" width="50px">
@@ -621,13 +636,23 @@
           </el-form-item>
 
           <!-- 鎶樻墸璁惧畾 -->
-          <el-form-item label="鎶樻墸" style="display: flex">
+          <!-- <el-form-item label="鎶樻墸" style="display: flex">
             <el-input style="width: 90px" type="number" v-model="discount" :value="discount"></el-input>
+          </el-form-item> -->
+
+          <el-form-item label="鎶樻墸">
+            <!-- {{ discount }} -->
+            <el-input-number ref="inputNumber" style="width: 150px" v-model="discount" :precision="1" :step="0.1"
+              :max="10" :min="0" @change="debounceNumberChange"></el-input-number>
           </el-form-item>
 
           <!-- 搴斾粯閲戦 -->
-          <el-form-item label="搴斾粯" style="display: flex">
+          <!-- <el-form-item label="搴斾粯" style="display: flex">
             <el-input placeholder="搴斾粯閲戦" :value="TotalPrice1 * (discount / 10)" style="width: 90px"></el-input>
+          </el-form-item> -->
+          <el-form-item label="搴斾粯">
+            <el-input placeholder="搴斾粯閲戦" v-model="TotalPrice" style="width: 206px" @input="changeXianjia"
+              @blur="numberChangeXianPrice(discount, discount)" />
           </el-form-item>
 
           <!-- 浠樻绫诲瀷 -->
@@ -785,6 +810,12 @@
               </el-table-column>
               <el-table-column align="center" prop="price" label="璐圭敤鍚堣">
               </el-table-column>
+              <el-table-column align="center" prop="sfzt" label="璐圭敤鐘舵��">
+                <template v-slot="scope">
+                  <span v-if="scope.row.sfzt">{{ '宸茬粨璐�' }}</span>
+                  <span v-else>{{ '鏈粨璐�' }}</span>
+                </template>
+              </el-table-column>
             </el-table>
             <h3>浠樻璇︽儏</h3>
             <el-table :data="bill" style="width: 100%; margin-top: 10px">
@@ -934,6 +965,7 @@
   getForceChexiao,
 } from "@/api/hosp/order";
 import moment from "moment";
+import Big from "big.js";
 import { getZhList, getlistByZhId } from "@/api/system/package";
 import { getwater } from "@/api/hosp/customer";
 import { getInfo } from "@/api/login";
@@ -1026,6 +1058,7 @@
       },
       TreedataList: [],
       discount: 10,
+      lastXianPrice: 0,
       DataList: [],
       shijianlist: [],
       // 濂楅鎻愪氦鎸夐挳
@@ -1034,6 +1067,7 @@
       activeName: "1",
       proIds: [],
       TotalPrice1: 0,
+      TotalPrice: 0,
       TotalPrice6: 0,
       TotalPrice7: 0,
       numberList: [],
@@ -1342,8 +1376,6 @@
       // 鍏堣皟鐢� getInfo 鑾峰彇 userId
       getInfo()
         .then((res) => {
-          console.log(res, 1111);
-
           const dqdlr = res.user.userId; // 鑾峰彇 userId
           console.log("User ID:", dqdlr);
           const params = { viewNum, tjNumber, dqdlr }; // 灏� userId 鍔犲叆 params
@@ -1364,7 +1396,6 @@
 
     // 寮哄埗鎾ら攢鎸夐挳
     ForceChexiao() {
-
       const tjNum = this.tjnumbers;
       this.isLoading = true
       this.$confirm(
@@ -1377,17 +1408,13 @@
           customClass: "custom-message-box",
         }
       )
-
         .then(() => {
-
           getForceChexiao(tjNum).then((res) => {
-
             if (res.code == 200) {
               this.$modal.msgSuccess("鎾ら攢鎴愬姛");
               this.isLoading = false
               this.getList();
             }
-
           }).catch(() => {
             console.log("鍔犺浇澶辫触")
             this.isLoading = false;
@@ -1453,6 +1480,162 @@
           // 涓嶈鎿嶄綔鎴愬姛杩樻槸澶辫触锛岄兘浼氭墽琛�
 
         });
+    },
+
+
+    debounceNumberChange(currentValue, oldValue) {
+      clearTimeout(this.debounceTimer);
+      this.debounceTimer = setTimeout(() => {
+        this.numberChange(currentValue, oldValue);
+      }, 300);
+    },
+
+    // 鎶樻墸
+    numberChange(currentValue, oldValue) {
+      this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          this.discount = currentValue;
+          this.DataList3.forEach((item) => {
+            item.discount = this.discount;
+            const ordPrice = new Big(item.proPrice.toString());
+            const discount = new Big(item.discount.toString());
+            const result = ordPrice.times(discount.div(10));
+            item.nowPrice = result.toNumber();
+            // this.TotalPrice = this.DataList3.reduce((sum, item) => {
+            //   return sum.plus(new Big(item.nowPrice || "0"));
+            // }, new Big(0));
+            this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)).toFixed(2)
+          });
+        })
+        .catch(() => {
+          this.discount = oldValue;
+        });
+    },
+
+    changeXianjia() {
+      // 鍘熷鎶樻墸鐜囪绠�
+      if (this.TotalPrice1 !== 0) {
+        this.discount =
+          (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
+      }
+    },
+    numberChangeXianPrice(currentValue, oldValue) {
+      // 濡傛灉鐜颁环娌℃湁鍙樺寲锛岀洿鎺ヨ繑鍥�
+      if (this.TotalPrice === this.lastXianPrice || !this.TotalPrice) {
+        console.log(2222333)
+        return;
+      }
+      this.$confirm("纭畾淇敼鎵�鏈夊瓙椤圭殑鎶樻墸鍚楋紵", "鎻愮ず", {
+        confirmButtonText: "纭畾",
+        cancelButtonText: "鍙栨秷",
+        type: "warning",
+      })
+        .then(() => {
+          this.discount = currentValue;
+          // if (this.discount < this.getInfodis) {
+          //   this.discount = this.getInfodis;
+          // }
+          let totalYsprice = new Big(0);
+          console.log(this.DataList3, 11111)
+          this.DataList3.forEach((item) => {
+            item.discount = this.discount;
+            const ordPrice = new Big(item.proPrice);
+            const discount = new Big(item.discount);
+            const result = ordPrice.times(discount.div(10));
+            item.nowPrice = result.toNumber();
+            totalYsprice = totalYsprice.plus(new Big(item.nowPrice));
+          });
+          if (!totalYsprice.eq(this.TotalPrice)) {
+            const diff = new Big(this.TotalPrice).minus(totalYsprice);
+            if (this.tableData1.length > 0) {
+              const lastItem = this.tableData3[this.tableData3.length - 1];
+              const newYsPrice = new Big(lastItem.nowPrice)
+                .plus(diff)
+                .toNumber();
+              // console.log(
+              //   "hhh",
+              //   this.tableData1[this.tableData1.length - 1].nowPrice,
+              //   newYsPrice
+              // );
+              this.$set(
+                this.tableData3[this.tableData3.length - 1],
+                "nowPrice",
+                newYsPrice
+              );
+            }
+          }
+          this.lastXianPrice = this.TotalPrice;
+        })
+        .catch(() => {
+          this.discount = oldValue;
+        });
+    },
+    handleManualChange(row) {
+      this.updateProPrice(row);
+    },
+
+    //  validateDiscount(row) {
+    //   if (
+    //     this.TotalPrice !== undefined &&
+    //     !isNaN(this.TotalPrice) &&
+    //     this.TotalPrice !== this.lastXianPrice
+    //   ) {
+    //     this.updateProPrice1(row);
+    //     this.lastXianPrice = this.TotalPrice;
+    //   }
+    // },
+    // updateProPrice1(row) {
+    //     console.log( row,2222)
+    //   const ordPrice = new Big(row.proPrice);
+    //   const discount = new Big(row.discount);
+    //   const result = ordPrice.times(discount.div(10));
+    //   row.nowPrice = result.toNumber();
+    //   const totalYsPrice = this.tableData1.reduce((sum, item) => {
+    //     return sum.plus(new Big(item.nowPrice || "0"));
+    //   }, new Big(0));
+    //   const totalYsPriceNum = totalYsPrice.toNumber();
+    //   if (this.TotalPrice !== undefined && !isNaN(this.TotalPrice)) {
+    //     const xianPrice = new Big(this.TotalPrice);
+    //     const diff = xianPrice.minus(totalYsPriceNum);
+    //     if (!diff.eq(0) && this.tableData1.length > 0) {
+    //       const lastItem = this.tableData1[this.tableData1.length - 1];
+    //       const newYsPrice = new Big(lastItem.nowPrice).plus(diff).toNumber();
+    //       this.$set(
+    //         this.tableData1[this.tableData1.length - 1],
+    //         "nowPrice",
+    //         newYsPrice
+    //       );
+    //     }
+    //   }
+
+    // Update youhui calculation
+    //   if (this.TotalPrice1 !== 0 && this.TotalPrice !== 0) {
+    //     this.discount =
+    //       (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
+    //   } else {
+    //     this.discount = 0;
+    //   }
+    // },
+
+    updateProPrice(row) {
+      if (row.proPrice == 0) {
+        row.discount = 10
+        return
+      } else {
+        const ordPrice = new Big(row.proPrice);
+        const discount = new Big(row.discount);
+        const result = ordPrice.times(discount.div(10)); // ordPrice * (discount / 10)
+        row.nowPrice = result.toNumber();
+        this.TotalPrice = this.DataList3.reduce((sum, item) => {
+          return sum.plus(new Big(item.nowPrice || "0"));
+        }, new Big(0));
+        this.discount =
+          (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10;
+      }
     },
 
     handleRevoke() {
@@ -2014,7 +2197,9 @@
       this.DataList3 = [];
       this.Datalists = [];
       this.TotalPrice1 = 0;
-      this.orderId = row.orderId;
+      this.filterText = "",
+        this.filterage = "",
+        this.orderId = row.orderId;
       this.cusId = row.tjCusIdCard;
       this.userId = row.userId;
       this.customer = {
@@ -2094,6 +2279,10 @@
       this.DataList = [];
       this.DataList3 = [];
       this.Datalists = [];
+      this.TotalPrice = 0;
+      this.discount = 10;
+      this.filterText = "";
+      this.filterage = "";
       this.TotalPrice1 = 0;
       this.orderId = this.ids;
       this.cusId = this.cusIds;
@@ -2205,6 +2394,8 @@
           this.TotalPrice1 = 0;
           this.DataList3.forEach((item) => {
             this.TotalPrice1 += item.proPrice * item.sl;
+            this.TotalPrice = this.TotalPrice1 * (this.discount / 10)
+            this.lastXianPrice = this.TotalPrice;
           });
         });
       } else if (checked === false) {
@@ -2233,6 +2424,8 @@
           this.TotalPrice1 = 0;
           this.DataList3.forEach((item) => {
             this.TotalPrice1 += item.proPrice * item.sl;
+            this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10))
+            this.lastXianPrice = this.TotalPrice;
           });
         });
       }
@@ -2276,9 +2469,6 @@
         this.spliceData();
         this.TotalPrice1 = 0;
         this.DataList.forEach((item1) => {
-          console.log(item1.proPrice, 3322);
-          console.log(this.TotalPrice1, 1122);
-
           this.TotalPrice1 = item1.proPrice + this.TotalPrice1;
         });
         if (this.marryalls != 0) {
@@ -2296,8 +2486,18 @@
           });
         }
       });
+
       this.DataList3.forEach((item, index) => {
         if (item.proId == row.proId) {
+          let proParentId = item.proParentId
+          // 鑾峰彇褰撳墠閫変腑鐨勮妭鐐筴ey
+          const currentCheckedKeys = this.$refs.tree.getCheckedKeys();
+
+          // 鍒涘缓涓�涓柊鏁扮粍锛岀Щ闄ゆ兂瑕佸彇娑堥�変腑鐨勮妭鐐筴ey锛堣繖閲屽亣璁炬槸1锛�
+          const newCheckedKeys = currentCheckedKeys.filter(key => key !== proParentId);
+
+          // 浣跨敤setCheckedKeys鏂规硶鏇存柊閫変腑鐘舵��
+          this.$refs.tree.setCheckedKeys(newCheckedKeys);
           this.DataList3.splice(index, 1);
           this.marryalls = 0;
           this.DataList3.forEach((item1) => {
@@ -2305,21 +2505,36 @@
           });
         }
       });
+      if (this.DataList3.length == 0) {
+        this.discount = 10
+        this.checkedkey = []
+        this.$refs.tree.setCheckedKeys([])
+        this.TotalPrice1 = this.marryalls;
+        this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10))
+      } else if (this.DataList3.length == 1) {
+        this.discount = this.DataList3[0].discount
+        this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10)).toFixed(2)
+      }
       this.DataList.forEach((item, index) => {
         if (item.proId == row.proId) {
           this.DataList.splice(index, 1);
           this.TotalPrice1 = 0;
+          this.TotalPrice = 0;
           this.DataList.forEach((item1) => {
             this.TotalPrice1 = item1.proPrice + this.TotalPrice1;
+            this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10))
           });
           if (this.marryalls != 0) {
             this.TotalPrice1 += this.marryalls;
+            this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10))
           }
         }
       });
       this.TotalPrice1 = 0;
+      this.TotalPrice = 0;
       this.DataList3.forEach((item) => {
         this.TotalPrice1 += item.proPrice;
+        this.TotalPrice = new Big(this.TotalPrice1 * (this.discount / 10))
       });
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
@@ -2676,7 +2891,7 @@
 }
 
 .box1 {
-  width: 50%;
+  width: 35%;
   display: flex;
   flex-direction: column;
 }

--
Gitblit v1.8.0