优化结案流程
This commit is contained in:
@@ -2281,7 +2281,7 @@ class approvalProcessing(APIView):
|
||||
|
||||
if type == "结案申请":
|
||||
try:
|
||||
from business.models import Schedule
|
||||
from business.models import Schedule, Case
|
||||
schedule = Schedule.objects.get(id=approval.user_id, is_deleted=False)
|
||||
except Schedule.DoesNotExist:
|
||||
return Response({'status': 'error', 'message': '结案申请记录不存在或已被删除', 'code': 1}, status=status.HTTP_404_NOT_FOUND)
|
||||
@@ -2302,6 +2302,31 @@ class approvalProcessing(APIView):
|
||||
if error:
|
||||
return Response({'status': 'error', 'message': error, 'code': 1}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# 审批通过后,更新 Case.Closingapplication 字段
|
||||
# 刷新 schedule 和 approval 以获取最新状态
|
||||
schedule.refresh_from_db()
|
||||
approval.refresh_from_db()
|
||||
if schedule.state == "已完成" or approval.state == "已通过":
|
||||
try:
|
||||
import json
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
# 从 schedule.remark 中获取 case_id 和 closing_application_files
|
||||
remark_data = json.loads(schedule.remark) if schedule.remark else {}
|
||||
case_id = remark_data.get('case_id')
|
||||
closing_files = remark_data.get('closing_application_files', [])
|
||||
|
||||
if case_id and closing_files:
|
||||
case = Case.objects.filter(id=case_id, is_deleted=False).first()
|
||||
if case:
|
||||
case.Closingapplication = json.dumps(closing_files, ensure_ascii=False)
|
||||
case.save(update_fields=['Closingapplication'])
|
||||
logger.info(f"结案申请审批通过,已更新 Case(id={case_id}) 的 Closingapplication 字段")
|
||||
except Exception as e:
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.error(f"结案申请审批通过后更新 Case.Closingapplication 失败: {str(e)}")
|
||||
|
||||
return Response({'message': '处理成功', 'code': 0}, status=status.HTTP_200_OK)
|
||||
|
||||
return Response({'message': '处理成功', 'code': 0}, status=status.HTTP_200_OK)
|
||||
|
||||
@@ -1598,16 +1598,18 @@ class CaseAttachmentUpdate(APIView):
|
||||
case.Contractreturn = Contractreturn
|
||||
update_fields = ['Contractreturn']
|
||||
elif upload_type == "Closingapplication":
|
||||
case.Closingapplication = json.dumps(file_urls, ensure_ascii=False)
|
||||
update_fields = ['Closingapplication']
|
||||
# 结案申请需要审批通过后才更新 Case.Closingapplication 字段
|
||||
# 这里不直接更新,文件URL保存在 Schedule.remark 中,审批通过后再更新到 Case
|
||||
pass
|
||||
elif upload_type == "AgencyContract":
|
||||
case.AgencyContract = json.dumps(file_urls, ensure_ascii=False)
|
||||
update_fields = ['AgencyContract']
|
||||
|
||||
case.save(update_fields=update_fields)
|
||||
if update_fields:
|
||||
case.save(update_fields=update_fields)
|
||||
|
||||
# 结案申请:加入审批流程(独立于“案件管理”审批,避免覆盖 Case.approvers_order / Case.state)
|
||||
if upload_type == "Closingapplication" and case.state == "结案":
|
||||
if upload_type == "Closingapplication": # 审批通过后才更新 Case.Closingapplication 字段
|
||||
try:
|
||||
token = request.META.get('token')
|
||||
submitter = User.objects.get(token=token, is_deleted=False)
|
||||
|
||||
Reference in New Issue
Block a user