| | |
| | | <!-- --> |
| | | <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" |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等) |
| | | //例如:import 《组件名称》 from '《组件路径》'; |
| | | import { getDonationCost, exportFundCost } from "@/api/project/financesubject"; |
| | | export default { |
| | | name: "fundsummary", |
| | |
| | | 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); |
| | | }, |
| | | }, |
| | | }, |
| | | //方法集合 |
| | |
| | | |
| | | //调用接口获取成本数据 |
| | | getCostData(donorno) { |
| | | getDonationCost(donorno).then((res) => { |
| | | if (res.code == 200) { |
| | | let resList = res.data; |
| | | debugger |
| | | var arr = []; |
| | | for (var i in resList) { |
| | | arr.push(resList[i]); |
| | | 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) { |
| | | 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 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; |
| | | } |
| | | }); |
| | | after.forEach((value, index) => { |
| | | const num = Number(value); |
| | | if (!Number.isNaN(num) && num !== 0) { |
| | | this.fundList[index].amounted = num.toFixed(2); |
| | | hasData = true; |
| | | } |
| | | }); |
| | | this.noCostData = !hasData; |
| | | } else { |
| | | this.$modal.msgError(res.msg || "获取成本明细失败"); |
| | | } |
| | | |
| | | let arr1 = arr.slice(0, 53); |
| | | arr1.forEach((item, i) => { |
| | | if (item !== 0) { |
| | | this.fundList[i].amount = item.toFixed(2); |
| | | } |
| | | }); |
| | | |
| | | arr1 = arr.slice(53, 106); |
| | | arr1.forEach((item, i) => { |
| | | if (item !== 0) { |
| | | this.fundList[i].amounted = item.toFixed(2); |
| | | } |
| | | }); |
| | | |
| | | // 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.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() {}, //生命周期 - 挂载之前 |