feat: 添加更多文件类型支持,添加全部通过功能

This commit is contained in:
皓月归尘 2025-03-04 03:36:44 +08:00
parent ffdb1d07a3
commit b21510f8a9
11 changed files with 163 additions and 58 deletions

View File

@ -44,6 +44,7 @@ buttons:Deselect: Deselect
buttons:DeleteInBatches: Delete In Batches buttons:DeleteInBatches: Delete In Batches
buttons:ExportInBatches: Export In Batches buttons:ExportInBatches: Export In Batches
buttons:AgressInBatches: Agress In Batches buttons:AgressInBatches: Agress In Batches
buttons:AgressAll: Agress All
buttons:DisagressInBatches: Disagress In Batches buttons:DisagressInBatches: Disagress In Batches
buttons:ExitInBatches: Exit In Batches buttons:ExitInBatches: Exit In Batches
buttons:ExportAll: Export All buttons:ExportAll: Export All
@ -55,7 +56,7 @@ buttons:ForceToExit: Force Exit
buttons:DataAdmin: Data Admin buttons:DataAdmin: Data Admin
buttons:Audit: Audit buttons:Audit: Audit
buttons:Feedback: Feedback buttons:Feedback: Feedback
buttons:ErrorRecovery: Error Recovery buttons:ErrorRecovery: Report Code Error
search:Total: Total search:Total: Total
search:History: History search:History: History
search:Collect: Collect search:Collect: Collect
@ -125,8 +126,8 @@ menus:CodeQueryCount: Query Statistics
menus:QueryCodedetails: Log Detail menus:QueryCodedetails: Log Detail
menus:DataQuality: Data Quality menus:DataQuality: Data Quality
menus:DataImport: Data Import menus:DataImport: Data Import
menus:DataFeedback: Data Feedback menus:DataFeedback: Data Review
menus:DataMaintain: Data Export menus:DataMaintain: Data Maintenance
status:Load: Loading... status:Load: Loading...
status:Message: Message status:Message: Message
status:Notify: Notify status:Notify: Notify

View File

@ -44,6 +44,7 @@ buttons:Deselect: 取消选择
buttons:DeleteInBatches: 批量删除 buttons:DeleteInBatches: 批量删除
buttons:ExportInBatches: 批量导出 buttons:ExportInBatches: 批量导出
buttons:AgressInBatches: 批量通过 buttons:AgressInBatches: 批量通过
buttons:AgressAll: 全部通过
buttons:DisagressInBatches: 批量驳回 buttons:DisagressInBatches: 批量驳回
buttons:ExportAll: 全部导出 buttons:ExportAll: 全部导出
buttons:UploadAvatar: 上传头像 buttons:UploadAvatar: 上传头像

View File

@ -11,8 +11,8 @@ import { filterEmptyObject } from "./utils";
/** /**
* *
*/ */
export const getCodeTemplateAPI = () => { export const getCodeTemplateAPI = (type: string) => {
return http.request<Blob>("get", "/api/code/template", { return http.request<Blob>("get", `/api/code/template/${type}`, {
responseType: "blob" // 设置响应类型为 blob responseType: "blob" // 设置响应类型为 blob
}); });
}; };
@ -20,8 +20,8 @@ export const getCodeTemplateAPI = () => {
/** /**
* *
*/ */
export const getQueryTemplateAPI = () => { export const getQueryTemplateAPI = (type: string) => {
return http.request<Blob>("get", "/api/code/queryTemplate", { return http.request<Blob>("get", `/api/code/queryTemplate/${type}`, {
responseType: "blob" // 设置响应类型为 blob responseType: "blob" // 设置响应类型为 blob
}); });
}; };
@ -326,3 +326,8 @@ export const putCodeFeedbackAuditAPI = (data: {
}) => { }) => {
return http.request<null>("put", `/api/code/feedbackAudit`, { data }); return http.request<null>("put", `/api/code/feedbackAudit`, { data });
}; };
/**全部审核通过 */
export const putCodeFeedbackAuditAllAPI = () => {
return http.request<null>("put", `/api/codeImportAudit/all`);
};

View File

@ -9,7 +9,7 @@
<el-form-item label="查询文本" prop="query_text" class="w-[50%]"> <el-form-item label="查询文本" prop="query_text" class="w-[50%]">
<el-input <el-input
v-model="form.query_text" v-model="form.query_text"
placeholder="请输入查询文本~" placeholder="请输入商品文本描述~"
class="w-full" class="w-full"
clearable clearable
type="textarea" type="textarea"
@ -57,7 +57,6 @@
<IconifyIconOffline <IconifyIconOffline
:icon="UploadIcon" :icon="UploadIcon"
width="26" width="26"
:limit="1"
class="m-auto mb-2" class="m-auto mb-2"
/> />
可点击或拖拽上传 可点击或拖拽上传
@ -67,9 +66,24 @@
<div class="flex items-center justify-center"> <div class="flex items-center justify-center">
<el-button <el-button
class="w-full my-2" class="w-full my-2"
:disabled="hasAuth('code:btn:queryTemplate')" type="success"
@click="onDownloadTemplate" :disabled="!hasAuth('code:btn:queryTemplate')"
>{{ t("buttons:DownLodedTemplate") }}</el-button @click="onDownloadTemplate('xlsx')"
>{{ t("buttons:DownLodedTemplate") }}(.xlsx)</el-button
>
<el-button
class="w-full my-2"
type="warning"
:disabled="!hasAuth('code:btn:queryTemplate')"
@click="onDownloadTemplate('csv')"
>{{ t("buttons:DownLodedTemplate") }}(.csv)</el-button
>
<el-button
class="w-full my-2"
type="info"
:disabled="!hasAuth('code:btn:queryTemplate')"
@click="onDownloadTemplate('xls')"
>{{ t("buttons:DownLodedTemplate") }}(.xls)</el-button
> >
<el-popconfirm title="是否确认上传?" @confirm="handleUpload"> <el-popconfirm title="是否确认上传?" @confirm="handleUpload">
<template #reference> <template #reference>

View File

@ -161,9 +161,9 @@ export const useIndex = (tableRef: Ref) => {
tableRef.value.getTableRef().clearSelection(); tableRef.value.getTableRef().clearSelection();
}; };
/**下载模版文件 */ /**下载模版文件 */
const onDownloadTemplate = async () => { const onDownloadTemplate = async (type: string) => {
try { try {
const blob = await getQueryTemplateAPI(); const blob = await getQueryTemplateAPI(type);
// 生成下载链接 // 生成下载链接
// @ts-ignore // @ts-ignore
@ -172,7 +172,7 @@ export const useIndex = (tableRef: Ref) => {
// 创建 <a> 元素并触发下载 // 创建 <a> 元素并触发下载
const link = document.createElement("a"); const link = document.createElement("a");
link.href = url; link.href = url;
link.download = "上传模版.xlsx"; // 设置下载文件名,确保后缀名正确 link.download = `上传模版.${type}`; // 设置下载文件名,确保后缀名正确
document.body.appendChild(link); // 将 <a> 元素添加到 DOM 中 document.body.appendChild(link); // 将 <a> 元素添加到 DOM 中
link.click(); // 模拟点击下载 link.click(); // 模拟点击下载
@ -184,13 +184,16 @@ export const useIndex = (tableRef: Ref) => {
} }
}; };
/** 上传文件前 */ /** 上传文件前 */
/** 上传文件前 */
const beforeUpload = async file => { const beforeUpload = async file => {
const isExcel = const isExcel =
file.type === file.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || // xlsx "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || // xlsx
file.type === "application/vnd.ms-excel" || // xls file.type === "application/vnd.ms-excel" || // xls
file.type === "text/csv" ||
file.name.endsWith(".xlsx") || // 兼容部分浏览器 file.name.endsWith(".xlsx") || // 兼容部分浏览器
file.name.endsWith(".xls"); // 兼容部分浏览器 file.name.endsWith(".xls") || // 兼容部分浏览器
file.name.endsWith(".csv"); // 兼容部分浏览器
// const maxSize = 20 * 1024 * 1024; // 20MB 限制 // const maxSize = 20 * 1024 * 1024; // 20MB 限制

View File

@ -112,7 +112,7 @@
'纠错', '纠错',
row.result_text[0], row.result_text[0],
row.query_text, row.query_text,
row.result_text[0].code ?? '' row.result_text[0]?.code ?? ''
) )
" "
> >

View File

@ -118,6 +118,7 @@
v-model:file-list="fileList" v-model:file-list="fileList"
drag drag
action="#" action="#"
:limit="10"
class="w-full" class="w-full"
:auto-upload="false" :auto-upload="false"
:before-upload="beforeUpload" :before-upload="beforeUpload"
@ -127,7 +128,6 @@
<IconifyIconOffline <IconifyIconOffline
:icon="UploadIcon" :icon="UploadIcon"
width="26" width="26"
:limit="1"
class="m-auto mb-2" class="m-auto mb-2"
/> />
可点击或拖拽上传 可点击或拖拽上传
@ -138,9 +138,26 @@
<el-button <el-button
v-if="hasAuth('code:btn:uploadTemplate')" v-if="hasAuth('code:btn:uploadTemplate')"
class="w-full my-2" class="w-full my-2"
type="success"
:disabled="!hasAuth('code:btn:uploadTemplate')" :disabled="!hasAuth('code:btn:uploadTemplate')"
@click="onDownloadTemplate" @click="onDownloadTemplate('xlsx')"
>{{ t("buttons:DownLodedTemplate") }}</el-button >{{ t("buttons:DownLodedTemplate") }}(.xlsx)</el-button
>
<el-button
v-if="hasAuth('code:btn:uploadTemplate')"
class="w-full my-2"
type="warning"
:disabled="!hasAuth('code:btn:uploadTemplate')"
@click="onDownloadTemplate('csv')"
>{{ t("buttons:DownLodedTemplate") }}(.csv)</el-button
>
<el-button
v-if="hasAuth('code:btn:uploadTemplate')"
class="w-full my-2"
type="info"
:disabled="!hasAuth('code:btn:uploadTemplate')"
@click="onDownloadTemplate('csv')"
>{{ t("buttons:DownLodedTemplate") }}(.xls)</el-button
> >
<el-popconfirm <el-popconfirm
v-if="hasAuth('code:btn:import')" v-if="hasAuth('code:btn:import')"
@ -175,6 +192,24 @@
{{ t("buttons:Deselect") }} {{ t("buttons:Deselect") }}
</el-button> </el-button>
</div> </div>
<el-popconfirm
v-if="hasAuth('code:btn:codeImportAuditAll')"
title="是否确认通过审核?"
@confirm="onbatchAgreeAll"
>
<template #reference>
<el-button
type="success"
text
class="mr-1"
:disabled="
selectedNum < 0 || !hasAuth('code:btn:codeImportAuditAll')
"
>
{{ t("buttons:AgressAll") }}
</el-button>
</template>
</el-popconfirm>
<el-popconfirm <el-popconfirm
v-if="hasAuth('code:btn:codeImportAudit')" v-if="hasAuth('code:btn:codeImportAudit')"
title="是否确认通过审核?" title="是否确认通过审核?"
@ -350,7 +385,8 @@ const {
onDownloadTemplate, onDownloadTemplate,
handleAudit, handleAudit,
onbatchDisagree, onbatchDisagree,
onbatchAgree onbatchAgree,
onbatchAgreeAll
} = useCode(tableRef); } = useCode(tableRef);
</script> </script>

View File

@ -12,6 +12,7 @@ import {
getCodeImportListAPI, getCodeImportListAPI,
getCodeTemplateAPI, getCodeTemplateAPI,
postAddCodeAPI, postAddCodeAPI,
putCodeFeedbackAuditAllAPI,
putCodeImportAuditAPI, putCodeImportAuditAPI,
putUpdateCodeImportAPI putUpdateCodeImportAPI
} from "@/api/code"; } from "@/api/code";
@ -358,9 +359,9 @@ export const useCode = (tableRef: Ref) => {
}); });
}; };
/**下载模版文件 */ /**下载模版文件 */
const onDownloadTemplate = async () => { const onDownloadTemplate = async (type: string) => {
try { try {
const blob = await getCodeTemplateAPI(); const blob = await getCodeTemplateAPI(type);
// 生成下载链接 // 生成下载链接
// @ts-ignore // @ts-ignore
@ -369,7 +370,7 @@ export const useCode = (tableRef: Ref) => {
// 创建 <a> 元素并触发下载 // 创建 <a> 元素并触发下载
const link = document.createElement("a"); const link = document.createElement("a");
link.href = url; link.href = url;
link.download = "上传模版.xlsx"; // 设置下载文件名,确保后缀名正确 link.download = `上传模版.${type}`; // 设置下载文件名,确保后缀名正确
document.body.appendChild(link); // 将 <a> 元素添加到 DOM 中 document.body.appendChild(link); // 将 <a> 元素添加到 DOM 中
link.click(); // 模拟点击下载 link.click(); // 模拟点击下载
@ -386,8 +387,10 @@ export const useCode = (tableRef: Ref) => {
file.type === file.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || // xlsx "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || // xlsx
file.type === "application/vnd.ms-excel" || // xls file.type === "application/vnd.ms-excel" || // xls
file.type === "text/csv" ||
file.name.endsWith(".xlsx") || // 兼容部分浏览器 file.name.endsWith(".xlsx") || // 兼容部分浏览器
file.name.endsWith(".xls"); // 兼容部分浏览器 file.name.endsWith(".xls") || // 兼容部分浏览器
file.name.endsWith(".csv"); // 兼容部分浏览器
// const maxSize = 20 * 1024 * 1024; // 20MB 限制 // const maxSize = 20 * 1024 * 1024; // 20MB 限制
@ -414,11 +417,12 @@ export const useCode = (tableRef: Ref) => {
uploadStatus.value = true; uploadStatus.value = true;
for (const file of fileList.value) { for (const file of fileList.value) {
if (file.status === "success") { if (file.status === "success") {
const data = await getAddCodeAPI(fileId.value); // const data =
if (data.success) { await getAddCodeAPI(fileId.value);
message("导入成功!", { type: "success" }); // if (data.success) {
await onSearch(); // message("导入成功", { type: "success" });
} // await onSearch();
// }
continue; continue;
} }
try { try {
@ -430,11 +434,12 @@ export const useCode = (tableRef: Ref) => {
fileId.value = res.data.id; fileId.value = res.data.id;
message(`${res.data.name}上传成功!`, { type: "success" }); message(`${res.data.name}上传成功!`, { type: "success" });
fileIds.value.push(res.data); fileIds.value.push(res.data);
const data = await getAddCodeAPI(fileId.value); // const data =
if (data.success) { await getAddCodeAPI(fileId.value);
message(`导入成功!`, { type: "success" }); // if (data.success) {
await onSearch(); // message(`导入成功!`, { type: "success" });
} // await onSearch();
// }
} else { } else {
file.status = "fail"; file.status = "fail";
} }
@ -605,6 +610,18 @@ export const useCode = (tableRef: Ref) => {
message(res.msg, { type: "error", duration: 5000 }); message(res.msg, { type: "error", duration: 5000 });
} }
}; };
/**全部通过 */
const onbatchAgreeAll = async () => {
const res = await putCodeFeedbackAuditAllAPI();
if (res.success) {
message(res.msg, {
type: "success"
});
onSearch();
} else {
message(res.msg, { type: "error", duration: 5000 });
}
};
/**批量驳回 */ /**批量驳回 */
const onbatchDisagree = async () => { const onbatchDisagree = async () => {
// 返回当前选中的行 // 返回当前选中的行
@ -654,6 +671,7 @@ export const useCode = (tableRef: Ref) => {
onDownloadTemplate, onDownloadTemplate,
handleAudit, handleAudit,
onbatchDisagree, onbatchDisagree,
onbatchAgree onbatchAgree,
onbatchAgreeAll
}; };
}; };

View File

@ -118,6 +118,7 @@
v-model:file-list="fileList" v-model:file-list="fileList"
drag drag
action="#" action="#"
:limit="10"
class="w-full" class="w-full"
:auto-upload="false" :auto-upload="false"
:before-upload="beforeUpload" :before-upload="beforeUpload"
@ -127,7 +128,6 @@
<IconifyIconOffline <IconifyIconOffline
:icon="UploadIcon" :icon="UploadIcon"
width="26" width="26"
:limit="1"
class="m-auto mb-2" class="m-auto mb-2"
/> />
可点击或拖拽上传 可点击或拖拽上传
@ -138,9 +138,26 @@
<el-button <el-button
v-if="hasAuth('code:btn:uploadTemplate')" v-if="hasAuth('code:btn:uploadTemplate')"
class="w-full my-2" class="w-full my-2"
type="success"
:disabled="!hasAuth('code:btn:uploadTemplate')" :disabled="!hasAuth('code:btn:uploadTemplate')"
@click="onDownloadTemplate" @click="onDownloadTemplate('xlsx')"
>{{ t("buttons:DownLodedTemplate") }}</el-button >{{ t("buttons:DownLodedTemplate") }}(.xlsx)</el-button
>
<el-button
v-if="hasAuth('code:btn:uploadTemplate')"
class="w-full my-2"
type="warning"
:disabled="!hasAuth('code:btn:uploadTemplate')"
@click="onDownloadTemplate('csv')"
>{{ t("buttons:DownLodedTemplate") }}(.csv)</el-button
>
<el-button
v-if="hasAuth('code:btn:uploadTemplate')"
class="w-full my-2"
type="info"
:disabled="!hasAuth('code:btn:uploadTemplate')"
@click="onDownloadTemplate('xls')"
>{{ t("buttons:DownLodedTemplate") }}(.xls)</el-button
> >
<el-popconfirm <el-popconfirm
v-if="hasAuth('code:btn:import')" v-if="hasAuth('code:btn:import')"

View File

@ -298,9 +298,9 @@ export const useCode = (tableRef: Ref) => {
}); });
}; };
/**下载模版文件 */ /**下载模版文件 */
const onDownloadTemplate = async () => { const onDownloadTemplate = async (type: string) => {
try { try {
const blob = await getCodeTemplateAPI(); const blob = await getCodeTemplateAPI(type);
// 生成下载链接 // 生成下载链接
// @ts-ignore // @ts-ignore
@ -326,8 +326,10 @@ export const useCode = (tableRef: Ref) => {
file.type === file.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || // xlsx "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || // xlsx
file.type === "application/vnd.ms-excel" || // xls file.type === "application/vnd.ms-excel" || // xls
file.type === "text/csv" ||
file.name.endsWith(".xlsx") || // 兼容部分浏览器 file.name.endsWith(".xlsx") || // 兼容部分浏览器
file.name.endsWith(".xls"); // 兼容部分浏览器 file.name.endsWith(".xls") || // 兼容部分浏览器
file.name.endsWith(".csv"); // 兼容部分浏览器
// const maxSize = 20 * 1024 * 1024; // 20MB 限制 // const maxSize = 20 * 1024 * 1024; // 20MB 限制
@ -354,11 +356,12 @@ export const useCode = (tableRef: Ref) => {
uploadStatus.value = true; uploadStatus.value = true;
for (const file of fileList.value) { for (const file of fileList.value) {
if (file.status === "success") { if (file.status === "success") {
const data = await getAddCodeAPI(fileId.value); // const data =
if (data.success) { await getAddCodeAPI(fileId.value);
message("导入成功!", { type: "success" }); // if (data.success) {
await onSearch(); // message("导入成功!", { type: "success" });
} // await onSearch();
// }
continue; continue;
} }
try { try {
@ -370,11 +373,12 @@ export const useCode = (tableRef: Ref) => {
fileId.value = res.data.id; fileId.value = res.data.id;
message(`${res.data.name}上传成功!`, { type: "success" }); message(`${res.data.name}上传成功!`, { type: "success" });
fileIds.value.push(res.data); fileIds.value.push(res.data);
const data = await getAddCodeAPI(fileId.value); // const data =
if (data.success) { await getAddCodeAPI(fileId.value);
message(`导入成功!`, { type: "success" }); // if (data.success) {
await onSearch(); // message(`导入成功!`, { type: "success" });
} // await onSearch();
// }
} else { } else {
file.status = "fail"; file.status = "fail";
} }

View File

@ -5,6 +5,7 @@ import { transformI18n } from "@/plugins/i18n";
import { IconSelect } from "@/components/ReIcon"; import { IconSelect } from "@/components/ReIcon";
import Segmented, { OptionsType } from "@/components/ReSegmented"; import Segmented, { OptionsType } from "@/components/ReSegmented";
import ReAnimateSelector from "@/components/ReAnimateSelector"; import ReAnimateSelector from "@/components/ReAnimateSelector";
import { hasAuth } from "@/utils/auth";
import type { FormRules } from "element-plus"; import type { FormRules } from "element-plus";
const menuTypeOptions: Array<OptionsType> = [ const menuTypeOptions: Array<OptionsType> = [
@ -433,7 +434,12 @@ defineExpose({ getRef });
/> />
</el-form-item> </el-form-item>
</re-col> </re-col>
<re-col v-if="newFormInline.menu_type < 3" :value="12" :xs="24" :sm="24"> <re-col
v-if="hasAuth('permission:btn:admin')"
:value="12"
:xs="24"
:sm="24"
>
<el-form-item label="管理专属"> <el-form-item label="管理专属">
<Segmented <Segmented
:modelValue="newFormInline.is_admin ? 0 : 1" :modelValue="newFormInline.is_admin ? 0 : 1"