forked from gzzfw/frontEnd/gzDyh

dminyi
2024-08-09 a2a5220469a3e1f8bc216f47c887ca4c941920b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
 * @Company: hugeInfo
 * @Author: lwh
 * @Date: 2022-03-30 21:41:50
 * @LastEditTime: 2022-11-01 19:10:33
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 调解档案
 */
 
import React, { useEffect, useState } from 'react';
import { useNavigate, useLocation, useSearchParams } from 'react-router-dom';
import { Form, Typography } from 'antd';
import Page from '../../../components/Page';
import * as $$ from '../../../utils/utility';
import TableView from '../../../components/TableView';
import TableSearch from '../../../components/TableSearch';
import publicDataStatus from '../../../status/publicData';
 
// 调度总览列表
function getMediateArchivesApi(submitData) {
    return $$.ax.request({ url: 'caseInfo/pageCaseFiles', type: 'get', data: submitData, service: 'mediate' });
}
 
const { Link } = Typography;
 
const MediateArchives = () => {
    let location = useLocation();
 
    let navigate = useNavigate();
 
    const [searchParams] = useSearchParams();
 
    const [form] = Form.useForm();
 
    // 搜索
    const [search, setSearch] = useState({ page: 1, size: 10 });
 
    // 数据
    const [data, setData] = useState({ tableData: [] });
 
      // 调解组织select框数据
    const [adjustOrgData, setAdjustOrgData] = useState([]);
 
    // 查看,签收跳转
    function handleJump(record) {
        $$.setSessionStorage(location.pathname, {
            search,
            title: record.caseNo,
            breadcrumbData: [{ title: '调解档案', url: location.pathname }, { title: '查看' }],
            tableActive: record.id,
            pageFrom: 'mediateArchives',
        });
        navigate(`/mediate/caseDetail?caseId=${record.id}&judicialId=${record.judicId}&back=${location.pathname}`);
    }
 
    // 搜索 or 重置
    function handleSearch(type, data) {
        if (type === 'recovery') {
            // 案件详情返回时恢复跳转前查询
            let obj = Object.assign({}, data);
            if (obj.fileTimeStart) {
                obj.fileTime = [$$.myMoment(obj.fileTimeStart), $$.myMoment(obj.fileTimeEnd)];
            }
            form.setFieldsValue(obj);
            getMediateArchives(data);
            return;
        }
        if (type === 'reset') {
            form.resetFields();
            getMediateArchives({ page: 1, size: 10, type: '0' });
            return;
        }
        if (type === 'search' || type === 'changePage') {
            let values = form.getFieldsValue();
            $$.changeTimeFormat(values, 'fileTime', 'fileTimeStart', 'fileTimeEnd');
            let obj = type === 'changePage' ? { page: data[0], size: data[1] } : { page: 1 };
            getMediateArchives({ ...search, ...values, ...obj });
        }
    }
 
    // 获取数据
    async function getMediateArchives(submitData) {
        global.setSpinning(true);
        const res = await getMediateArchivesApi(submitData);
        global.setSpinning(false);
        if (res.type) {
            setData({
                total: res.data.totalElements,
                tableData: res.data.content,
            });
            setSearch(submitData);
        }
    }
 
    // 初始化
    useEffect(() => {
    publicDataStatus.getUnitData((data) => setAdjustOrgData(data));
        let returnRouteData = $$.getSessionStorage(location.pathname);
        if (searchParams.get('isBack') && !!returnRouteData) {
            handleSearch('recovery', returnRouteData.search);
        } else {
            handleSearch('reset');
        }
        if (!!returnRouteData) {
            $$.clearSessionStorage(location.pathname);
        }
    }, []);
 
    const columns = [
        { title: '档案编号', dataIndex: 'fileNo', width: 80 },
        { title: '调解案号', dataIndex: 'caseNo' },
        { title: '纠纷受理时间', dataIndex: 'acceptTime' },
        { title: '归档时间', dataIndex: 'fileTime' },
        {
            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: 'otherMediator' },
        { title: '申请人', dataIndex: 'plaintiffs' },
        { title: '被申请人', dataIndex: 'defendants' },
        { title: '纠纷发生地', dataIndex: 'addr' },
        { title: '纠纷类型', dataIndex: 'caseTypeName' },
        {
            title: '操作',
            dataIndex: 'action',
            width: 50,
            render: (_, record) => <Link onClick={() => handleJump(record)}>查看</Link>,
        },
    ];
 
    return (
        <Page pageHead={{ title: '调解档案', subtitle: '查看账号下已归档的案件信息' }}>
            <div className="mediateAll">
                <div className="pageSearch">
                    <TableSearch
                        labelLength={6}
                        form={form}
                        itemData={[
                            { type: 'Input', name: 'plaintiffs', label: '申请人' },
                            { type: 'Input', name: 'defendants', label: '被申请人' },
                            { type: 'RangePicker', name: 'fileTime', label: '归档时间' },
                            { type: 'Input', name: 'fileNo', label: '档案编号', placeholder: '查询档案编号' },
                            { type: 'Input', name: 'caseNo', label: '调解案号' },
                            { type: 'Select', name: 'mediResult', label: '调解结果', selectdata: $$.options.mediResult },
                            { type: 'Input', name: 'mediateBookNo', label: '诉前调书号', placeholder: '输入查询诉前调书号' },
                            { type: 'Input', name: 'addr', label: '纠纷发生地' },
              { type: 'TreeSelect', name: 'mediateUnitId', label: '调解组织', placeholder: '查询调解组织名称', treedata: adjustOrgData },
                            { type: 'Input', name: 'mediateNo', label: '诉前调解案号', placeholder: '输入查询诉前调解案号' },
                            { type: 'Select', name: 'caseType', label: '纠纷类型', selectdata: $$.caseOptions.caseCause },
                            { type: 'Input', name: 'mediator', label: '调解员' },
                        ]}
                        handleReset={() => handleSearch('reset')}
                        handleSearch={() => handleSearch('search')}
                    />
                </div>
                <div className="pageTable">
                    <TableView
                        showHeader
                        title="查询结果"
                        columns={columns}
                        dataSource={data.tableData}
                        pagination={{
                            current: search.page,
                            pageSize: search.size,
                            total: data.total,
                            onChange: (page, pageSize) => handleSearch('changePage', [page, pageSize]),
                        }}
                        rowClassName={(record, index) => (record.id === data.tableActive ? 'tableRowActive' : '')}
                    />
                </div>
            </div>
        </Page>
    );
};
 
export default MediateArchives;