mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 补充公司账户角色和状态相关字段
This commit is contained in:
+3
@@ -24,5 +24,8 @@ public class AccountFilterDTO {
|
||||
|
||||
private Integer isSuper;
|
||||
|
||||
/** 公司成员角色:owner / member */
|
||||
private String role;
|
||||
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
+3
@@ -18,6 +18,9 @@ public class UpdateAccountDTO {
|
||||
|
||||
private Long positionId;
|
||||
|
||||
@Pattern(regexp = "^(owner|member)$", message = "公司成员角色必须是 owner 或 member")
|
||||
private String companyRole;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String remark;
|
||||
|
||||
+6
@@ -24,6 +24,12 @@ public class CompanyAccountVO {
|
||||
|
||||
private String positionName;
|
||||
|
||||
/** 公司成员角色 code:owner / member */
|
||||
private String role;
|
||||
|
||||
/** 公司成员角色展示名 */
|
||||
private String roleName;
|
||||
|
||||
private String loginCode;
|
||||
|
||||
private String phone;
|
||||
|
||||
+19
@@ -240,6 +240,15 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
||||
}
|
||||
}
|
||||
|
||||
// 如果公司成员角色有更新
|
||||
if (StringUtils.hasText(updateAccountDTO.getCompanyRole())) {
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
CompanyMemberPO member = companyMemberService.getByUserIdAndCompanyId(user.getId(), companyId);
|
||||
if (member != null) {
|
||||
companyMemberService.changeRole(member.getId(), CompanyMemberRole.fromCode(updateAccountDTO.getCompanyRole()));
|
||||
}
|
||||
}
|
||||
|
||||
// 如果部门有更新,更新部门成员
|
||||
if (updateAccountDTO.getDepartmentId() != null) {
|
||||
DepartmentMemberPO existingMember = departmentMemberService.getByUserIdAndDepartmentId(user.getId(), updateAccountDTO.getDepartmentId());
|
||||
@@ -336,6 +345,12 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
||||
|
||||
// 获取公司所有成员的用户ID列表
|
||||
List<CompanyMemberVO> members = companyMemberService.getByCompanyId(companyId);
|
||||
if (pageQuery.getFilters() != null && StringUtils.hasText(pageQuery.getFilters().getRole())) {
|
||||
String roleCode = pageQuery.getFilters().getRole();
|
||||
members = members.stream()
|
||||
.filter(member -> roleCode.equals(member.getRole()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<Long> userIds = members.stream().map(CompanyMemberVO::getUserId).collect(Collectors.toList());
|
||||
if (userIds.isEmpty()) {
|
||||
return PageResultVO.create(List.of(), 0L, pageQuery.getPage(), pageQuery.getPageSize());
|
||||
@@ -427,6 +442,10 @@ public class AccountServiceImpl extends ServiceImpl<UserMapper, UserPO> implemen
|
||||
CompanyMemberPO companyMember = companyMemberService.getByUserIdAndCompanyId(user.getId(), companyId);
|
||||
if (companyMember != null) {
|
||||
accountVO.setCompanyId(companyMember.getCompanyId());
|
||||
if (companyMember.getRole() != null) {
|
||||
accountVO.setRole(companyMember.getRole().getCode());
|
||||
accountVO.setRoleName(companyMember.getRole().getDescription());
|
||||
}
|
||||
// 设置公司名称
|
||||
var company = companyService.getById(companyMember.getCompanyId());
|
||||
if (company != null) {
|
||||
|
||||
+2
@@ -396,6 +396,8 @@ public class SuperAccountServiceImpl extends ServiceImpl<UserMapper, UserPO> imp
|
||||
// 取第一个公司成员
|
||||
CompanyMemberVO companyMember = companyMembers.get(0);
|
||||
accountVO.setCompanyId(companyMember.getCompanyId());
|
||||
accountVO.setRole(companyMember.getRole());
|
||||
accountVO.setRoleName(companyMember.getRoleName());
|
||||
var company = companyService.getById(companyMember.getCompanyId());
|
||||
if (company != null) {
|
||||
accountVO.setCompanyName(company.getName());
|
||||
|
||||
@@ -11,6 +11,8 @@ export namespace AccountDTO {
|
||||
phone: string;
|
||||
/** 真实姓名 */
|
||||
realName: string;
|
||||
/** 公司成员角色:owner=公司拥有者,member=成员 */
|
||||
companyRole?: 'member' | 'owner';
|
||||
/** 部门ID */
|
||||
departmentId?: number;
|
||||
/** 岗位ID */
|
||||
@@ -29,7 +31,9 @@ export namespace AccountDTO {
|
||||
departmentId?: number;
|
||||
/** 岗位ID */
|
||||
positionId?: number;
|
||||
/** 状态(0-正常 1-删除 2-停用 3-冻结) */
|
||||
/** 公司成员角色:owner=公司拥有者,member=成员 */
|
||||
companyRole?: 'member' | 'owner';
|
||||
/** 状态(0-停用 1-正常) */
|
||||
status?: number;
|
||||
/** 备注信息 */
|
||||
remark?: string;
|
||||
@@ -49,9 +53,9 @@ export namespace AccountDTO {
|
||||
departmentId?: number;
|
||||
/** 岗位ID */
|
||||
positionId?: number;
|
||||
/** 角色 */
|
||||
role?: string;
|
||||
/** 状态(0-正常 1-删除 2-停用 3-冻结) */
|
||||
/** 公司成员角色 */
|
||||
role?: 'member' | 'owner';
|
||||
/** 状态(0-停用 1-正常) */
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ export namespace AccountVO {
|
||||
positionId?: number;
|
||||
/** 岗位名称 */
|
||||
positionName?: string;
|
||||
/** 公司成员角色 code:owner / member */
|
||||
role?: 'member' | 'owner';
|
||||
/** 公司成员角色展示名 */
|
||||
roleName?: string;
|
||||
/** 登录账号 */
|
||||
loginCode: string;
|
||||
/** 手机号码 */
|
||||
@@ -29,10 +33,6 @@ export namespace AccountVO {
|
||||
avatar?: string;
|
||||
/** 头像图片ID */
|
||||
avatarImageId?: number;
|
||||
/** 角色 */
|
||||
role?: string;
|
||||
/** 角色名称 */
|
||||
roleName?: string;
|
||||
/** 密码安全级别 */
|
||||
pwdSecurityLevel?: number;
|
||||
/** 密码最后更新时间 */
|
||||
|
||||
+31
-7
@@ -59,10 +59,16 @@ interface PositionSelectOption {
|
||||
}
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<AccountDTO.CreateAccountDTO & { status?: number }>({
|
||||
const formData = ref<
|
||||
AccountDTO.CreateAccountDTO & {
|
||||
companyRole?: 'member' | 'owner';
|
||||
status?: number;
|
||||
}
|
||||
>({
|
||||
password: '',
|
||||
phone: '',
|
||||
realName: '',
|
||||
companyRole: 'member',
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
remark: '',
|
||||
@@ -82,12 +88,16 @@ const positionOptions = computed(() => {
|
||||
// 模态框标题
|
||||
const modalTitle = computed(() => (isEdit.value ? '编辑账户' : '添加账户'));
|
||||
|
||||
// 状态选项
|
||||
// 公司成员角色选项
|
||||
const companyRoleOptions = [
|
||||
{ label: '公司拥有者', value: 'owner' },
|
||||
{ label: '成员', value: 'member' },
|
||||
];
|
||||
|
||||
// 状态选项(sys_user.status:0=停用,1=正常)
|
||||
const statusOptions = [
|
||||
{ label: '正常', value: 0 },
|
||||
{ label: '删除', value: 1 },
|
||||
{ label: '停用', value: 2 },
|
||||
{ label: '冻结', value: 3 },
|
||||
{ label: '正常', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
// 重置表单
|
||||
@@ -96,6 +106,7 @@ function resetForm() {
|
||||
password: '',
|
||||
phone: '',
|
||||
realName: '',
|
||||
companyRole: 'member',
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
remark: '',
|
||||
@@ -227,10 +238,11 @@ async function open(accountData?: AccountVO.AccountInfoVO | null) {
|
||||
password: '', // 编辑时密码为空
|
||||
phone: accountData.phone || '',
|
||||
realName: accountData.realName,
|
||||
companyRole: accountData.role || 'member',
|
||||
departmentId: accountData.departmentId,
|
||||
positionId: accountData.positionId || undefined,
|
||||
remark: accountData.remark || '',
|
||||
status: accountData.status,
|
||||
status: accountData.status ?? 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -373,6 +385,18 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="成员角色"
|
||||
name="companyRole"
|
||||
:rules="[{ required: true, message: '请选择成员角色' }]"
|
||||
>
|
||||
<Select
|
||||
v-model:value="formData.companyRole"
|
||||
placeholder="请选择成员角色"
|
||||
:options="companyRoleOptions"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
@@ -39,12 +39,16 @@ const searchForm = ref({
|
||||
status: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 状态选项
|
||||
// 公司成员角色选项(org_company_member.role)
|
||||
const companyRoleOptions = [
|
||||
{ label: '公司拥有者', value: 'owner' },
|
||||
{ label: '成员', value: 'member' },
|
||||
];
|
||||
|
||||
// 状态选项(sys_user.status:0=停用,1=正常)
|
||||
const statusOptions = [
|
||||
{ label: '正常', value: 0 },
|
||||
{ label: '删除', value: 1 },
|
||||
{ label: '停用', value: 2 },
|
||||
{ label: '冻结', value: 3 },
|
||||
{ label: '正常', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
];
|
||||
|
||||
// 搜索表单配置
|
||||
@@ -78,6 +82,16 @@ const formOptions = computed(() => ({
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'role',
|
||||
label: '成员角色',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: companyRoleOptions,
|
||||
placeholder: '请选择成员角色',
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
@@ -134,8 +148,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
{
|
||||
field: 'role',
|
||||
title: '角色',
|
||||
minWidth: 100,
|
||||
title: '成员角色',
|
||||
minWidth: 110,
|
||||
slots: { default: 'role' },
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
@@ -289,26 +304,33 @@ const handleBatchDelete = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status: number) => {
|
||||
const statusMap = {
|
||||
0: '正常',
|
||||
1: '删除',
|
||||
2: '停用',
|
||||
3: '冻结',
|
||||
// 获取公司成员角色文本
|
||||
const getRoleText = (role?: string, roleName?: string) => {
|
||||
if (roleName) return roleName;
|
||||
const roleMap: Record<string, string> = {
|
||||
owner: '公司拥有者',
|
||||
member: '成员',
|
||||
};
|
||||
return statusMap[status as keyof typeof statusMap] || '未知';
|
||||
return role ? roleMap[role] || role : '-';
|
||||
};
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status: number, statusName?: string) => {
|
||||
if (statusName) return statusName;
|
||||
const statusMap: Record<number, string> = {
|
||||
0: '停用',
|
||||
1: '正常',
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
};
|
||||
|
||||
// 获取状态颜色
|
||||
const getStatusColor = (status: number) => {
|
||||
const colorMap = {
|
||||
0: 'green',
|
||||
1: 'red',
|
||||
2: 'orange',
|
||||
3: 'purple',
|
||||
const colorMap: Record<number, string> = {
|
||||
0: 'orange',
|
||||
1: 'green',
|
||||
};
|
||||
return colorMap[status as keyof typeof colorMap] || 'default';
|
||||
return colorMap[status] || 'default';
|
||||
};
|
||||
|
||||
// 处理模态框成功回调
|
||||
@@ -340,10 +362,17 @@ function handleModalSuccess() {
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 成员角色列 -->
|
||||
<template #role="{ row }">
|
||||
<Tag :color="row.role === 'owner' ? 'gold' : 'blue'">
|
||||
{{ getRoleText(row.role, row.roleName) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
<!-- 状态列 -->
|
||||
<template #status="{ row }">
|
||||
<Tag :color="getStatusColor(row.status)">
|
||||
{{ getStatusText(row.status) }}
|
||||
{{ getStatusText(row.status, row.statusName) }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user