fix: update some service and handlers

This commit is contained in:
riefive
2025-10-06 10:09:24 +07:00
parent ecdc5d80d9
commit fe23c75aca
23 changed files with 235 additions and 897 deletions
+26 -6
View File
@@ -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;
}