import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Divider, Image } from "antd";
import dayjs from "dayjs";
import { useEffect, useState } from "react";
import { getFileUrl } from "zy-react-library/utils";
import { NS_BI_MARK_INFO } from "~/enumerate/namespace";
import DisclaimerSign from "../eightWordPubilc/DisclaimerSign";
import OpinionSign from "../eightWordPubilc/OpinionSign";
import SafetyMeasures from "../eightWordPubilc/SafetyMeasures";
import "../eightWordPubilc/index.less";

function HoistingWork(props) {
  const [info, setInfo] = useState({});

  const getData = async () => {
    const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
    setInfo(basicInfo);
  };

  useEffect(() => {
    getData();
  }, []);

  return (
    <div className="work_ticket_details">
      <table>
        <thead>
          <tr>
            <td colSpan={4} style={{ border: "none" }}>
              <Divider orientation="left">吊装安全作业票</Divider>
            </td>
          </tr>
          <tr>
            <td colSpan={4} style={{ border: "none" }}>
              <span>编号：</span>
              <span>{info.checkNo}</span>
            </td>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td className="title">申请单位</td>
            <td>{info?.info?.applyUnit}</td>
            <td className="title">申请时间</td>
            <td>{dayjs(info?.info?.applyTime || info?.createTime).format("YYYY-MM-DD HH:mm:ss")}</td>
          </tr>
          <tr>
            <td className="title">吊装地点</td>
            <td>{info?.info?.workLocation}</td>
            <td className="title">作业类型</td>
            <td>{info?.info?.operationTypeName}</td>
          </tr>
          <tr>
            <td className="title">吊具名称</td>
            <td>{info?.info?.hoistName}</td>
            <td className="title">作业级别</td>
            <td>{info?.info?.workLevelName}</td>
          </tr>
          <tr>
            <td className="title">吊装作业人</td>
            <td>{info?.info?.workUserName}</td>
            <td className="title">司索人</td>
            <td>{info?.info?.pullUserName}</td>
          </tr>
          <tr>
            <td className="title">指挥人</td>
            <td>{info?.info?.commandUserName}</td>
            <td rowSpan={2} className="title">吊物内容</td>
            <td rowSpan={2}>{info?.info?.workContent}</td>
          </tr>
          <tr>
            <td className="title">吊物质量（吨）</td>
            <td>{info?.info?.hoistWeight}</td>
          </tr>
          <tr>
            <td className="title">作业单位</td>
            <td>{info?.info?.step_21?.actUserDepartmentName}</td>
            <td className="title">监护人</td>
            <td>
              {info?.info?.step_20?.signPath
                && <Image src={getFileUrl() + info?.info?.step_20?.signPath} width={50} height={50} />}
            </td>
          </tr>
          <tr>
            <td className="title">作业人</td>
            <td>{info?.info?.workUserName}</td>
            <td className="title">作业负责人</td>
            <td>
              {info?.info?.step_21?.signPath
                && <Image src={getFileUrl() + info?.info?.step_21?.signPath} width={50} height={50} />}
            </td>
          </tr>
          <tr>
            <td className="title">关联的其他特殊作业及安全作业票编号</td>
            <td colSpan={3}>{info?.info?.linkSpecialWorks}</td>
          </tr>
          <tr>
            <td className="title">风险辨识结果</td>
            <td colSpan={3}>{info?.info?.riskResults}</td>
          </tr>
          <tr>
            <td className="title">作业实施时间</td>
            <td colSpan={3}>{`${info?.info?.workStartTime} 至 ${info?.info?.workEndTime} 止`}</td>
          </tr>
          <SafetyMeasures colSpan={4} workId={props.id} />
          <DisclaimerSign
            colSpan={2}
            safetyRemarks={info?.info?.step_18?.remarks}
            safetySignPath={info?.info?.step_18?.signPath}
            safetySignTime={info?.info?.step_18?.status !== 0 && info?.info?.step_18?.signTime}
            AcceptRemarks={info?.info?.step_19?.remarks}
            AcceptSignPath={info?.info?.step_19?.signPath}
            AcceptSignTime={info?.info?.step_19?.status !== 0 && info?.info?.step_19?.signTime}
          />
          <OpinionSign
            title="作业指挥负责人意见"
            colSpan={4}
            remarks={info?.info?.step_21?.remarks}
            signPath={info?.info?.step_21?.signPath}
            signTime={info?.info?.step_21?.status !== 0 && info?.info?.step_21?.signTime}
          />
          <OpinionSign
            title="所在单位意见"
            colSpan={4}
            remarks={info?.info?.step_22?.remarks}
            signPath={info?.info?.step_22?.signPath}
            signTime={info?.info?.step_22?.status !== 0 && info?.info?.step_22?.signTime}
          />
          <OpinionSign
            title="审核部门意见"
            colSpan={4}
            remarks={info?.info?.step_23?.remarks}
            signPath={info?.info?.step_23?.signPath}
            signTime={info?.info?.step_23?.status !== 0 && info?.info?.step_23?.signTime}
          />
          <OpinionSign
            title="审批部门意见"
            colSpan={4}
            remarks={info?.info?.step_24?.remarks}
            signPath={info?.info?.step_24?.signPath}
            signTime={info?.info?.step_24?.status !== 0 && info?.info?.step_24?.signTime}
          />
          <OpinionSign
            title="完工验收"
            colSpan={4}
            remarks={info?.info?.step_25?.remarks}
            signPath={info?.info?.step_25?.signPath}
            signTime={info?.info?.step_25?.status !== 0 && info?.info?.step_25?.signTime}
          />
        </tbody>
      </table>
    </div>
  );
}

export default Connect([NS_BI_MARK_INFO], true)(HoistingWork);
