feat: 组织架构重构 - 公司成员与部门成员模块,登录逻辑及权限改造

- 新增 org_company_member 表及模块(公司成员:owner/member 角色)
- 新增 org_department_member 表及模块(部门成员:一用户可属多部门)
- 移除 sys_user 的 companyId/departmentId/positionId 字段
- 重构 UserMenuServiceImpl 权限逻辑:super→全系统 / owner→公司菜单 / member→职位菜单
- 修复 RoleAspect 中 role='company' 应为 'admin' 的 BUG
- CurrentUserContext 注入 CompanyMemberService,新增 getCurrentMemberRole()
- 登录时公司选择逻辑:优先 lastCompanyId,需状态可用且未过期
- 超管(super)登录跳过公司校验
- 创建公司时自动创建拥有者账号并写入 org_company_member(role=owner)
- 联系人字段替换为拥有者姓名+拥有者电话
- org_company 表新增 owner_name/owner_phone 字段
- sys_user.phone 唯一约束修正
- 同步更新 SQL 设计文件(31张表 DDL)
This commit is contained in:
小蟑螂
2026-03-29 01:30:00 +08:00
parent 749779d452
commit 3b5e2abd43
47 changed files with 2531 additions and 561 deletions
@@ -9,12 +9,12 @@ export namespace CompanyDTO {
name: string;
/** 公司地址 */
address?: string;
/** 联系人 */
contactPerson?: string;
/** 联系电话 */
contactPhone?: string;
/** 邮箱 */
email?: string;
/** 公司拥有者姓名 */
ownerName: string;
/** 公司拥有者电话 */
ownerPhone: string;
/** logo图片ID */
logoImageId?: number;
/** 状态 (0-禁用 1-正常) */
@@ -29,10 +29,6 @@ export namespace CompanyDTO {
name: string;
/** 公司地址 */
address?: string;
/** 联系人 */
contactPerson?: string;
/** 联系电话 */
contactPhone?: string;
/** 邮箱 */
email?: string;
/** logo图片ID */
@@ -47,10 +43,6 @@ export namespace CompanyDTO {
export interface CompanyFiltersDTO {
/** 公司名称(模糊查询) */
name?: string;
/** 联系人(模糊查询) */
contactPerson?: string;
/** 联系电话(精确查询) */
contactPhone?: string;
/** 邮箱(精确查询) */
email?: string;
/** 状态 */
@@ -20,11 +20,19 @@ const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
const externalRoutes: RouteRecordRaw[] = [];
/**
* 将静态路由挂为 BasicLayout(Root)路由的子路由,
* 使其能共享布局(如侧边栏、头部),而不是独占整个页面。
*/
const rootRoute = coreRoutes.find((r) => r.name === 'Root');
if (rootRoute && !rootRoute.children?.length) {
rootRoute.children = staticRoutes;
}
/** 路由列表,由基本路由、外部路由和404兜底路由组成
* 无需走权限验证(会一直显示在菜单中) */
const routes: RouteRecordRaw[] = [
...coreRoutes,
...staticRoutes,
...externalRoutes,
fallbackNotFoundRoute,
];
@@ -58,9 +58,9 @@ const imageLoadError = ref(false); // 图片加载错误状态
interface FormData {
name: string;
address: string;
contactPerson: string;
contactPhone: string;
email: string;
ownerName: string;
ownerPhone: string;
logoImageId?: number;
status: boolean;
expireTime: any;
@@ -70,9 +70,9 @@ interface FormData {
const formData = ref<FormData>({
name: '',
address: '',
contactPerson: '',
contactPhone: '',
email: '',
ownerName: '',
ownerPhone: '',
logoImageId: undefined,
status: true,
expireTime: undefined,
@@ -98,9 +98,9 @@ function initFormData() {
formData.value = {
name: currentCompanyData.value.name,
address: currentCompanyData.value.address || '',
contactPerson: currentCompanyData.value.contactPerson || '',
contactPhone: currentCompanyData.value.contactPhone || '',
email: currentCompanyData.value.email || '',
ownerName: '',
ownerPhone: '',
logoImageId: undefined,
status: currentCompanyData.value.status === 1, // 转换为boolean
expireTime: currentCompanyData.value.expireTime
@@ -115,9 +115,9 @@ function initFormData() {
formData.value = {
name: '',
address: '',
contactPerson: '',
contactPhone: '',
email: '',
ownerName: '',
ownerPhone: '',
logoImageId: undefined,
status: true,
expireTime: undefined,
@@ -145,10 +145,15 @@ async function handleSubmit() {
loading.value = true;
// 准备提交数据
const submitData = {
const submitData: any = {
...formData.value,
status: formData.value.status ? 1 : 0, // 转换boolean为number
};
// 编辑时排除拥有者字段
if (isEdit.value) {
delete submitData.ownerName;
delete submitData.ownerPhone;
}
// 处理日期格式
if (submitData.expireTime) {
@@ -404,28 +409,29 @@ onUnmounted(() => {
<Input v-model:value="formData.name" placeholder="请输入公司名称" />
</Form.Item>
<!-- 仅创建时显示:拥有者信息 -->
<template v-if="!isEdit">
<Form.Item
label="拥有者姓名"
name="ownerName"
:rules="[{ required: true, message: '请输入公司拥有者姓名' }]"
>
<Input v-model:value="formData.ownerName" placeholder="请输入公司拥有者姓名" />
</Form.Item>
<Form.Item
label="拥有者电话"
name="ownerPhone"
:rules="[{ required: true, message: '请输入公司拥有者电话' }, { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }]"
>
<Input v-model:value="formData.ownerPhone" placeholder="请输入公司拥有者电话" />
</Form.Item>
</template>
<Form.Item label="公司地址" name="address">
<Input v-model:value="formData.address" placeholder="请输入公司地址" />
</Form.Item>
<Form.Item label="联系人" name="contactPerson">
<Input
v-model:value="formData.contactPerson"
placeholder="请输入联系人"
/>
</Form.Item>
<Form.Item
label="联系电话"
name="contactPhone"
:rules="[{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }]"
>
<Input
v-model:value="formData.contactPhone"
placeholder="请输入联系电话"
/>
</Form.Item>
<Form.Item
label="邮箱"
name="email"
@@ -32,8 +32,6 @@ const companyMenuDrawerRef = ref();
// 搜索表单
const searchForm = ref({
name: '',
contactPerson: '',
contactPhone: '',
email: '',
status: undefined as number | undefined,
expired: undefined as string | undefined,
@@ -66,13 +64,13 @@ const gridOptions: VxeGridProps<any> = {
showOverflow: 'tooltip' as const,
},
{
field: 'contactPerson',
title: '联系人',
field: 'ownerName',
title: '拥有者姓名',
minWidth: 120,
},
{
field: 'contactPhone',
title: '联系电话',
field: 'ownerPhone',
title: '拥有者电话',
minWidth: 150,
},
{
@@ -168,8 +166,7 @@ const gridOptions: VxeGridProps<any> = {
pageSize: page.pageSize,
filters: {
name: searchForm.value.name || undefined,
contactPerson: searchForm.value.contactPerson || undefined,
contactPhone: searchForm.value.contactPhone || undefined,
email: searchForm.value.email || undefined,
status: searchForm.value.status,
expired: expiredValue,
@@ -210,20 +207,20 @@ const formOptions = computed(() => ({
{
component: 'Input',
componentProps: {
placeholder: '请输入联系人(回车搜索)',
placeholder: '请输入拥有者姓名(回车搜索)',
onPressEnter: () => gridApi?.reload(),
},
fieldName: 'contactPerson',
label: '联系人',
fieldName: 'ownerName',
label: '拥有者姓名',
},
{
component: 'Input',
componentProps: {
placeholder: '请输入联系电话(回车搜索)',
placeholder: '请输入拥有者电话(回车搜索)',
onPressEnter: () => gridApi?.reload(),
},
fieldName: 'contactPhone',
label: '联系电话',
fieldName: 'ownerPhone',
label: '拥有者电话',
},
{
component: 'Input',