/*
|
* @Author: dminyi 1301963064@qq.com
|
* @Date: 2023-11-29 14:52:48
|
* @LastEditors: lwh
|
* @LastEditTime: 2024-01-23 18:09:39
|
* @FilePath: \hugeDyh2.0\customerSystem\src\views\caseDetail\components\modify.jsx
|
* @Description: 调节总览修改页面
|
*/
|
|
import React, { useEffect, useState } from 'react';
|
import { Button, Typography, Space } from 'antd';
|
import { CheckCircleFilled } from '@ant-design/icons';
|
import { useSearchParams, useNavigate } from 'react-router-dom';
|
import {
|
material_apply,
|
material_apply_active,
|
material_evidence,
|
material_evidence_active,
|
material_other,
|
material_other_active,
|
} from '../../../assets/images/icon';
|
import * as $$ from '../../../utils/utility';
|
import Page from '../../../components/Page';
|
import { CasePerfectionForm1 } from '../../../components/disputeRegistration/casePerfection';
|
import sopStatus from '../../../status/sopStatus';
|
import SelectObjModal from '../../../components/SelectObjModal';
|
import ProgressStep from '../../../components/ProgressStep';
|
import ResultFeedback from '../../mediationWindow/component/ResultFeedback';
|
|
// 获取案件信息
|
function getCaseDataApi(caseId, isDraft) {
|
return $$.ax.request({ url: `caseInfo/${isDraft ? 'getDraftInfo' : 'getCaseInfo'}?id=${caseId}`, type: 'get', service: 'mediate' });
|
}
|
|
// 案情完善
|
function registerApi(submitData) {
|
return $$.ax.request({ url: 'caseInfo/caseRegister', type: 'post', data: submitData, service: 'mediate' });
|
}
|
|
//全局修改接口
|
// function getCaseDataApi(submitData) {
|
// return $$.ax.request({ url: 'caseInfo/globalUpdate', type: 'post', data: submitData, service: 'mediate' });
|
// }
|
|
// 移除系列案中的案件
|
function deleteFolderCaseApi(caseId) {
|
return $$.ax.request({ url: 'caseInfo/removeDraftSerie?id=' + caseId, type: 'get', service: 'mediate' });
|
}
|
|
// 系列案提交调解
|
function submitFolderCaseApi(submitData) {
|
return $$.ax.request({ url: 'caseInfo/submitSerie', type: 'post', data: submitData, service: 'mediate' });
|
}
|
|
|
// 调解导航
|
function getCacheLatjCaseGuideApi(submitData) {
|
return $$.ax.request({ url: 'guide/cacheLatjCaseGuide', type: 'get', data: submitData, service: 'mediate' });
|
}
|
|
// 人工智能推荐
|
function getCacheOpenAiCaseGuideApi(submitData) {
|
return $$.ax.request({ url: 'guide/cacheOpenAiCaseGuideList', type: 'get', data: submitData, service: 'mediate' });
|
}
|
|
// 案件特征缓存接口
|
function cacheCaseFeatureApi(submitData) {
|
return $$.ax.request({ url: `guide/cacheCaseFeature`, type: 'get', data: submitData, service: 'mediate' });
|
}
|
|
// 类案推荐的案件特征缓存接口
|
function cacheLatjCaseFeatureListApi(submitData) {
|
return $$.ax.request({ url: `guide/cacheLatjCaseFeatureList`, type: 'get', data: submitData, service: 'mediate' });
|
}
|
|
|
|
/**
|
* isMediationWindow, // 判断是否来自调解视窗则不显示提交成功后的显示 和 page的头部
|
* onSuccessSubmit, // 提交成功后的回调
|
*/
|
|
const Modify = ({ isMediationWindow, onSuccessSubmit }) => {
|
const [searchParams] = useSearchParams();
|
|
// 判断路由是否有caseId则为完善,无则为新增
|
const caseId = searchParams.get('caseId');
|
|
// 判断如果来自草稿修改则执行不同的api接口
|
const isDraft = searchParams.get('isDraft');
|
|
const navigate = useNavigate();
|
|
// 是否登记成功, '1':草稿案件 '2':正式案件
|
const [isRegisterSuccess, setIsRegisterSuccess] = useState(false);
|
|
// 案件数据
|
const [data, setData] = useState({});
|
|
// 意向调解员modal
|
const [selectModal, setSelectModal] = useState(false);
|
|
// 调解员
|
const [wantUser, setWantUser] = useState({});
|
|
// 新增后的案件id
|
const [newCaseId, setNewCaseId] = useState('');
|
|
// 材料tabs选中项
|
const materialTabs = [
|
{ label: '全部', value: 'all' },
|
{ label: '申请材料', value: '22_00018-101', tag: '申请', icon: material_apply, iconActive: material_apply_active },
|
{ label: '证据材料', value: '22_00018-102', tag: '证据', icon: material_evidence, iconActive: material_evidence_active },
|
{ label: '其他材料', value: '22_00018-199', tag: '其他', icon: material_other, iconActive: material_other_active },
|
];
|
const [materialActive, setMaterialActive] = useState(1);
|
|
// 保存
|
function handleSubmit(submitData, caseType, caseIndex) {
|
// 非系列案
|
submitData.acceptTime = $$.timeFormat(submitData.acceptTime, 'isValue');
|
submitData.occurTime = $$.timeFormat(submitData.occurTime, 'isValue');
|
// 二次校验,从快速登记保存的草稿进行常规登记修改时,验证申请人是否存在身份证
|
let info = false;
|
forEach1: for (let i = 0; i < submitData['plaintiffList']?.length; i++) {
|
if (!$$.verifyEmpty(submitData['plaintiffList'][i].certiNo)) {
|
info = true;
|
$$.info({ type: 'warning', content: `请填写申请人${submitData['plaintiffList'][i].trueName}的证件号码` });
|
break forEach1;
|
}
|
}
|
if (info) return;
|
if (caseType === 1) {
|
submitData = { ...submitData, ...wantUser };
|
if (submitData.inputStatus === '1') {
|
$$.modalInfo({
|
title: '确定将案件保存为草稿信息吗?',
|
content: '不生成正式案号,仅存在于「登记列表中」,需转为正式案件后才可以进行调解',
|
okText: '保存草稿',
|
cancelText: '我再想想',
|
onOk: () => register(submitData),
|
});
|
} else {
|
$$.modalInfo({
|
title: '确定提交当前调解信息吗?',
|
content: '提交前请仔细核对纠纷信息和双方申请人信息,确定提交调解吗?',
|
okText: '确定提交',
|
cancelText: '我再想想',
|
onOk: () => { register(submitData) },
|
});
|
}
|
}
|
|
|
// 系列案中单个案件的保存
|
if (caseType === 2) {
|
saveFolderCase(submitData, caseIndex);
|
}
|
}
|
|
|
// 移除系列案中的案件
|
function handleDeleteFolderCase(caseId, caseIndex) {
|
$$.modalInfo({
|
title: '移除案件确认',
|
content: '确定从当前系列案中移除该案件吗?',
|
okText: '确定移除',
|
onOk: async () => {
|
global.setSpinning(true);
|
const res = await deleteFolderCaseApi(caseId);
|
global.setSpinning(false);
|
if (res.type) {
|
$$.infoSuccess({ content: '移除成功' });
|
data.content.splice(caseIndex, 1);
|
setData({ ...data });
|
}
|
},
|
});
|
}
|
|
// 系列案提交调解
|
function handleSubmitFolderCase() {
|
let submitData = { content: data.content, ...wantUser };
|
// 二次校验:1.从快速登记保存的草稿进行常规登记修改时,验证申请人是否存在身份证; 2.复制案件后生成系列案二次验证
|
let info = false;
|
let arr = ['caseType', 'mediType', 'area', 'caseDes', 'caseClaim'];
|
submitData.content.forEach((x, t) => {
|
if (arr.find((item) => !x[item])) {
|
info = `请填写系列案${t + 1}的纠纷信息并保存`;
|
return;
|
}
|
if (x['plaintiffList'].length < 1) {
|
info = `请添加系列案${t + 1}的申请人并保存`;
|
return;
|
}
|
if (x['defendantList'].length < 1) {
|
info = `请添加系列案${t + 1}的被申请人并保存`;
|
return;
|
}
|
forEach1: for (let i = 0; i < x['plaintiffList']?.length; i++) {
|
if (!$$.verifyEmpty(x['plaintiffList'][i].certiNo)) {
|
info = `请填写系列案${t + 1}的申请人${x['plaintiffList'][i].trueName}的证件号码`;
|
break forEach1;
|
}
|
}
|
});
|
if (info) {
|
$$.info({ type: 'warning', content: info });
|
return;
|
}
|
$$.modalInfo({
|
title: '系列案提交确认',
|
content: '确定提交当前系列案吗?',
|
okText: '确定提交',
|
onOk: async () => {
|
submitData.content.forEach((x) => (x.inputStatus = '2'));
|
global.setSpinning(true);
|
const res = await submitFolderCaseApi(submitData);
|
global.setSpinning(false);
|
if (res.type) {
|
setIsRegisterSuccess('2');
|
}
|
},
|
});
|
}
|
|
|
|
// 调解视窗-Openai接口-缓存
|
async function getCacheOpenAiCaseGuide(submitData, tableActive) {
|
$$.setLocal(`cacheOpenAiCaseGuideList${submitData.caseId}`, '')
|
const res = await getCacheOpenAiCaseGuideApi(submitData);
|
if (res.type) {
|
$$.clearLocal(`cacheOpenAiCaseGuideList${submitData.caseId}`)
|
}
|
}
|
|
// 调解视窗-类案推荐-缓存
|
async function getCacheLatjCaseGuide(submitData, tableActive) {
|
$$.setLocal(`cacheLatjCaseGuide${submitData.caseId}`, '')
|
const res = await getCacheLatjCaseGuideApi(submitData);
|
if (res.type) {
|
$$.clearLocal(`cacheLatjCaseGuide${submitData.caseId}`)
|
cacheLatjCaseFeatureList(submitData)
|
}
|
}
|
|
// 案件特征缓存
|
async function cacheCaseFeature(submitData) {
|
$$.setLocal(`cacheCaseFeature${submitData.caseId}`, '')
|
const res = await cacheCaseFeatureApi(submitData);
|
if (res.type) {
|
$$.clearLocal(`cacheCaseFeature${submitData.caseId}`)
|
|
}
|
}
|
|
// 类案推荐的案件特征缓存接口
|
async function cacheLatjCaseFeatureList(submitData) {
|
$$.setLocal(`cacheLatjCaseFeatureList${submitData.caseId}`, '')
|
const res = await cacheLatjCaseFeatureListApi(submitData);
|
if (res.type) {
|
$$.clearLocal(`cacheLatjCaseFeatureList${submitData.caseId}`)
|
}
|
}
|
|
|
// 系列案中单个案件保存信息
|
async function saveFolderCase(submitData, caseIndex) {
|
global.setSpinning(true);
|
const res = await registerApi(submitData);
|
global.setSpinning(false);
|
if (res.type) {
|
$$.infoSuccess({ content: '保存成功' });
|
data.content.splice(caseIndex, 1, submitData);
|
// changeTime:用于更新系列案展示的申请人和被申请人
|
setData({ ...data, changeTime: $$.timeFormat(new Date()) });
|
console.log('res', res.data);
|
// 1:类案推荐,2:法条推荐,3:要素提取,4:司法解释,5:调解策略,6:争议焦点
|
getCacheOpenAiCaseGuide({ caseId: res.data, guideTypes: '3,5,6' })
|
getCacheLatjCaseGuide({ caseId: res.data })
|
cacheCaseFeature({ caseId: res.data })
|
}
|
}
|
|
// 非系列案纠纷登记(保存表单数据)
|
async function register(submitData) {
|
global.setSpinning(true);
|
const res = await registerApi(submitData);
|
global.setSpinning(false);
|
if (res.type) {
|
if (isMediationWindow) {
|
$$.infoSuccess({ content: '修改成功' });
|
onSuccessSubmit();
|
} else {
|
setIsRegisterSuccess(submitData.inputStatus);
|
setNewCaseId(res.data);
|
console.log('res', res.data);
|
// 1:类案推荐,2:法条推荐,3:要素提取,4:司法解释,5:调解策略,6:争议焦点
|
getCacheOpenAiCaseGuide({ caseId: res.data, guideTypes: '3,5,6' })
|
getCacheLatjCaseGuide({ caseId: res.data })
|
cacheCaseFeature({ caseId: res.data })
|
}
|
}
|
}
|
|
useEffect(() => {
|
// 获取案件信息
|
async function getCaseData() {
|
global.setSpinning(true);
|
const res = await getCaseDataApi(caseId);
|
global.setSpinning(false);
|
if (res.type) {
|
setData(res.data);
|
if (res.data?.wantUserId) {
|
setWantUser({ wantUserId: res.data.wantUserId, wantUserName: res.data.wantUserName });
|
}
|
}
|
}
|
if (caseId) {
|
getCaseData();
|
} else {
|
setData({ serieStatus: '1' });
|
setWantUser({});
|
}
|
setIsRegisterSuccess(false);
|
return () => {
|
sopStatus.handleVisible(false);
|
};
|
}, [caseId]);
|
|
return (
|
<div style={{ backgroundColor: '#fff' }}>
|
<Page
|
>
|
{!isRegisterSuccess &&
|
// 登记组件
|
<CasePerfectionForm1
|
isMediationWindow={true}
|
showResult
|
showResultButton
|
showMediationPower
|
caseId={caseId}
|
data={data}
|
materialTabs={materialTabs}
|
materialActive={materialActive}
|
wantUser={wantUser}
|
handleSubmit={handleSubmit}
|
handleChangeTab={(x, t) => setMaterialActive(t)}
|
handleOpenWantUser={() => setSelectModal(true)}
|
handleCloseWantUser={() => setWantUser({ wantUserId: null, wantUserName: null })}
|
handleDeleteFolderCase={handleDeleteFolderCase}
|
handleSubmitFolderCase={handleSubmitFolderCase}
|
/>
|
}
|
{/* 选择调解员modal */}
|
<SelectObjModal
|
visible={selectModal}
|
checkKeys={wantUser.wantUserId ? [{ label: wantUser.wantUserName, value: wantUser.wantUserId }] : undefined}
|
onOk={(value) => {
|
setSelectModal(false);
|
setWantUser({ wantUserId: value.keys[0], wantUserName: value.items[0].name });
|
}}
|
onClose={() => setSelectModal(false)}
|
/>
|
{/* <ResultFeedback caseId={caseId} /> */}
|
</Page>
|
|
</div>
|
);
|
};
|
|
|
|
export default Modify;
|