127 lines
2.5 KiB
Plaintext
127 lines
2.5 KiB
Plaintext
import { request } from "@utils";
|
|||
|
|
|
||
|
|
const API_PATH = "/bre/tree";
|
||
|
|
|
||
|
|
const TreeAPI = {
|
||
|
|
getTreeList(query: TreePageQuery) {
|
||
|
|
return request<ApiResponse<PageResult<TreeTable>>>({
|
||
|
|
url: `${API_PATH}/list`,
|
||
|
|
method: "get",
|
||
|
|
params: query,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
getTreeDetail(query: number) {
|
||
|
|
return request<ApiResponse<TreeTable>>({
|
||
|
|
url: `${API_PATH}/detail/${query}`,
|
||
|
|
method: "get",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
getTreeOptions() {
|
||
|
|
return request<ApiResponse<TreeOption[]>>({
|
||
|
|
url: `${API_PATH}/options`,
|
||
|
|
method: "get",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
createTree(body: TreeForm) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/create`,
|
||
|
|
method: "post",
|
||
|
|
data: body,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
updateTree(id: number, body: TreeForm) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/update/${id}`,
|
||
|
|
method: "put",
|
||
|
|
data: body,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
deleteTree(body: number[]) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/delete`,
|
||
|
|
method: "delete",
|
||
|
|
data: body,
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
exportTree(body: TreePageQuery) {
|
||
|
|
return request<Blob>({
|
||
|
|
url: `${API_PATH}/export`,
|
||
|
|
method: "post",
|
||
|
|
data: body,
|
||
|
|
responseType: "blob",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
downloadTemplateTree() {
|
||
|
|
return request<Blob>({
|
||
|
|
url: `${API_PATH}/download/template`,
|
||
|
|
method: "post",
|
||
|
|
responseType: "blob",
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
importTree(body: FormData) {
|
||
|
|
return request<ApiResponse>({
|
||
|
|
url: `${API_PATH}/import`,
|
||
|
|
method: "post",
|
||
|
|
data: body,
|
||
|
|
headers: {
|
||
|
|
"Content-Type": "multipart/form-data",
|
||
|
|
},
|
||
|
|
});
|
||
|
|
},
|
||
|
|
};
|
||
|
|
|
||
|
|
export default TreeAPI;
|
||
|
|
|
||
|
|
export interface TreePageQuery extends PageQuery, UserByQueryParams {
|
||
|
|
combination_id?: number;
|
||
|
|
plot_id?: number;
|
||
|
|
planting_id?: number;
|
||
|
|
tree_no?: string;
|
||
|
|
status?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface TreeOption {
|
||
|
|
value: number;
|
||
|
|
label: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface TreeTable extends BaseType {
|
||
|
|
combination_id?: number;
|
||
|
|
combination_name?: string;
|
||
|
|
plot_id?: number;
|
||
|
|
plot_name?: string;
|
||
|
|
planting_id?: number;
|
||
|
|
planting_name?: string;
|
||
|
|
tree_no?: string;
|
||
|
|
row_orientation?: string;
|
||
|
|
row_no?: number;
|
||
|
|
col_no?: number;
|
||
|
|
planted_date?: string;
|
||
|
|
bre_personnel_id?: number;
|
||
|
|
bre_personnel_name?: string;
|
||
|
|
status?: string;
|
||
|
|
remark?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface TreeForm extends BaseFormType {
|
||
|
|
combination_id?: number;
|
||
|
|
plot_id?: number;
|
||
|
|
planting_id?: number;
|
||
|
|
tree_no?: string;
|
||
|
|
row_orientation?: string;
|
||
|
|
row_no?: number;
|
||
|
|
col_no?: number;
|
||
|
|
planted_date?: string;
|
||
|
|
bre_personnel_id?: number;
|
||
|
|
status?: string;
|
||
|
|
remark?: string;
|
||
|
|
}
|