forked from gzzfw/frontEnd/gzDyh

dminyi
2024-09-02 564bfb399c4bf4d9a59d7d5d2f2bf56f75f5b220
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
 * @Company: hugeInfo
 * @Author: lwh
 * @Date: 2022-03-23 09:35:00
 * @LastEditTime: 2022-11-30 12:24:11
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 调度历史
 */
 
import React, { useState, useEffect } from 'react';
import * as $$ from '../../../utils/utility';
import { Form, Typography } from 'antd';
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
import Page from '../../../components/Page/index';
import TableView from '../../../components/TableView';
import TableSearch from '../../../components/TableSearch';
import MyTabs from '../../../components/MyTabs';
 
// 调度历史列表
function listQueryApi(submitData) {
    return $$.ax.request({ url: 'caseDisp/pageHistory', type: 'get', data: submitData, service: 'disp' });
}
 
const { Link } = Typography;
 
const MediateHis = () => {
    const [form] = Form.useForm();
 
    const navigate = useNavigate();
 
    const [searchParams] = useSearchParams();
 
    const location = useLocation();
 
    // 搜索
    const [search, setSearch] = useState({ page: 1, size: 10, acceptObjSign: '1' });
 
    // 数据
    const [data, setData] = useState({ tableData: [] });
 
    // 搜索 or 重置
    function handleSearch(type, data, tableActive) {
        if (type === 'recovery') {
            // 详情返回时恢复跳转前查询
            let obj = { ...search, ...data };
            if (obj.dispTimeStart) {
                obj.dispTime = [$$.myMoment(obj.dispTimeStart), $$.myMoment(obj.dispTimeEnd)];
            }
            form.setFieldsValue(obj);
            getData(obj, tableActive);
        }
        if (type === 'search') {
            let values = form.getFieldsValue();
            $$.changeTimeFormat(values, 'dispTime', 'dispTimeStart', 'dispTimeEnd');
            getData({ ...search, ...values, page: 1 });
        }
        if (type === 'reset') {
            form.resetFields();
            getData({ page: 1, size: 10, acceptObjSign: '1' });
        }
    }
 
    const columns = () => {
        const otherColumns =
            search.acceptObjSign === '1'
                ? [{ title: '已调度天数', dataIndex: 'dispTime2', render: (_, record) => parseInt($$.getHours(new Date(), record.dispTime)?.hours / 24) }]
                : [];
        const columnsData = [
            { title: '调解案号', dataIndex: 'caseNo' },
            ...otherColumns,
            { title: '调度方式', dataIndex: 'dispWayName' },
            { title: '受理对象', dataIndex: 'acceptObjName' },
            { title: '申请渠道', dataIndex: 'applyCanalName' },
            { title: '调度状态', dataIndex: 'statusName' },
            { title: '纠纷类型', dataIndex: 'caseTypeName' },
            { title: '申请人', dataIndex: 'plaintiffs' },
            { title: '被申请人', dataIndex: 'defendants' },
            { title: '纠纷发生地', dataIndex: 'addr' },
            { title: '调解类型', dataIndex: 'mediTypeName' },
            { title: '调度时间', dataIndex: 'dispTime' },
            { title: '调度人', dataIndex: 'dispUserName' },
            {
                title: '操作',
                dataIndex: 'action',
                width: 50,
                render: (_, record) => {
                    return (
                        <Link onClick={() => handleJump(record.caseNo, record.caseId, record.dispId)}>{search.acceptObjSign === '1' ? '处理' : '查看'}</Link>
                    );
                },
            },
        ];
        return columnsData;
    };
 
    // 查看,处理跳转
    function handleJump(title, caseId, dispId) {
        $$.setSessionStorage(location.pathname, {
            search: { ...search },
            breadcrumbData: [{ title: '调度历史', url: location.pathname }, { title: '调度记录' }],
            title,
            tableActive: dispId,
            isEdit: search.acceptObjSign === '1' ? true : false,
            pageFrom: 'mediateHis',
        });
        navigate(`/mediate/caseDetail?caseId=${caseId}&dispId=${dispId}&back=${location.pathname}`);
    }
 
    // 获取数据
    async function getData(submitData, tableActive) {
        global.setSpinning(true);
        const res = await listQueryApi(submitData);
        global.setSpinning(false);
        if (res.type) {
            setSearch(submitData);
            setData({
                total: res.data?.dtoPage?.totalElements,
                tableData: res.data?.dtoPage?.content || [],
                tableActive,
                countWqs: res.data.countWqs,
                countYqs: res.data.countYqs,
            });
        }
    }
 
    // 初始化
    useEffect(() => {
        let returnRouteData = $$.getSessionStorage(location.pathname);
        if (searchParams.get('isBack') && !!returnRouteData) {
            handleSearch('recovery', returnRouteData.search, returnRouteData.tableActive);
        } else {
            handleSearch('reset');
        }
        if (!!returnRouteData) {
            $$.clearSessionStorage(location.pathname);
        }
    }, []);
 
    const countWqs = (search.acceptObjSign === '1' ? data.total : data.countWqs) || 0;
 
    const countYqs = (search.acceptObjSign === '2' ? data.total : data.countYqs) || 0;
 
    return (
        <Page pageHead={{ title: '调度历史', subtitle: '展示账号下已调度的矛盾纠纷案件列表' }}>
            <div className="mediateList">
                <div className="pageSearch">
                    <TableSearch
                        form={form}
                        itemData={[
                            { type: 'Input', name: 'plaintiffs', label: '申请人' },
                            { type: 'Input', name: 'defendants', label: '被申请人' },
                            { type: 'RangePicker', name: 'dispTime', label: '调度时间' },
                            {
                                type: 'Select',
                                name: 'applyCanal',
                                label: '申请渠道',
                                selectdata: $$.options.caseCanal,
                            },
                            { type: 'Input', name: 'acceptObjName', label: '受理对象', placeholder: '调解组织名称或调解员姓名' },
                            {
                                type: 'Select',
                                name: 'dispWay',
                                label: '调度方式',
                                selectdata: [
                                    { value: '1', label: '系统调度' },
                                    { value: '2', label: '人工调度' },
                                ],
                            },
                            { type: 'Input', name: 'caseNo', label: '调解案号' },
                            { type: 'Input', name: 'addr', label: '纠纷发生地' },
                            {
                                type: 'Select',
                                name: 'caseType',
                                label: '纠纷类型',
                                selectdata: $$.caseOptions.caseCause,
                            },
                        ]}
                        handleReset={() => handleSearch('reset')}
                        handleSearch={() => handleSearch('search')}
                    />
                </div>
                <div className="pageTabs">
                    <MyTabs
                        tabs={[
                            { key: '1', label: `未签收(${$$.showMoreNum(countWqs)})` },
                            { key: '2', label: `已签收(${$$.showMoreNum(countYqs)})` },
                        ]}
                        activeKey={search.acceptObjSign}
                        onChange={(activeKey) => getData({ ...search, page: 1, size: 10, acceptObjSign: activeKey })}
                    />
                </div>
                <div className="pageTable">
                    <TableView
                        showHeader
                        title="查询结果"
                        rowKey="dispId"
                        columns={columns()}
                        dataSource={data.tableData}
                        pagination={{
                            current: search.page,
                            pageSize: search.size,
                            total: data.total,
                            onChange: (page, pageSize) => getData({ ...search, page, size: pageSize }),
                        }}
                        rowClassName={(record) => (record.dispId === data.tableActive ? 'tableRowActive' : '')}
                    />
                </div>
            </div>
        </Page>
    );
};
 
export default MediateHis;