forked from ddrilling/asb_cloud_front
67 lines
1.6 KiB
JavaScript
Executable File
67 lines
1.6 KiB
JavaScript
Executable File
import {Modal} from 'antd'
|
|
import '../../styles/smbo.css'
|
|
|
|
import {useState} from "react";
|
|
|
|
export const SquareIndicator = ({state}) =>{
|
|
let bgColor = "#AAA"
|
|
switch (state){
|
|
case 1:
|
|
bgColor = "#1B1"
|
|
break
|
|
case 2:
|
|
bgColor = "#DD1"
|
|
break
|
|
case 3:
|
|
bgColor = "#D11"
|
|
break
|
|
default:
|
|
break
|
|
}
|
|
return (<svg width="32" height="32" version="1.1" viewBox="0 0 13 13" xmlns="http://www.w3.org/2000/svg">
|
|
<rect x=".25" y=".25" width="12" height="12"
|
|
fill={bgColor}
|
|
stroke="#ececec" strokeLinejoin="round" strokeWidth=".51"/>
|
|
</svg>)
|
|
}
|
|
|
|
export default function SmboPlate({title, state, operatingTime, units, children, captionValue}){
|
|
const [isModalVisible, setIsModalVisible] = useState(false)
|
|
|
|
|
|
const openModal = () => {
|
|
setIsModalVisible(!!children)
|
|
}
|
|
|
|
const closeModal = () => {
|
|
setIsModalVisible(false)
|
|
}
|
|
|
|
const plates_smbo_equip = (
|
|
<div className="plate_container" onClick={openModal}>
|
|
<div className="plate_title">{title}</div>
|
|
<div className="plate_state"><SquareIndicator state={state}/></div>
|
|
|
|
<div className="plate_param_title">{captionValue??'наработка'} :</div>
|
|
<div className="plate_param_value">{operatingTime}</div>
|
|
<div className="plate_param_units">{units??'ч'}</div>
|
|
</div>
|
|
)
|
|
|
|
return(<>
|
|
{plates_smbo_equip}
|
|
|
|
<Modal
|
|
title={title}
|
|
centered
|
|
visible={isModalVisible}
|
|
onOk={closeModal}
|
|
onCancel={closeModal}
|
|
width={800}
|
|
>
|
|
<div>
|
|
{children}
|
|
</div>
|
|
</Modal>
|
|
</>)
|
|
} |