广州市综治平台前端
liuwh
4 days ago fa5361c6776f01975737fb5630594a9c60924fc5
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
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-07-08 09:33:05
 * @LastEditTime: 2022-11-03 10:17:36
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 我的退回页面,TODO:暂不需要
 */
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';
 
// 获取我的退回数据
function getMyReturnDataApi(submitData) {
    return $$.ax.request({ url: 'caseTask/pageMyTask', type: 'get', data: submitData, service: 'mediate' });
}
 
const { Link } = Typography;
 
const MyReturn = () => {
    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: [] });
 
    // 查看,签收跳转
    function handleJump(record) {
        $$.setSessionStorage(location.pathname, {
            search: search,
            breadcrumbData: [{ title: '我的退回', url: location.pathname }, { title: '处理' }],
            title: record.caseNo,
            tabs: [{ label: '处理', key: 'caseHandle' }],
            tableActive: record.id,
            pageFrom: 'myReturn',
        });
        navigate(`/mediate/caseDetail?caseId=${record.caseId}&taskId=${record.id}&back=${location.pathname}`);
    }
 
    // 搜索 or 重置
    function handleSearch(type, data) {
        if (type === 'recovery') {
            // 案件详情返回时恢复跳转前查询
            let obj = Object.assign({}, data.search);
            if (obj.returnStart) obj.returnTime = [$$.myMoment(obj.returnStart), $$.myMoment(obj.returnEnd)];
            form.setFieldsValue(obj);
            getMyReturnData(obj, data.tableActive);
            return;
        }
        if (type === 'reset') {
            form.resetFields();
            getMyReturnData({ page: 1, size: 10 });
            return;
        }
        if (type === 'search') {
            let values = form.getFieldsValue();
            $$.changeTimeFormat(values, 'returnTime', 'returnStart', 'returnEnd');
            getMyReturnData({ ...search, ...values, page: 1 });
            return;
        }
        if (type === 'changePage') {
            getMyReturnData({ ...search, page: data[0], size: data[1] });
        }
    }
 
    // 获取数据
    async function getMyReturnData(submitData, tableActive) {
        global.setSpinning(true);
        const res = await getMyReturnDataApi({ ...submitData, pageType: '3' });
        global.setSpinning(false);
        if (res.type) {
            setData({
                total: res.data?.totalElements,
                tableData: res.data?.content,
                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 = [
        { title: '任务名称', dataIndex: 'taskNodeName' },
        { title: '调解案号', dataIndex: 'caseNo' },
        { title: '申请人', dataIndex: 'plaintiffs' },
        { title: '被申请人', dataIndex: 'defendants' },
        { title: '纠纷发生地', dataIndex: 'addr' },
        { title: '纠纷类型', dataIndex: 'caseTypeName' },
        { title: '申请渠道', dataIndex: 'canalName' },
        { title: '退回人', dataIndex: 'returnUserName' },
        { title: '退回时间', dataIndex: 'returnTime' },
        { title: '退回理由', dataIndex: 'returnContent' },
        {
            title: '操作',
            dataIndex: 'action',
            width: 50,
            render: (_, record) => <Link onClick={() => handleJump(record)}>处理</Link>,
        },
    ];
 
    return (
        <Page pageHead={{ title: '我的退回', subtitle: '被下一环节退回的任务清单' }}>
            <div className="myReturn">
                <div className="pageSearch">
                    <TableSearch
                        form={form}
                        itemData={[
                            { type: 'Input', name: 'plaintiffs', label: '申请人' },
                            { type: 'Input', name: 'defendants', label: '被申请人' },
                            { type: 'RangePicker', name: 'returnTime', label: '退回时间' },
                            { type: 'Input', name: 'caseNo', label: '调解案号' },
                            { type: 'Input', name: 'addr', label: '纠纷发生地' },
                        ]}
                        handleReset={() => handleSearch('reset')}
                        handleSearch={() => handleSearch('search')}
                    />
                </div>
                <div className="pageTable myReturn-table">
                    <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) => (record.id === data.tableActive ? 'tableRowActive' : '')}
                    />
                </div>
            </div>
        </Page>
    );
};
 
export default MyReturn;