| | |
| | | > |
| | | <template #menuType> |
| | | <ElRadioGroup v-model="form.menuType" :disabled="disableMenuType"> |
| | | <ElRadioButton value="menu">菜单</ElRadioButton> |
| | | <ElRadioButton value="button">按钮</ElRadioButton> |
| | | <ElRadioButton value="menu">{{ t('pages.manager.menuPda.type.menu') }}</ElRadioButton> |
| | | <ElRadioButton value="button">{{ t('pages.manager.menuPda.type.button') }}</ElRadioButton> |
| | | </ElRadioGroup> |
| | | </template> |
| | | </ArtForm> |
| | | |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <ElButton @click="handleCancel">取消</ElButton> |
| | | <ElButton type="primary" @click="handleSubmit">确定</ElButton> |
| | | <ElButton @click="handleCancel">{{ t('common.cancel') }}</ElButton> |
| | | <ElButton type="primary" @click="handleSubmit">{{ t('common.confirm') }}</ElButton> |
| | | </span> |
| | | </template> |
| | | </ElDialog> |
| | |
| | | |
| | | <script setup> |
| | | import ArtForm from '@/components/core/forms/art-form/index.vue' |
| | | import { useI18n } from 'vue-i18n' |
| | | |
| | | const { t } = useI18n() |
| | | |
| | | const createMenuPdaFormState = () => ({ |
| | | menuType: 'menu', |
| | |
| | | const form = reactive(createMenuPdaFormState()) |
| | | |
| | | const isEdit = computed(() => Boolean(form.id)) |
| | | const dialogTitle = computed(() => `${isEdit.value ? '编辑' : '新建'}${form.menuType === 'button' ? '按钮' : '菜单'}`) |
| | | const dialogTitle = computed(() => |
| | | isEdit.value |
| | | ? form.menuType === 'button' |
| | | ? t('pages.manager.menuPda.dialog.titleEditButton') |
| | | : t('pages.manager.menuPda.dialog.titleEditMenu') |
| | | : form.menuType === 'button' |
| | | ? t('pages.manager.menuPda.dialog.titleAddButton') |
| | | : t('pages.manager.menuPda.dialog.titleAddMenu') |
| | | ) |
| | | const disableMenuType = computed(() => props.lockType || isEdit.value) |
| | | |
| | | const rules = computed(() => ({ |
| | | name: [{ required: true, message: form.menuType === 'button' ? '请输入权限名称' : '请输入菜单名称', trigger: 'blur' }], |
| | | route: form.menuType === 'menu' ? [{ required: true, message: '请输入路由地址', trigger: 'blur' }] : [], |
| | | name: [ |
| | | { |
| | | required: true, |
| | | message: |
| | | form.menuType === 'button' |
| | | ? t('pages.manager.menuPda.dialog.validation.permissionName') |
| | | : t('pages.manager.menuPda.dialog.validation.menuName'), |
| | | trigger: 'blur' |
| | | } |
| | | ], |
| | | route: |
| | | form.menuType === 'menu' |
| | | ? [{ required: true, message: t('pages.manager.menuPda.dialog.validation.route'), trigger: 'blur' }] |
| | | : [], |
| | | authority: |
| | | form.menuType === 'button' |
| | | ? [{ required: true, message: '请输入权限标识', trigger: 'blur' }] |
| | | ? [{ required: true, message: t('pages.manager.menuPda.dialog.validation.authority'), trigger: 'blur' }] |
| | | : [] |
| | | })) |
| | | |
| | | const formItems = computed(() => { |
| | | const items = [ |
| | | { label: '菜单类型', key: 'menuType', span: 24 }, |
| | | { label: t('pages.manager.menuPda.dialog.menuType'), key: 'menuType', span: 24 }, |
| | | { |
| | | label: '上级菜单', |
| | | label: t('pages.manager.menuPda.dialog.parentMenu'), |
| | | key: 'parentId', |
| | | type: 'treeselect', |
| | | span: 24, |
| | |
| | | value: 'value', |
| | | children: 'children' |
| | | }, |
| | | placeholder: '请选择上级菜单', |
| | | placeholder: t('pages.manager.menuPda.dialog.placeholder.parentMenu'), |
| | | checkStrictly: true, |
| | | clearable: false, |
| | | defaultExpandAll: true |
| | | } |
| | | }, |
| | | { |
| | | label: form.menuType === 'button' ? '权限名称' : '菜单名称', |
| | | label: |
| | | form.menuType === 'button' |
| | | ? t('pages.manager.menuPda.dialog.permissionName') |
| | | : t('pages.manager.menuPda.dialog.menuName'), |
| | | key: 'name', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: form.menuType === 'button' ? '请输入权限名称' : '请输入菜单名称', |
| | | placeholder: |
| | | form.menuType === 'button' |
| | | ? t('pages.manager.menuPda.dialog.placeholder.permissionName') |
| | | : t('pages.manager.menuPda.dialog.placeholder.menuName'), |
| | | clearable: true |
| | | } |
| | | } |
| | |
| | | if (form.menuType === 'menu') { |
| | | items.push( |
| | | { |
| | | label: '路由地址', |
| | | label: t('pages.manager.menuPda.dialog.route'), |
| | | key: 'route', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入路由地址', |
| | | placeholder: t('pages.manager.menuPda.dialog.placeholder.route'), |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '组件标识', |
| | | label: t('pages.manager.menuPda.dialog.component'), |
| | | key: 'component', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入组件标识', |
| | | placeholder: t('pages.manager.menuPda.dialog.placeholder.component'), |
| | | clearable: true |
| | | } |
| | | } |
| | |
| | | |
| | | items.push( |
| | | { |
| | | label: '权限标识', |
| | | label: t('pages.manager.menuPda.dialog.authority'), |
| | | key: 'authority', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入权限标识', |
| | | placeholder: t('pages.manager.menuPda.dialog.placeholder.authority'), |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '图标', |
| | | label: t('pages.manager.menuPda.dialog.icon'), |
| | | key: 'icon', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入图标名称', |
| | | placeholder: t('pages.manager.menuPda.dialog.placeholder.icon'), |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '排序', |
| | | label: t('pages.manager.menuPda.dialog.sort'), |
| | | key: 'sort', |
| | | type: 'number', |
| | | span: 24, |
| | |
| | | } |
| | | }, |
| | | { |
| | | label: '状态', |
| | | label: t('pages.manager.menuPda.dialog.status'), |
| | | key: 'status', |
| | | type: 'select', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请选择状态', |
| | | placeholder: t('pages.manager.menuPda.dialog.placeholder.status'), |
| | | options: [ |
| | | { label: '启用', value: 1 }, |
| | | { label: '禁用', value: 0 } |
| | | { label: t('common.status.enabled'), value: 1 }, |
| | | { label: t('common.status.disabled'), value: 0 } |
| | | ] |
| | | } |
| | | }, |
| | | { |
| | | label: '备注', |
| | | label: t('table.memo'), |
| | | key: 'memo', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | type: 'textarea', |
| | | rows: 3, |
| | | placeholder: '请输入备注', |
| | | placeholder: t('pages.manager.menuPda.dialog.placeholder.memo'), |
| | | clearable: true |
| | | } |
| | | } |