z
wwl
2025-01-06 9bf8ea5b40a41425148ca99f012c76bbdb44daf2
z
1个文件已修改
69 ■■■■■ 已修改文件
src/views/system/comp/index.vue 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/comp/index.vue
@@ -1093,44 +1093,53 @@
      }
    },
    resetright() {
      this.queryParams.price = 0;
      this.queryParams.xianprice = 0; // 初始化现价
      this.youhui = 0; // 初始化优惠
  if (this.dataList.length == 0) {
    return; // 如果数据列表为空,直接返回
  } else {
    this.queryParams.price = 0; // 初始化总价
    this.queryParams.xianprice = 0; // 初始化现价
    this.youhui = 0; // 初始化优惠
      const newItemsToAdd = [];
    const newItemsToAdd = []; // 用于存储新需要添加的项目
      this.dataList.forEach((item) => {
        this.$refs.tre.toggleRowSelection(item, false);
        // 使用 $set 确保响应性
        this.$set(item, 'limits', 10);
        this.$set(item, 'ysPrice', item.proPrice);
    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); // 更新单个项目的价格
        }
      });
      // 检查是否已经存在相同的项目
      const existingItem = this.OnenewpacName.find(existing => existing.proId === item.proId);
      if (!existingItem) {
        newItemsToAdd.push(item); // 如果不存在相同项目,则添加到新数组
        this.updateProPrice(item); // 更新单个项目的价格
      }
    });
      // 添加新项目到 OnenewpacName
      this.OnenewpacName.push(...newItemsToAdd);
    // 添加新项目到 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--;
          }
    // 删除重复项目,这里我们只需处理新添加的项目和原有项目之间的重复
    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--; // 因为删除了一个元素,当前的j要减1
        }
      }
    }
    this.queryParams.price = 0
    this.queryParams.xianprice = 0
    // 重新计算总价和现价
    this.OnenewpacName.forEach((item) => {
      this.queryParams.price += item.proPrice; // 累加原价
      this.queryParams.xianprice += item.ysPrice || 0; // 累加现价,如果ysPrice为undefined则累加0
    });
      this.OnenewpacName.forEach((item) => {
        this.queryParams.price += item.proPrice;
        this.queryParams.xianprice += item.ysPrice || 0; // 确保ysPrice存在
      })
    },
    // 计算优惠,这里假设优惠是现价与原价的差额百分比
    this.youhui = (Math.floor((this.queryParams.xianprice / this.queryParams.price) * 100) / 100) * 10;
  }
},
    handledbelete(row) {
      this.queryParams.price = 0;
      this.queryParams.xianprice = 0; // 初始化现价