修复创建案件
This commit is contained in:
@@ -8,7 +8,7 @@ from .models import User, Approval, Department, OperationLog
|
||||
from business.models import permission
|
||||
from finance.models import Income, Accounts, Payment, Reimbursement, BonusChange
|
||||
from finance.models import Invoice
|
||||
from business.models import ProjectRegistration, Case, SealApplication
|
||||
from business.models import ProjectRegistration, Case, SealApplication, PreFiling
|
||||
import datetime
|
||||
from utility.utility import flies
|
||||
from django.contrib.sessions.backends.db import SessionStore
|
||||
@@ -678,6 +678,17 @@ class roxyExhibition(APIView):
|
||||
|
||||
approvals = Approval.objects.filter(query, is_deleted=False).order_by('-id')
|
||||
|
||||
# 过滤掉关联的案件已被删除的审批记录
|
||||
# 获取所有已删除的案件ID(转为字符串,因为Approval.user_id是CharField)
|
||||
deleted_case_ids = Case.objects.filter(is_deleted=True).values_list('id', flat=True)
|
||||
deleted_case_ids_str = [str(cid) for cid in deleted_case_ids]
|
||||
|
||||
# 排除 type="案件管理" 且关联的案件已被删除的审批记录
|
||||
if deleted_case_ids_str:
|
||||
approvals = approvals.exclude(
|
||||
Q(type="案件管理") & Q(user_id__in=deleted_case_ids_str)
|
||||
)
|
||||
|
||||
# 调试信息(生产环境可以注释掉)
|
||||
# print(f"用户: {user.username}, 部门IDs: {user_department_ids_str}")
|
||||
# print(f"查询到的审批数量: {approvals.count()}")
|
||||
@@ -693,10 +704,54 @@ class roxyExhibition(APIView):
|
||||
user_agents_page = paginator.page(paginator.num_pages)
|
||||
data = []
|
||||
for info in user_agents_page.object_list:
|
||||
title = info.title
|
||||
content = info.content
|
||||
|
||||
# 如果是案件管理类型的审批,添加委托人名字和相对方名字以便区分
|
||||
if info.type == "案件管理":
|
||||
try:
|
||||
case_id = int(info.user_id)
|
||||
case = Case.objects.filter(id=case_id, is_deleted=False).select_related('user').first()
|
||||
if case and case.user and not case.user.is_deleted:
|
||||
prefiling = case.user
|
||||
# 解析委托人名字
|
||||
client_names = []
|
||||
try:
|
||||
if prefiling.client_username:
|
||||
client_data = json.loads(prefiling.client_username) if isinstance(prefiling.client_username, str) else prefiling.client_username
|
||||
if isinstance(client_data, list):
|
||||
client_names = [item.get('name', '') for item in client_data if item.get('name')]
|
||||
except (json.JSONDecodeError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
# 解析相对方名字
|
||||
party_names = []
|
||||
try:
|
||||
if prefiling.party_username:
|
||||
party_data = json.loads(prefiling.party_username) if isinstance(prefiling.party_username, str) else prefiling.party_username
|
||||
if isinstance(party_data, list):
|
||||
party_names = [item.get('name', '') for item in party_data if item.get('name')]
|
||||
except (json.JSONDecodeError, TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
# 构建名字字符串
|
||||
client_str = '、'.join(client_names) if client_names else '未知'
|
||||
party_str = '、'.join(party_names) if party_names else '未知'
|
||||
|
||||
# 添加到title中,格式:案件管理信息提交(委托人:XXX vs 相对方:XXX)
|
||||
title = f"案件管理信息提交(委托人:{client_str} vs 相对方:{party_str})"
|
||||
|
||||
# 也更新content,添加案件信息
|
||||
if "提交了一份案件信息" in content:
|
||||
content = f"{content} - 委托人:{client_str},相对方:{party_str}"
|
||||
except (ValueError, TypeError, AttributeError):
|
||||
# 如果解析失败,保持原有title和content
|
||||
pass
|
||||
|
||||
itme = {
|
||||
'id': info.id,
|
||||
"title": info.title,
|
||||
"content": info.content,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"times": info.times,
|
||||
"completeTiem": info.completeTiem,
|
||||
"personincharge": info.personincharge,
|
||||
|
||||
Reference in New Issue
Block a user