|
|
@@ -125,16 +125,56 @@ export default {
|
|
|
info: {
|
|
|
handler(v) {
|
|
|
if (v.sheetDTO && v.sheetDTO.length) {
|
|
|
- this.tabs = v.sheetDTO.map((item) => item.title)
|
|
|
- this.activeTab = this.tabs[this.activeTabIndex] || ''
|
|
|
- this.initData(this.activeTabIndex)
|
|
|
+ const ids = v.sheetDTO.map(item => item.title);
|
|
|
+
|
|
|
+ this.$common.request('query', {
|
|
|
+ key: 'cxsyxm',
|
|
|
+ params: ids
|
|
|
+ }).then(nameres => {
|
|
|
+ if (nameres.variables.data && nameres.variables.data.length > 0) {
|
|
|
+ const idToNameMap = {};
|
|
|
+ nameres.variables.data.forEach(item => {
|
|
|
+ idToNameMap[item.id_] = item.jian_yan_xiang_mu;
|
|
|
+ });
|
|
|
+
|
|
|
+ v.sheetDTO.forEach((sheetItem, index) => {
|
|
|
+ const id = sheetItem.title;
|
|
|
+ const name = idToNameMap[id];
|
|
|
+ if (name) {
|
|
|
+ sheetItem.title = name;
|
|
|
+
|
|
|
+ if (sheetItem.reportDataDTO) {
|
|
|
+ Object.keys(sheetItem.reportDataDTO).forEach(tableKey => {
|
|
|
+ const table = sheetItem.reportDataDTO[tableKey];
|
|
|
+ if (table && table.list && Array.isArray(table.list)) {
|
|
|
+ table.list.forEach(listItem => {
|
|
|
+ if (listItem.A === id) {
|
|
|
+ listItem.A = name;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.tabs = v.sheetDTO.map(item => item.title);
|
|
|
+ this.activeTab = this.tabs[this.activeTabIndex] || '';
|
|
|
+ this.initData(this.activeTabIndex);
|
|
|
+ }).catch(err => {
|
|
|
+
|
|
|
+ this.tabs = v.sheetDTO.map(item => item.title);
|
|
|
+ this.activeTab = this.tabs[this.activeTabIndex] || '';
|
|
|
+ this.initData(this.activeTabIndex);
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
immediate: true,
|
|
|
deep: true
|
|
|
},
|
|
|
activeTabIndex(v) {
|
|
|
- this.initData(v)
|
|
|
+ this.initData(v);
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -155,7 +195,7 @@ export default {
|
|
|
.map((k) => ({
|
|
|
title: k,
|
|
|
header:reportDataDTO[k]?.header || this.getTableHeader(reportDataDTO[k]?.list) || '',
|
|
|
- hideHeader: this.$utils.isEmpty(reportDataDTO[k].header),
|
|
|
+ hideHeader: this.$utils.isEmpty(reportDataDTO[k]?.header),
|
|
|
list: reportDataDTO[k].list,
|
|
|
note: reportDataDTO[k].note
|
|
|
}))
|
|
|
@@ -176,13 +216,16 @@ export default {
|
|
|
this.reportData = reportData
|
|
|
},
|
|
|
getTableHeader(data) {
|
|
|
- return data.length
|
|
|
- ? Object.keys(data[0]).map((key) => ({
|
|
|
- label: key,
|
|
|
- prop: key,
|
|
|
- slot: true
|
|
|
- }))
|
|
|
- : []
|
|
|
+ // 使用可选链操作符和空值合并运算符
|
|
|
+ if (!data?.length) {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+
|
|
|
+ return Object.keys(data[0]).map((key) => ({
|
|
|
+ label: key,
|
|
|
+ prop: key,
|
|
|
+ slot: true
|
|
|
+ }))
|
|
|
},
|
|
|
getSpanMethod(table) {
|
|
|
return (params) => {
|