fix(UserOperateDialog): 用户新增和编辑时的对话框里,昵称应该是必填项。
feat(User):搜索框组件新增按“所属公司”搜索;index组件新增“所属公司”字段;新增、编辑的对话框应该可以新增或修改“所属公司”。
This commit is contained in:
@@ -102,3 +102,11 @@ export function fetchBatchDeleteDictData(ids: number[]) {
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
/** 通过岗位编码获取该字典的所有字典数据 */
|
||||
export function fetchGetDictDataByCode(code: String) {
|
||||
return request<Api.Dict.PageResult<Api.Dict.DictData>>({
|
||||
url: `${DICT_DATA_PREFIX}/code?code=${code}`,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
3
src/typings/api/system-manage.d.ts
vendored
3
src/typings/api/system-manage.d.ts
vendored
@@ -130,6 +130,7 @@ declare namespace Api {
|
||||
deptName?: string | null;
|
||||
positionId?: number | null;
|
||||
positionName?: string | null;
|
||||
company?: string | null;
|
||||
email?: string | null;
|
||||
mobile?: string | null;
|
||||
sex?: UserGender | null;
|
||||
@@ -148,6 +149,7 @@ declare namespace Api {
|
||||
mobile?: string;
|
||||
deptId?: number;
|
||||
roleId?: number;
|
||||
company?: string;
|
||||
}
|
||||
>;
|
||||
|
||||
@@ -158,6 +160,7 @@ declare namespace Api {
|
||||
remark?: string | null;
|
||||
positionId?: number | null;
|
||||
resignedAt?: number | null;
|
||||
company?: string | null;
|
||||
email?: string | null;
|
||||
mobile?: string | null;
|
||||
sex?: UserGender | null;
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
fetchDeleteDept,
|
||||
fetchDeleteUser,
|
||||
fetchGetDeptList,
|
||||
fetchGetDictDataByCode,
|
||||
fetchGetPostSimpleList,
|
||||
fetchGetRoleSimpleList,
|
||||
fetchGetUser,
|
||||
@@ -41,7 +42,8 @@ function getInitSearchParams(): Api.SystemManage.UserSearchParams {
|
||||
mobile: undefined,
|
||||
status: undefined,
|
||||
deptId: undefined,
|
||||
roleId: undefined
|
||||
roleId: undefined,
|
||||
company: undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -135,6 +137,7 @@ const operateType = ref<UI.TableOperateType>('add');
|
||||
const editingUserId = ref<number | null>(null);
|
||||
const postOptions = ref<Api.SystemManage.PostSimple[]>([]);
|
||||
const roleOptions = ref<Api.SystemManage.RoleSimple[]>([]);
|
||||
const companyOptions = ref<any>([]);
|
||||
const resetPasswordVisible = ref(false);
|
||||
const resetPasswordUserId = ref<number | null>(null);
|
||||
const resetPasswordUsername = ref<string | null>(null);
|
||||
@@ -194,6 +197,16 @@ const { columns, columnChecks, data, loading, getDataByPage, mobilePagination }
|
||||
showOverflowTooltip: true,
|
||||
formatter: row => getNullableLabel(row.deptName)
|
||||
},
|
||||
{
|
||||
prop: 'company',
|
||||
label: '所属公司',
|
||||
minWidth: 140,
|
||||
showOverflowTooltip: true,
|
||||
formatter: row => {
|
||||
const companyItem = companyOptions.value.find((item: any) => item.value === row.company);
|
||||
return companyItem?.label || '--';
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'positionName',
|
||||
label: $t('page.system.user.positionName'),
|
||||
@@ -347,7 +360,11 @@ async function loadDeptTree() {
|
||||
}
|
||||
|
||||
async function loadFormOptions() {
|
||||
const [postResult, roleResult] = await Promise.all([fetchGetPostSimpleList(), fetchGetRoleSimpleList()]);
|
||||
const [postResult, roleResult, companyResult] = await Promise.all([
|
||||
fetchGetPostSimpleList(),
|
||||
fetchGetRoleSimpleList(),
|
||||
fetchGetDictDataByCode('system_user_company')
|
||||
]);
|
||||
|
||||
if (!postResult.error) {
|
||||
postOptions.value = postResult.data;
|
||||
@@ -356,6 +373,10 @@ async function loadFormOptions() {
|
||||
if (!roleResult.error) {
|
||||
roleOptions.value = roleResult.data.filter(item => item.status === 0);
|
||||
}
|
||||
|
||||
if (!companyResult.error) {
|
||||
companyOptions.value = companyResult.data;
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadUserTable(page = searchParams.pageNo) {
|
||||
@@ -624,6 +645,7 @@ onMounted(async () => {
|
||||
<UserSearch
|
||||
v-model:model="searchParams"
|
||||
:role-options="roleOptions"
|
||||
:company-options="companyOptions"
|
||||
:disabled="!currentDept"
|
||||
@reset="handleResetSearch"
|
||||
@search="handleSearch"
|
||||
@@ -707,6 +729,7 @@ onMounted(async () => {
|
||||
:dept-tree="deptTree"
|
||||
:post-options="postOptions"
|
||||
:role-options="roleOptions"
|
||||
:company-options="companyOptions"
|
||||
@submitted="handleSubmitted"
|
||||
/>
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ interface Props {
|
||||
deptTree: Api.SystemManage.Dept[];
|
||||
postOptions: Api.SystemManage.PostSimple[];
|
||||
roleOptions: Api.SystemManage.RoleSimple[];
|
||||
companyOptions: Api.Dict.DictData[];
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
@@ -80,6 +81,7 @@ function createDefaultModel(): Model {
|
||||
remark: '',
|
||||
deptId: props.currentDeptId ?? 0,
|
||||
positionId: null,
|
||||
company: null,
|
||||
email: '',
|
||||
mobile: '',
|
||||
sex: 1,
|
||||
@@ -100,6 +102,7 @@ const rules = computed(() => {
|
||||
|
||||
return {
|
||||
username: [createRequiredRule($t('page.system.user.form.userName')), patternRules.userName],
|
||||
nickname: [createRequiredRule($t('page.system.user.form.nickName'))],
|
||||
deptId: [createRequiredRule($t('page.system.user.form.deptName'))],
|
||||
positionId: [createRequiredRule($t('page.system.user.form.positionName'))],
|
||||
mobile: getNullableText(model.value.mobile) ? [patternRules.phone] : [],
|
||||
@@ -133,6 +136,7 @@ async function handleInitModel() {
|
||||
remark: user.remark ?? '',
|
||||
deptId: user.deptId,
|
||||
positionId: user.positionId ?? null,
|
||||
company: user.company ?? null,
|
||||
email: user.email ?? '',
|
||||
mobile: user.mobile ?? '',
|
||||
sex: user.sex ?? 0,
|
||||
@@ -155,6 +159,7 @@ async function handleSubmit() {
|
||||
remark: getNullableText(model.value.remark),
|
||||
deptId: model.value.deptId,
|
||||
positionId: model.value.positionId,
|
||||
company: model.value.company,
|
||||
email: getNullableText(model.value.email),
|
||||
mobile: getNullableText(model.value.mobile),
|
||||
sex: model.value.sex,
|
||||
|
||||
@@ -8,6 +8,7 @@ defineOptions({ name: 'UserSearch' });
|
||||
|
||||
interface Props {
|
||||
roleOptions: Api.SystemManage.RoleSimple[];
|
||||
companyOptions: Api.Dict.DictData[];
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
@@ -72,6 +73,19 @@ const model = defineModel<Api.SystemManage.UserSearchParams>('model', { required
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :lg="6" :md="8" :sm="12">
|
||||
<ElFormItem label="所属公司" prop="company">
|
||||
<ElSelect
|
||||
v-model="model.company"
|
||||
clearable
|
||||
filterable
|
||||
:disabled="disabled"
|
||||
placeholder="请选择所属公司"
|
||||
>
|
||||
<ElOption v-for="item in companyOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElCol>
|
||||
<ElCol :lg="6" :md="8" :sm="12">
|
||||
<ElFormItem :label="$t('page.system.user.userRole')" prop="roleId">
|
||||
<ElSelect
|
||||
|
||||
Reference in New Issue
Block a user