广州市综治平台前端
liuwh
6 days ago bd4e6eb3d29de84c00f5e448f5839300873a6abe
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
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-05-14 14:15:01
 * @LastEditTime: 2022-12-02 14:43:26
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 开始司法确认
 */
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { useSearchParams } from 'react-router-dom';
import { Row, Col, Space, Select, Input, Button, Radio } from 'antd';
import * as $$ from '../../../utils/utility';
 
const { Option } = Select;
 
// 获取司法确认预约记录
function getOrderRecordApi(submitData) {
    return $$.ax.request({ url: `judicInfo/pcWindowMeetInfos?caseId=${submitData}`, type: 'get', service: 'mediate' });
}
 
// 开始司法确认
function startMediationApi(submitData) {
    return $$.ax.request({ url: `judicInfo/pcWindowStartJudic`, type: 'post', service: 'mediate', data: submitData });
}
 
/**
 * onStartMediation, // 开始司法确认回调函数
 */
const MediateStart = ({ onStartMediation }) => {
    const [searchParams] = useSearchParams();
 
    const caseId = searchParams.get('caseId');
 
    // 提交数据
    const [submitData, setSubmitData] = useState({});
 
    // 没有预约计划外的则不可以选择计划内
    const [startTypeDis, setStartTypeDis] = useState(false);
 
    function handleChangeInput(key, value) {
        if (key === 'meetWay') {
            submitData.meetWay = value[0];
            submitData.meetWayName = value[1];
        } else {
            submitData[key] = value;
        }
        setSubmitData({ ...submitData });
    }
 
    // 确定开始
    async function handleStart() {
        global.setSpinning(true);
        const res = await startMediationApi({ caseId, startType: submitData.startType, meetInfo: submitData.startType === '2' ? submitData : undefined });
        global.setSpinning(false);
        if (res.type) {
            onStartMediation();
        }
    }
 
    useEffect(() => {
        // 获取预约记录
        async function getOrderRecord() {
            global.setSpinning(true);
            const res = await getOrderRecordApi(caseId);
            global.setSpinning(false);
            if (res.type) {
                let data = res.data?.reverse() || [];
                setSubmitData({
                    startType: data[0]?.id ? '1' : '2',
                    meetWay: $$.options.meetWay[0].value,
                    meetWayName: $$.options.meetWay[0].label,
                    ...data[0],
                });
                setStartTypeDis(!data[0]?.id);
            }
        }
        getOrderRecord();
    }, [caseId]);
 
    return (
        <>
            <div className="mediationWindow-modal-main">
                <Row gutter={[16, 16]}>
                    <Col span={24}>
                        <h5>开始选项</h5>
                        <Radio.Group onChange={(e) => handleChangeInput('startType', e.target.value)} value={submitData.startType} disabled={startTypeDis}>
                            <Space direction="vertical">
                                <Radio value="1">
                                    计划内司法确认
                                    {submitData.startType === '1' && <span className="mediationWindow-modal-subtitle">(在预约司法确认时间内的开始)</span>}
                                </Radio>
                                <Radio value="2">
                                    计划外司法确认
                                    {submitData.startType === '2' && (
                                        <span className="mediationWindow-modal-subtitle">(临时司法确认或不在预约司法确认时间内的开始)</span>
                                    )}
                                </Radio>
                            </Space>
                        </Radio.Group>
                    </Col>
                    <Col span={24}>
                        <h5>司法确认方式</h5>
                        <Select
                            onChange={(value, options) => handleChangeInput('meetWay', [value, options.label])}
                            value={submitData.meetWay}
                            style={{ width: '250px' }}
                        >
                            {$$.options.meetWay.map((x) => (
                                <Option value={x.value} key={x.value} label={x.label}>
                                    {x.label}
                                </Option>
                            ))}
                        </Select>
                    </Col>
                    <Col span={24}>
                        <h5>司法确认地点</h5>
                        <Input
                            style={{ width: '500px' }}
                            onChange={(e) => handleChangeInput('meetAddr', e.target.value)}
                            value={submitData.meetAddr}
                            placeholder="输入案件的实际司法确认地址"
                            allowClear
                        />
                    </Col>
                    <Col span={24}>
                        <h5>司法确认须知</h5>
                        <div className="mediationWindow-modal-subtitle">
                            <div>平台将在司法确认开始后对司法确认过程进行计时,并在司法确认结束后终止计时。 </div>
                            <div>结束确认:已经具备司法确认结论,反馈司法确认结果。</div>
                        </div>
                    </Col>
                </Row>
            </div>
            <div className="mediationWindow-modal-footer">
                <Button type="primary" onClick={handleStart}>
                    立即开始
                </Button>
            </div>
        </>
    );
};
 
MediateStart.propTypes = {
    onStartMediation: PropTypes.func,
};
 
export default MediateStart;