forked from gzzfw/frontEnd/gzDyh

zhangyongtian
2024-09-12 2c947a24d56801c4c48c5d6ac7c43f1ede04d3d7
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
215
216
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-03-08 17:31:29
 * @LastEditTime: 2022-08-04 14:20:53
 * @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 MyTabs from '../../components/MyTabs';
 
// 获取签收列表
function getSignForListDataApi(submitData) {
    return $$.ax.request({ url: 'caseSign/pageQuery', type: 'get', data: submitData, service: 'mediate' });
}
 
const { Link } = Typography;
 
const SignForList = () => {
    const location = useLocation();
 
    const navigate = useNavigate();
 
    const [searchParams] = useSearchParams();
 
    const [form] = Form.useForm();
 
    // 搜索
    const [search, setSearch] = useState({ page: 1, size: 10, status: '1' });
 
    // 数据
    const [data, setData] = useState({});
 
    // 查看,签收跳转
    function handleJump(type, record) {
        $$.setSessionStorage(location.pathname, {
            search,
            breadcrumbData: [{ title: '签收列表', url: location.pathname }, { title: type === 'check' ? '签收详情' : '签收' }],
            title: record.caseNo,
            subtitle: '签收处理相关案件',
            tabs: [{ label: '签收', key: 'signFor' }],
            tableActive: record.id,
            signForEditType: type,
            pageFrom: 'signForList',
        });
        navigate(`/mediate/caseDetail?caseId=${record.caseId}&signForId=${record.id}&back=${location.pathname}`);
    }
 
    // 搜索 or 重置
    function handleSearch(type, data) {
        if (type === 'recovery') {
            // 案件详情返回时恢复跳转前查询
            let obj = Object.assign({}, data.search);
            if (obj.acceptStart) {
                obj.acceptTime = [$$.myMoment(obj.acceptStart), $$.myMoment(obj.acceptEnd)];
            }
            if (obj.createStart) {
                obj.createTime = [$$.myMoment(obj.createStart), $$.myMoment(obj.createEnd)];
            }
            form.setFieldsValue(obj);
            getSignForListData(data.search, data.tableActive);
            return;
        }
        if (type === 'reset') {
            form.resetFields();
            getSignForListData({ page: 1, size: 10, status: search.status });
            return;
        }
        if (type === 'search') {
            let values = form.getFieldsValue();
            $$.changeTimeFormat(values, 'acceptTime', 'acceptStart', 'acceptEnd');
            $$.changeTimeFormat(values, 'createTime', 'createStart', 'createEnd');
            getSignForListData({ ...search, ...values, page: 1 });
            return;
        }
        if (type === 'changeTabs' || type === 'changePage') {
            let obj = type === 'changeTabs' ? { page: 1, status: data } : { page: data[0], size: data[1] };
            getSignForListData({ ...search, ...obj });
        }
    }
 
    // 获取数据
    async function getSignForListData(submitData, tableActive) {
        global.setSpinning(true);
        const res = await getSignForListDataApi(submitData);
        global.setSpinning(false);
        if (res.type) {
            setData({
                total: res.data?.caseSignPage?.totalElements,
                tableData: res.data?.caseSignPage?.content || [],
                countWqcStatus: res.data?.countWqcStatus,
                countYqcStatus: res.data?.countYqcStatus,
                tableActive,
            });
            setSearch(submitData);
        }
    }
 
    // 初始化
    useEffect(() => {
        let returnRouteData = $$.getSessionStorage(location.pathname);
        if (searchParams.get('isBack') && !!returnRouteData) {
            handleSearch('recovery', returnRouteData);
        } else {
            handleSearch('reset');
        }
        if (!!returnRouteData) {
            $$.clearSessionStorage(location.pathname);
        }
    }, []);
 
    // 表头
    const columns = (type) => {
        let typeColumns =
            type === '1'
                ? [
                        { title: '派单时间', dataIndex: 'createTime' },
                        {
                            title: '处理时限',
                            dataIndex: 'expireTime',
                            render: (text, record) => {
                                let obj = $$.getHours(text);
                                return record.status === '1' ? (
                                    <span className={obj.isNegativeNum ? 'tableView-dangerTime' : ''}>{!!text ? `${obj.hours}小时` : '-'}</span>
                                ) : (
                                    '-'
                                );
                            },
                        },
                  ]
                : [
                        { title: '签收时间', dataIndex: 'signTime' },
                        { title: '签收人', dataIndex: 'handlerUserName' },
                  ];
        return [
            { title: '调解案号', dataIndex: 'caseNo' },
            { title: '申请人', dataIndex: 'plaintiffs' },
            { title: '被申请人', dataIndex: 'defendants' },
            { title: '纠纷发生地', dataIndex: 'addr' },
            { title: '调解类型', dataIndex: 'mediTypeName' },
            { title: '纠纷类型', dataIndex: 'caseTypeName' },
            { title: '申请渠道', dataIndex: 'canalName' },
            ...typeColumns,
            { title: '纠纷受理时间', dataIndex: 'acceptTime' },
            {
                title: '操作',
                dataIndex: 'action',
                width: 50,
                render: (_, record) => (
                    <Link onClick={() => handleJump(search.status === '1' ? 'edit' : 'check', record)}>{search.status === '1' ? '处理' : '查看'}</Link>
                ),
            },
        ];
    };
 
    const countWqc = (search.status === '1' ? data.total : data.countWqcStatus) || 0;
 
    const countYqc = (search.status === '2' ? data.total : data.countYqcStatus) || 0;
 
    return (
        <Page pageHead={{ title: '签收列表', subtitle: '签收案件列表' }}>
            <div className="signForList">
                <div className="pageSearch">
                    <TableSearch
                        labelLength={6}
                        form={form}
                        itemData={[
                            { type: 'Input', name: 'plaintiffs', label: '申请人' },
                            { type: 'Input', name: 'defendants', label: '被申请人' },
                            { type: 'RangePicker', name: 'acceptTime', label: '纠纷受理时间' },
                            { type: 'Input', name: 'caseNo', label: '调解案号' },
                            { type: 'Input', name: 'addr', label: '纠纷发生地' },
                            { type: 'RangePicker', name: 'createTime', label: '派单时间' },
                        ]}
                        handleReset={() => handleSearch('reset')}
                        handleSearch={() => handleSearch('search')}
                    />
                </div>
                <div className="pageTabs">
                    <MyTabs
                        tabs={[
                            { key: '1', label: `待签收(${$$.showMoreNum(countWqc)})` },
                            { key: '2', label: `已签收(${$$.showMoreNum(countYqc)})` },
                        ]}
                        activeKey={search.status || '0'}
                        onChange={(activeKey) => handleSearch('changeTabs', activeKey)}
                    />
                </div>
                <div className="pageTable">
                    <TableView
                        showHeader
                        title="查询结果"
                        columns={columns(search.status)}
                        dataSource={data.tableData || []}
                        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>
    );
};
 
export default SignForList;