李红攀:小程序新增农事记录

This commit is contained in:
2026-06-10 10:35:51 +08:00
parent 66f47cdde4
commit 273772d68a
8 changed files with 950 additions and 1 deletions

82
src/api/agri/operation.ts Normal file
View File

@@ -0,0 +1,82 @@
import type { PageParam, PageResult } from '@/http/types'
import { http } from '@/http/http'
/** 操作类型枚举 */
export const OPERATION_TYPE_OPTIONS = [
{ label: '播种', value: 0 },
{ label: '浇水', value: 1 },
{ label: '施肥', value: 2 },
{ label: '除草', value: 3 },
{ label: '打药', value: 4 },
{ label: '其他', value: 5 },
]
/** 操作类型映射 */
export const OPERATION_TYPE_MAP: Record<number, string> = {
0: '播种',
1: '浇水',
2: '施肥',
3: '除草',
4: '打药',
5: '其他',
}
export interface AgriOperationVO {
id: number
batchId: number
batchNo: string
cropName: string
operationType: number
operationDate: string
operatorName?: string
workContent?: string
imageUrls?: string
remark?: string
createTime?: string
}
export interface AgriOperationPageReqVO extends PageParam {
batchId?: number
operationType?: number
}
export interface AgriOperationFormReqVO {
id?: number
batchId: number
operationType: number
operationDate: string
operatorName?: string
workContent?: string
imageUrls?: string
remark?: string
}
/** 获取农事操作分页列表 */
export function getOperationPage(params: AgriOperationPageReqVO) {
return http.get<PageResult<AgriOperationVO>>('/agri/operation/page', params)
}
/** 获取农事操作详情 */
export function getOperation(id: number) {
return http.get<AgriOperationVO>(`/agri/operation/get?id=${id}`)
}
/** 创建农事操作 */
export function createOperation(data: AgriOperationFormReqVO) {
return http.post<number>('/agri/operation/create', data)
}
/** 更新农事操作 */
export function updateOperation(data: AgriOperationFormReqVO) {
return http.put<void>('/agri/operation/update', data)
}
/** 删除农事操作 */
export function deleteOperation(id: number) {
return http.delete<void>(`/agri/operation/delete?id=${id}`)
}
/** 导出农事操作 */
export function exportOperation(params: AgriOperationPageReqVO) {
return http.get<any>('/agri/operation/export', params, { responseType: 'blob' })
}