1
wwl
2025-01-22 067c77dee145023f983eea591dfaf3be8ffc1ab9
src/views/system/tijian/index.vue
@@ -1075,6 +1075,9 @@
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
    filterage(val) {
      this.$refs.treas.filter(val);
    },
@@ -2511,7 +2514,6 @@
      this.loading = true;
      getProParentIdDxList().then((response) => {
        this.Treedata = response.data.list;
        if (this.tableData[0]) {
          this.tableData[0].tjProjectList.forEach((selectionitem) => {
            this.Treedata.forEach((item) => {
@@ -2626,30 +2628,36 @@
        });
      }
    },
    // 点击获取每个树节点
    handleCurrentChecked(data, checked, checkedNodes) {
      this.dataObj = data;
      if (checked.checkedNodes.length != 0) {
        let proId = data.proId;
        getProSonDxList(proId).then((res) => {
          this.TreedataList = res.data.list;
      if (checked.checkedNodes.length > 0) {
        const promises = checked.checkedNodes.map(node => getProSonDxList(node.proId));
        Promise.all(promises).then(results => {
          this.TreedataList = results.flatMap(res => res.data.list);
          this.checkedListkey = [];
          this.DataList = [];
          this.TreedataList.forEach((item) => {
            this.checkedListkey.push(item.proId);
            this.DataList.push(item);
            this.spliceData();
            this.DataList.forEach((item1) => {
              if (item1.proParentId == data.proId) {
                item1.propinName = data.proName;
              }
            });
          });
          this.spliceData(); // 假设这个方法是你定义的其他地方处理数据的
          // 更新名称和计算总价
          this.DataList.forEach((item1) => {
            const parent = checked.checkedNodes.find(node => node.proId === item1.proParentId);
            if (parent) {
              item1.propinName = parent.proName;
            }
          });
          this.TotalPrice1 = 0;
          this.marryall = 0;
          if (this.DataList.length != 0) {
            this.list1 = false;
            this.DataList.forEach((item) => {
              this.marryall = item.proPrice * item.sl;
              this.marryall += Number(item.proPrice) * Number(item.sl);
            });
          }
        });
@@ -2830,13 +2838,11 @@
      this.DataLists = [];
    },
    // 处理订单项目
    processOrderItems(cusId) {
      getTransitionList1(cusId).then((response) => {
        this.tableData1 = response.data;
        if (this.tableData1) {
          let totalOrdPrice = new Big(0);
          let totalNowPrice = new Big(0);
          this.tableData1.forEach((item) => {
            if (item.tjCategory != null) {
              this.tjCategory = item.tjCategory;
@@ -2846,18 +2852,9 @@
                this.treeList.push(item9.proId);
              });
            }
            // 使用Big.js进行加法以避免精度丢失
            totalOrdPrice = totalOrdPrice.plus(new Big(item.ordPrice || 0));
            totalNowPrice = totalNowPrice.plus(new Big(item.nowPrice || 0));
            this.TotalPrice1 += item.ordPrice || 0; // 累加应收金额
            this.TotalPrice += item.nowPrice || 0; // 累加实收金额
          });
          // 将Big数转换回数值并保留两位小数
          this.TotalPrice1 = totalOrdPrice.toNumber().toFixed(2);
          this.TotalPrice = totalNowPrice.toNumber().toFixed(2);
          // 确保TotalPrice是一个字符串,防止后续操作导致精度丢失
          this.TotalPrice = this.TotalPrice.toString();
          // 计算折扣
          this.discount = this.TotalPrice1 > 0 ?
            (Math.floor((this.TotalPrice / this.TotalPrice1) * 100) / 100) * 10 : 0;