优化案件模块

This commit is contained in:
27942
2026-01-20 17:03:26 +08:00
parent c24fc64f6d
commit 513f2d529d
2 changed files with 33 additions and 6 deletions

View File

@@ -2439,6 +2439,10 @@ class reimbursement(APIView):
now = datetime.now()
date_string = now.strftime("%Y-%m-%d")
# 根据团队类型决定初始状态
# 如果是团队类型且需要审核,状态为"审核中";否则为"已通过"(直接抄送财务)
initial_state = "审核中" if (team and team.team_type == 'team') else "已通过"
reim = Reimbursement.objects.create(
person=person,
times=times,
@@ -2446,13 +2450,13 @@ class reimbursement(APIView):
amount=amount,
FeeDescription=FeeDescription,
submit_tiem=date_string,
state="审核中" if (team and team.team_type == 'team') else "待财务处理"
state=initial_state
)
# 使用统一的审核流程函数
from User.utils import create_approval_with_team_logic
content = f"{person}{times}提交了报销申请,报销理由:{reason}付款金额:{amount}付款日期:{times},费用说明:{FeeDescription}"
content = f"{person}{times}提交了报销申请,报销理由:{reason}报销金额:{amount}报销日期:{times},费用说明:{FeeDescription}"
approval, approvers_order_json, needs_approval = create_approval_with_team_logic(
team_name=team_name,
@@ -2460,7 +2464,7 @@ class reimbursement(APIView):
title=person + "报销申请",
content=content,
approval_type="报销申请",
user_id=reim.id,
user_id=str(reim.id),
business_record=reim,
today=date_string
)
@@ -2499,7 +2503,10 @@ class reimbursement(APIView):
'data': {
'id': reim.id,
'state': reim.state,
'needs_approval': team is None or team.team_type != 'personal'
'approval_id': approval.id if approval else None,
'needs_approval': team is None or team.team_type != 'personal', # 是否需要审批(前端用这个字段判断是团队还是个人)
'team_type': team.team_type if team else None, # 团队类型personal/team前端用这个字段判断
'team_name': team_name # 团队名称
}
}, status=status.HTTP_200_OK)