/*
|
* @Company: hugeInfo
|
* @Author: ldh
|
* @Date: 2023-02-08 14:20:37
|
* @LastEditTime: 2023-04-11 11:12:31
|
* @LastEditors: lwh
|
* @Version: 1.0.0
|
* @Description: 人民调解初审
|
*/
|
import React, { useState, useEffect } from 'react';
|
import './index.less';
|
import { useNavigate, useLocation, useSearchParams } from 'react-router-dom';
|
import { Col, Form, Input, Row, Select, Space, Table, Typography, Button } from 'antd';
|
import Page from '../../../components/Page';
|
import TableView from '../../../components/TableView';
|
import TableSearch from '../../../components/TableSearch';
|
import {
|
ax,
|
changeTimeFormat,
|
clearSessionStorage,
|
dateFormat,
|
getSessionStorage,
|
infoSuccess,
|
modalInfo,
|
myMoment,
|
setSessionStorage,
|
} from '../../../utils/utility';
|
import MyModal from '../../../components/MyModal';
|
import publicDataStatus from '../../../status/publicData';
|
|
const { Link } = Typography;
|
|
const { TextArea } = Input;
|
|
function getDataApi(submitData) {
|
return ax.request({ url: 'rmtj/pageFirstAudit', type: 'get', data: submitData, service: 'mediate' });
|
}
|
|
// 获取审核记录
|
function getExamineHistoryApi(applyId) {
|
return ax.request({ url: `rmtj/listAuditHis?applyId=${applyId}`, type: 'get', service: 'mediate' });
|
}
|
|
// 审核 or 批量审核
|
function examineApi(submitData) {
|
return ax.request({ url: submitData.applyId ? 'rmtj/firstApplyAudit' : 'rmtj/batchFirstApplyAudit', type: 'post', data: submitData, service: 'mediate' });
|
}
|
|
// 移除 or 批量移除
|
function removeApi(submitData) {
|
return ax.request({
|
url: Array.isArray(submitData) ? 'rmtj/batchRemoveFirstApply' : 'rmtj/removeFirstApply',
|
type: Array.isArray(submitData) ? 'post' : 'get',
|
data: submitData,
|
service: 'mediate',
|
});
|
}
|
|
const FirstTrial = () => {
|
const location = useLocation();
|
|
const navigate = useNavigate();
|
|
const [searchParams] = useSearchParams();
|
|
const [form] = Form.useForm();
|
|
// 搜索
|
const [search, setSearch] = useState({ page: 1, size: 10 });
|
|
// 调解组织select框数据
|
const [adjustOrgData, setAdjustOrgData] = useState([]);
|
|
// 数据
|
const [data, setData] = useState({ tableData: [] });
|
|
const [modal, setModal] = useState({ visible: false, submit: {} });
|
|
// 审核记录
|
const [examineHis, setExamineHis] = useState([]);
|
|
// table选择数据
|
const [selectedRowsObj, setSelectedRowsObj] = useState({});
|
|
function handleGetSelectedRowKeys(type) {
|
let arr = [];
|
for (let item in selectedRowsObj) {
|
arr = arr.concat(selectedRowsObj[item][type]);
|
}
|
return arr;
|
}
|
const selectedRowKeys = handleGetSelectedRowKeys('selectedRowKeys');
|
|
const columns = [
|
{ title: '调解案号', dataIndex: 'caseNo' },
|
{
|
title: '调解结果',
|
dataIndex: 'mediResultName',
|
render: (text, record) =>
|
!text ? '-' : <div className={`public-tag public-tag-${record.mediResult === '22_00025-1' ? 'tagGreen' : 'tagRed'}`}>{text}</div>,
|
},
|
{ title: '调解组织', dataIndex: 'mediateUnitName' },
|
{ title: '调解员', dataIndex: 'mediator' },
|
{ title: '申请人', dataIndex: 'plaintiffs' },
|
{ title: '被申请人', dataIndex: 'defendants' },
|
{ title: '纠纷发生地', dataIndex: 'addr' },
|
{ title: '纠纷类型', dataIndex: 'caseTypeName' },
|
{ title: '申请渠道', dataIndex: 'canalName' },
|
{ title: '提审时间', dataIndex: 'applyTime' },
|
{
|
title: '初审结果',
|
dataIndex: 'firstAuditResultName',
|
render: (text, record) =>
|
!text ? '-' :
|
record.firstAuditResult === '0' ? text :
|
<div className={`public-tag public-tag-${record.firstAuditResult === '1' ? 'tagGreen' : 'tagRed'}`}>{text}</div>
|
},
|
{
|
title: '终审结果',
|
dataIndex: 'endAuditResultName',
|
render: (text, record) =>
|
!text ? '-' :
|
record.endAuditResult === '0' ? text :
|
<div className={`public-tag public-tag-${record.endAuditResult === '1' ? 'tagGreen' : 'tagRed'}`}>{text}</div>
|
},
|
{
|
title: '转入结果',
|
dataIndex: 'rmtjStatusName',
|
render: (text, record) =>
|
!text ? '-' :
|
record.rmtjStatus === '1' || record.rmtjStatus === '2' ? text :
|
<div className={`public-tag public-tag-${record.rmtjStatus === '3' ? 'tagBlue2' : 'tagRed'}`}>{text}</div>
|
},
|
{ title: '转入案号', dataIndex: 'rmtjCaseId' },
|
{
|
title: '操作',
|
dataIndex: 'action',
|
width: 120,
|
render: (_, record) => (
|
<Space>
|
<Link onClick={() => handleCheck(record)}>查看</Link>
|
{record.firstAuditResult !== '1' && (
|
<Link onClick={() => getExamineHistory(record)}>{record.firstAuditResult === '0' ? '审核' : '重审'}</Link>
|
)}
|
<Link onClick={() => handleRemove(record, 'one')}>移除</Link>
|
</Space>
|
),
|
},
|
];
|
|
// 查看
|
function handleCheck(record) {
|
setSessionStorage(location.pathname, {
|
search,
|
title: record.caseNo,
|
breadcrumbData: [{ title: '人民调解初审', url: location.pathname }, { title: '查看' }],
|
tableActive: record.id,
|
pageFrom: 'mediateAll',
|
});
|
navigate(`/mediate/caseDetail?caseId=${record.id}&judicialId=${record.judicId}&back=${location.pathname}`);
|
}
|
|
function handleChangeInput(key, value) {
|
if (Array.isArray(key)) {
|
modal.submit[key[0]] = value[0];
|
modal.submit[key[1]] = value[1];
|
} else {
|
modal.submit[key] = value;
|
}
|
setModal({ ...modal });
|
}
|
|
// 搜索 or 重置
|
function handleSearch(type, data, tableActive) {
|
if (type === 'recovery') {
|
let obj = { ...data };
|
if (obj.applyTime) {
|
obj.applyTime = [myMoment(obj.applyStart), myMoment(obj.applyEnd)];
|
}
|
form.setFieldsValue(obj);
|
getData(data, tableActive);
|
return;
|
}
|
if (type === 'reset') {
|
form.resetFields();
|
getData({ page: 1, size: 10 });
|
return;
|
}
|
if (type === 'search' || type === 'changePage') {
|
let values = form.getFieldsValue();
|
changeTimeFormat(values, 'applyTime', 'applyStart', 'applyEnd');
|
let obj = type === 'changePage' ? { page: data[0], size: data[1] } : { page: 1 };
|
getData({ ...search, ...values, ...obj });
|
}
|
}
|
|
// 获取数据
|
async function getData(submitData, tableActive) {
|
global.setSpinning(true);
|
const res = await getDataApi(submitData);
|
global.setSpinning(false);
|
if (res.type) {
|
setData({ total: res.data.totalElements, tableData: res.data.content, tableActive });
|
setSearch(submitData);
|
}
|
}
|
|
// 获取审核记录
|
async function getExamineHistory(record) {
|
global.setSpinning(true);
|
const res = await getExamineHistoryApi(record.applyId);
|
global.setSpinning(false);
|
if (res.type) {
|
setExamineHis(res.data || []);
|
setModal({ visible: true, title: record.caseNo, submit: { applyId: record.applyId, auditResult: '1', auditResultName: '同意' } });
|
}
|
}
|
|
// 审核
|
async function handleExamine() {
|
global.setSpinning(true);
|
const res = await examineApi(modal.submit);
|
global.setSpinning(false);
|
if (res.type) {
|
infoSuccess({ content: '审核成功' });
|
setModal({ visible: false });
|
getData(search);
|
}
|
}
|
|
// 移除
|
function handleRemove(record, type) {
|
modalInfo({
|
title: '移除确认',
|
content: type === 'one' ? `是否移除${record.caseNo}?` : `是否移除${selectedRowKeys.length}个案件?`,
|
okText: '确认移除',
|
onOk: async () => {
|
global.setSpinning(true);
|
const res = await removeApi(type === 'one' ? { applyId: record.applyId } : selectedRowKeys);
|
global.setSpinning(false);
|
if (res.type) {
|
infoSuccess({ content: '移除成功' });
|
getData(search);
|
}
|
},
|
});
|
}
|
|
function downloadXls () {
|
window.open(`https://zfw-dyh.by.gov.cn/dyh-mediate/api/v1/caseOut/rmtj/selectExcels?caseIds=${selectedRowKeys}`);
|
};
|
|
function downloadFile () {
|
// let caseIds = selectedRowKeys.map(({ caseId }) => caseId).join(',');
|
window.open(`https://zfw-dyh.by.gov.cn/dyh-mediate/api/v1/caseOut/rmtj/selectFiles?caseIds=${selectedRowKeys}`);
|
};
|
|
// 初始化
|
useEffect(() => {
|
publicDataStatus.getUnitData((data) => setAdjustOrgData(data));
|
let returnRouteData = getSessionStorage(location.pathname);
|
if (searchParams.get('isBack') && !!returnRouteData) {
|
handleSearch('recovery', returnRouteData.search, returnRouteData.tableActive);
|
} else {
|
handleSearch('reset');
|
}
|
if (!!returnRouteData) {
|
clearSessionStorage(location.pathname);
|
}
|
}, []);
|
|
|
|
return (
|
<>
|
<Page pageHead={{ title: '人民调解初审' }}>
|
<div className="firstTrial">
|
<div className="pageSearch">
|
<TableSearch
|
labelLength={8}
|
form={form}
|
itemData={[
|
{ type: 'Input', name: 'plaintiffs', label: '申请人' },
|
{ type: 'Input', name: 'defendants', label: '被申请人' },
|
{ type: 'Input', name: 'caseNo', label: '调解案号' },
|
{ type: 'TreeSelect', name: 'mediateUnitId', label: '调解组织', placeholder: '查询调解组织名称', treedata: adjustOrgData },
|
{
|
type: 'Select',
|
name: 'firstAuditResult',
|
label: '人民调解初审结果',
|
selectdata: [
|
{ label: '待审核', value: '0' },
|
{ label: '同意', value: '1' },
|
{ label: '拒绝', value: '2' },
|
],
|
},
|
{
|
type: 'Select',
|
name: 'endAuditResult',
|
label: '终审结果',
|
selectdata: [
|
{ label: '待审核', value: '0' },
|
{ label: '同意', value: '1' },
|
{ label: '拒绝', value: '2' },
|
],
|
},
|
{
|
type: 'Select',
|
name: 'rmtjStatus',
|
label: '转入结果',
|
selectdata: [
|
{ label: '未转入', value: '1' },
|
{ label: '转入中', value: '2' },
|
{ label: '已转入', value: '3' },
|
{ label: '转入失败', value: '4' },
|
],
|
},
|
{ type: 'Input', name: 'rmtjCaseId', label: '转入案号' },
|
{ type: 'RangePicker', name: 'applyTime', label: '提审时间' },
|
]}
|
handleReset={() => handleSearch('reset')}
|
handleSearch={() => handleSearch('search')}
|
/>
|
</div>
|
<div className="pageTable">
|
<TableView
|
showHeader
|
title="查询结果"
|
buttonAction={[
|
<Button disabled={!selectedRowKeys.length ? true : false} onClick={downloadXls}>
|
导出Excel
|
</Button>,
|
<Button disabled={!selectedRowKeys.length ? true : false} onClick={downloadFile}>
|
下载附件
|
</Button>,
|
<Button
|
disabled={!selectedRowKeys.length ? true : false}
|
onClick={() =>
|
setModal({
|
type: 'all',
|
visible: true,
|
title: `${selectedRowKeys.length}个案件批量审核`,
|
submit: { applyIdList: selectedRowKeys, auditResult: '1', auditResultName: '同意' },
|
})
|
}
|
>
|
批量审核
|
</Button>,
|
<Button disabled={!selectedRowKeys.length ? true : false} onClick={handleRemove}>
|
批量移除
|
</Button>,
|
]}
|
columns={columns}
|
dataSource={data.tableData}
|
rowSelection={{
|
selectedRowKeys,
|
onChange: (selectedRowKeys) => {
|
let obj = { [search.page]: { selectedRowKeys } };
|
setSelectedRowsObj({ ...selectedRowsObj, ...obj });
|
},
|
}}
|
pagination={{
|
current: search.page,
|
pageSize: search.size,
|
total: data.total,
|
onChange: (page, pageSize) => handleSearch('changePage', [page, pageSize]),
|
}}
|
rowClassName={(record) => (record.id === data.tableActive ? 'tableRowActive' : '')}
|
/>
|
</div>
|
</div>
|
</Page>
|
<MyModal visible={modal.visible} width={600} onCancel={() => setModal({ visible: false })} onOk={handleExamine} okText="提交">
|
<h4>{modal.title}</h4>
|
<Row gutter={[16, 16]}>
|
<Col span={24}>
|
<h5>审核结果</h5>
|
<Select
|
style={{ width: '100%' }}
|
value={modal.submit?.auditResult}
|
onChange={(value, option) => handleChangeInput(['auditResult', 'auditResultName'], [value, option.label])}
|
options={[
|
{ label: '同意', value: '1' },
|
{ label: '拒绝', value: '2' },
|
]}
|
placeholder="请选择"
|
/>
|
</Col>
|
<Col span={24}>
|
<h5>审核意见</h5>
|
<TextArea
|
rows={2}
|
value={modal.submit?.auditContent}
|
onChange={(e) => handleChangeInput('auditContent', e.target.value)}
|
placeholder="请输入"
|
/>
|
</Col>
|
</Row>
|
{!modal.type && (
|
<>
|
<div className="firstTrial-divider" />
|
<h4>审核记录</h4>
|
<Table
|
columns={[
|
{ title: '审核结果', dataIndex: 'auditResultName' },
|
{ title: '审核意见', dataIndex: 'auditContent' },
|
{ title: '审核人', dataIndex: 'auditerName' },
|
{ title: '审核时间', dataIndex: 'auditTime', render: (text) => dateFormat(text) },
|
]}
|
dataSource={examineHis}
|
direction="暂无历史记录"
|
pagination={false}
|
size="small"
|
rowKey="applyId"
|
/>
|
</>
|
)}
|
</MyModal>
|
</>
|
);
|
};
|
|
export default FirstTrial;
|