oms/backend/app/model/principalSubsidiary.js
liufumingren 85938c81ec feat: 组织架构、权限管理与员工档案
- 组织架构:主体管理改为组织架构页(左侧 tab:集团设置 / 下属公司),主体列表仅保留顶部下拉切换
  - 新增下属公司表 principal_subsidiaries、接口与页面,按当前主体隔离
  - 集团设置读取/编辑当前主体基础信息,补所属主体校验与更新字段白名单
- 权限管理:新增 permissions / roles / role_permissions 表
  - 权限以现有顶级菜单为分类,每个菜单两种范围:集团全部 / 所在公司
  - 系统预设角色:系统管理员(全部集团权限)、货主权限(全部所在公司权限)
  - 权限管理页只展示角色组,支持按菜单勾选权限;系统预设角色只读
- 员工档案:账号菜单改为员工档案
  - 新增员工-下属公司多对多关联(principal_user_companies)
  - 创建/编辑员工必须选择角色组;除所有者外必须至少关联一家公司
- 菜单重命名与旧地址重定向;账号导出新增角色组、所属公司

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 20:52:43 +08:00

37 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 下属公司模型,对应 principal_subsidiaries 表(按主体隔离)。
*
* 组织架构 → 下属公司:登记集团(当前主体)下属的公司档案,
* 仅用于档案维护,不参与商品/订单等业务数据归属。
* @param {Egg.Application} app egg application
* @return {object} principalSubsidiary model
*/
module.exports = app => {
const { BIGINT, STRING, TINYINT, DATE } = app.Sequelize;
const PrincipalSubsidiary = app.model.define('principal_subsidiary', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体(集团)ID' },
name: { type: STRING(100), allowNull: false, comment: '公司名称' },
credit_code: { type: STRING(50), comment: '统一社会信用代码' },
contact_name: { type: STRING(50), comment: '联系人' },
contact_phone: { type: STRING(20), comment: '联系电话' },
address: { type: STRING(255), comment: '公司地址' },
status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' },
remark: { type: STRING(255), comment: '备注' },
created_at: { type: DATE, comment: '创建时间' },
updated_at: { type: DATE, comment: '更新时间' },
}, {
tableName: 'principal_subsidiaries',
comment: '下属公司',
});
PrincipalSubsidiary.associate = () => {
app.model.PrincipalSubsidiary.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' });
};
return PrincipalSubsidiary;
};