| | |
| | | |
| | | <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 { buildRoleDialogModel, createRoleFormState, getRoleStatusOptions } from '../rolePage.helpers' |
| | | import { useI18n } from 'vue-i18n' |
| | | |
| | | const props = defineProps({ |
| | | visible: { required: false, default: false }, |
| | |
| | | const emit = defineEmits(['update:visible', 'submit']) |
| | | const formRef = ref() |
| | | const form = reactive(createRoleFormState()) |
| | | const { t } = useI18n() |
| | | |
| | | const isEdit = computed(() => props.dialogType === 'edit') |
| | | const dialogTitle = computed(() => (isEdit.value ? '编辑角色' : '新增角色')) |
| | | const dialogTitle = computed(() => |
| | | isEdit.value ? t('pages.system.role.dialog.editTitle') : t('pages.system.role.dialog.addTitle') |
| | | ) |
| | | |
| | | const rules = computed(() => ({ |
| | | name: [{ required: true, message: '请输入角色名称', trigger: 'blur' }] |
| | | name: [{ required: true, message: t('pages.system.role.dialog.validationName'), trigger: 'blur' }] |
| | | })) |
| | | |
| | | function createInputFormItem(label, key, placeholder, extraProps = {}, extraConfig = {}) { |
| | |
| | | } |
| | | |
| | | const formItems = computed(() => [ |
| | | createInputFormItem('角色名称', 'name', '请输入角色名称'), |
| | | createInputFormItem('角色编码', 'code', '请输入角色编码'), |
| | | createSelectFormItem('状态', 'status', '请选择状态', getRoleStatusOptions()), |
| | | createInputFormItem('备注', 'memo', '请输入备注', { type: 'textarea', rows: 3 }, { span: 24 }) |
| | | createInputFormItem( |
| | | t('pages.system.role.dialog.name'), |
| | | 'name', |
| | | t('pages.system.role.dialog.namePlaceholder') |
| | | ), |
| | | createInputFormItem( |
| | | t('pages.system.role.dialog.code'), |
| | | 'code', |
| | | t('pages.system.role.dialog.codePlaceholder') |
| | | ), |
| | | createSelectFormItem( |
| | | t('pages.system.role.dialog.status'), |
| | | 'status', |
| | | t('pages.system.role.dialog.statusPlaceholder'), |
| | | getRoleStatusOptions() |
| | | ), |
| | | createInputFormItem( |
| | | t('pages.system.role.dialog.memo'), |
| | | 'memo', |
| | | t('pages.system.role.dialog.memoPlaceholder'), |
| | | { type: 'textarea', rows: 3 }, |
| | | { span: 24 } |
| | | ) |
| | | ]) |
| | | |
| | | const resetForm = () => { |