| | |
| | | |
| | | <script setup> |
| | | import ArtForm from '@/components/core/forms/art-form/index.vue' |
| | | import { buildRoleDialogModel, createRoleFormState } from '../rolePage.helpers' |
| | | import { buildRoleDialogModel, createRoleFormState, getRoleStatusOptions } from '../rolePage.helpers' |
| | | |
| | | const props = defineProps({ |
| | | visible: { required: false, default: false }, |
| | |
| | | name: [{ required: true, message: '请输入角色名称', trigger: 'blur' }] |
| | | })) |
| | | |
| | | const formItems = computed(() => [ |
| | | { |
| | | label: '角色名称', |
| | | key: 'name', |
| | | function createInputFormItem(label, key, placeholder, extraProps = {}, extraConfig = {}) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'input', |
| | | props: { |
| | | placeholder: '请输入角色名称', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '角色编码', |
| | | key: 'code', |
| | | type: 'input', |
| | | props: { |
| | | placeholder: '请输入角色编码', |
| | | clearable: true |
| | | } |
| | | }, |
| | | { |
| | | label: '状态', |
| | | key: 'status', |
| | | placeholder, |
| | | clearable: true, |
| | | ...extraProps |
| | | }, |
| | | ...extraConfig |
| | | } |
| | | } |
| | | |
| | | function createSelectFormItem(label, key, placeholder, options, extraProps = {}, extraConfig = {}) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'select', |
| | | props: { |
| | | placeholder: '请选择状态', |
| | | placeholder, |
| | | clearable: true, |
| | | options: [ |
| | | { label: '正常', value: 1 }, |
| | | { label: '禁用', value: 0 } |
| | | ] |
| | | } |
| | | }, |
| | | { |
| | | label: '备注', |
| | | key: 'memo', |
| | | type: 'input', |
| | | span: 24, |
| | | props: { |
| | | type: 'textarea', |
| | | rows: 3, |
| | | placeholder: '请输入备注', |
| | | clearable: true |
| | | } |
| | | options, |
| | | ...extraProps |
| | | }, |
| | | ...extraConfig |
| | | } |
| | | } |
| | | |
| | | const formItems = computed(() => [ |
| | | createInputFormItem('角色名称', 'name', '请输入角色名称'), |
| | | createInputFormItem('角色编码', 'code', '请输入角色编码'), |
| | | createSelectFormItem('状态', 'status', '请选择状态', getRoleStatusOptions()), |
| | | createInputFormItem('备注', 'memo', '请输入备注', { type: 'textarea', rows: 3 }, { span: 24 }) |
| | | ]) |
| | | |
| | | const resetForm = () => { |