新增分段管理
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import http from './http'
|
||||
import type { SimpleFieldBatchPayload, SimpleFieldPayload, SimpleFieldRecord } from '@/types/simpleField'
|
||||
|
||||
function q(params?: Record<string, unknown>) {
|
||||
return { params }
|
||||
}
|
||||
|
||||
export async function listSimpleFields(fieldType?: string, carType?: string, keyword?: string) {
|
||||
const { data } = await http.get<SimpleFieldRecord[]>('/simple-fields', q({
|
||||
fieldType,
|
||||
carType,
|
||||
q: keyword
|
||||
}))
|
||||
return data
|
||||
}
|
||||
|
||||
export async function saveSimpleField(payload: SimpleFieldPayload) {
|
||||
const { data } = payload.id
|
||||
? await http.put<SimpleFieldRecord>(`/simple-fields/${payload.id}`, payload)
|
||||
: await http.post<SimpleFieldRecord>('/simple-fields', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function deleteSimpleField(id: string) {
|
||||
await http.delete(`/simple-fields/${id}`)
|
||||
}
|
||||
|
||||
export async function saveSimpleFieldsBatch(payload: SimpleFieldBatchPayload) {
|
||||
const { data } = await http.post<{ count: number }>('/simple-fields/batch', payload)
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user