feat: 补充公司账户角色和状态相关字段

This commit is contained in:
2026-08-24 15:11:30 +08:00
parent ecb53524bd
commit 2de29b0ac0
9 changed files with 127 additions and 37 deletions
@@ -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>