Browse Source

feat:价格信息库初步完成

main
buaixuexideshitongxue 3 weeks ago
parent
commit
edbdbd0a34
  1. 154
      src/api/price/excel.ts
  2. 10
      src/api/request.ts
  3. 13
      src/components/file/preview.vue
  4. 1491
      src/views/price/ExcelSearch.vue

154
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 }
});
}

10
src/api/request.ts

@ -122,11 +122,11 @@ function ajax(url: string, options: Options) {
deleteToken() deleteToken()
location.href = '/' location.href = '/'
} }
if(message.includes("用户名或密码有误")){ // if(message.includes("用户名或密码有误")){
feedback.msgError(message) // feedback.msgError(message)
}else{ // }else{
feedback.msgError("请联系开发人员,数据存在问题") // feedback.msgError("请联系开发人员,数据存在问题")
} // }
console.log(message) console.log(message)
reject(res) reject(res)
} }

13
src/components/file/preview.vue

@ -217,6 +217,19 @@ watch(preview, (val) => {
emit("update:show", 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 rotate = ref(0);
const scale = ref(0); const scale = ref(0);
const translateX = ref(0); const translateX = ref(0);

1491
src/views/price/ExcelSearch.vue

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save