qx
2025-07-04 4c4abb59d6ee838c61b851fcc7be93c0522c39c4
src/views/system/package/index.vue
@@ -118,8 +118,12 @@
        <el-form-item label="折扣">
          <el-input-number style="width: 150px" v-model="youhui" :precision="2" :step="0.1" :max="10" :min="0.1" @change="debounceNumberChange" :debounce="3000"></el-input-number>
        </el-form-item>
        <el-form-item label="现价" prop="xianprice">
        <!-- <el-form-item label="现价" prop="xianprice">
          <el-input v-model="form.xianprice" placeholder="现价" clearable style="width: 140px" @input="changeXianjia" @blur="numberChangeXianPrice(youhui, youhui)" type="number" :debounce="3000" min="0"/>
        </el-form-item> -->
        <el-form-item label="现价" prop="xianprice">
          <el-input v-model="form.xianprice" placeholder="现价" clearable style="width: 140px" @input="changeXianjia"
            type="number" :debounce="3000" min="0"/>
        </el-form-item>
        <el-form-item label="关键字" prop="keywords">
          <el-select multiple v-model="form.keywords" placeholder="请选择关键字" style="width: 160px" @change="sel" filterable clearable>
@@ -147,7 +151,7 @@
      <el-row style="display: flex; width: 1300px">
        <el-col>
          <div style="text-align: center; margin-bottom: 10px; margin-top: 10px">项目列表</div>
          <el-input placeholder="输入关键字进行过滤" v-model="filterText" @input="debounceFilter" clearable />
          <el-input placeholder="输入关键字进行过滤" v-model="queryParams1.nr" @input="handleFilterInput" clearable />
          <div class="tab3" style="height: 365px">
            <el-tree
              class="filter-tree"
@@ -315,11 +319,12 @@
    this.getCategory();
  },
  methods: {
    debounceFilter() {
      clearTimeout(this.debounceTimer);
      this.debounceTimer = setTimeout(() => {
        this.filterTree();
      }, 600);
    handleFilterInput() {
      this.queryParams1.page = 1;
      this.getDataList();
      this.$nextTick(() => {
        this.$refs.tree.setCheckedKeys(this.checkedNodes);
      });
    },
    filterTree() {
      if (!this.filterText) {
@@ -777,7 +782,7 @@
      this.DataList = this.DataList.filter((item) => item.proParentId !== row.proParentId);
      this.TotalPrice1 = this.DataList.reduce((sum, item) => sum + item.priceOrd, 0);
    },
    submitForm() {
    /* submitForm() {
      this.form.limits = this.youhui;
      this.form.price = this.pics;
      this.form.priceNow = this.form.xianprice;
@@ -813,6 +818,85 @@
        this.open = false;
        this.getList();
      });
    }, */
    submitForm() {
      // 检查现价是否发生变化
      if (this.form.xianprice !== this.lastXianPrice) {
        this.$confirm("确定修改所有子项的折扣吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          // 更新所有子项的折扣
          this.youhui = (Math.floor((this.form.xianprice / this.pics) * 100) / 100) * 10;
          let totalYsprice = new Big(0);
          this.DataList.forEach((item) => {
            item.limits = this.youhui;
            const ordPrice = new Big(item.priceOrd);
            const discount = new Big(item.limits);
            const result = ordPrice.times(discount.div(10));
            item.priceNow = result.toNumber();
            totalYsprice = totalYsprice.plus(new Big(item.priceNow));
          });
          if (!totalYsprice.eq(this.form.xianprice)) {
            const diff = new Big(this.form.xianprice).minus(totalYsprice);
            if (this.DataList.length > 0) {
              const lastItem = this.DataList[this.DataList.length - 1];
              const newYsPrice = new Big(lastItem.priceNow).plus(diff).toNumber();
              this.$set(this.DataList[this.DataList.length - 1], "priceNow", newYsPrice);
            }
          }
          // 保存数据
          return this.saveData();
        }).catch(() => {
          // 用户取消操作,恢复原来的现价
          this.form.xianprice = this.lastXianPrice;
        });
      } else {
        // 现价没有变化,直接保存
        this.saveData();
      }
    },
     // 新增一个方法处理保存逻辑
     saveData() {
      this.form.limits = this.youhui;
      this.form.price = this.pics;
      this.form.priceNow = this.form.xianprice;
      if (this.keys) {
        this.form.keywords = this.keys;
      }
      let packageProjects = [];
      this.DataList.forEach((item) => {
        packageProjects.push({
          proName: item.proName,
          proId: item.proId,
          priceNow: item.priceNow,
          limits: item.limits,
          priceOrd: item.priceOrd,
        });
      });
      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,
        sort: this.form.sort,
        retailPrice: this.form.retailPrice,
        tjCategory: this.form.tjCategory,
        pacRemark: this.form.pacRemark,
        detail: this.form.detail,
      };
      return saveOreditTjPacNew(data).then((res) => {
        this.open = false;
        this.getList();
      });
    },
    handleDelete(row) {
      const pacIds = row.pacId || this.ids;