forked from gzzfw/frontEnd/gzDyh

liuwh
2024-09-14 b39c972062c4d95554db7207aa4c9eb93d3adae8
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-07-25 09:10:30
 * @LastEditTime: 2022-10-08 12:00:45
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 司法确认申请列表 - 申请司法确认
 */
import React, { useState, useEffect, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import { Row, Col, Button, Select, Input, Typography, Form, Space } from 'antd';
import { FileTextOutlined, FileAddOutlined, BranchesOutlined, CloseCircleFilled, CheckCircleFilled } from '@ant-design/icons';
import { cardIconCaseCheck } from '../../../assets/images/icon';
import * as $$ from '../../../utils/utility';
import Page from '../../../components/Page';
import MyModal from '../../../components/MyModal';
import MyUpload from '../../../components/MyUpload';
import TableSearch from '../../../components/TableSearch';
import TableView from '../../../components/TableView';
import { DisputeMsg } from '../../caseDetail/components';
 
const { Option } = Select;
 
const { TextArea } = Input;
 
// 立案法院
function getFilingCourtApi() {
    return $$.ax.request({ url: 'ctUnit/listCourt', type: 'get', service: 'cust' });
}
 
// 获取调解成功案件
function getSuccessCaseDataApi(submitData) {
    return $$.ax.request({ url: 'judicInfo/pageSuccessCase', type: 'get', data: submitData, service: 'mediate' });
}
 
// 申请材料api
function getApplicationFileApi(submitData) {
    return $$.ax.request({ url: `judicInfo/getCaseApplyFile?caseId=${submitData}`, type: 'get', service: 'mediate' });
}
 
// 司法申请提交
function applyJudicialApi(submitData) {
    return $$.ax.request({ url: 'judicInfo/unitApplyJudic', type: 'post', data: submitData, service: 'mediate' });
}
 
const ApplyJudicial = () => {
    const navigate = useNavigate();
 
    const [form] = Form.useForm();
 
    const [formData, setFormData] = useState({});
 
    const [caseModalSearch, setCaseModalSearch] = useState({ page: 1, size: 10 });
 
    // 成功案件modal
    const [caseModal, setCaseModal] = useState({ visible: false, data: [] });
 
    const [caseCheckModal, setCaseCheckModal] = useState(false);
 
    // 立案法院数据
    const [flingCourtSelectData, setFlingCourtSelectData] = useState([]);
 
    const myUploadRef = useRef();
 
    const [isSuccess, setIsSuccess] = useState(false);
 
    // 案件信息
    const [caseData, setCaseData] = useState({});
 
    const columns = [
        { title: '调解案号', dataIndex: 'caseNo' },
        { title: '申请人', dataIndex: 'plaintiffs' },
        { title: '被申请人', dataIndex: 'defendants' },
        { title: '纠纷类型', dataIndex: 'caseTypeName' },
        { title: '调解类型', dataIndex: 'mediTypeName' },
        { title: '纠纷发生地详址', dataIndex: 'addr' },
        { title: '调解开始', dataIndex: 'mediStartTime' },
        { title: '调解结束', dataIndex: 'mediEndTime' },
        { title: '调解组织', dataIndex: 'mediateUnitName' },
        { title: '调解员', dataIndex: 'mediateUserName' },
        {
            title: '操作',
            dataIndex: 'action',
            width: 50,
            render: (_, record) => <Typography.Link onClick={() => handleChooseCase(record)}>选择</Typography.Link>,
        },
    ];
 
    function handleChangeInput(key, value) {
        if (key === 'courtId') {
            formData.courtId = value[0];
            formData.courtName = value[1];
        } else {
            formData[key] = value;
        }
        setFormData({ ...formData });
    }
 
    // 弹窗查询
    function handleSearch(type, values) {
        let obj = {};
        if (type === 'search') {
            obj = { ...caseModalSearch, ...form.getFieldsValue(), page: 1 };
            $$.changeTimeFormat(obj, 'mediateTime', 'mediEndStart', 'mediEndEnd');
        } else if (type === 'reset') {
            form.resetFields();
            obj = { page: 1, size: 10 };
        } else if (type === 'page') {
            obj = { ...caseModalSearch, page: values.page, size: values.pageSize };
        }
        getSuccessCaseData(obj);
    }
 
    // 选择成功的案件
    function handleChooseCase(record) {
        setFormData({ ...formData, caseId: record.id });
        setCaseModal({ visible: false });
        getApplicationFile(record);
    }
 
    // 提交申请
    function handleApply() {
        let msg = '';
        if (!formData.caseId) {
            msg = '请选择案件';
        } else if (!formData.courtId) {
            msg = '请选择受理单位';
        } else if (!myUploadRef.current.fileList) {
            msg = '请上传调解协议书';
        }
        if (!!msg) {
            $$.info({ type: 'error', content: msg });
            return;
        }
        $$.modalInfo({
            title: '申请司法确认提交确认',
            content: '确定提交当前司法确认申请吗?',
            okText: '确定提交',
            cancelText: '我再想想',
            onOk: applyJudicial,
        });
    }
 
    // 获取调解成功的案件材料
    async function getApplicationFile(record) {
        global.setSpinning(true);
        const res = await getApplicationFileApi(record.id);
        global.setSpinning(false);
        if (res.type) {
            setCaseData({ ...record, fileList: res.data || [] });
        }
    }
 
    // 获取成功案件数据
    async function getSuccessCaseData(submitData) {
        global.setSpinning(true);
        const res = await getSuccessCaseDataApi(submitData);
        global.setSpinning(false);
        if (res.type) {
            setCaseModalSearch(submitData);
            setCaseModal({ visible: true, data: res.data?.content || [], total: res.data?.totalElements });
        }
    }
 
    // 提交申请
    async function applyJudicial() {
        global.setSpinning(true);
        const res = await applyJudicialApi(formData);
        global.setSpinning(false);
        if (res.type) {
            setIsSuccess(true);
        }
    }
 
    // 初始化获取立案法院
    useEffect(() => {
        async function getFilingCourt() {
            const res = await getFilingCourtApi();
            if (res.type) {
                let data = res.data || [];
                setFlingCourtSelectData(data);
                setFormData({ ...formData, courtId: data[0]?.value, courtName: data[0]?.label });
            }
        }
        getFilingCourt();
    }, []);
 
    return (
        <Page
            pageHead={{
                title: '申请司法确认',
                subtitle: '向司法确认受理单位提交司法确认申请',
                breadcrumbData: [{ title: '司法确认申请列表', url: '/mediate/applicationList' }, { title: '申请司法确认' }],
                handleReturn: () => navigate('/mediate/applicationList', { replace: true }),
            }}
        >
            <div className="applyJudicial">
                {isSuccess ? (
                    <div className="applyJudicial-over">
                        <CheckCircleFilled className="applyJudicial-over-icon" />
                        <div className="h6">申请已提交</div>
                        <div className="applyJudicial-over-subtitle">可在「司法确认申请列表」中查看和跟进已提交的申请结果和进度</div>
                        <Space size="large">
                            <Button type="primary" onClick={() => navigate(-1)}>
                                司法确认申请列表
                            </Button>
                            <Button onClick={() => navigate('/mediate/workbench')}>工作台</Button>
                        </Space>
                    </div>
                ) : (
                    <Row gutter={[16, 16]}>
                        <Col span={24}>
                            <h4>
                                <FileTextOutlined className="applyJudicial-titleIcon" />
                                <span>申请信息</span>
                            </h4>
                            <h5>
                                调解案件
                                <span className="leftRequired">*</span>
                            </h5>
                            {formData.caseId ? (
                                <div className="public-fileCard">
                                    <img src={cardIconCaseCheck} alt="" onClick={() => setCaseCheckModal(true)} style={{ cursor: 'pointer' }} />
                                    <div className="public-fileCard-main">
                                        <Typography.Text ellipsis={{ tooltip: caseData.plaintiffs }}>申请人:{caseData.plaintiffs}</Typography.Text>
                                        <Typography.Text ellipsis={{ tooltip: caseData.defendants }} style={{ marginTop: '4px', display: 'block' }}>
                                            被申请人:{caseData.defendants}
                                        </Typography.Text>
                                    </div>
                                    <div
                                        className="public-fileCard-del"
                                        onClick={() => {
                                            setFormData({ ...formData, caseId: undefined });
                                            setCaseData({});
                                        }}
                                    >
                                        <CloseCircleFilled />
                                    </div>
                                </div>
                            ) : (
                                <Button onClick={() => handleSearch('reset')} icon={<FileAddOutlined />}>
                                    选择调解成功的案件
                                </Button>
                            )}
                        </Col>
                        <Col span={24}>
                            <h5>
                                受理单位
                                <span className="leftRequired">*</span>
                            </h5>
                            <Select
                                style={{ width: '354px' }}
                                placeholder="选择开展司法确认工作的相关单位"
                                value={formData.courtId}
                                onChange={(value, options) => handleChangeInput('courtId', [value, options.label])}
                            >
                                {flingCourtSelectData.length !== 0 &&
                                    flingCourtSelectData.map((item) => {
                                        return (
                                            <Option key={item.value} value={item.value} label={item.label}>
                                                {item.label}
                                            </Option>
                                        );
                                    })}
                            </Select>
                        </Col>
                        <Col span={24}>
                            <h5>申请说明</h5>
                            <TextArea
                                value={formData.applyContent}
                                onChange={(e) => handleChangeInput('applyContent', e.target.value)}
                                rows={2}
                                placeholder="描述申请的背景和理由"
                                allowClear
                            />
                        </Col>
                        {!!formData.caseId && (
                            <>
                                <Col span={24}>
                                    <div className="applyJudicial-divider" />
                                </Col>
                                <Col span={24}>
                                    <h4>
                                        <BranchesOutlined className="applyJudicial-titleIcon" />
                                        <span>申请材料</span>
                                    </h4>
                                    <h5>
                                        调解协议书
                                        <span className="leftRequired">*</span>
                                    </h5>
                                    <MyUpload
                                        fileId={formData.caseId}
                                        fileType="22_00018-302"
                                        myUploadRef={myUploadRef}
                                        fileList={caseData.fileList?.filter((item) => item.ownerType === '22_00018-302')[0]?.fileList || []}
                                    />
                                </Col>
                                <Col span={24}>
                                    <h5>司法确认申请书</h5>
                                    <MyUpload
                                        fileId={formData.caseId}
                                        fileType="22_00018-402"
                                        fileList={caseData.fileList?.filter((item) => item.ownerType === '22_00018-402')[0]?.fileList || []}
                                    />
                                </Col>
                                <Col span={24}>
                                    <h5>人民调解委员会主持调解的证明</h5>
                                    <MyUpload
                                        fileId={formData.caseId}
                                        fileType="22_00018-306"
                                        fileList={caseData.fileList?.filter((item) => item.ownerType === '22_00018-306')[0]?.fileList || []}
                                    />
                                </Col>
                                <Col span={24}>
                                    <h5>其他材料</h5>
                                    <MyUpload
                                        fileId={formData.caseId}
                                        fileType="22_00018-409"
                                        fileList={caseData.fileList?.filter((item) => item.ownerType === '22_00018-409')[0]?.fileList || []}
                                    />
                                </Col>
                            </>
                        )}
                        <Col span={24}>
                            <Button onClick={handleApply} type="primary">
                                提交申请
                            </Button>
                        </Col>
                    </Row>
                )}
            </div>
            <MyModal width={1200} visible={caseModal.visible} cancelText="关闭页面" onCancel={() => setCaseModal({ visible: false })}>
                <Row gutter={[16, 16]}>
                    <Col span={24}>
                        <h4 style={{ margin: 0 }}>选择调解成功案件</h4>
                    </Col>
                    <Col span={24}>
                        <TableSearch
                            form={form}
                            itemData={[
                                { type: 'Input', name: 'plaintiffs', label: '申请人' },
                                { type: 'Input', name: 'defendants', label: '被申请人' },
                                { type: 'RangePicker', name: 'mediateTime', label: '调解时间' },
                                { type: 'Input', name: 'mediateUserName', label: '调解员' },
                                { type: 'Input', name: 'addr', label: '纠纷发生地' },
                                { type: 'Input', name: 'caseNo', label: '调解案号' },
                            ]}
                            handleReset={() => handleSearch('reset')}
                            handleSearch={() => handleSearch('search')}
                        />
                    </Col>
                    <Col span={24}>
                        <div className="applyJudicial-divider" />
                    </Col>
                    <Col span={24}>
                        <div className="applyJudicial-modalTable">
                            <TableView
                                size="small"
                                showHeader
                                title="查询结果"
                                columns={columns}
                                dataSource={caseModal.data}
                                pagination={{
                                    total: caseModal.total,
                                    pageSize: caseModalSearch.size,
                                    current: caseModalSearch.page,
                                    onChange: (page, pageSize) => handleSearch('page', { page, pageSize }),
                                }}
                            />
                        </div>
                    </Col>
                </Row>
            </MyModal>
            <MyModal width={1200} visible={caseCheckModal} onCancel={() => setCaseCheckModal(false)} footer={false}>
                <DisputeMsg caseId={formData.caseId} isModal />
            </MyModal>
        </Page>
    );
};
 
export default ApplyJudicial;