广州市综治平台前端
xusd
2025-06-07 ee685c9f350ec9241107d4e8a05799768a0bce9a
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
import React, { useRef, useState, useEffect } from 'react';
import { Row, Col } from 'antd';
import { Form, Input, Button, Select } from '@arco-design/web-react';
import ArcoUpload from '@/components/ArcoUpload';
import { Scrollbars } from 'react-custom-scrollbars';
import SelectObjModal from '@/components/SelectObjModal/selectPerson';
import * as $$ from '@/utils/utility';
import { useNavigate } from 'react-router-dom';
 
const FormItem = Form.Item;
const TextArea = Input.TextArea;
const appUrl = $$.appUrl;
 
function assign(data) {
    return $$.ax.request({ url: `caseTask/assign`, type: 'post', service: 'mediate', data });
}
 
function delFile(id) {
    return $$.ax.request({ url: `fileInfo/deleteFileById`, type: 'get', service: 'sys', data: { id } });
}
 
export default function BackModel(props) {
    const navigate = useNavigate();
    const formRef = useRef();
    const [isModalVisible, setIsModalVisible] = useState(false);
    const [wantUser, setWantUser] = useState({});
    const [mainDept, setMainDept] = useState('handleUnit'); //判断打开弹窗的是承办部门还是配合部门
    const [selectOptions, setSelectOptions] = useState({}); //两个部门选择的options
 
    useEffect(() => {}, []);
 
    const handleSubmit = () => {
        formRef.current.validate(undefined, (errors, values) => {
            if (!errors) {
                handleAssign({
                    caseTaskId: props.caseTaskId,
                    assignContent: values.assignContent,
                    handleUnitId: wantUser['handleUnit'][0].value,
                    handleUnitName: wantUser['handleUnit'][0].name,
                    assistUnitList:
                        wantUser['assistUnit'] &&
                        wantUser['assistUnit'].map((item) => {
                            return {
                                uitId: item.value,
                                uitName: item.name,
                            };
                        }),
                });
            }
        });
    };
 
    const handleTemplate = (type) => {
        if (type === 1) {
            formRef.current.setFieldValue(
                'assignContent',
                '本事项经初步核实,认为属于贵部门职责范围内的矛盾纠纷化解工作。请组织专门人员负责此事,尽快查明事实真相,依法依规进行处理,并在处理过程中充分考虑当事人的合理诉求,确保公平公正,维护当事人的合法权益。同时,请务必保持与当事人的沟通畅通,及时反馈办理进展,以增强矛盾纠纷化解工作的透明度和公信力。'
            );
        } else {
            formRef.current.setFieldValue('assignContent', '');
        }
    };
 
    //交办请求
    const handleAssign = async (data) => {
        const res = await assign(data);
        if (res.type) {
            $$.infoSuccess({ content: '交办成功!' });
            props.onCancel();
            navigate('/mediate/visit/visitWorkBench');
        }
    };
 
    //删除文件
    const handleDelFile = async (id) => {
        const res = await delFile(id);
        if (res.type) {
            $$.infoSuccess({ content: '删除成功!' });
        }
    };
 
    //form数据同步要提交的数据
    const handleSync = (field, value) => {
        wantUser[field] = wantUser[field].filter((item) => value.indexOf(item.value) != -1);
        setWantUser(wantUser);
    };
 
    return (
        <div>
            <Scrollbars style={{ height: '550px' }} autoHide>
                <Form
                    ref={formRef}
                    layout="vertical"
                    requiredSymbol={false}
                    initialValues={{}} //默认值
                    scrollToFirstError
                >
                    <Row>
                        <Col span={24}>
                            <FormItem
                                label={
                                    <div style={{ display: 'flex' }}>
                                        承办部门<div className="must">必填</div>
                                    </div>
                                }
                                field="handleUnit"
                                rules={[{ required: true, message: '请选择承办部门' }]}
                            >
                                <Select
                                    mode="multiple"
                                    placeholder="请选择承办部门"
                                    allowClear
                                    onFocus={(e) => {
                                        e.stopPropagation();
                                        setIsModalVisible(true);
                                        setMainDept('handleUnit');
                                    }}
                                    options={selectOptions['handleUnit']}
                                    onChange={(v) => {
                                        handleSync('handleUnit', v);
                                    }}
                                ></Select>
                            </FormItem>
                        </Col>
                        <Col span={24}>
                            <FormItem
                                label={
                                    <div style={{ display: 'flex' }}>
                                        配合部门<div style={{ color: '#86909C' }}>(可多选)</div>
                                    </div>
                                }
                                field="assistUnit"
                            >
                                <Select
                                    mode="multiple"
                                    placeholder="请选择配合部门"
                                    allowClear
                                    onFocus={(e) => {
                                        e.stopPropagation();
                                        setIsModalVisible(true);
                                        setMainDept('assistUnit');
                                    }}
                                    options={selectOptions['assistUnit']}
                                    onChange={(v) => {
                                        handleSync('assistUnit', v);
                                    }}
                                ></Select>
                            </FormItem>
                        </Col>
                        <Col span={24} style={{ position: 'relative' }}>
                            <div style={{ position: 'absolute', display: 'flex ', top: '28px', zIndex: 1 }}>
                                <div
                                    className="myTag"
                                    style={{ marginRight: '22px' }}
                                    onClick={() => {
                                        handleTemplate(1);
                                    }}
                                >
                                    公共模板1:通用交办意见范本
                                </div>
                            </div>
                            <FormItem
                                label={
                                    <div style={{ display: 'flex' }}>
                                        交办意见<div className="must">必填</div>
                                    </div>
                                }
                                field="assignContent"
                                rules={[{ required: true, message: '请选择交办理由' }]}
                            >
                                <TextArea autoSize={{ minRows: 4, maxRows: 8 }} placeholder="请填写交办的具体理由" style={{ marginTop: '40px' }} />
                            </FormItem>
                        </Col>
                        <Col span={24} className="doubleFile">
                            <ArcoUpload
                                params={{
                                    action: `${appUrl.fileUrl}/${appUrl.sys}/api/web/fileInfo/upload?mainId=${props.caseId}&ownerId=${props.caseTaskId}&ownerType=22_00018-501`,
                                }}
                                field="file"
                                label="附件材料"
                                handleDelFile={handleDelFile}
                            />
                        </Col>
                    </Row>
                </Form>
            </Scrollbars>
            <div className="dialogFooter">
                <Button type="primary" className="dialogPrimary" onClick={handleSubmit}>
                    提交
                </Button>
            </div>
            <SelectObjModal
                visible={isModalVisible}
                checkKeys={wantUser[mainDept]}
                onOk={(value) => {
                    console.log(value);
                    setIsModalVisible(false);
                    wantUser[mainDept] = value.items;
                    setWantUser(wantUser);
                    selectOptions[mainDept] = value.items.map((item) => ({
                        label: item.name,
                        value: item.value,
                    }));
                    setSelectOptions(selectOptions);
                    formRef.current.setFieldValue(
                        mainDept,
                        value.items.map((item) => item.value)
                    );
                }}
                onClose={() => setIsModalVisible(false)}
                type="dept"
                isCheckbox={mainDept === 'handleUnit' ? false : true}
            />
        </div>
    );
}