fix: update some service and handlers
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import { createCrudHandler } from '~/handlers/_handler'
|
||||
import { postUnit, patchUnit, removeUnit } from '~/services/unit.service'
|
||||
|
||||
// Handlers
|
||||
import { genCrudHandler } from '~/handlers/_handler'
|
||||
|
||||
// Services
|
||||
import { getList, create, update, remove } from '~/services/unit.service'
|
||||
|
||||
// Types
|
||||
import type { Unit } from "~/models/unit";
|
||||
|
||||
export const {
|
||||
recId,
|
||||
@@ -14,8 +21,21 @@ export const {
|
||||
handleActionEdit,
|
||||
handleActionRemove,
|
||||
handleCancelForm,
|
||||
} = createCrudHandler({
|
||||
post: postUnit,
|
||||
patch: patchUnit,
|
||||
remove: removeUnit,
|
||||
} = genCrudHandler({
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
})
|
||||
|
||||
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = [];
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Unit) => ({
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
}))
|
||||
}
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user