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