diff --git a/src/api/price/excel.ts b/src/api/price/excel.ts new file mode 100644 index 0000000..f56125b --- /dev/null +++ b/src/api/price/excel.ts @@ -0,0 +1,154 @@ +/** + * 价格库Excel相关API + */ +import request from "@/api/request"; + +/** + * Excel导入请求参数 + */ +export interface ImportExcelParams { + file: File; + batchName?: string; +} + +/** + * 搜索请求参数 + */ +export interface SearchExcelParams { + keyword: string; + current?: number; + size?: number; + batchId?: string; +} + +/** + * 批次信息 + */ +export interface BatchInfo { + batchId: string; + batchName: string; + fileName: string; + totalRows: number; + uploadTime: string; +} + +/** + * Excel行数据 + */ +export interface ExcelRowData { + id: number; + fileName: string; + filePath: string; + sheetName: string; + rowIndex: number; + rowData: string; + batchId: string; + batchName: string; + uploadTime: string; +} + +/** + * 搜索联想结果项 + */ +export interface SearchSuggestion { + batchId: string; + batchName: string; + fileName: string; + matchType: 'name' | 'data'; + matchContent: string; + rowData?: ExcelRowData; +} + +/** + * Excel多Sheet导入 + * @param file 上传的文件 + * @param batchName 批次名称(可选) + */ +export function importExcel(file: File, batchName?: string) { + const formData = new FormData(); + formData.append('file', file); + if (batchName) { + formData.append('batchName', batchName); + } + return request.post({ + url: '/price/excel/import', + body: formData, + headers: { 'Content-Type': 'multipart/form-data' } + }); +} + +/** + * 搜索Excel数据(用于联想下拉) + * @param keyword 搜索关键字 + * @param size 返回数量(默认10条) + */ +export function searchExcelData(keyword: string, size: number = 10) { + return request.post({ + url: '/price/excel/search', + body: { + keyword, + size, + current: 1 + } + }); +} + +/** + * 分页搜索Excel数据 + * @param params 搜索参数 + */ +export function searchExcelDataPage(params: SearchExcelParams) { + return request.post({ + url: '/price/excel/search', + body: { + keyword: params.keyword, + current: params.current || 1, + size: params.size || 10, + batchId: params.batchId + } + }); +} + +/** + * 根据批次ID查询所有数据 + * @param batchId 批次ID + */ +export function getBatchData(batchId: string) { + return request.get({ + url: `/price/excel/batch/${batchId}` + }); +} + +/** + * 删除批次数据 + * @param batchId 批次ID + */ +export function deleteBatch(batchId: string) { + return request.del({ + url: `/price/excel/batch/${batchId}` + }); +} + +/** + * 分页获取批次列表 + * @param keyword 搜索关键字(可选) + * @param current 当前页 + * @param size 每页大小 + */ +export function getBatchListPage(keyword?: string, current?: number, size?: number) { + return request.get({ + url: '/price/excel/batch/list', + params: { keyword, current, size } + }); +} + +/** + * 删除批次数据 + * @param batchName 批次 + */ +export function deleteBatchData(batchName: string) { + return request.post({ + url: '/price/excel/del', + body: { batchName } + }); +} diff --git a/src/api/request.ts b/src/api/request.ts index 47c9798..77be619 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -122,11 +122,11 @@ function ajax(url: string, options: Options) { deleteToken() location.href = '/' } - if(message.includes("用户名或密码有误")){ - feedback.msgError(message) - }else{ - feedback.msgError("请联系开发人员,数据存在问题") - } + // if(message.includes("用户名或密码有误")){ + // feedback.msgError(message) + // }else{ + // feedback.msgError("请联系开发人员,数据存在问题") + // } console.log(message) reject(res) } diff --git a/src/components/file/preview.vue b/src/components/file/preview.vue index deda371..c055c8a 100644 --- a/src/components/file/preview.vue +++ b/src/components/file/preview.vue @@ -217,6 +217,19 @@ watch(preview, (val) => { emit("update:show", val); }); +// 监听文件列表变化,更新当前预览文件 +watch( + () => props.files, + (newFiles) => { + if (newFiles && newFiles.length > 0) { + if (!newFiles.includes(activeFile.value)) { + activeFile.value = newFiles[0]; + fileRrror.value = false; + } + } + } +); + const rotate = ref(0); const scale = ref(0); const translateX = ref(0); diff --git a/src/views/price/ExcelSearch.vue b/src/views/price/ExcelSearch.vue new file mode 100644 index 0000000..c1d610e --- /dev/null +++ b/src/views/price/ExcelSearch.vue @@ -0,0 +1,1491 @@ + + + + + + 价格库搜索 + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + 搜索 + + + + + + + + + + + + + + 上传 Excel 文件 + 支持 .xls 和 .xlsx 格式,单个文件不超过 100MB + + + + + + {{ uploadLoading ? '上传中...' : '选择文件' }} + + + + + + + + + + + + + + + 表格列表 + + + + + + + + + + + + + {{ row.fileName }} + + + + + + {{ row.batchName }} + + + + + + + {{ formatDate(row.uploadTime) }} + + + + + + {{ row.uploadUserName }} + + + + + + + {{ row.rowIndex }} + + + + + + + 查看 + + + 删除 + + + + + + + + + + + + + + + + + + 数据列表 + + + + + + + + 当前显示:{{ searchKeyword }} 相关的 {{ searchResultList.length }} 条数据 + + + + + + + + + + {{ item.fileName }} + {{ item.sheetName }} + + 第 {{ item.rowIndex }} 行 + + + + + + + : + + + + + + + + + + + + + + + + + + + 数据来源 + + + + {{ currentRow?.fileName }} + + + {{ currentRow?.sheetName }} + + + 第 {{ currentRow?.rowIndex }} 行 + + + {{ currentRow?.batchName || '默认批次' }} + + + + + + + + + 数据内容 + + + + + 表格视图 + + + + + + + + + {{ currentRow?.rowData }} + + + + + + + + + + + + + + +
{{ currentRow?.rowData }}