1
wwl
2025-01-08 aa4451fa555c7d86502c0416a5cf3be343acb67c
src/views/system/comp/index.vue
@@ -341,7 +341,7 @@
              </el-form-item>
              <el-form-item label="现价">
                <el-input ref="inputName" v-model="queryParams.xianprice" placeholder="合计" clearable
                  style="width: 140px" />
                  style="width: 140px" @input="changeXianjia" @blur="numberChangeXianPrice(youhui, youhui)" />
              </el-form-item>
              <el-form-item>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuerys">重置</el-button>
@@ -459,8 +459,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="8" :xs="24">
@@ -804,6 +804,13 @@
    this.getList();
  },
  methods: {
    changeXianjia() {
      // 原始折扣率计算
      this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10
    },
    validateDiscount(row) {
      if (row.limits > 10) {
        row.limits = 10; // 强制将值设置为最大值
@@ -1014,7 +1021,44 @@
        });
    },
    numberChangeXianPrice(currentValue, oldValue) {
      this.$confirm("确定修改所有子项的折扣吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.youhui = currentValue;
          if (this.youhui < this.getInfodis) {
            this.youhui = this.getInfodis;
          }
          let totalYsprice = new Big(0); // 初始化总 ysprice
          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();
            totalYsprice = totalYsprice.plus(new Big(item.ysPrice));
          });
          // 计算完所有 ysPrice 后进行调整
          if (totalYsprice.toNumber() !== this.queryParams.xianprice) {
            const diff = this.queryParams.xianprice - totalYsprice.toNumber();
            if (this.OnenewpacName.length > 0) {
              const lastItem = this.OnenewpacName[this.OnenewpacName.length - 1];
              lastItem.ysPrice += diff;
              // 调整后更新 queryParams.xianprice
              this.queryParams.xianprice = totalYsprice.plus(diff).toNumber();
            }
          }
        })
        .catch(() => {
          this.youhui = oldValue;
        });
    },
    changegroupingName() {
      if (this.selectionList.length <= 0) {
        this.$modal.msgError("请先选中部门或添加新的部门");