1
wwl
2025-03-05 cb1f69717eed3b6a61b6c61a8934bac752782b2d
src/views/system/package/index.vue
@@ -24,19 +24,19 @@
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="套餐分类" prop="categoryId">
      <el-form-item label="体检类别" prop="tjCategory">
        <el-select
          v-model="queryParams.categoryId"
          v-model="queryParams.tjCategory"
          placeholder="请选择状态"
          style="width: 200px"
          filterable
          clearable
        >
          <el-option
            v-for="dict in categoryList"
            v-for="dict in dict.type.dict_tjtype"
            :key="dict.id"
            :label="dict.name"
            :value="dict.id"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
@@ -131,12 +131,19 @@
        />
        <!-- <el-table-column label="编号" align="center" prop="pacId" /> -->
        <el-table-column
          label="套餐分类"
          label="体检类别"
          width="100px"
          align="center"
          prop="categoryNames"
          fixed
        ></el-table-column>
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.dict_tjtype"
              :value="scope.row.tjCategory"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="套餐名称"
          align="center"
@@ -240,12 +247,12 @@
          align="center"
          prop="retailPrice"
        ></el-table-column>
        <el-table-column
        <!-- <el-table-column
          label="原价"
          width="90px"
          align="center"
          prop="counterPrice"
        ></el-table-column>
        ></el-table-column> -->
        <el-table-column
          label="已售数量"
          width="90px"
@@ -363,12 +370,7 @@
          </el-select>
        </el-form-item>
        <el-form-item label="套餐类目" prop="categoryId">
          <!-- <el-input
            v-model="form.createId"
            placeholder="请输入商品类目"
            style="width: 200px"
          /> -->
        <!--  <el-form-item label="套餐类目" prop="categoryId">
          <el-select
            v-model="form.categoryId"
            placeholder="请选择套餐类目"
@@ -384,26 +386,24 @@
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="关键字" prop="keywords">
        </el-form-item> -->
        <el-form-item label="体检类别" prop="tjCategory">
          <el-select
            multiple
            v-model="form.keywords"
            placeholder="请选择关键字"
            v-model="form.tjCategory"
            placeholder="请选择体检类别"
            style="width: 150px"
            @change="sel"
            filterable
            clearable
          >
            <el-option
              v-for="item in keywordList"
              :key="item.id"
              :label="item.keyword"
              :value="item.id"
              v-for="dict in dict.type.dict_tjtype"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否上架" prop="isOnSale">
          <!-- <el-radio-group v-model="form.pacStatus">
              <el-radio :label="0">启用</el-radio>
@@ -412,7 +412,7 @@
          <el-select
            v-model="form.isOnSale"
            placeholder="请选择是否上架"
            style="width: 150px"
            style="width: 140px"
            filterable
            clearable
          >
@@ -467,19 +467,21 @@
            style="width: 140px"
          />
        </el-form-item>
        <el-form-item label="体检类别" prop="tjCategory">
        <el-form-item label="关键字" prop="keywords">
          <el-select
            v-model="form.tjCategory"
            placeholder="请选择体检类别"
            style="width: 150px"
            multiple
            v-model="form.keywords"
            placeholder="请选择关键字"
            style="width: 160px"
            @change="sel"
            filterable
            clearable
          >
            <el-option
              v-for="dict in dict.type.dict_tjtype"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
              v-for="item in keywordList"
              :key="item.id"
              :label="item.keyword"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
@@ -560,7 +562,7 @@
          <el-input
            placeholder="输入关键字进行过滤"
            @input="handleFilterInput"
            v-model="queryParams.nr"
            v-model="queryParams1.nr"
            clearable
          />
          <div class="tab3" style="height: 365px">
@@ -580,11 +582,11 @@
            </el-tree>
            <pagination
              small
              v-show="total > 0"
              :total="total"
              :page.sync="queryParams.page"
              :limit.sync="queryParams.pageSize"
              @pagination="handlePageChange"
              v-show="total1 > 0"
              :total="total1"
              :page.sync="queryParams1.page"
              :limit.sync="queryParams1.pageSize"
              @pagination="getDataList"
            />
          </div>
        </el-col>
@@ -823,16 +825,21 @@
      // 是否显示弹出层
      open: false,
      Seachopen: false,
      checkedNodes: [],
      pacId: "",
      // 总条数
      total: 0,
      total1: 0,
      // 查询参数
      queryParams: {
        page: 1,
        pageNum: 1,
        pageSize: 10,
        pacName: null,
        pacRemark: null,
      },
      queryParams1: {
        page: 1,
        pageSize: 30,
        nr: "",
      },
      // 表单参数
@@ -857,9 +864,9 @@
        // categoryId: [
        //   { required: true, validator: checkPhoneNum, trigger: "change" },
        // ],
        keywords: [
        /*  keywords: [
          { required: true, validator: checkPhoneNum, trigger: "change" },
        ],
        ], */
        isOnSale: [
          { required: true, validator: checkPhoneNum, trigger: "change" },
        ],
@@ -868,6 +875,9 @@
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        counterPrice: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
        tjCategory: [
          { required: true, validator: checkPhoneNum, trigger: "blur" },
        ],
      },
@@ -941,6 +951,7 @@
      this.loading = true;
      listCategory(this.queryParams).then((response) => {
        this.categoryList = response.rows;
        console.log(this.categoryList, 9988);
      });
    },
    shangpin(vals) {},
@@ -1063,6 +1074,8 @@
      // });
      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 = [];
@@ -1088,6 +1101,8 @@
      this.open = true;
      getPacInFo(row.pacId).then((response) => {
        this.form = response.data;
        console.log(this.form, 445);
        this.form.keywords = this.form.keywords.slice(0, -1);
        this.form.keywords = this.form.keywords.split(",");
        this.DataList = [];
@@ -1149,13 +1164,18 @@
    /** 删除按钮操作 */
    handleDelete1(row) {
      this.DataList = this.DataList.filter((item) => item.proId !== row.proId);
      const tree = this.$refs.tree;
      const node = tree.getNode(row.proId); // 根据节点的唯一标识获取节点对象
      if (node) {
        node.setChecked(false); // 取消选中状态
      // 从 checkedNodes 中移除
      const index = this.checkedNodes.indexOf(row.proId);
      if (index > -1) {
        this.checkedNodes.splice(index, 1);
      }
      const tree = this.$refs.tree;
      const node = tree.getNode(row.proId);
      if (node) {
        node.setChecked(false);
      }
      this.updateTotalPrice();
    },
    getSelectValue(val) {
      this.form.tjProjectList.forEach((formitem) => {
        if (formitem.proName == val) {
@@ -1267,13 +1287,18 @@
    },
    getDataList() {
      this.loading = true;
      search(this.queryParams).then((response) => {
      search(this.queryParams1).then((response) => {
        this.Treedata = response.data.list; // 更新树形数据
        this.total = response.data.total; // 更新总条数
        this.total1 = response.data.total; // 更新总条数
        this.pics = this.DataList.reduce(
          (total, item) => total + item.priceOrd,
          0
        );
        // 确保在数据加载后保持选中状态
        this.$nextTick(() => {
          this.$refs.tree.setCheckedKeys(this.checkedNodes);
        });
      });
      this.loading = false;
    },
@@ -1284,12 +1309,12 @@
    //     this.Treedata = response.data.list;
    //     /*  if (this.form.tjProjectList) {
    //       this.form.tjProjectList.forEach((item) => {
    //         this.Treedata.forEach((item1) => {
    //         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) {
@@ -1299,7 +1324,7 @@
    //               }
    //               this.updateProPrice(item1); // 更新价格或其他逻辑
    //             });
    //           }
    //         });
    //       });
@@ -1340,8 +1365,12 @@
    //   });
    // },
    handleFilterInput() {
      this.queryParams.page = 1; // 搜索时重置为第一页
      this.queryParams1.page = 1; // 搜索时重置为第一页
      this.getDataList(); // 调用接口获取数据
      // 在过滤后,重新设置选中状态
      this.$nextTick(() => {
        this.$refs.tree.setCheckedKeys(this.checkedNodes);
      });
    },
    // 分页事件
@@ -1351,36 +1380,49 @@
      this.getDataList(); // 调用接口获取数据
    },
    handleCurrentChecked(data, checked, checkedNodes) {
      this.dataObj = data;
      this.checkedObj = checked;
    handleCurrentChecked(data, checked, indeterminate) {
      if (checked) {
        // 检查是否已存在于 DataL
        this.DataList.push({
          proId: data.proId,
          proName: data.proName,
          priceOrd: data.proPrice, // 原价,确保赋值正确
          limits: 10,
          priceNow: data.proPrice,
        });
        // 如果已选列表中不存在此项目,则添加
        if (!this.DataList.some((item) => item.proId === data.proId)) {
          this.DataList.push({
            proId: data.proId,
            proName: data.proName,
            priceOrd: data.proPrice,
            limits: 10,
            priceNow: data.proPrice,
          });
        }
        // 添加到 checkedNodes 数组
        if (!this.checkedNodes.includes(data.proId)) {
          this.checkedNodes.push(data.proId);
        }
      } else {
        let index = this.DataList.findIndex(
          (item) => item.proId === data.proId
        // 取消选中时,从DataList中移除
        this.DataList = this.DataList.filter(
          (item) => item.proId !== data.proId
        );
        if (index !== -1) {
          this.DataList.splice(index, 1);
        // 从 checkedNodes 中移除
        const index = this.checkedNodes.indexOf(data.proId);
        if (index > -1) {
          this.checkedNodes.splice(index, 1);
        }
      }
      this.pics = 0;
      this.TotalPrice1 = 0;
      this.DataList.forEach((item) => {
        this.pics += item.priceOrd;
        this.form.counterPrice += item.priceOrd;
        this.TotalPrice1 += item.priceOrd; // 可以根据需要改成优惠价 `priceNow`
      });
    },
      // 更新优惠价和总价
      this.updateTotalPrice();
    },
    updateTotalPrice() {
      // 计算所有项目的总优惠价
      this.form.xianprice = this.DataList.reduce((sum, item) => {
        return sum.plus(new Big(item.priceNow || "0"));
      }, new Big(0)).toNumber();
      // 计算原价总和
      this.pics = this.DataList.reduce(
        (total, item) => total + item.priceOrd,
        0
      );
    },
    spliceData() {
      for (var i = 0; i < this.DataList.length; i++) {
        for (var j = i + 1; j < this.DataList.length; j++) {
@@ -1452,7 +1494,7 @@
      if (this.keys) {
        this.form.keywords = this.keys; // 如果有 this.keys,则直接赋值
      } else {
        this.form.keywords = this.form.keywords.toString(); // 如果没有,则将 this.form.keywords 转成字符串
        // this.form.keywords = this.form.keywords; // 如果没有,则将 this.form.keywords 转成字符串
      }
      let packageProjects = []; // 定义一个空数组
@@ -1475,7 +1517,7 @@
        price: this.pics,
        pacId: this.form.pacId || null,
        isOnSale: this.form.isOnSale,
        keywords: this.form.keywords,
        // keywords: this.form.keywords,
        sort: this.form.sort,
        retailPrice: this.form.retailPrice,
        tjCategory: this.form.tjCategory,