广州市综治平台前端
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
/*
 * @Company: hugeInfo
 * @Author: ldh
 * @Date: 2022-07-13 15:51:50
 * @LastEditTime: 2022-11-28 10:51:30
 * @LastEditors: ldh
 * @Version: 1.0.0
 * @Description: 工作流模板管理
 */
import React, { useState, useEffect } from 'react';
import { useNavigate, useLocation, useSearchParams } from 'react-router-dom';
import { Button, Form, Space, Typography } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import Page from '../../../components/Page';
import TableView from '../../../components/TableView';
import TableSearch from '../../../components/TableSearch';
import * as $$ from '../../../utils/utility';
 
// 获取工作流模板数据
function getWorkflowTempApi(submitData) {
    return $$.ax.request({ url: '', type: 'get', data: submitData, service: '' });
}
 
const { Link } = Typography;
 
const WorkflowTemplate = () => {
    const location = useLocation();
 
    const navigate = useNavigate();
 
    const [searchParams] = useSearchParams();
 
    const [form] = Form.useForm();
 
    // 搜索
    const [search, setSearch] = useState({ page: 1, size: 10 });
 
    // 数据
    const [data, setData] = useState({});
 
    const columns = [
        { title: '流程模板类型', dataIndex: 'xxx1' },
        { title: '流程模板名称', dataIndex: 'xxx2' },
        { title: '流程步骤', dataIndex: 'xxx3' },
        { title: '流程模板描述', dataIndex: 'xxx4' },
        { title: '生效状态', dataIndex: 'xxx5', width: 85, render: (text) => <div className={`public-tag public-tag-tagBlue`}>启用中</div> },
        { title: '更新时间', dataIndex: 'xxx6' },
        { title: '更新人', dataIndex: 'xxx7' },
        { title: '适用用户', dataIndex: 'xxx8' },
        {
            title: '操作',
            dataIndex: 'action',
            width: 210,
            render: (_, record) => (
                <Space size="middle">
                    <Link>启用</Link>
                    <Link onClick={() => handleJump('change', record)}>修改</Link>
                    <Link>配置节点</Link>
                    <Link onClick={() => handleDel(record)}>删除</Link>
                </Space>
            ),
        },
    ];
 
    // 新建,修改,查看跳转
    function handleJump(editType, record) {
        $$.setSessionStorage(location.pathname, {
            search,
            tableActive: null,
        });
        navigate(`/mediate/workflowTemplate/workflowTemplateEdit?editType=${editType}&back=${location.pathname}`, { state: { aa: 11 } });
    }
 
    // 删除模板
    function handleDel(record) {
        $$.modalInfo({ title: '工作流模板删除确认', content: `确定删除「婚姻纠纷通用调解流程」吗?`, cancelText: '我再想想', okText: '确定删除' });
    }
 
    // 搜索 or 重置
    function handleSearch(type, data) {
        if (type === 'recovery') {
            // 案件详情返回时恢复跳转前查询
            let obj = Object.assign({}, data.search);
            form.setFieldsValue(obj);
            getWorkflowTemp(obj);
            return;
        }
        if (type === 'reset') {
            form.resetFields();
            getWorkflowTemp({ page: 1, size: 10 });
            return;
        }
        if (type === 'search') {
            let values = form.getFieldsValue();
            getWorkflowTemp({ ...search, ...values, page: 1 });
            return;
        }
        if (type === 'changePage') {
            getWorkflowTemp({ ...search, page: data[0], size: data[1] });
        }
    }
 
    // 获取数据
    async function getWorkflowTemp(submitData, tableActive) {
        global.setSpinning(true);
        const res = await getWorkflowTempApi(submitData);
        global.setSpinning(false);
        if (res.type) {
            setData({ total: res.data?.totalElements, tableData: res.data?.content || [], tableActive });
        }
    }
 
    return (
        <Page pageHead={{ title: '工作流模板管理', subtitle: '为平台内调解及司法确认涉及的工作流制作相关模板' }}>
            <div className="workflowTemplate">
                <div className="pageSearch">
                    <TableSearch
                        labelLength={6}
                        form={form}
                        itemData={[
                            { type: 'Input', name: 'xxx1', label: '流程模板名称' },
                            {
                                type: 'Select',
                                name: 'xxx2',
                                label: '流程模板类型',
                                selectdata: [
                                    { label: '纠纷调解', value: '1' },
                                    { label: '司法确认', value: '2' },
                                ],
                            },
                            {
                                type: 'Select',
                                name: 'xxx3',
                                label: '生效状态',
                                selectdata: [
                                    { label: '启用', value: '1' },
                                    { label: '停用', value: '2' },
                                ],
                            },
                            {
                                type: 'Select',
                                name: 'xxx4',
                                label: '适用客户',
                                selectdata: [],
                                placeholder: '选择使用流程模板的客户名称',
                            },
                        ]}
                        handleReset={() => handleSearch('reset')}
                        handleSearch={() => handleSearch('search')}
                    />
                </div>
                <div className="pageTable">
                    <TableView
                        showHeader
                        title="查询结果"
                        buttonAction={[
                            <Button type="primary" icon={<PlusOutlined />} onClick={() => handleJump('add')}>
                                新建流程模板
                            </Button>,
                        ]}
                        columns={columns}
                        dataSource={data.tableData || [{}]}
                        rowClassName={(record, index) => (record.id === data.tableActive ? 'tableRowActive' : '')}
                        pagination={{
                            current: search.page,
                            pageSize: search.size,
                            total: data.total,
                            onChange: (page, pageSize) => handleSearch('changePage', [page, pageSize]),
                        }}
                    />
                </div>
            </div>
        </Page>
    );
};
 
export default WorkflowTemplate;