refactor: 重构查询结果导出功能
- 修改导出文件名统一为英文 "QueryResults" - 更新导出数据格式,增加新字段并调整原有逻辑 - 优化代码结构,提高可读性和可维护性
This commit is contained in:
parent
b9b64ceb5a
commit
ceef159ec4
@ -178,7 +178,7 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
:icon="useRenderIcon(Export)"
|
:icon="useRenderIcon(Export)"
|
||||||
:disabled="!hasAuth('code:btn:export')"
|
:disabled="!hasAuth('code:btn:export')"
|
||||||
@click="exportToExcel([queryResult], '查询结果')"
|
@click="exportToExcel([queryResult], 'QueryResults')"
|
||||||
>
|
>
|
||||||
{{ t("buttons.ExportAll") }}
|
{{ t("buttons.ExportAll") }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
@ -123,6 +123,30 @@ export const useIndex = (tableRef: Ref) => {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: transformI18n($t("HtsDescription.tag.standard_description")),
|
||||||
|
prop: "result_text",
|
||||||
|
formatter: ({ result_text }) => {
|
||||||
|
if (result_text.length > 0) {
|
||||||
|
if (result_text[0]["hts_data"]) {
|
||||||
|
if (result_text[0]["hts_data"]["fiveResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["fiveResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["fourResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["fourResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["threeResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["threeResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["secondResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["secondResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["oneResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["oneResult"]["description"];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: transformI18n($t("buttons.Operation")),
|
label: transformI18n($t("buttons.Operation")),
|
||||||
fixed: "right",
|
fixed: "right",
|
||||||
@ -363,16 +387,20 @@ export const useIndex = (tableRef: Ref) => {
|
|||||||
transformI18n($t("QueryStatistics.tag.operationTime")),
|
transformI18n($t("QueryStatistics.tag.operationTime")),
|
||||||
transformI18n($t("QueryStatistics.tag.enterTextId")),
|
transformI18n($t("QueryStatistics.tag.enterTextId")),
|
||||||
transformI18n($t("QueryStatistics.tag.enterText")),
|
transformI18n($t("QueryStatistics.tag.enterText")),
|
||||||
transformI18n($t("QueryStatistics.tag.resultStatus"))
|
transformI18n($t("QueryStatistics.tag.resultStatus")),
|
||||||
|
transformI18n($t("QueryStatistics.tag.resultId")),
|
||||||
|
transformI18n($t("HtsDescription.tag.similar_code")),
|
||||||
|
transformI18n($t("HtsDescription.tag.similar_description")),
|
||||||
|
transformI18n($t("HtsDescription.tag.standard_description"))
|
||||||
];
|
];
|
||||||
for (let i = 1; i <= 5; i++) {
|
// for (let i = 1; i <= 5; i++) {
|
||||||
headers.push(
|
// headers.push(
|
||||||
`${transformI18n($t("QueryStatistics.tag.resultId")) + i}`,
|
// `${transformI18n($t("QueryStatistics.tag.resultId")) + i}`,
|
||||||
`${transformI18n($t("QueryStatistics.tag.HTSCode")) + i}`,
|
// `${transformI18n($t("QueryStatistics.tag.HTSCode")) + i}`,
|
||||||
`${transformI18n($t("QueryStatistics.tag.description")) + i}`,
|
// `${transformI18n($t("QueryStatistics.tag.description")) + i}`,
|
||||||
`${transformI18n($t("QueryStatistics.tag.matchRatio")) + i}`
|
// `${transformI18n($t("QueryStatistics.tag.matchRatio")) + i}`
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
const data = [];
|
const data = [];
|
||||||
let index = 1;
|
let index = 1;
|
||||||
for (const jsonData of dataList) {
|
for (const jsonData of dataList) {
|
||||||
@ -417,19 +445,63 @@ export const useIndex = (tableRef: Ref) => {
|
|||||||
if (typeof response.result_text === "string") {
|
if (typeof response.result_text === "string") {
|
||||||
response.result_text = JSON.parse(response.result_text);
|
response.result_text = JSON.parse(response.result_text);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 5; i++) {
|
if (response.result_text.length > 0) {
|
||||||
if (i < response.result_text.length) {
|
row.push(
|
||||||
const match = response.result_text[i];
|
response.result_text[0]["id"],
|
||||||
row.push(
|
response.result_text[0]["code"],
|
||||||
match.id,
|
response.result_text[0]["description"]
|
||||||
match.code,
|
);
|
||||||
match.description,
|
if (response.result_text[0]["hts_data"]) {
|
||||||
match.match_rate
|
if (response.result_text[0]["hts_data"]["fiveResult"]) {
|
||||||
);
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["fiveResult"][
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["fourResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["fourResult"][
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["threeResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["threeResult"][
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["secondResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["secondResult"][
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["oneResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["oneResult"][
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
row.push("");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
row.push("", "", "", "");
|
row.push("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// for (let i = 0; i < 5; i++) {
|
||||||
|
// if (i < response.result_text.length) {
|
||||||
|
// const match = response.result_text[i];
|
||||||
|
// row.push(
|
||||||
|
// match.id,
|
||||||
|
// match.code,
|
||||||
|
// match.description,
|
||||||
|
// match.match_rate
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// row.push("", "", "", "");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
data.push(row);
|
data.push(row);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -460,7 +532,7 @@ export const useIndex = (tableRef: Ref) => {
|
|||||||
response_result: selecteList
|
response_result: selecteList
|
||||||
};
|
};
|
||||||
|
|
||||||
exportToExcel([exportData], "查询结果");
|
exportToExcel([exportData], "QueryResults");
|
||||||
};
|
};
|
||||||
/**处理反馈 */
|
/**处理反馈 */
|
||||||
/**处理反馈 */
|
/**处理反馈 */
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<el-popconfirm
|
<el-popconfirm
|
||||||
v-if="hasAuth('code:btn:export')"
|
v-if="hasAuth('code:btn:export')"
|
||||||
:title="t('tip.exportAll')"
|
:title="t('tip.exportAll')"
|
||||||
@confirm="exportToExcel([queryInfo], '查询结果')"
|
@confirm="exportToExcel([queryInfo], 'QueryResults')"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button
|
<el-button
|
||||||
@ -353,6 +353,30 @@ const columns: TableColumnList = [
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: transformI18n($t("HtsDescription.tag.standard_description")),
|
||||||
|
prop: "result_text",
|
||||||
|
formatter: ({ result_text }) => {
|
||||||
|
if (result_text.length > 0) {
|
||||||
|
if (result_text[0]["hts_data"]) {
|
||||||
|
if (result_text[0]["hts_data"]["fiveResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["fiveResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["fourResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["fourResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["threeResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["threeResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["secondResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["secondResult"]["description"];
|
||||||
|
} else if (result_text[0]["hts_data"]["oneResult"]) {
|
||||||
|
return result_text[0]["hts_data"]["oneResult"]["description"];
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: transformI18n($t("buttons.Operation")),
|
label: transformI18n($t("buttons.Operation")),
|
||||||
fixed: "right",
|
fixed: "right",
|
||||||
@ -421,16 +445,20 @@ const exportToExcel = (dataList: QueryCodeLogInfo[], filename: string) => {
|
|||||||
transformI18n($t("QueryStatistics.tag.operationTime")),
|
transformI18n($t("QueryStatistics.tag.operationTime")),
|
||||||
transformI18n($t("QueryStatistics.tag.enterTextId")),
|
transformI18n($t("QueryStatistics.tag.enterTextId")),
|
||||||
transformI18n($t("QueryStatistics.tag.enterText")),
|
transformI18n($t("QueryStatistics.tag.enterText")),
|
||||||
transformI18n($t("QueryStatistics.tag.resultStatus"))
|
transformI18n($t("QueryStatistics.tag.resultStatus")),
|
||||||
|
transformI18n($t("QueryStatistics.tag.resultId")),
|
||||||
|
transformI18n($t("HtsDescription.tag.similar_code")),
|
||||||
|
transformI18n($t("HtsDescription.tag.similar_description")),
|
||||||
|
transformI18n($t("HtsDescription.tag.standard_description"))
|
||||||
];
|
];
|
||||||
for (let i = 1; i <= 5; i++) {
|
// for (let i = 1; i <= 5; i++) {
|
||||||
headers.push(
|
// headers.push(
|
||||||
`${transformI18n($t("QueryStatistics.tag.resultId")) + i}`,
|
// `${transformI18n($t("QueryStatistics.tag.resultId")) + i}`,
|
||||||
`${transformI18n($t("QueryStatistics.tag.HTSCode")) + i}`,
|
// `${transformI18n($t("QueryStatistics.tag.HTSCode")) + i}`,
|
||||||
`${transformI18n($t("QueryStatistics.tag.description")) + i}`,
|
// `${transformI18n($t("QueryStatistics.tag.description")) + i}`,
|
||||||
`${transformI18n($t("QueryStatistics.tag.matchRatio")) + i}`
|
// `${transformI18n($t("QueryStatistics.tag.matchRatio")) + i}`
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
const data = [];
|
const data = [];
|
||||||
let index = 1;
|
let index = 1;
|
||||||
for (const jsonData of dataList) {
|
for (const jsonData of dataList) {
|
||||||
@ -477,15 +505,52 @@ const exportToExcel = (dataList: QueryCodeLogInfo[], filename: string) => {
|
|||||||
queryTextDetail,
|
queryTextDetail,
|
||||||
queryStatus
|
queryStatus
|
||||||
];
|
];
|
||||||
|
if (response.result_text.length > 0) {
|
||||||
for (let i = 0; i < 5; i++) {
|
row.push(
|
||||||
if (i < response.result_text.length) {
|
response.result_text[0]["id"],
|
||||||
const match = response.result_text[i];
|
response.result_text[0]["code"],
|
||||||
row.push(match.id, match.code, match.description, match.match_rate);
|
response.result_text[0]["description"]
|
||||||
|
);
|
||||||
|
if (response.result_text[0]["hts_data"]) {
|
||||||
|
if (response.result_text[0]["hts_data"]["fiveResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["fiveResult"]["description"]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["fourResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["fourResult"]["description"]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["threeResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["threeResult"][
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["secondResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["secondResult"][
|
||||||
|
"description"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} else if (response.result_text[0]["hts_data"]["oneResult"]) {
|
||||||
|
row.push(
|
||||||
|
response.result_text[0]["hts_data"]["oneResult"]["description"]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
row.push("");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
row.push("", "", "", "");
|
row.push("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// for (let i = 0; i < 5; i++) {
|
||||||
|
// if (i < response.result_text.length) {
|
||||||
|
// const match = response.result_text[i];
|
||||||
|
// row.push(match.id, match.code, match.description, match.match_rate);
|
||||||
|
// } else {
|
||||||
|
// row.push("", "", "", "");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
data.push(row);
|
data.push(row);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -516,7 +581,7 @@ const onbatchExport = async () => {
|
|||||||
response_result: JSON.stringify(selecteList)
|
response_result: JSON.stringify(selecteList)
|
||||||
};
|
};
|
||||||
|
|
||||||
exportToExcel([exportData], "查询结果");
|
exportToExcel([exportData], "QueryResults");
|
||||||
};
|
};
|
||||||
/**处理反馈 */
|
/**处理反馈 */
|
||||||
const handleFeedback = async (
|
const handleFeedback = async (
|
||||||
|
@ -431,7 +431,7 @@ export const useQueryLog = (tableRef: Ref) => {
|
|||||||
endTime: form.timeRange[1] ? form.timeRange[1] : null
|
endTime: form.timeRange[1] ? form.timeRange[1] : null
|
||||||
});
|
});
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
exportToExcel(res.data.result, "全部查询结果");
|
exportToExcel(res.data.result, "AllQueryResults");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**批量导出 */
|
/**批量导出 */
|
||||||
@ -447,7 +447,7 @@ export const useQueryLog = (tableRef: Ref) => {
|
|||||||
ids.includes(item.id)
|
ids.includes(item.id)
|
||||||
); // 筛选出选中的数据
|
); // 筛选出选中的数据
|
||||||
|
|
||||||
exportToExcel(selecteList, "查询结果");
|
exportToExcel(selecteList, "QueryResults");
|
||||||
};
|
};
|
||||||
/**部门列表 */
|
/**部门列表 */
|
||||||
const departments = ref<DepartmentInfo[]>([]);
|
const departments = ref<DepartmentInfo[]>([]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user