Fix: Refactor Organization CRUD {id} to {code}
This commit is contained in:
@@ -47,7 +47,7 @@ const title = ref('')
|
||||
|
||||
// #region Props & Emits
|
||||
const props = defineProps<{
|
||||
divisionId: number
|
||||
divisionId: string
|
||||
}>()
|
||||
const division = ref<Division>({} as Division)
|
||||
// #endregion
|
||||
@@ -152,7 +152,7 @@ watch([recId, recAction], () => {
|
||||
console.log(recId, recAction)
|
||||
switch (recAction.value) {
|
||||
case ActionEvents.showEdit:
|
||||
getDetailDivisionPosition(recId.value)
|
||||
getDetailDivisionPosition(recItem.value.code)
|
||||
title.value = 'Edit Jabatan'
|
||||
isReadonly.value = false
|
||||
isFormEntryDialogOpen.value = true
|
||||
@@ -201,8 +201,8 @@ watch([recId, recAction], () => {
|
||||
@submit="
|
||||
(values: DivisionPositionFormData | Record<string, any>, resetForm: () => void) => {
|
||||
console.log(values)
|
||||
if (recId > 0) {
|
||||
handleActionEdit(recId, values, getDivisionPositionList, onResetState, toast)
|
||||
if (recItem?.code.length > 0) {
|
||||
handleActionEdit(recItem.code, values, getDivisionPositionList, onResetState, toast)
|
||||
return
|
||||
}
|
||||
handleActionSave(values, getDivisionPositionList, onResetState, toast)
|
||||
@@ -215,7 +215,7 @@ watch([recId, recAction], () => {
|
||||
v-model:open="isRecordConfirmationOpen"
|
||||
action="delete"
|
||||
:record="recItem"
|
||||
@confirm="() => handleActionRemove(recId, getDivisionPositionList, toast)"
|
||||
@confirm="() => handleActionRemove(recItem.code, getDivisionPositionList, toast)"
|
||||
@cancel=""
|
||||
>
|
||||
<template #default="{ record }">
|
||||
|
||||
@@ -105,26 +105,23 @@ const getCurrentDivisionDetail = async (id: number | string) => {
|
||||
watch([recId, recAction], () => {
|
||||
switch (recAction.value) {
|
||||
case ActionEvents.showDetail:
|
||||
if (Number(recId.value) > 0) {
|
||||
const id = Number(recId.value)
|
||||
if (recItem.value.code.length > 0) {
|
||||
navigateTo({
|
||||
name: 'org-src-division-id',
|
||||
params: {
|
||||
id: recItem.value.code,
|
||||
},
|
||||
})
|
||||
|
||||
recAction.value = ''
|
||||
recItem.value = null
|
||||
recId.value = 0
|
||||
isFormEntryDialogOpen.value = false
|
||||
isReadonly.value = false
|
||||
|
||||
navigateTo({
|
||||
name: 'org-src-division-id',
|
||||
params: {
|
||||
id,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
break
|
||||
case ActionEvents.showEdit:
|
||||
getCurrentDivisionDetail(recId.value)
|
||||
getCurrentDivisionDetail(recItem.value.code)
|
||||
title.value = 'Edit Divisi'
|
||||
isReadonly.value = false
|
||||
break
|
||||
@@ -146,7 +143,7 @@ watch(
|
||||
if (result.success) {
|
||||
const currentData = result.body.data || []
|
||||
const normalizedData = currentData.filter((division: Division) => !division.parent_id)
|
||||
divisionsTrees.value = getValueTreeItems(normalizedData)
|
||||
divisionsTrees.value = getValueTreeItems(normalizedData, true)
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -190,9 +187,9 @@ onMounted(async () => {
|
||||
:is-readonly="isReadonly"
|
||||
@submit="
|
||||
(values: DivisionFormData | Record<string, any>, resetForm: () => void) => {
|
||||
console.log(values)
|
||||
if (recId > 0) {
|
||||
handleActionEdit(recId, values, getDivisionList, resetForm, toast)
|
||||
// console.log(values)
|
||||
if (recItem?.code.length > 0) {
|
||||
handleActionEdit(recItem.code, values, getDivisionList, resetForm, toast)
|
||||
return
|
||||
}
|
||||
handleActionSave(values, getDivisionList, resetForm, toast)
|
||||
@@ -207,7 +204,7 @@ onMounted(async () => {
|
||||
v-model:open="isRecordConfirmationOpen"
|
||||
action="delete"
|
||||
:record="recItem"
|
||||
@confirm="() => handleActionRemove(recId, getDivisionList, toast)"
|
||||
@confirm="() => handleActionRemove(recItem.code, getDivisionList, toast)"
|
||||
@cancel=""
|
||||
>
|
||||
<template #default="{ record }">
|
||||
|
||||
Reference in New Issue
Block a user