122 lines
2.5 KiB
Plaintext
122 lines
2.5 KiB
Plaintext
import { request } from "@utils";
|
|
|
|
const API_PATH = "/bre/planting";
|
|
|
|
const PlantingAPI = {
|
|
getPlantingList(query: PlantingPageQuery) {
|
|
return request<ApiResponse<PageResult<PlantingTable>>>({
|
|
url: `${API_PATH}/list`,
|
|
method: "get",
|
|
params: query,
|
|
});
|
|
},
|
|
|
|
getPlantingDetail(query: number) {
|
|
return request<ApiResponse<PlantingTable>>({
|
|
url: `${API_PATH}/detail/${query}`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
getPlantingOptions() {
|
|
return request<ApiResponse<PlantingOption[]>>({
|
|
url: `${API_PATH}/options`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
createPlanting(body: PlantingForm) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/create`,
|
|
method: "post",
|
|
data: body,
|
|
});
|
|
},
|
|
|
|
updatePlanting(id: number, body: PlantingForm) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/update/${id}`,
|
|
method: "put",
|
|
data: body,
|
|
});
|
|
},
|
|
|
|
deletePlanting(body: number[]) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/delete`,
|
|
method: "delete",
|
|
data: body,
|
|
});
|
|
},
|
|
|
|
exportPlanting(body: PlantingPageQuery) {
|
|
return request<Blob>({
|
|
url: `${API_PATH}/export`,
|
|
method: "post",
|
|
data: body,
|
|
responseType: "blob",
|
|
});
|
|
},
|
|
|
|
downloadTemplatePlanting() {
|
|
return request<Blob>({
|
|
url: `${API_PATH}/download/template`,
|
|
method: "post",
|
|
responseType: "blob",
|
|
});
|
|
},
|
|
|
|
importPlanting(body: FormData) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/import`,
|
|
method: "post",
|
|
data: body,
|
|
headers: {
|
|
"Content-Type": "multipart/form-data",
|
|
},
|
|
});
|
|
},
|
|
};
|
|
|
|
export default PlantingAPI;
|
|
|
|
export interface PlantingPageQuery extends PageQuery, UserByQueryParams {
|
|
combination_id?: number;
|
|
plot_id?: number;
|
|
bre_personnel_id?: number;
|
|
seedling_id?: number;
|
|
}
|
|
|
|
export interface PlantingOption {
|
|
value: number;
|
|
label: string;
|
|
}
|
|
|
|
export interface PlantingTable extends BaseType {
|
|
combination_id?: number;
|
|
combination_name?: string;
|
|
plot_id?: number;
|
|
plot_name?: string;
|
|
planting_date?: string;
|
|
tree_count?: number;
|
|
row_no?: number;
|
|
col_no?: number;
|
|
bre_personnel_id?: number;
|
|
bre_personnel_name?: string;
|
|
seedling_id?: number;
|
|
seedling_name?: string;
|
|
remark?: string;
|
|
}
|
|
|
|
export interface PlantingForm extends BaseFormType {
|
|
combination_id?: number;
|
|
plot_id?: number;
|
|
planting_date?: string;
|
|
tree_count?: number;
|
|
row_no?: number;
|
|
col_no?: number;
|
|
bre_personnel_id?: number;
|
|
seedling_id?: number;
|
|
remark?: string;
|
|
}
|