更新
This commit is contained in:
1 parent
184d5b0403
commit
a758966fae
18 files changed
+2002
-19
No files matched your search
@@ -380,6 +380,73 @@ func (c *BackendApprovalController) FlowDelete() {
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// FlowPerm POST /backend/approval/flow/perm
|
||||
// 审批中心「审批权限」设置:只更新流程权限相关字段(适用部门 / 是否默认 / 启用状态),
|
||||
// 不动节点编排。设为默认流时自动取消同分类(biz_type)下其它流程的默认标记。
|
||||
func (c *BackendApprovalController) FlowPerm() {
|
||||
claims, err := requireBackend(&c.Controller)
|
||||
if err != nil {
|
||||
jsonErr(&c.Controller, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
tid := uint64(claims.TenantId)
|
||||
|
||||
var payload struct {
|
||||
ID uint64 `json:"id"`
|
||||
ApplyDeptIDs []uint64 `json:"apply_dept_ids"`
|
||||
IsDefault int8 `json:"is_default"`
|
||||
Status int8 `json:"status"`
|
||||
}
|
||||
if err := c.readTenantBody(&payload); err != nil {
|
||||
jsonErr(&c.Controller, 400, 400, err.Error())
|
||||
return
|
||||
}
|
||||
if payload.ID == 0 {
|
||||
jsonErr(&c.Controller, 400, 400, "无效ID")
|
||||
return
|
||||
}
|
||||
var f models.TenantApprovalFlow
|
||||
if err := models.Orm.QueryTable(new(models.TenantApprovalFlow)).
|
||||
Filter("id", payload.ID).Filter("tid", tid).Filter("is_deleted", 0).One(&f); err != nil {
|
||||
jsonErr(&c.Controller, 404, 404, "流程不存在")
|
||||
return
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
params := orm.Params{
|
||||
"apply_dept_ids": joinUintCSV(payload.ApplyDeptIDs),
|
||||
"is_default": payload.IsDefault,
|
||||
"status": payload.Status,
|
||||
"update_time": now,
|
||||
}
|
||||
if _, err := models.Orm.QueryTable(new(models.TenantApprovalFlow)).
|
||||
Filter("id", payload.ID).Filter("tid", tid).Update(params); err != nil {
|
||||
jsonErr(&c.Controller, 500, 500, "保存失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 设为默认流:取消同分类其它流程的默认标记,保证每个分类只有一条默认流
|
||||
if payload.IsDefault == 1 {
|
||||
models.Orm.QueryTable(new(models.TenantApprovalFlow)).
|
||||
Filter("tid", tid).Filter("biz_type", f.BizType).
|
||||
Filter("id__ne", payload.ID).Filter("is_deleted", 0).
|
||||
Update(orm.Params{"is_default": 0, "update_time": now})
|
||||
}
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "保存成功"}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// joinUintCSV 把 ID 列表拼成逗号分隔串(与 parseIDSlice 互逆)。
|
||||
func joinUintCSV(ids []uint64) string {
|
||||
parts := make([]string, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
if id > 0 {
|
||||
parts = append(parts, strconv.FormatUint(id, 10))
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, ",")
|
||||
}
|
||||
|
||||
// Options GET /backend/approval/options
|
||||
// 编排界面数据源:当前租户的功能模块 + 审批人候选(用户 / 角色 / 部门 / 职位)。
|
||||
func (c *BackendApprovalController) Options() {
|
||||
|
||||
Reference in new issue
Block a user