feat(system): 用户模块新增组织编码功能
- 在用户组件中新增 orgCodeOptions 数据选项 - 调用 fetchGetDictDataByCode 获取 'rdms_object_direction' 字典数据 - 将组织编码选项传递给用户组织操作对话框组件 - 在用户操作对话框中新增所属公司选择字段 - 修改组织操作对话框支持组织编码下拉选择功能 - 仅当组织类型为 'direction'(方向) 时显示编码下拉选项 - 更新国际化配置中组织类型 'direction' 的显示文本从 '条线' 改为 '方向'
This commit is contained in:
@@ -138,6 +138,7 @@ const editingUserId = ref<number | null>(null);
|
||||
const postOptions = ref<Api.SystemManage.PostSimple[]>([]);
|
||||
const roleOptions = ref<Api.SystemManage.RoleSimple[]>([]);
|
||||
const companyOptions = ref<any>([]);
|
||||
const orgCodeOptions = ref<any>([]);
|
||||
const resetPasswordVisible = ref(false);
|
||||
const resetPasswordUserId = ref<number | null>(null);
|
||||
const resetPasswordUsername = ref<string | null>(null);
|
||||
@@ -360,10 +361,11 @@ async function loadDeptTree() {
|
||||
}
|
||||
|
||||
async function loadFormOptions() {
|
||||
const [postResult, roleResult, companyResult] = await Promise.all([
|
||||
const [postResult, roleResult, companyResult, orgCodeResult] = await Promise.all([
|
||||
fetchGetPostSimpleList(),
|
||||
fetchGetRoleSimpleList(),
|
||||
fetchGetDictDataByCode('system_user_company')
|
||||
fetchGetDictDataByCode('system_user_company'),
|
||||
fetchGetDictDataByCode('rdms_object_direction')
|
||||
]);
|
||||
|
||||
if (!postResult.error) {
|
||||
@@ -377,6 +379,10 @@ async function loadFormOptions() {
|
||||
if (!companyResult.error) {
|
||||
companyOptions.value = companyResult.data;
|
||||
}
|
||||
|
||||
if (!orgCodeResult.error) {
|
||||
orgCodeOptions.value = orgCodeResult.data;
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadUserTable(page = searchParams.pageNo) {
|
||||
@@ -753,6 +759,7 @@ onMounted(async () => {
|
||||
:row-data="editingDeptData"
|
||||
:parent-id="orgParentId"
|
||||
:dept-tree="deptTree"
|
||||
:org-code-options="orgCodeOptions"
|
||||
@submitted="handleDeptSubmitted"
|
||||
/>
|
||||
|
||||
|
||||
@@ -332,6 +332,13 @@ watch(visible, async value => {
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="所属公司" prop="company">
|
||||
<ElSelect v-model="model.company" clearable filterable placeholder="请选择所属公司">
|
||||
<ElOption v-for="item in companyOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem :label="$t('page.system.user.userRole')" prop="roleIds">
|
||||
<ElSelect
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { commonStatusOptions } from '@/constants/business';
|
||||
import { fetchCreateDept, fetchUpdateDept } from '@/service/api';
|
||||
import { useForm, useFormRules } from '@/hooks/common/form';
|
||||
import {computed, nextTick, ref, watch} from 'vue';
|
||||
import {commonStatusOptions} from '@/constants/business';
|
||||
import {fetchCreateDept, fetchUpdateDept} from '@/service/api';
|
||||
import {useForm, useFormRules} from '@/hooks/common/form';
|
||||
import BusinessFormDialog from '@/components/custom/business-form-dialog.vue';
|
||||
import { $t } from '@/locales';
|
||||
import {$t} from '@/locales';
|
||||
|
||||
defineOptions({ name: 'UserOrgOperateDialog' });
|
||||
defineOptions({name: 'UserOrgOperateDialog'});
|
||||
|
||||
interface Props {
|
||||
operateType: UI.TableOperateType;
|
||||
rowData?: Api.SystemManage.Dept | null;
|
||||
parentId?: number | null;
|
||||
deptTree: Api.SystemManage.Dept[];
|
||||
orgCodeOptions: Api.Dict.DictData[];
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
@@ -27,8 +28,8 @@ const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
|
||||
const { formRef, validate } = useForm();
|
||||
const { createRequiredRule } = useFormRules();
|
||||
const {formRef, validate} = useForm();
|
||||
const {createRequiredRule} = useFormRules();
|
||||
|
||||
const submitting = ref(false);
|
||||
|
||||
@@ -43,10 +44,10 @@ const title = computed(() => {
|
||||
});
|
||||
|
||||
const orgTypeOptions: CommonType.Option<Api.SystemManage.DeptOrgType, App.I18n.I18nKey>[] = [
|
||||
{ value: 'company', label: 'page.system.user.orgType.company' },
|
||||
{ value: 'dept', label: 'page.system.user.orgType.dept' },
|
||||
{ value: 'direction', label: 'page.system.user.orgType.direction' },
|
||||
{ value: 'team', label: 'page.system.user.orgType.team' }
|
||||
{value: 'company', label: 'page.system.user.orgType.company'},
|
||||
{value: 'dept', label: 'page.system.user.orgType.dept'},
|
||||
{value: 'direction', label: 'page.system.user.orgType.direction'},
|
||||
{value: 'team', label: 'page.system.user.orgType.team'}
|
||||
];
|
||||
|
||||
type Model = Api.SystemManage.SaveDeptParams;
|
||||
@@ -76,6 +77,11 @@ const parentTree = computed(() => {
|
||||
|
||||
const expandParentTree = computed(() => !isEdit.value && (props.parentId ?? 0) === 0);
|
||||
|
||||
// 只有组(direction)类型的组织才可以选择编码
|
||||
const isCodeSelectable = computed(() => {
|
||||
return model.value.orgType === 'direction';
|
||||
});
|
||||
|
||||
const rules = {
|
||||
name: createRequiredRule($t('page.system.user.form.orgName')),
|
||||
parentId: createRequiredRule($t('page.system.user.form.parentOrg')),
|
||||
@@ -143,7 +149,7 @@ async function handleSubmit() {
|
||||
} as Api.SystemManage.SaveDeptParams;
|
||||
|
||||
if (isEdit.value && props.rowData) {
|
||||
const { error } = await fetchUpdateDept({
|
||||
const {error} = await fetchUpdateDept({
|
||||
id: props.rowData.id,
|
||||
...payload
|
||||
});
|
||||
@@ -160,7 +166,7 @@ async function handleSubmit() {
|
||||
return;
|
||||
}
|
||||
|
||||
const { error, data } = await fetchCreateDept(payload);
|
||||
const {error, data} = await fetchCreateDept(payload);
|
||||
|
||||
submitting.value = false;
|
||||
|
||||
@@ -197,7 +203,7 @@ watch(visible, async value => {
|
||||
<ElRow :gutter="16">
|
||||
<ElCol :span="24">
|
||||
<ElFormItem :label="$t('page.system.user.orgName')" prop="name">
|
||||
<ElInput v-model="model.name" :placeholder="$t('page.system.user.form.orgName')" />
|
||||
<ElInput v-model="model.name" :placeholder="$t('page.system.user.form.orgName')"/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="24">
|
||||
@@ -216,13 +222,21 @@ watch(visible, async value => {
|
||||
<ElCol :span="12">
|
||||
<ElFormItem :label="$t('page.system.user.orgTypeLabel')" prop="orgType">
|
||||
<ElSelect v-model="model.orgType" :placeholder="$t('page.system.user.form.orgTypeLabel')">
|
||||
<ElOption v-for="item in orgTypeOptions" :key="item.value" :label="$t(item.label)" :value="item.value" />
|
||||
<ElOption v-for="item in orgTypeOptions" :key="item.value" :label="$t(item.label)" :value="item.value"/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
<ElFormItem :label="$t('page.system.user.orgCode')" prop="code">
|
||||
<ElInput v-model="model.code" :placeholder="$t('page.system.user.form.orgCode')" />
|
||||
<ElSelect v-if="isCodeSelectable" v-model="model.code" clearable filterable placeholder="请选择组织编码">
|
||||
<ElOption
|
||||
v-for="item in props.orgCodeOptions"
|
||||
:key="item.value"
|
||||
:label="item.value"
|
||||
:value="item.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElInput v-else v-model="model.code" :placeholder="$t('page.system.user.form.orgCode')"/>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :span="12">
|
||||
|
||||
Reference in New Issue
Block a user