import { Spin } from 'antd';
import { VmInfoCollection, VmMap, VmWrapper } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { BaseService } from "../../api";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
var BaseInfo = function BaseInfo(props) {
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var mapCenter = props.mapCenter,
    id = props.id;
  var _BaseService$useBaseD = BaseService.useBaseDetail(id, 'wgs84'),
    info = _BaseService$useBaseD.info,
    baseInfo = _BaseService$useBaseD.baseInfo,
    center = _BaseService$useBaseD.center,
    mapPoints = _BaseService$useBaseD.mapPoints,
    geometryType = _BaseService$useBaseD.geometryType,
    loading = _BaseService$useBaseD.loading;
  var records = BaseService.useGetRecord(info === null || info === void 0 ? void 0 : info.orderNo);
  var getStep = function getStep() {
    if ((records === null || records === void 0 ? void 0 : records.length) < 2) {
      return -1;
    }
    if (records[records.length - 1].processDetail) {
      var obj = JSON.parse(records[records.length - 1].processDetail);
      if (obj.processResult === 'Pass') {
        return 2;
      }
    }
    if (records.find(function (v) {
      return v.processType === 'Pf';
    }) && records[records.length - 1].processType !== 'Pf') {
      return 1;
    }
    if (records.find(function (v) {
      return v.processType === 'Pf';
    })) {
      return 0;
    }
  };
  return /*#__PURE__*/_jsxs("div", {
    className: "zg-base",
    children: [/*#__PURE__*/_jsx(Spin, {
      spinning: loading,
      className: "zg-base-spin"
    }), /*#__PURE__*/_jsx("div", {
      className: "zg-base-left",
      children: /*#__PURE__*/_jsxs(VmWrapper, {
        title: "\u4E8B\u4EF6\u63CF\u8FF0",
        children: [/*#__PURE__*/_jsx(VmInfoCollection, {
          data: baseInfo,
          horizontal: true,
          width: "50%",
          gap: 12
        }), /*#__PURE__*/_jsx("div", {
          className: "zg-base-map",
          children: /*#__PURE__*/_jsx(VmMap, {
            mapCenter: center || mapCenter,
            newMapPoints: mapPoints,
            address: info === null || info === void 0 ? void 0 : info.address,
            geometryType: geometryType
          })
        })]
      })
    }), /*#__PURE__*/_jsx("div", {
      className: "zg-base-right",
      children: /*#__PURE__*/_jsxs(VmWrapper, {
        title: "\u6574\u6539\u6D41\u7A0B",
        children: [/*#__PURE__*/_jsx("div", {
          className: "zg-base-process ".concat(isDark ? 'dark' : ''),
          children: [{
            title: '派发',
            key: '1'
          }, {
            title: '处理',
            key: '2'
          }, {
            title: '结束',
            key: '3'
          }].map(function (ele, index) {
            var isDone = getStep() >= index;
            return /*#__PURE__*/_jsxs("div", {
              className: "zg-base-process-item",
              children: [/*#__PURE__*/_jsx("div", {
                className: "zg-base-process-item-order ".concat(isDone ? 'active' : ''),
                children: index + 1
              }), /*#__PURE__*/_jsx("div", {
                className: "zg-base-process-item-title ".concat(isDone ? 'active' : ''),
                children: ele.title
              }), index < records.length && /*#__PURE__*/_jsx("div", {
                className: "zg-base-process-line ".concat(isDone ? 'active' : '')
              })]
            }, ele.key);
          })
        }), /*#__PURE__*/_jsx("div", {
          className: "zg-p-list ".concat(isDark ? 'dark' : ''),
          children: records === null || records === void 0 ? void 0 : records.map(function (ele, index) {
            var isDone = getStep() + 1 >= index;
            var detailObj = ele.processDetail ? JSON.parse(ele.processDetail) : {};
            return /*#__PURE__*/_jsxs("div", {
              className: "zg-p-list-item",
              children: [/*#__PURE__*/_jsxs("div", {
                className: "zg-p-list-item-head",
                children: [/*#__PURE__*/_jsxs("div", {
                  className: "zg-p-list-item-head-title",
                  children: [/*#__PURE__*/_jsx("img", {
                    src: require("../../imgs/dot".concat(isDone ? '_done' : '', ".png"))
                  }), /*#__PURE__*/_jsx("div", {
                    children: ele.processTypeStr
                  })]
                }), /*#__PURE__*/_jsx("div", {
                  children: ele.processTimeStr
                })]
              }), /*#__PURE__*/_jsxs("div", {
                className: "zg-p-list-item-content",
                children: [/*#__PURE__*/_jsx("div", {
                  className: "zg-p-list-item-line",
                  style: index === records.length - 1 ? {
                    background: 'unset'
                  } : {}
                }), /*#__PURE__*/_jsxs("div", {
                  children: [ele.processContent, /*#__PURE__*/_jsx("div", {
                    className: "zg-p-list-item-content-bg",
                    children: getBaseShow(ele.processType, detailObj)
                  })]
                })]
              })]
            }, ele.key);
          })
        })]
      })
    })]
  });
};
export default BaseInfo;
function getBaseShow(type, detailObj) {
  var tempArr = [];
  switch (type) {
    case 'Xj':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '问题照片',
          key: 'photos',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.photos,
          componentType: 'IMAGE'
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
    case 'Pf':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '责任单位',
          key: 'responsibleUnitName',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.responsibleUnitName
        }, {
          label: '责任人',
          key: 'responsibleStaffNames',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.responsibleStaffNames
        }, {
          label: '整改时限',
          key: 'reformTimeDay',
          value: "".concat(detailObj.reformTimeDay || 0, "\u5929").concat(detailObj.reformTimeHour || 0, "\u5C0F\u65F6").concat(detailObj.reformTimeMin || 0, "\u5206")
        }, {
          label: '截止时间',
          key: 'endDateTime',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.endDateTime
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
    case 'Sqyq':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '原截止时间',
          key: 'oldEndTime',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.oldEndTime
        }, {
          label: '期望截止时间',
          key: 'newEndTime',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.newEndTime
        }, {
          label: '申请理由',
          key: 'applyReason',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.applyReason
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
    case 'Cs':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '结果',
          key: 'processResult',
          value: "".concat(detailObj.processResult === 'Accept' ? '接受整改' : detailObj.processResult === 'Reject' ? '拒绝整改' : detailObj.processResult)
        }, {
          label: '原因',
          key: 'rejectReason',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.rejectReason
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
      break;
    case 'Dzgtjfk':
    case 'Tjfk':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '反馈内容',
          key: 'feedbackContent',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.feedbackContent
        }, {
          label: '反馈附件',
          key: 'photos',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.photos,
          componentType: 'IMAGE'
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
    case 'Jjzgsh':
    case 'Yqsh':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '结果',
          key: 'processResult',
          value: detailObj.processResult === 'Fail' ? '不通过' : '通过'
        }, {
          label: '审批意见',
          key: 'auditOpinion',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.auditOpinion
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
    case 'Jgsh':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '结果',
          key: 'processResult',
          value: detailObj.processResult === 'Fail' ? '不通过' : '通过'
        }, {
          label: '审批意见',
          key: 'auditOpinion',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.auditOpinion
        }, {
          title: '附件',
          key: 'photos',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.photos,
          componentType: 'IMAGE'
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
    case 'Dzg':
      return /*#__PURE__*/_jsx(VmInfoCollection, {
        data: [{
          label: '第三方单位',
          key: 'thirdResponsibleUnitName',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.thirdResponsibleUnitName
        }, {
          label: '责任人',
          key: 'thirdResponsibleStaffNames',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.thirdResponsibleStaffNames
        }, {
          label: '整改时限',
          key: 'reformTimeDay',
          value: "".concat(detailObj.reformTimeDay || 0, "\u5929").concat(detailObj.reformTimeHour || 0, "\u5C0F\u65F6").concat(detailObj.reformTimeMin || 0, "\u5206")
        }, {
          label: '截止时间',
          key: 'endDateTime',
          value: detailObj === null || detailObj === void 0 ? void 0 : detailObj.endDateTime
        }],
        horizontal: true,
        width: "100%",
        gap: 12
      });
    default:
      return /*#__PURE__*/_jsx(_Fragment, {});
  }
}