114 lines
2.2 KiB
Plaintext
114 lines
2.2 KiB
Plaintext
import { request } from "@utils";
|
|||
|
|
|
||
|
|
const API_PATH = "/bre/plot";
|
||
|
|
|
||
|
|
const PlotAPI = {
|
||
|
|
getPlotList(query: PlotPageQuery) {
|
||
|
|
return request<ApiResponse<PageResult<PlotTable>>>({
|
||
|
|
url: `${API_PATH}/list`,
|
||
|
|
method: "get",
|
||
|
|
params: query,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
getPlotDetail(query: number) {
|
||
|
|
return request<ApiResponse<PlotTable>>({
|
||
|
|
url: `${API_PATH}/detail/${query}`,
|
||
|
|
method: "get",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
createPlot(body: PlotForm) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/create`,
|
||
|
|
method: "post",
|
||
|
|
data: body,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
updatePlot(id: number, body: PlotForm) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/update/${id}`,
|
||
|
|
method: "put",
|
||
|
|
data: body,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
deletePlot(body: number[]) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/delete`,
|
||
|
|
method: "delete",
|
||
|
|
data: body,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
exportPlot(body: PlotPageQuery) {
|
||
|
|
return request<Blob>({
|
||
|
|
url: `${API_PATH}/export`,
|
||
|
|
method: "post",
|
||
|
|
data: body,
|
||
|
|
responseType: "blob",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
downloadTemplatePlot() {
|
||
|
|
return request<Blob>({
|
||
|
|
url: `${API_PATH}/download/template`,
|
||
|
|
method: "post",
|
||
|
|
responseType: "blob",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
importPlot(body: FormData) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/import`,
|
||
|
|
method: "post",
|
||
|
|
data: body,
|
||
|
|
headers: {
|
||
|
|
"Content-Type": "multipart/form-data",
|
||
|
|
},
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
getPlotOptions() {
|
||
|
|
return request<ApiResponse<PlotOption[]>>({
|
||
|
|
url: `${API_PATH}/options`,
|
||
|
|
method: "get",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
export default PlotAPI;
|
||
|
|
|
||
|
|
export interface PlotPageQuery extends PageQuery, UserByQueryParams {
|
||
|
|
site_id?: number;
|
||
|
|
plot_code?: string;
|
||
|
|
row_orientation?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface PlotTable extends BaseType {
|
||
|
|
site_id?: number;
|
||
|
|
site_name?: string;
|
||
|
|
plot_code?: string;
|
||
|
|
row_orientation?: string;
|
||
|
|
row_count?: number;
|
||
|
|
col_count?: number;
|
||
|
|
grid_note?: string;
|
||
|
|
area?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface PlotForm extends BaseFormType {
|
||
|
|
site_id?: number;
|
||
|
|
plot_code?: string;
|
||
|
|
row_orientation?: string;
|
||
|
|
row_count?: number;
|
||
|
|
col_count?: number;
|
||
|
|
grid_note?: string;
|
||
|
|
area?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface PlotOption {
|
||
|
|
value: number;
|
||
|
|
label: string;
|
||
|
|
}
|