import {Card, Col, Row, Input, Space, Select, Upload, Button, message, Tag} from "antd";
import './hiddenDangerInspection.less'
import MyCard, {BarChart, MyTable, PieChart} from "@/pages/business_hiddentrouble/component/MyCard";
import {ExportOutlined, UploadOutlined} from "@ant-design/icons";
import {render} from "react-dom";
const { Search } = Input;

const dataList=[
    {
        title:'隐患总数',
        num:'169',
        data:'12',
        flag:1,
        grow:1,
        backgroundColor:'#E5EEFE',
        color:'#1269FF',
    },
    {
        title:'已整改隐患',
        num:'169',
        data:'12',
        flag:1,
        grow:1,
        backgroundColor:'#D9F8E8',
        color:'#1DCE74',
    },
    {
        title:'整改中隐患',
        num:'169',
        data:'8',
        flag:2,
        grow:0,
        backgroundColor:'#FFF3E9',
        color:'orange',
    },
    {
        title:'超期未整改',
        num:'169',
        data:'2',
        flag:3,
        grow:0,
        backgroundColor:'#FFE6E8',
        color:'#FF3E48',
    }
]
export const Select1=()=>{
    return(
        <Select defaultValue="所有领域" style={{ width: 120 }}>
            <Select.Option value="sample" >所有领域</Select.Option>
        </Select>
    )
}
export const Select2=()=>{
    return(
        <Select defaultValue="所有频次" style={{ width: 120 }}>
            <Select.Option value="sample">所有频次</Select.Option>
        </Select>
    )
}
const props = {
    name: 'file',
    action: 'https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload',
    headers: {
        authorization: 'authorization-text',
    },
    onChange(info) {
        if (info.file.status !== 'uploading') {
            console.log(info.file, info.fileList);
        }
        if (info.file.status === 'done') {
            message.success(`${info.file.name} file uploaded successfully`);
        } else if (info.file.status === 'error') {
            message.error(`${info.file.name} file upload failed.`);
        }
    },
};
export const Import=()=>{
  return(
        <Upload {...props}>
            <Button icon={<UploadOutlined />} style={{color:'#2E4CD4'}}>导入</Button>
        </Upload>
      )


}
export const Export=()=>{
    return(
        <Button icon={<ExportOutlined/>} style={{color:'#2E4CD4'}}>导出</Button>
    )
}
export const levelList= {
    '一般隐患':['#DAF3FF','#00AAFA'],
    '中等隐患':['#FFF3E9','#FF8800'],
    '极高隐患':['#FFE0E2','#FF3E48'],
}

const columns=[
    {align:'center',title:'检查项',dataIndex:'inspectionItems',key:'inspectionItems'},
    {align:'center',title:'隐患名称',dataIndex:'name',key:'name'},
    {align:'center',title:'隐患等级',dataIndex:'level',key:'level',render:(level)=>{

        return <Tag color={levelList[level][0]} style={{color:levelList[level][1]}}>{level}</Tag>
    }},
    {align:'center',title:'登记时间',dataIndex:'createTime',key:'createTime'},
    {align:'center',title:'隐患来源',dataIndex:'source',key:'source'},
    {align:'center',title:'隐患描述',dataIndex:'description',key:'description',ellipsis:{showTitle:true}},
    {align:'center',title:'治理类型',dataIndex:'type',key:'type'},
    {align:'center',title:'治理期限',dataIndex:'deadline',key:'deadline'},
    {align:'center',title:'整改负责人',dataIndex:'head',key:'head'},
    {align:'center',title:'隐患状态',dataIndex:'state',key:'state',render:(state)=>{return <span style={{color:'green'}}>{state}</span>}},
    {align:'center',title:'验收时间',dataIndex:'acceptanceTime',key:'acceptanceTime'},
    {align:'center',title:'操作',dataIndex:'operation',key:'operation',render:(_,record)=>{
        return <Button type={"link"}>详情</Button>
    }},
]

const dataSource=[
    {key:1,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述111111111111111111111111111111111111',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:2,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'中等隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:3,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'极高隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:4,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:5,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:6,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:7,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:8,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:9,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:10,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:11,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:12,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:13,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:14,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:15,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:16,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:17,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:18,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:19,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:20,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:21,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:21,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:21,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:21,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},
    {key:21,inspectionItems:'设备运行温度',name:'D10精馏车间',level:'一般隐患',createTime:'2025-03-01',source:'日常排查',description:'隐患描述',type:'限期整改',deadline:'2025-09-03',head:'张小龙',state:'已验收',acceptanceTime:'2025-09-03'},

]


const HiddenDangerInspection=()=>{
    return(
        < >
            <header style={{overflow: 'hidden',marginBottom:'10px'}}>
                <Row gutter={10}>
                    {dataList.map((item) => {
                        return <Col span={6}><MyCard {...item}> </MyCard></Col>
                    })}
                </Row>
            </header>
            <section style={{overflow: 'hidden',marginBottom:'10px'}}>
                <Row gutter={10}>
                    <Col span={8}>
                        <PieChart title={'检查领域分布'}></PieChart>
                    </Col>
                    <Col span={16}>
                        <BarChart></BarChart>
                    </Col>
                </Row>
            </section>
            <footer>
                <div style={{width:'100%',backgroundColor:'#fff',padding:'15px'}}>
                    <Space direction='vertical' size={"middle"} style={{width:'100%'}}>
                        <Row >
                            <span style={{borderRight: '3px solid blue', marginRight: '15px'}}></span>
                            <span style={{fontSize:'16px',fontWeight:'600'}}>检查频次分布</span>
                        </Row>
                        <Row style={{display:'flex',justifyContent:'space-between'}}>
                                <div>
                                    <Search placeholder="搜素检查项" style={{ width: 300 }} />
                                </div>
                                <div>
                                    <Space>
                                        <Select1></Select1>
                                        <Select2></Select2>
                                        <Import></Import>
                                        <Export></Export>
                                    </Space>
                                </div>
                        </Row>
                        <Row>
                            <MyTable dataSource={dataSource} columns={columns}></MyTable>
                        </Row>
                    </Space>
                </div>
            </footer>


        </>
    )
}
export default HiddenDangerInspection
