qx
qx
1 天以前 e2ce0493b0978ed2706eed28555bd83ed329cb97
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>
@@ -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="折扣">
                <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>
          <!-- 付款类型 -->
@@ -786,10 +811,10 @@
              <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>
                <template v-slot="scope">
                  <span v-if="scope.row.sfzt">{{ '已结账' }}</span>
                  <span v-else>{{ '未结账' }}</span>
                </template>
              </el-table-column>
            </el-table>
            <h3>付款详情</h3>
@@ -940,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";
@@ -1032,6 +1058,7 @@
      },
      TreedataList: [],
      discount: 10,
      lastXianPrice:0,
      DataList: [],
      shijianlist: [],
      // 套餐提交按钮
@@ -1040,6 +1067,7 @@
      activeName: "1",
      proIds: [],
      TotalPrice1: 0,
      TotalPrice: 0,
      TotalPrice6: 0,
      TotalPrice7: 0,
      numberList: [],
@@ -1348,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
@@ -1370,7 +1396,6 @@
    // 强制撤销按钮
    ForceChexiao() {
      const tjNum = this.tjnumbers;
      this.isLoading = true
      this.$confirm(
@@ -1383,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;
@@ -1459,6 +1480,172 @@
          // 不论操作成功还是失败,都会执行
        });
    },
    updateProPrice(row) {
      console.log(row)
      const ordPrice = new Big(row.ordPrice);
      const discount = new Big(row.discount);
      const result = ordPrice.times(discount.div(10)); // ordPrice * (discount / 10)
      row.nowPrice = result.toNumber();
      this.TotalPrice = this.tableData1.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;
    },
    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))
          });
        })
        .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) {
        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.tableData3, 11111)
          this.tableData3.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) {
      console.log(row, 55555)
      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() {
@@ -2021,8 +2208,8 @@
      this.Datalists = [];
      this.TotalPrice1 = 0;
      this.filterText = "",
      this.filterage = "",
      this.orderId = row.orderId;
        this.filterage = "",
        this.orderId = row.orderId;
      this.cusId = row.tjCusIdCard;
      this.userId = row.userId;
      this.customer = {
@@ -2103,8 +2290,8 @@
      this.DataList3 = [];
      this.Datalists = [];
      this.filterText = "",
      this.filterage = "",
      this.TotalPrice1 = 0;
        this.filterage = "",
        this.TotalPrice1 = 0;
      this.orderId = this.ids;
      this.cusId = this.cusIds;
      this.userId = this.userIds;
@@ -2215,6 +2402,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;
          });
        });
      } else if (checked === false) {
@@ -2243,6 +2432,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;
          });
        });
      }