import { Button, Descriptions, Modal } from "antd";
import { getLabelName } from "zy-react-library/utils";
import { SENSOR_ATTR_OPTIONS, SENSOR_STATUS_OPTIONS, YES_NO_OPTIONS } from "~/enumerate/constant";

function ViewModal(props) {
  const record = props.record || {};

  return (
    <Modal
      destroyOnClose
      title="查看"
      open={props.open}
      cancelText="关闭"
      width={800}
      onCancel={props.onCancel}
      maskClosable={false}
      footer={(
        <div>
          <Button onClick={props.onCancel}>关闭</Button>
        </div>
      )}
    >
      <Descriptions
        bordered
        column={2}
        labelStyle={{ width: 180 }}
        items={[
          { label: "传感器编码", children: record.sensorCode || "-", span: 2 },
          { label: "传感器名称", children: record.sensorName || "-", span: 2 },
          { label: "传感器类型", children: record.sensorTypeName || "-", span: 2 },
          {
            label: "传感器属性",
            children: getLabelName({ status: record.sensorAttr, list: SENSOR_ATTR_OPTIONS }) || record.sensorAttr || "-",
            span: 2,
          },
          {
            label: "传感器状态",
            children: getLabelName({ status: record.sensorStatus, list: SENSOR_STATUS_OPTIONS }) || record.sensorStatus || "-",
            span: 2,
          },
          { label: "安装位置", children: record.installPosition || "-", span: 2 },
          { label: "出厂日期", children: record.factoryDate || "-", span: 2 },
          {
            label: "是否阈值设定",
            children: getLabelName({ status: record.thresholdFlag, list: YES_NO_OPTIONS }) || record.thresholdFlag || "-",
            span: 2,
          },

        ]}
      />
    </Modal>
  );
}

export default ViewModal;
