2024-09-20 15:02:50 +08:00
|
|
|
import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react';
|
|
|
|
|
import BasicCrudModal from '../../../../components/crud/BasicCrudModal';
|
|
|
|
|
import { Table, Card, Modal, Form, Input, Button, Row,Col, Timeline, message, Tabs,Image } from 'antd';
|
|
|
|
|
import {FileWordOutlined,FilePdfOutlined,FileZipOutlined,FileExcelOutlined } from '@ant-design/icons';
|
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
import AdcdTreeSelector from "./AdcdTreeSelector";
|
|
|
|
|
import ToolBar from './toolbar';
|
|
|
|
|
import ModalForm from './form';
|
|
|
|
|
import apiurl from '../../../../service/apiurl';
|
|
|
|
|
import usePageTable from '../../../../components/crud/usePageTable2';
|
|
|
|
|
import { createCrudService } from '../../../../components/crud/_';
|
|
|
|
|
import {CrudOpRender_text} from '../../../../components/crud/CrudOpRender';
|
|
|
|
|
|
|
|
|
|
const url = "http://223.75.53.141:9102/test.by-lyf.tmp"
|
|
|
|
|
const Page = () => {
|
|
|
|
|
const role = useSelector(state => state.auth.role);
|
|
|
|
|
console.log(role);
|
|
|
|
|
|
2024-09-23 13:49:58 +08:00
|
|
|
const editBtn = role?.rule?.find(item => item.menuName == "编辑")||true;
|
|
|
|
|
const viewBtn = role?.rule?.find(item => item.menuName == "查看")||true;
|
|
|
|
|
const delBtn = role?.rule?.find(item => item.menuName == "删除")||true;
|
2024-09-20 15:02:50 +08:00
|
|
|
const checkType = {
|
|
|
|
|
1: "低风险",
|
|
|
|
|
2: "一般风险",
|
|
|
|
|
3: "较大风险",
|
|
|
|
|
4:"重大风险"
|
|
|
|
|
}
|
|
|
|
|
const risk = {
|
|
|
|
|
1: "low",
|
|
|
|
|
2: "yiban",
|
|
|
|
|
3: "jiaoda",
|
|
|
|
|
4:"zhongda"
|
|
|
|
|
}
|
|
|
|
|
const refModal = useRef();
|
|
|
|
|
const columns = [
|
|
|
|
|
{ title: '序号', key: 'inx', dataIndex: 'inx', width: 60, align: "center" },
|
|
|
|
|
{title: '风险辨识名称', key: 'name', dataIndex: 'name', width: 240,align: 'center',},
|
|
|
|
|
{
|
|
|
|
|
title: '风险等级', key: 'riskLevel', dataIndex: 'riskLevel', width: 200,align: 'center',
|
|
|
|
|
render: (value) => <span>{value ? checkType[value] : ''}</span>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '风险标识', key: 'riskLevel', dataIndex: 'riskLevel', width: 150,align: 'center',
|
|
|
|
|
render: (value) => <div>{value ?
|
|
|
|
|
<img src={`${process.env.PUBLIC_URL}/assets/xyt/rcgl/${risk[value]}.svg`}
|
|
|
|
|
alt='' /> : ''}</div>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '可能导致的后果', key: 'result', dataIndex: 'result', width: 250, ellipsis: true,align: 'center',
|
|
|
|
|
render: (value) => <span>{value ? value.map(item => item.dictNm).join():''}</span>
|
|
|
|
|
},
|
|
|
|
|
{title: '主要防范措施', key: 'preventMeasure', dataIndex: 'preventMeasure', width: 200,align: 'center',},
|
|
|
|
|
{title: '创建日期', key: 'createDate', dataIndex: 'createDate', width: 200,align: 'center',},
|
|
|
|
|
{
|
|
|
|
|
title: '操作', key: 'operation', width: 200, fixed: 'right',align: 'center',
|
|
|
|
|
render: (value, row, index) => (
|
|
|
|
|
<CrudOpRender_text
|
|
|
|
|
edit={editBtn ? true : false}
|
|
|
|
|
del={delBtn ? true : false}
|
|
|
|
|
view={viewBtn ? true : false}
|
|
|
|
|
command={(cmd) => () => command(cmd)(row)} />)
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
const [code, setCode] = useState()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]);
|
|
|
|
|
|
|
|
|
|
const command = (type) => (params) => {
|
|
|
|
|
if (type === 'save') {
|
|
|
|
|
refModal.current.showSave({code});
|
|
|
|
|
} else if (type === 'edit') {
|
|
|
|
|
refModal.current.showEdit({ ...params,code });
|
|
|
|
|
} else if (type === 'view') {
|
|
|
|
|
refModal.current.showView(params);
|
|
|
|
|
} else if (type === 'del') {
|
|
|
|
|
refModal.current.onDeleteGet(apiurl.rcgl.aqgl.fxgkqd.delete + `/${params.id}`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.rcgl.aqgl.fxgkqd.page).find_noCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (code) {
|
|
|
|
|
let params = {
|
|
|
|
|
search: {
|
|
|
|
|
menuId:code,
|
|
|
|
|
orderField: "createDate",
|
|
|
|
|
isAsc: false
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
search(params)
|
|
|
|
|
}
|
|
|
|
|
}, [code]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className='content-box' style={{ backgroundColor: '#fff', height: '100%',display:'flex',padding:'10px' }}>
|
|
|
|
|
<div className='lf adcdTreeSelectorBox' style={{height:'calc(100vh - 168px)',width:'340px'}}>
|
|
|
|
|
<AdcdTreeSelector hasAlertBox={false} setAdcd={setCode}/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className='AdcdTreeTableBox' style={{flex:1,overflowX:"auto"}}>
|
|
|
|
|
<Card className='nonebox'>
|
|
|
|
|
<ToolBar
|
|
|
|
|
onSave={command('save')}
|
|
|
|
|
role={role}
|
|
|
|
|
/>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<Table
|
|
|
|
|
columns={columns}
|
|
|
|
|
rowKey="id"
|
|
|
|
|
{...tableProps}
|
|
|
|
|
scroll={{ x: width, y: "calc( 100vh - 400px )" }}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<BasicCrudModal
|
|
|
|
|
width={1000}
|
|
|
|
|
ref={refModal}
|
|
|
|
|
title=""
|
|
|
|
|
component={ModalForm}
|
|
|
|
|
onCrudSuccess={refresh}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Page;
|