yxh
2 天以前 484b1f3e41a561e438ce4cdbec0e09958c932767
src/views/project/components/fundsummary/index.vue
@@ -1,8 +1,18 @@
<!--  -->
<template>
  <div class="app-container" :donorno="donorno">
    <el-alert
      v-if="noCostData"
      title="该案例暂无成本数据"
      type="info"
      :closable="false"
      show-icon
      style="margin-bottom: 10px"
    />
    <el-table
      v-loading="costLoading"
      border
      class="table-bordered"
      :data="fundList"
      :span-method="objectSpanMethod"
      label-width="96px"
@@ -622,19 +632,22 @@
      organMedicineSupportCostRowIndex: 0,
      //器官获取手术成本合并行数
      organMedicineSupportCostRowSpan: 0,
      curdorno: null,
      // 成本明细加载中
      costLoading: false,
      // 当前案例是否没有成本数据
      noCostData: false,
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {
    //监听donorno发生改变时触发
    curdorno(newVal) {
      this.curdorno = newVal;
      //alert(this.donorno);
      //console.log("监听到捐献编号变化" + this.curdorno);
      this.getCostData(this.curdorno);
    // 监听案例 ID 变化,立即加载成本明细
    donorno: {
      immediate: true,
      handler(val) {
        this.getCostData(val);
      },
    },
  },
  //方法集合
@@ -911,55 +924,65 @@
    //调用接口获取成本数据
    getCostData(donorno) {
      getDonationCost(donorno).then((res) => {
      if (donorno === null || donorno === undefined || donorno === "") {
        this.costLoading = false;
        this.noCostData = false;
        return;
      }
      this.costLoading = true;
      this.noCostData = false;
      this.resetCostAmounts();
      getDonationCost(donorno)
        .then((res) => {
        if (res.code == 200) {
          let resList = res.data;
          var arr = [];
          for (var i in resList) {
            arr.push(resList[i]);
            const data = res.data || {};
            const before = [];
            for (let i = 1; i <= 52; i++) {
              before.push(data["fy" + i]);
          }
            before.push(data.fyhj);
            const after = [];
            for (let i = 1; i <= 52; i++) {
              after.push(data["sh" + i]);
            }
            after.push(data.shhj);
          let arr1 = arr.slice(0, 53);
          arr1.forEach((item, i) => {
            if (item !== 0) {
              this.fundList[i].amount = item.toFixed(2);
            let hasData = false;
            before.forEach((value, index) => {
              const num = Number(value);
              if (!Number.isNaN(num) && num !== 0) {
                this.fundList[index].amount = num.toFixed(2);
                hasData = true;
            }
          });
          arr1 = arr.slice(53, 106);
          arr1.forEach((item, i) => {
            if (item !== 0) {
              this.fundList[i].amounted = item.toFixed(2);
            after.forEach((value, index) => {
              const num = Number(value);
              if (!Number.isNaN(num) && num !== 0) {
                this.fundList[index].amounted = num.toFixed(2);
                hasData = true;
            }
          });
          // this.fundList = resList
          // for (let i = 0; i < resList.length; i++) {
          //   let itemIndex = this.fundList.findIndex(
          //     (item) => resList[i].itemname == item.itemname
          //   );
          //   console.log(itemIndex);
          //   if (itemIndex > -1) {
          //     if(resList[i].amount != "0.00"){
          //       this.fundList[itemIndex].amount =
          //       resList[i].amount;
          //     }else{
          //       this.fundList[itemIndex].amount =
          //       ""
          //     }
          //   }
          // }
            this.noCostData = !hasData;
          } else {
            this.$modal.msgError(res.msg || "获取成本明细失败");
        }
          this.costLoading = false;
        })
        .catch(() => {
          this.costLoading = false;
          this.$modal.msgError("获取成本明细失败");
        });
    },
    resetCostAmounts() {
      this.fundList.forEach((item) => {
        item.amount = "";
        item.amounted = "";
      });
    },
  },
  //生命周期 - 创建完成(可以访问当前this实例)
  created() {
    this.calculateRowSpanConfig();
  },
  //生命周期 - 挂载完成(可以访问DOM元素)
  mounted() {
    this.curdorno = this.donorno;
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前