forked from gzzfw/frontEnd/gzDyh

liuwh
2024-09-13 6a2c0e50aabe2c2fda7671d75d7550f12d72e411
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
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-05-14 14:15:01
 * @LastEditTime: 2022-12-02 14:30:55
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 开始调解
 */
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
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: `caseInfo/pcWindowMeetInfos?caseId=${submitData}`, type: 'get', service: 'mediate' });
}
 
// 开始调解
function startMediationApi(submitData) {
    return $$.ax.request({ url: `caseInfo/pcWindowStartMediate`, type: 'post', service: 'mediate', data: submitData });
}
 
/**
 * onStartMediation, // 开始调解回调函数
 */
const MediateStart = ({ caseId, onStartMediation }) => {
    // 提交数据
    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>结束调解:已经具备调解结论,反馈调解结果。</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;