1
wwl
2025-01-04 492a91ada4f0f98d9d800b55f9dddda7b53f7dd8
src/views/system/comp/index.vue
@@ -31,7 +31,7 @@
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single" @click="mainDepartment"
          v-hasPermi="['system:comp:edit']">维护部门</el-button>
          v-hasPermi="['system:comp:edit']">维护套餐</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
@@ -333,8 +333,8 @@
                <el-input ref="inputName" v-model="queryParams.price" placeholder="合计" clearable style="width: 140px" />
              </el-form-item>
              <el-form-item label="优惠">
                <el-input-number ref="inputNumber" style="width: 150px" v-model="youhui" :precision="2"
                  :step="0.1" :max="10" :min="1"></el-input-number>
                <el-input-number ref="inputNumber" style="width: 150px" v-model="youhui" :precision="2" :step="0.1"
                  :max="10" :min="1" @change="numberChange"></el-input-number>
              </el-form-item>
              <el-form-item label="现价">
                <el-input ref="inputName" v-model="queryParams.xianprice" placeholder="合计" clearable
@@ -372,8 +372,8 @@
          <el-col :span="2" :xs="24">
            <div style="margin: 240% 16%">
              <el-button type="primary" size="medium " icon="el-icon-back"
                style="writing-mode: vertical-rl; text-align: center;letter-spacing: 10px;"
                @click="resetright">确认</el-button>
                style="writing-mode: vertical-rl; text-align: center;letter-spacing: 10px;" @click="resetright">确
                认</el-button>
            </div>
          </el-col>
          <el-col :span="11" :xs="24">
@@ -801,7 +801,7 @@
      this.updateProPrice(row); // 更新价格或其他逻辑
    },
    updateProPrice(row) {
      const proPrice = new Big(row.proPrice);
      const limits = new Big(row.limits);
@@ -810,7 +810,7 @@
      this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => {
        return sum.plus(new Big(item.ysPrice || '0'));
      }, new Big(0)).toNumber();
      this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price)*100)/100)*10
      this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10
    },
    getList() {
      this.$nextTick(() => {
@@ -971,16 +971,34 @@
        }
      });
    },
    // 折扣
    numberChange(currentValue) {
      this.forms.limits = currentValue;
      /* if (this.forms.limits > this.getInfodis) {
        this.forms.limits = this.getInfodis;
        this.forms.ysPrice = (
          this.forms.price *
          (this.forms.limits / 10)
        ).toFixed(2);
      } */
    numberChange(currentValue, oldValue) {
      this.$confirm("确定修改所有子项的折扣吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.youhui = currentValue;
          if (this.youhui < this.getInfodis) {
            this.youhui = this.getInfodis;
            // this.$modal.msgError(`该人员最高优惠权限为${this.getInfodis}折`);
          }
          this.OnenewpacName.forEach((item) => {
            item.limits = this.youhui
            const proPrice = new Big(item.proPrice);
            const limits = new Big(item.limits);
            const result = proPrice.times(limits.div(10));  // ordPrice * (discount / 10)
            item.ysPrice = result.toNumber();
            this.queryParams.xianprice = this.OnenewpacName.reduce((sum, item) => {
              return sum.plus(new Big(item.ysPrice || '0'));
            }, new Big(0));
          })
          // ----------------------------------------------------------
        })
        .catch(() => {
          this.youhui = oldValue;
        });
    },
@@ -1074,37 +1092,74 @@
        this.dataList = selection;
      }
    },
    // 单项选定按钮
    resetright() {
      this.queryParams.price = 0;
      this.dataList.forEach((item) => {
        this.$refs.tre.toggleRowSelection(item, false);
        this.OnenewpacName.push(item);
      });
  this.queryParams.price = 0;
  this.queryParams.xianprice = 0; // 初始化现价
  this.youhui = 0; // 初始化优惠
      for (var i = 0; i < this.OnenewpacName.length - 1; i++) {
        for (var j = i + 1; j < this.OnenewpacName.length; j++) {
          if (this.OnenewpacName[i].proId == this.OnenewpacName[j].proId) {
            this.OnenewpacName.splice(j, 1);
            j--;
          }
        }
  const newItemsToAdd = [];
  this.dataList.forEach((item) => {
    this.$refs.tre.toggleRowSelection(item, false);
    // 使用 $set 确保响应性
    this.$set(item, 'limits', 10);
    this.$set(item, 'ysPrice', item.proPrice);
    // 检查是否已经存在相同的项目
    const existingItem = this.OnenewpacName.find(existing => existing.proId === item.proId);
    if (!existingItem) {
      newItemsToAdd.push(item);
      this.updateProPrice(item); // 更新单个项目的价格
    }
  });
  // 添加新项目到 OnenewpacName
  this.OnenewpacName.push(...newItemsToAdd);
  // 删除重复项目,这里我们只需处理新添加的项目和原有项目之间的重复
  for (let i = this.OnenewpacName.length - newItemsToAdd.length; i < this.OnenewpacName.length - 1; i++) {
    for (let j = i + 1; j < this.OnenewpacName.length; j++) {
      if (this.OnenewpacName[i].proId === this.OnenewpacName[j].proId) {
        this.OnenewpacName.splice(j, 1);
        j--;
      }
      return this.OnenewpacName.forEach((item) => {
        this.queryParams.price += item.proPrice;
      });
    },
    handledbelete(row) {
      this.queryParams.price = 0;
      this.OnenewpacName.forEach((item, index) => {
        if (item.proId == row.proId) {
          this.OnenewpacName.splice(index, 1);
        }
      });
      return this.OnenewpacName.forEach((item) => {
        this.queryParams.price += item.proPrice;
      });
    },
    }
  }
  // 计算总价和现价
  this.OnenewpacName.forEach((item) => {
    this.queryParams.price += item.proPrice;
    this.queryParams.xianprice += item.ysPrice || 0; // 确保ysPrice存在
  });
  // 计算优惠
  if (this.queryParams.price > 0) {
    this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10;
  } else {
    this.youhui = 0;
  }
},
handledbelete(row) {
  this.queryParams.price = 0;
  this.queryParams.xianprice = 0; // 初始化现价
  this.youhui = 0; // 初始化优惠
  // 先找到并删除项目
  this.OnenewpacName = this.OnenewpacName.filter(item => item.proId !== row.proId);
  // 然后更新总价和现价
  this.OnenewpacName.forEach((item) => {
    this.queryParams.price += item.proPrice;
    this.queryParams.xianprice += item.ysPrice || 0; // 确保ysPrice存在
  });
  // 计算优惠
  if (this.queryParams.price > 0) {
    this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10;
  } else {
    this.youhui = 0;
  }
},
    submitrighr() {
      this.openOne = false;
@@ -1258,7 +1313,7 @@
          this.OnenewpacName.forEach((item, index) => {
            this.queryParams.price += item.proPrice;
          });
          this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price)*100)/100)*10
          this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10
        });
      }
      // console.log(this.groupList[0].id, 9966);
@@ -1311,7 +1366,7 @@
      });
      let data = {
        groupingName: this.forms.groupingName,