incidentView.jsx 8.28 KB
Newer Older
皮倩雯's avatar
皮倩雯 committed
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
import React, { useEffect, useState } from 'react';
import { Form, Modal, Table, Input, Select, Tooltip, Button, notification, Spin, Image, Menu, Dropdown, Space, Popconfirm } from 'antd';
import { CM_Event_ReloadEventExtendPages, CM_Event_RemoveEventExtendPage } from '@/services/standingBook/api';
import {
    PlusSquareFilled,
    EditTwoTone,
    DeleteOutlined,
    PlusSquareOutlined,
    RollbackOutlined
} from '@ant-design/icons';
import AddViewModal from './AddViewModal'
import { useHistory } from 'react-router-dom';
import { set } from 'immutable';
import styles from './incident.less';
const incidentView = props => {
    const history = useHistory();
    const [tableData, setTableData] = useState([])
    const [addViewVisible, setAddViewVisible] = useState(false)
    const [treeLoading, setTreeLoading] = useState(false)
    const [flag,setFlag] = useState(0)
    const [obj,setObj] = useState('')
    const [type,setType] = useState('')

    const columns = [
        {
            title: () => (<span style={{fontWeight:'bold'}}>视图标签</span>),
            dataIndex: 'WebLabel',
            key: 'WebLabel',
            width: 150,
            ellipsis: true,
            render: item => (
                <div
                    ref={r => {
                        if (r) {
                            r.innerHTML = item;
                        }
                    }}
                />
            )
        }
        ,
        {
            title: () => (<span style={{fontWeight:'bold'}}>视图模块</span>),
            dataIndex: 'WebPage',
            key: 'WebPage',
            width: 150,
            ellipsis: true,
            render: item => (
                <div
                    ref={r => {
                        if (r) {
                            r.innerHTML = item;
                        }
                    }}
                />
            )
        },
        {
            title: () => (<span style={{fontWeight:'bold'}}>视图参数</span>),
            dataIndex: 'WebParam',
            key: 'WebParam',
            width: 150,
            ellipsis: true,
            render: item => (
                <div
                    ref={r => {
                        if (r) {
                            r.innerHTML = item;
                        }
                    }}
                />
            )
        },
        ,
        {
            title: () => (<span style={{fontWeight:'bold'}}>手持视图标签</span>),
            dataIndex: 'MobileLabel',
            key: 'MobileLabel',
            width: 150,
            ellipsis: true,
            render: item => (
                <div
                    ref={r => {
                        if (r) {
                            r.innerHTML = item;
                        }
                    }}
                />
            )
        },
        {
            title: () => (<span style={{fontWeight:'bold'}}>手持视图模块</span>),
            dataIndex: 'MobilePage',
            key: 'MobilePage',
            width: 150,
            ellipsis: true,
            render: item => (
                <div
                    ref={r => {
                        if (r) {
                            r.innerHTML = item;
                        }
                    }}
                />
            )
        },
        ,
        {
            title: () => (<span style={{fontWeight:'bold'}}>手持视图参数</span>),
            dataIndex: 'MobileParam',
            key: 'MobileParam',
            width: 150,
            ellipsis: true,
            render: item => (
                <div
                    ref={r => {
                        if (r) {
                            r.innerHTML = item;
                        }
                    }}
                />
            )
        },
        {
            title: () => (<span style={{fontWeight:'bold'}}>操作</span>),
            key: 'action',
            aligin: 'center',
            width: 50,
            render: record => (
                <Space size="middle">

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

        }
    ]

    useEffect(()=>{
        setTreeLoading(true);
       CM_Event_ReloadEventExtendPages({eventName:props.location.state.formObj.name}).then(res=>{
        setTreeLoading(false);
        if (res.msg === 'Ok'||res.msg==='') {
            console.log(res.data)
            setTableData(res.data)
        }
       })
        
    },[flag])

    const onSumbit =()=>{
        callBackSubmit()
    }

    const addView=()=>{
        setType('add')
        setAddViewVisible(true)
    }

    const editView = record =>{
        setType('edit')
        setAddViewVisible(true)
        setObj(record.ID)
    }

    const deleteView= record =>{
        console.log(record)
        CM_Event_RemoveEventExtendPage({eventExtendId:record.ID}).then(res=>{
            if (res.msg === '') {
                notification.success({
                    message: '提示',
                    duration: 3,
                    description: '删除成功',
                });
                setFlag(flag + 1);
            } else {
                notification.error({
                    message: '提示',
                    duration: 3,
                    description: res.msg,
                });
            }
        })
    }
    const okk =()=>{
        setAddViewVisible(false)
        setFlag(flag+1)
    }
    const back = () => {
皮倩雯's avatar
皮倩雯 committed
210
        let rember = props.location.state.rember;
皮倩雯's avatar
皮倩雯 committed
211
        history.push({
212
          pathname: '/biz/workflow/event',
皮倩雯's avatar
皮倩雯 committed
213
          state: { rember },
皮倩雯's avatar
皮倩雯 committed
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
        });
      };
    return(
            <>
            <Spin tip="loading..." spinning={treeLoading}>
                <div className={styles.containerBox}>
                    <div className={styles.config}>
                        <div className={styles.title}>{`${props.location.state.title2}受理流程和权限`}</div>
                        <div className={styles.btn}>
                            <Button
                                type="primary"
                                icon={<PlusSquareOutlined />}
                                onClick={() => addView()}
                            >
                                新增
                            </Button>

                            <Button type="primary" icon={<RollbackOutlined />} onClick={()=>back()}>
                                返回
                            </Button>
                        </div>
                    </div>
            <Table
                size="small"
                rowKey='ID'
                bordered
                onRow={record => {
                    return {
                      onDoubleClick: event => {event.stopPropagation(); editView(record)}, //双击
                    };
                  }}
                columns={columns}
皮倩雯's avatar
皮倩雯 committed
246
                style={{overflowY: 'scroll'}}
皮倩雯's avatar
皮倩雯 committed
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
                dataSource={tableData}
                pagination={false}
                scroll={{ x: 'max-content'}}
            />
            </div>
            </Spin>
            <AddViewModal
                visible={addViewVisible} 
                title="事件辅助视图配置"
                onClose={()=>setAddViewVisible(false)}
                title2={props.location.state.title2}
                callBackSubmit={okk}
                obj={obj}
                type={type}
                placement="right"
            />
        
        </>
    )
}
export default incidentView;