Refactor MasterDetailMntC.vue for improved readability and consistency
This commit is contained in:
@@ -107,7 +107,7 @@ const dialogModel = computed({
|
||||
set: (v: boolean) => emit('update:modelValue', v),
|
||||
})
|
||||
|
||||
function normalizeOptions (options: Array<Option | string | number>) {
|
||||
function normalizeOptions(options: Array<Option | string | number>) {
|
||||
return options.map((o) => {
|
||||
if (typeof o === 'string' || typeof o === 'number') {
|
||||
return { title: String(o), value: o }
|
||||
@@ -121,7 +121,7 @@ const normalizedPermissionOptions = computed(() => normalizeOptions(props.permis
|
||||
|
||||
const form = reactive<GenericRecord>({})
|
||||
|
||||
function resetForm (next: GenericRecord) {
|
||||
function resetForm(next: GenericRecord) {
|
||||
for (const key of Object.keys(form)) {
|
||||
delete form[key]
|
||||
}
|
||||
@@ -129,7 +129,7 @@ function resetForm (next: GenericRecord) {
|
||||
}
|
||||
|
||||
const getDefaultStatus = (): OptionValue | '' => normalizedStatusOptions.value[0]?.value ?? ''
|
||||
function getDefaultPermission (): OptionValue | '' {
|
||||
function getDefaultPermission(): OptionValue | '' {
|
||||
return normalizedPermissionOptions.value[0]?.value ?? ''
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ const formPermission = computed<OptionValue | ''>({
|
||||
},
|
||||
})
|
||||
|
||||
function syncFromItem () {
|
||||
function syncFromItem() {
|
||||
const item = props.item ?? {}
|
||||
resetForm({ ...item })
|
||||
|
||||
@@ -182,12 +182,12 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
function handleCancel () {
|
||||
function handleCancel() {
|
||||
emit('cancel')
|
||||
dialogModel.value = false
|
||||
}
|
||||
|
||||
function handleSubmit () {
|
||||
function handleSubmit() {
|
||||
emit('submit', { ...form })
|
||||
|
||||
if (props.closeOnSubmit) {
|
||||
|
||||
Reference in New Issue
Block a user