1
wwl
2025-03-03 2865369d52bed1a3ac334a4c82a70babab93a96f
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 {
        // 取消选中时,从DataList中移除
        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;
    },
    // 点击获取每个树节点