forked from gzzfw/frontEnd/gzDyh

dminyi
2024-08-09 a2a5220469a3e1f8bc216f47c887ca4c941920b0
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
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-07-14 11:29:36
 * @LastEditTime: 2022-11-28 14:39:42
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 工作流程新建 or 修改
 */
import React, { useState, useEffect } from 'react';
import { useNavigate, useSearchParams, useLocation } from 'react-router-dom';
import { Button, Row, Col, Input, Select, Switch, Space, Typography, Radio, Checkbox } from 'antd';
import { FileTextOutlined, AimOutlined, BranchesOutlined, BankOutlined, AppstoreOutlined } from '@ant-design/icons';
import Page from '../../../components/Page';
import * as $$ from '../../../utils/utility';
import TableView from '../../../components/TableView';
import MyModal from '../../../components/MyModal';
import SelectObjModal from '../../../components/SelectObjModal';
 
const { TextArea } = Input;
 
const { Option } = Select;
 
const WorkflowManageEdit = () => {
    const navigate = useNavigate();
 
    const location = useLocation();
 
    const [searchParams] = useSearchParams();
 
    // 区别纠纷调解 or 司法确认
    const type = searchParams.get('type') || 'mediate';
 
    // 区别新增 or 修改
    const editType = searchParams.get('editType') || 'add';
 
    // 表单数据
    const [formData, setFormData] = useState({});
 
    // 是否选择流程步骤
    const [stepData, setStepData] = useState({ visible: false });
 
    // 执行者选择modal
    const [actionUser, setActionUser] = useState({ visible: false });
 
    // 选择组织modal
    const [unitVisible, setUnitVisible] = useState(false);
 
    // 选择纠纷类型modal
    const [disputeModal, setDisputeModal] = useState({ visible: false });
 
    const title = `${editType === 'add' ? '新建' : '修改'}${type === 'mediate' ? '纠纷调解' : '司法确认'}流程`;
 
    // 步骤columns
    const columns = [
        { title: '步骤顺序', dataIndex: 'num', render: (text, record, index) => index + 1 },
        { title: '步骤名称', dataIndex: 'xxx1' },
        { title: '步骤描述', dataIndex: 'xxx2' },
        {
            title: '处理时限',
            dataIndex: 'expireTime',
            render: (text, record, index) => {
                let obj = $$.getHours(text);
                return record.status === '1' ? (
                    <span className={obj.isNegativeNum ? 'tableView-dangerTime' : ''}>{!!text ? `${obj.hours}小时` : '-'}</span>
                ) : (
                    '-'
                );
            },
        },
        { title: '步骤页面名称', dataIndex: 'xxx3' },
        { title: '步骤页面编号', dataIndex: 'xxx4' },
        { title: '执行者', dataIndex: 'xxx5', render: (text) => <span className="public-tag public-tag-tagBlue2">未设置</span> },
        { title: '操作', dataIndex: 'action', render: () => <Typography.Link>设置执行者</Typography.Link>, width: 100 },
    ];
 
    // 选择步骤
    function handleChooseStep() {
        setStepData({ visible: true });
    }
 
    // 表单修改
    function handleChangeInput(key, value) {
        console.log(key, value);
        setFormData({ ...formData, [key]: value });
    }
 
    // 表单提交
    function handleSubmitForm(values) {
        $$.modalInfo({ title: '工作流模板新建确认', content: `确定建立「婚姻纠纷通用调解流程」吗?`, cancelText: '我再想想', okText: '确定创建' });
    }
 
    // 保存信息
    function handleSaveMsg() {
        if (editType === 'add') {
            $$.modalInfo({ title: '保存工作流确认', content: '确定保存工作流信息吗?', okText: '确定保存' });
        } else {
            $$.modalInfo({ title: '修改工作流确认', content: '修改成功后将不会改变该工作流的生效状态,确定进行修改工作流操作吗?', okText: '确定修改' });
        }
    }
 
    useEffect(() => {
        console.log(location.state);
        setFormData({});
    }, []);
 
    const radioArr = [
        {
            label: '所有人',
            value: 1,
            subtitle: '(拥有该页面权限的所有人)',
        },
        {
            label: '上一步骤选择',
            value: 2,
            subtitle: '(由上一步骤执行者选择当前步骤的执行者)',
        },
        {
            label: '上一步骤执行者',
            value: 3,
            subtitle: '(上一步骤的执行者为当前步骤的执行者)',
        },
        {
            label: '固定角色',
            value: 4,
            subtitle: '(固定角色作为当前步骤的执行者)',
        },
    ];
 
    return (
        <Page
            pageHead={{
                title: title,
                subtitle: type === 'mediate' ? '设置工作流步骤、适用组织单位及纠纷类型等信息' : '设置司法确认有关组织进行司法确认工作的流程步骤等信息',
                breadcrumbData: [{ title: '工作流管理', url: '/mediate/workflowManage' }, { title: title }],
                handleReturn: () => navigate(-1),
            }}
        >
            <div className="workflowManage-edit">
                <div className="workflowManage-edit-form">
                    <Row gutter={[16, 16]}>
                        <Col span={24}>
                            <h4>
                                <FileTextOutlined className="workflowManage-edit-titleIcon" />
                                <span>基础信息</span>
                            </h4>
                            <h5>
                                流程名称
                                <span className="leftRequired">*</span>
                            </h5>
                            <Input
                                style={{ width: '340px' }}
                                value={formData.xxx1}
                                onChange={(e) => handleChangeInput('xxx1', e.target.value)}
                                placeholder="输入流程名称"
                                allowClear
                            />
                        </Col>
                        {type === 'mediate' && (
                            <Col span={24}>
                                <h5>调解类型</h5>
                                <Select
                                    value={formData.mediType}
                                    style={{ width: '340px' }}
                                    onChange={(value, option) => handleChangeInput('mediType', [value, option.children])}
                                >
                                    {$$.options.mediateType.map((x, t) => (
                                        <Option key={x.value}>{x.label}</Option>
                                    ))}
                                </Select>
                            </Col>
                        )}
                        <Col span={24}>
                            <h5>流程描述</h5>
                            <TextArea
                                value={formData.xxx1}
                                onChange={(e) => handleChangeInput('xxx1', e.target.value)}
                                placeholder="简要描述流程的特点及使用的场景"
                                allowClear
                            />
                        </Col>
                        <Col span={24}>
                            <div className="workflowManage-edit-divider" />
                        </Col>
                        <Col span={24}>
                            <h4>
                                <AimOutlined className="workflowManage-edit-titleIcon" />
                                <span>适用范围</span>
                            </h4>
                            {type === 'mediate' ? (
                                <>
                                    <Space>
                                        <h5 style={{ margin: 0 }}>自定义适用组织</h5>
                                        <Switch size="small" checked={formData.xxx2} onChange={(checked) => handleChangeInput('xxx2', checked)} />
                                    </Space>
                                    <div className="workflowManage-edit-switchSubtitle">
                                        {formData.xxx2 ? '工作流将仅对设置的组织单位生效' : '默认适用全部的组织单位,如需为指定组织单位单独设置流程信息,请开启此选项'}
                                    </div>
                                    {formData.xxx2 && (
                                        <Space size="middle">
                                            <Button type="dashed" icon={<BankOutlined />}>
                                                选择组织
                                            </Button>
                                            <span>已选择:5个组织</span>
                                        </Space>
                                    )}
                                </>
                            ) : (
                                <>
                                    <h5>
                                        适用组织<span className="leftRequired">*</span>
                                    </h5>
                                    <div className="workflowManage-edit-switchSubtitle">根据司法确认现行规定,仅有法院、派驻法庭及法官工作站具备司法确认的受理资格</div>
                                    <Space size="middle">
                                        <Button type="dashed" icon={<BankOutlined />}>
                                            选择组织
                                        </Button>
                                        <span>已选择:5个组织</span>
                                    </Space>
                                </>
                            )}
                        </Col>
                        {type === 'mediate' && (
                            <Col span={24}>
                                <Space>
                                    <h5 style={{ margin: 0 }}>自定义纠纷类型</h5>
                                    <Switch size="small" checked={formData.xxx3} onChange={(checked) => handleChangeInput('xxx3', checked)} />
                                </Space>
                                <div className="workflowManage-edit-switchSubtitle">
                                    {formData.xxx3 ? '工作流将仅对设置的纠纷类型生效' : '默认适用全部的纠纷类型,如需为指定纠纷类型单独设置流程信息,请开启此选项'}
                                </div>
                                {formData.xxx3 && (
                                    <Space size="middle">
                                        <Button type="dashed" icon={<AppstoreOutlined />} onClick={() => setDisputeModal({ visible: true })}>
                                            选择纠纷类型
                                        </Button>
                                        <span>已选择:8个纠纷类型</span>
                                    </Space>
                                )}
                            </Col>
                        )}
                        <Col span={24}>
                            <div className="workflowManage-edit-divider" />
                        </Col>
                        <Col span={24}>
                            <h4>
                                <BranchesOutlined className="workflowManage-edit-titleIcon" />
                                <span>流程步骤</span>
                            </h4>
                            {stepData.visible ? (
                                <TableView columns={columns} dataSource={[{}]} />
                            ) : (
                                <div className="workflowManage-edit-step">
                                    {[1, 2, 3, 4, 5, 6, 7].map((x, t) => {
                                        return (
                                            <div className="workflowManage-edit-step-item" key={t}>
                                                <h5 className="workflowManage-edit-step-header">
                                                    <div className="workflowManage-edit-step-icon">
                                                        <BranchesOutlined />
                                                    </div>
                                                    <div>简易案件通用调解流程</div>
                                                </h5>
                                                <Space direction="vertical" className="workflowManage-edit-step-content">
                                                    <div>
                                                        <h5>流程步骤</h5>
                                                        <div>签收、受理审查、指派调解员、纠纷调解、结果确认、结案归档</div>
                                                    </div>
                                                    <div>
                                                        <h5>更新时间</h5>
                                                        <div>{$$.dateFormat(new Date())}</div>
                                                    </div>
                                                    <div>
                                                        <h5>流程描述</h5>
                                                        <div>适合简单的矛盾纠纷案件的快速调解需求。</div>
                                                    </div>
                                                </Space>
                                                <div className="workflowManage-edit-step-button">
                                                    <Button type="primary" onClick={handleChooseStep}>
                                                        使用
                                                    </Button>
                                                </div>
                                            </div>
                                        );
                                    })}
                                </div>
                            )}
                        </Col>
                    </Row>
                </div>
                <Space size="middle">
                    <Button type="primary" onClick={handleSaveMsg}>
                        保存信息
                    </Button>
                    {stepData.visible && (
                        <Button className="public-mainBtn" onClick={() => setStepData({ visible: false })}>
                            重置流程步骤
                        </Button>
                    )}
                </Space>
            </div>
            {/* 设置执行者 */}
            <MyModal
                visible={actionUser.visible}
                width={558}
                onCancel={() => setActionUser({ visible: false })}
                cancelText="关闭页面"
                okText="保存设置"
                onOk={() => console.log(99)}
            >
                <Row gutter={[16, 16]}>
                    <Col span={24}>
                        <h4 style={{ margin: 0 }}>设置执行者</h4>
                    </Col>
                    <Col span={24}>
                        <h5>步骤名称</h5>
                        <div>签收</div>
                    </Col>
                    <Col span={24}>
                        <h5>执行者类型</h5>
                        <Radio.Group>
                            <Space direction="vertical">
                                {radioArr.map((x, t) => (
                                    <Radio value={x.value} key={x.value}>
                                        {x.label}
                                        <span className="workflowManage-edit-subtitle">{x.subtitle}</span>
                                    </Radio>
                                ))}
                            </Space>
                        </Radio.Group>
                    </Col>
                    <Col span={24}>
                        <h5>
                            选择角色<span className="leftRequired">*</span>
                        </h5>
                        <Select style={{ width: '220px' }}></Select>
                    </Col>
                </Row>
            </MyModal>
            {/* 选择组织 */}
            <SelectObjModal visible={unitVisible} checkKeys={[]} type="unit" isCheckbox onClose={() => setUnitVisible(false)} />
            {/* 选择纠纷类型 */}
            <MyModal
                visible={disputeModal.visible}
                width={558}
                onCancel={() => setDisputeModal({ visible: false })}
                cancelText="关闭页面"
                okText="保存设置"
                onOk={() => console.log(99)}
            >
                <Row gutter={[16, 16]}>
                    <Col span={24}>
                        <h4 style={{ margin: 0 }}>自定义纠纷类型</h4>
                    </Col>
                    <Col span={24}>
                        <div className="workflowManage-edit-dispute-flex">
                            <h5>纠纷类型</h5>
                            <Typography.Link>全选</Typography.Link>
                        </div>
                        <Checkbox.Group style={{ width: '100%' }}>
                            <Row>
                                <Col
                                    span={24}
                                    className={`workflowManage-edit-dispute-checkbox workflowManage-edit-dispute-checkboxActive`}
                                    style={{ padding: '4px 12px' }}
                                >
                                    <Checkbox value={1}>荔湾区政法委</Checkbox>
                                </Col>
                                <Col span={24} className="workflowManage-edit-dispute-checkbox">
                                    <Checkbox value={2}>白云区政法委</Checkbox>
                                </Col>
                            </Row>
                        </Checkbox.Group>
                    </Col>
                </Row>
            </MyModal>
        </Page>
    );
};
 
export default WorkflowManageEdit;