ProcessModal.jsx 6.1 KB
Newer Older
皮倩雯's avatar
皮倩雯 committed
1
import React, { useEffect, useState } from 'react';
皮倩雯's avatar
皮倩雯 committed
2
import { Modal, Table, Tooltip, notification, Space, Popconfirm } from 'antd';
皮倩雯's avatar
皮倩雯 committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import {
    PlusSquareFilled,
    EditTwoTone,
    DeleteOutlined,
} from '@ant-design/icons';
import styles from './incident.less';
import { GetCM_Event_LoadEvenFlows, CM_Event_RemoveEvenFlow } from '@/services/standingBook/api';
import AddFlowsModal from './AddFlowsModal'
const ProcessModal = props => {
    const { callBackSubmit = () => { }, title1, visible, onCancel, formObj, maxLength} = props;
    const [tableData, setTableData] = useState([])
    const [addVisible, setAddVisible] = useState(false)
    const [isType, setIsType] = useState(''); // 弹窗类型
    const [record1, setRecord1] = useState('')
    const [obj, setObj] = useState('')
皮倩雯's avatar
皮倩雯 committed
18
    const [flag, setFlag] = useState(0)
皮倩雯's avatar
皮倩雯 committed
19 20 21 22


    const columns = [
        {
皮倩雯's avatar
皮倩雯 committed
23
            title: () => (<span style={{fontWeight:'bold'}}>流程名称</span>),
皮倩雯's avatar
皮倩雯 committed
24 25 26
            dataIndex: 'FlowName',
            key: 'FlowName',
            width: 150,
皮倩雯's avatar
皮倩雯 committed
27
            ellipsis: true,
皮倩雯's avatar
皮倩雯 committed
28 29 30 31 32 33 34 35 36
            // render: item => (
            //     <div
            //         ref={r => {
            //             if (r) {
            //                 r.innerHTML = item;
            //             }
            //         }}
            //     />
            // )
皮倩雯's avatar
皮倩雯 committed
37 38 39
        }
        ,
        {
皮倩雯's avatar
皮倩雯 committed
40
            title: () => (<span style={{fontWeight:'bold'}}>受理权限</span>),
皮倩雯's avatar
皮倩雯 committed
41 42
            dataIndex: 'FlowRoles',
            key: 'FlowRoles',
皮倩雯's avatar
皮倩雯 committed
43
            width: 400,
皮倩雯's avatar
皮倩雯 committed
44
            ellipsis: true,
皮倩雯's avatar
皮倩雯 committed
45 46 47 48 49 50 51 52 53
            // render: item => (
            //     <div
            //         ref={r => {
            //             if (r) {
            //                 r.innerHTML = item;
            //             }
            //         }}
            //     />
            // )
皮倩雯's avatar
皮倩雯 committed
54 55
        },
        {
皮倩雯's avatar
皮倩雯 committed
56
            title: () => (<span style={{fontWeight:'bold'}}>操作</span>),
皮倩雯's avatar
皮倩雯 committed
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
            key: 'action',
            aligin: 'center',
            render: record => (
                <Space size="middle">

                    <Tooltip title="编辑用户">
                        <EditTwoTone
                            onClick={() => editEventType(record)}
                            style={{ fontSize: '16px' }}
                        />
                    </Tooltip>
                    <Tooltip title="删除">
                        <Popconfirm
                            placement="bottomRight"
                            title={
                                <p>
                                    即将删除事件流程,是否确认删除?
                                </p>
                            }
                            okText="确认"
                            cancelText="取消"
                            onConfirm={() => deleteEventType(record)}
                        >
                            <DeleteOutlined style={{ fontSize: '16px', color: '#e86060' }} />
                        </Popconfirm>
                    </Tooltip>
                </Space>
            )

        }
    ]

    useEffect(() => {
        GetCM_Event_LoadEvenFlows({ eventTypeId: formObj.ID }).then(res => {
            if (res.msg === 'Ok') {
                console.log(res.data)
                setTableData(res.data)
            }
        })
皮倩雯's avatar
皮倩雯 committed
96
    },[visible,flag])
皮倩雯's avatar
皮倩雯 committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    const addIncident = () => {
        console.log(formObj.ID)
        setObj(formObj.ID)
        setAddVisible(true)
        setIsType('add')
    }
    const editEventType = record => {
        setObj(formObj.ID)
        setRecord1(record)
        setIsType('edit');
        setAddVisible(true)
    }
    const deleteEventType = record => {
        console.log(record)
        CM_Event_RemoveEvenFlow({ eventFlowIds: record.ID }).then(res=>{
            if (res.msg === '') {
                notification.success({
                    message: '提示',
                    duration: 3,
                    description: '删除成功',
皮倩雯's avatar
皮倩雯 committed
117
                    
皮倩雯's avatar
皮倩雯 committed
118
                });
皮倩雯's avatar
皮倩雯 committed
119
                setFlag(flag+1)
皮倩雯's avatar
皮倩雯 committed
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
            } else {
                notification.error({
                    message: '提示',
                    duration: 3,
                    description: res.msg,
                });
            }
        })
    }
    const onOK = () => {
        setAddVisible(false)
        GetCM_Event_LoadEvenFlows({ eventTypeId: formObj.ID }).then(res => {
            if (res.msg === 'Ok') {
                console.log(res.data)
                setTableData(res.data)
            }
        })
    }
    const onSumbit = () => {
        callBackSubmit()
    }
    return (
        <Modal
            title={`${title1}受理流程和权限`}
            visible={visible}
            width="800px"
            onCancel={onCancel}
            onOk={onSumbit}
皮倩雯's avatar
皮倩雯 committed
148
            
皮倩雯's avatar
皮倩雯 committed
149 150 151 152 153 154 155 156
        >
            <Tooltip title="添加事件类型">
                <PlusSquareFilled
                    onClick={() => addIncident()}
                    style={{
                        color: '#1890FF',
                        fontSize: '25px',
                        verticalAlign: 'middle',
皮倩雯's avatar
皮倩雯 committed
157 158
                        marginLeft: '25px',
                        marginBottom: '10px'
皮倩雯's avatar
皮倩雯 committed
159 160 161 162 163 164 165
                    }}
                />
            </Tooltip>
            <Table
                size="small"
                rowKey='ID'
                bordered
皮倩雯's avatar
皮倩雯 committed
166
                style={{ height: '15rem', overflowY: 'scroll', width: '700px', marginLeft: '25px' }}
皮倩雯's avatar
皮倩雯 committed
167 168 169 170 171 172 173
                onRow={record => {
                    return {
                      onDoubleClick: event => {event.stopPropagation(); editEventType(record)}, //双击
                    };
                  }}
                columns={columns}
                dataSource={tableData}
皮倩雯's avatar
皮倩雯 committed
174
                pagination={false}
皮倩雯's avatar
皮倩雯 committed
175 176 177 178 179 180 181 182
            />
            <AddFlowsModal
                visible={addVisible}
                obj={obj}
                formObj={formObj}
                type={isType} 
                record={record1}
                maxLength={maxLength}
皮倩雯's avatar
皮倩雯 committed
183
                onClose={() => setAddVisible(false)}
皮倩雯's avatar
皮倩雯 committed
184
                callBackSubmit={onOK}
皮倩雯's avatar
皮倩雯 committed
185
                placement="right"
皮倩雯's avatar
皮倩雯 committed
186 187 188 189 190
            />
        </Modal>
    )
}
export default ProcessModal;