You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

154 lines
2.9 KiB

/**
* 价格库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 }
});
}