feat: menu
parent
8ba4ef9b9a
commit
051f14c3b5
|
|
@ -8,7 +8,7 @@ import { ref, computed, unref } from 'vue'
|
||||||
import { BasicModal, useModalInner } from '@/components/Modal'
|
import { BasicModal, useModalInner } from '@/components/Modal'
|
||||||
import { BasicForm, useForm } from '@/components/Form'
|
import { BasicForm, useForm } from '@/components/Form'
|
||||||
import { formSchema } from './menu.data'
|
import { formSchema } from './menu.data'
|
||||||
import { createDeptApi, getDeptApi, updateDeptApi } from '@/api/system/dept'
|
import { createMenuApi, getMenuApi, updateMenuApi } from '@/api/system/menu'
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register'])
|
const emit = defineEmits(['success', 'register'])
|
||||||
const isUpdate = ref(true)
|
const isUpdate = ref(true)
|
||||||
|
|
@ -30,7 +30,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
|
||||||
isUpdate.value = !!data?.isUpdate
|
isUpdate.value = !!data?.isUpdate
|
||||||
|
|
||||||
if (unref(isUpdate)) {
|
if (unref(isUpdate)) {
|
||||||
const res = await getDeptApi(data.record.id)
|
const res = await getMenuApi(data.record.id)
|
||||||
rowId.value = res.id
|
rowId.value = res.id
|
||||||
setFieldsValue({
|
setFieldsValue({
|
||||||
...res
|
...res
|
||||||
|
|
@ -38,16 +38,16 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增部门' : '编辑部门'))
|
const getTitle = computed(() => (!unref(isUpdate) ? '新增菜单' : '编辑菜单'))
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
try {
|
try {
|
||||||
const values = await validate()
|
const values = await validate()
|
||||||
setModalProps({ confirmLoading: true })
|
setModalProps({ confirmLoading: true })
|
||||||
if (unref(isUpdate)) {
|
if (unref(isUpdate)) {
|
||||||
await updateDeptApi(values)
|
await updateMenuApi(values)
|
||||||
} else {
|
} else {
|
||||||
await createDeptApi(values)
|
await createMenuApi(values)
|
||||||
}
|
}
|
||||||
closeModal()
|
closeModal()
|
||||||
emit('success')
|
emit('success')
|
||||||
|
|
|
||||||
|
|
@ -154,8 +154,8 @@ export const formSchema: FormSchema[] = [
|
||||||
component: 'RadioButtonGroup',
|
component: 'RadioButtonGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
options: [
|
||||||
{ label: true, key: true, value: '显示' },
|
{ label: '显示', key: true, value: true },
|
||||||
{ label: false, key: false, value: '隐藏' }
|
{ label: '隐藏', key: false, value: false }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ifShow: ({ values }) => values.type !== 3
|
ifShow: ({ values }) => values.type !== 3
|
||||||
|
|
@ -166,8 +166,8 @@ export const formSchema: FormSchema[] = [
|
||||||
component: 'RadioButtonGroup',
|
component: 'RadioButtonGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
options: [
|
||||||
{ label: true, key: true, value: '显示' },
|
{ label: '显示', key: true, value: true },
|
||||||
{ label: false, key: false, value: '隐藏' }
|
{ label: '隐藏', key: false, value: false }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ifShow: ({ values }) => values.type !== 3
|
ifShow: ({ values }) => values.type !== 3
|
||||||
|
|
@ -178,8 +178,8 @@ export const formSchema: FormSchema[] = [
|
||||||
component: 'RadioButtonGroup',
|
component: 'RadioButtonGroup',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
options: [
|
||||||
{ label: true, key: true, value: '缓存' },
|
{ label: '缓存', key: true, value: true },
|
||||||
{ label: false, key: false, value: '不缓存' }
|
{ label: '不缓存', key: false, value: false }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
ifShow: ({ values }) => values.type === 2
|
ifShow: ({ values }) => values.type === 2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue