| | |
| | | > |
| | | <template #menuType> |
| | | <ElRadioGroup v-model="form.menuType" :disabled="disableMenuType"> |
| | | <ElRadioButton value="menu">菜单</ElRadioButton> |
| | | <ElRadioButton value="button">按钮</ElRadioButton> |
| | | <ElRadioButton value="menu">{{ t('pages.system.menu.form.typeMenu') }}</ElRadioButton> |
| | | <ElRadioButton value="button">{{ t('pages.system.menu.form.typeButton') }}</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> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { useI18n } from 'vue-i18n' |
| | | import ArtForm from '@/components/core/forms/art-form/index.vue' |
| | | |
| | | const createMenuFormState = () => ({ |
| | |
| | | }) |
| | | |
| | | const emit = defineEmits(['update:visible', 'submit']) |
| | | const { t } = useI18n() |
| | | const formRef = ref() |
| | | const form = reactive(createMenuFormState()) |
| | | |
| | | const isEdit = computed(() => Boolean(form.id)) |
| | | const dialogTitle = computed(() => `${isEdit.value ? '编辑' : '新建'}${form.menuType === 'button' ? '按钮' : '菜单'}`) |
| | | const dialogTitle = computed(() => |
| | | form.menuType === 'button' |
| | | ? t(isEdit.value ? 'pages.system.menu.form.titleEditButton' : 'pages.system.menu.form.titleAddButton') |
| | | : t(isEdit.value ? 'pages.system.menu.form.titleEditMenu' : 'pages.system.menu.form.titleAddMenu') |
| | | ) |
| | | const disableMenuType = computed(() => props.lockType || isEdit.value) |
| | | |
| | | const rules = computed(() => ({ |
| | | name: [{ required: true, message: form.menuType === 'button' ? '请输入权限名称' : '请输入菜单名称', trigger: 'blur' }], |
| | | name: [{ required: true, message: form.menuType === 'button' ? t('pages.system.menu.form.validationButtonName') : t('pages.system.menu.form.validationMenuName'), trigger: 'blur' }], |
| | | route: |
| | | form.menuType === 'menu' |
| | | ? [{ required: true, message: '请输入路由地址', trigger: 'blur' }] |
| | | ? [{ required: true, message: t('pages.system.menu.form.validationRoute'), trigger: 'blur' }] |
| | | : [], |
| | | authority: |
| | | form.menuType === 'button' |
| | | ? [{ required: true, message: '请输入权限标识', trigger: 'blur' }] |
| | | ? [{ required: true, message: t('pages.system.menu.form.validationAuthority'), trigger: 'blur' }] |
| | | : [] |
| | | })) |
| | | |
| | | const formItems = computed(() => { |
| | | const items = [ |
| | | { label: '菜单类型', key: 'menuType', span: 24 }, |
| | | { label: t('pages.system.menu.form.menuType'), key: 'menuType', span: 24 }, |
| | | { |
| | | label: '上级菜单', |
| | | label: t('pages.system.menu.form.parentId'), |
| | | key: 'parentId', |
| | | type: 'treeselect', |
| | | span: 24, |
| | |
| | | value: 'value', |
| | | children: 'children' |
| | | }, |
| | | placeholder: '请选择上级菜单', |
| | | placeholder: t('pages.system.menu.form.placeholderParent'), |
| | | checkStrictly: true, |
| | | clearable: false, |
| | | defaultExpandAll: true |
| | | } |
| | | }, |
| | | { |
| | | label: form.menuType === 'button' ? '权限名称' : '菜单名称', |
| | | label: form.menuType === 'button' ? t('pages.system.menu.form.nameButton') : t('pages.system.menu.form.nameMenu'), |
| | | key: 'name', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: form.menuType === 'button' ? '请输入权限名称' : '请输入菜单名称', |
| | | placeholder: form.menuType === 'button' ? t('pages.system.menu.form.placeholderButtonName') : t('pages.system.menu.form.placeholderMenuName'), |
| | | clearable: true |
| | | } |
| | | } |
| | |
| | | if (form.menuType === 'menu') { |
| | | items.push( |
| | | { |
| | | label: '路由地址', |
| | | label: t('pages.system.menu.form.route'), |
| | | key: 'route', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入路由地址', |
| | | placeholder: t('pages.system.menu.form.placeholderRoute'), |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '组件标识', |
| | | label: t('pages.system.menu.form.component'), |
| | | key: 'component', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入组件标识', |
| | | placeholder: t('pages.system.menu.form.placeholderComponent'), |
| | | clearable: true |
| | | } |
| | | } |
| | |
| | | |
| | | items.push( |
| | | { |
| | | label: '权限标识', |
| | | label: t('pages.system.menu.form.authority'), |
| | | key: 'authority', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入权限标识', |
| | | placeholder: t('pages.system.menu.form.placeholderAuthority'), |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '图标', |
| | | label: t('pages.system.menu.form.icon'), |
| | | key: 'icon', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请输入图标名称', |
| | | placeholder: t('pages.system.menu.form.placeholderIcon'), |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '排序', |
| | | label: t('pages.system.menu.form.sort'), |
| | | key: 'sort', |
| | | type: 'number', |
| | | span: 24, |
| | |
| | | } |
| | | }, |
| | | { |
| | | label: '状态', |
| | | label: t('pages.system.menu.form.status'), |
| | | key: 'status', |
| | | type: 'select', |
| | | span: 24, |
| | | props: { |
| | | placeholder: '请选择状态', |
| | | placeholder: t('pages.system.menu.form.placeholderStatus'), |
| | | options: [ |
| | | { label: '启用', value: 1 }, |
| | | { label: '禁用', value: 0 } |
| | | { label: t('common.status.enabled'), value: 1 }, |
| | | { label: t('common.status.disabled'), value: 0 } |
| | | ] |
| | | } |
| | | }, |
| | | { |
| | | label: '备注', |
| | | label: t('pages.system.menu.form.memo'), |
| | | key: 'memo', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | type: 'textarea', |
| | | rows: 3, |
| | | placeholder: '请输入备注', |
| | | placeholder: t('pages.system.menu.form.placeholderMemo'), |
| | | clearable: true |
| | | } |
| | | } |