feat: 账户关联根部门 + 员工新增自动带出账户
1. 账户管理:新建/编辑时可勾选关联 level=0 根部门(公司/分公司/子公司) 2. 后端新增 API: - PUT /social/accounts/:id/departments 批量关联根部门 - GET /social/accounts/:id/departments 查询已关联部门 - GET /social/department-account/:departmentId 按部门带出适用账户+标准 3. 部门更新 API 支持 socialAccountId/housingAccountId 字段 4. 员工新增表单:选定部门后自动带出社保公积金账户,可手动调整 5. 参保记录创建时写入 accountId Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,10 @@ const createDeptSchema = z.object({
|
||||
description: z.string().max(200).optional(),
|
||||
})
|
||||
|
||||
const updateDeptSchema = createDeptSchema.partial()
|
||||
const updateDeptSchema = createDeptSchema.partial().extend({
|
||||
socialAccountId: z.string().nullable().optional(),
|
||||
housingAccountId: z.string().nullable().optional(),
|
||||
})
|
||||
|
||||
/** 获取部门树 */
|
||||
router.get('/', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
@@ -109,6 +112,8 @@ router.put('/:id', authMiddleware, async (req: AuthRequest, res, next) => {
|
||||
...(data.sortOrder !== undefined ? { sortOrder: data.sortOrder } : {}),
|
||||
...(data.description !== undefined ? { description: data.description } : {}),
|
||||
...(level !== undefined ? { level } : {}),
|
||||
...(data.socialAccountId !== undefined ? { socialAccountId: data.socialAccountId } : {}),
|
||||
...(data.housingAccountId !== undefined ? { housingAccountId: data.housingAccountId } : {}),
|
||||
},
|
||||
})
|
||||
res.json({ success: true, data: dept })
|
||||
|
||||
Reference in New Issue
Block a user