This commit is contained in:
hero920103 committed 2026-11-14 07:54:01 +08:00
1 parent 4ab63e77ed
commit eb9b7beff5
16 files changed
+1031 -91

No files matched your search

+6
View File
@@ -482,6 +482,12 @@ func (c *BackendApprovalController) Options() {
"code": m.Code, "name": m.Name, "enabled": enabled,
})
}
// 进销存单据运行期按 biz_type = "erp_" + doc_type 找流程。这里额外开放「采购订单审批」
// 分类,让用户能配出只作用于采购订单的流程;不配时仍会回落到模块级 erp 流程。
// 分类 code 即 biz_type,与 FlowSave 的「分类与单据类型对齐」约定一致。
moduleList = append(moduleList, map[string]interface{}{
"code": models.ApprovalBizPurchaseOrder, "name": "采购订单审批", "enabled": true,
})
// 租户用户
var tu []models.SystemTenantUser
@@ -142,6 +142,25 @@ func (c *BackendApprovalRuntimeController) InstanceTodo() {
} else {
qs = qs.Filter("status", models.ApprovalTaskPending)
}
// 审批任务自带 biz_type,直接在任务查询上过滤,total 与分页才准确。
// erp = 只查进销存单据;non_erp = 只查其它审批,两个审批列表互不混入。
if bizType := strings.TrimSpace(c.GetString("biz_type")); bizType != "" {
switch bizType {
case "erp", "erp_":
qs = qs.Filter("biz_type__startswith", "erp_")
case "non_erp":
// 用已知单据类型精确排除,避免依赖 Exclude 对前缀操作符的支持
erpBizTypes := make([]string, 0, len(erpDocTypes))
for docType := range erpDocTypes {
erpBizTypes = append(erpBizTypes, models.ErpDocApprovalBizType(docType))
}
if len(erpBizTypes) > 0 {
qs = qs.Exclude("biz_type__in", erpBizTypes)
}
default:
qs = qs.Filter("biz_type", bizType)
}
}
total, _ := qs.Count()
var tasks []models.ApprovalTask
@@ -163,6 +182,7 @@ func (c *BackendApprovalRuntimeController) InstanceTodo() {
continue
}
taskView := oaApprovalTaskView(t, true, oaApprovalNodeTypes(inst)[t.NodeKey])
taskView["instance_id"] = t.InstanceID
taskView["instance"] = oaApprovalInstanceView(inst)
list = append(list, taskView)
}
+5
View File
@@ -578,6 +578,11 @@ func erpDocExecutableCore(a erpActor, id uint64) (map[string]interface{}, int, s
if e != nil {
return nil, 404, "单据未找到"
}
// 只有已生效单据可作为下推来源;作废、草稿、审批中、驳回都直接拒绝,
// 与保存时 erpValidateDocHead 的来源状态校验保持一致,避免绕过前端菜单
if doc.Status != models.ErpDocStatusApproved {
return nil, 400, "来源单据未生效,不能下推"
}
isReturn := doc.DocType == models.ErpDocPurchaseReturn || doc.DocType == models.ErpDocSalesReturn
items := erpDocItems(models.Orm, doc.ID)
out := make([]map[string]interface{}, 0, len(items))