import { Col, Row } from 'antd';
import { useContext } from 'react';
import { VmInfoCollection, VmTable, VmWrapper } from "../../../../_components";
import { BaseService, carAuditMap, carConfigMap, carIdentityMap, carSYMap } from "../../../api";
import { CarContext } from "../../../index";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var DetailInfo = function DetailInfo() {
  var _useContext = useContext(CarContext),
    id = _useContext.id,
    detail = _useContext.detail,
    _useContext$showField = _useContext.showFields,
    showFields = _useContext$showField === void 0 ? [] : _useContext$showField;
  var _BaseService$useServi = BaseService.useServiceInfo(id),
    serviceInfo = _BaseService$useServi.serviceInfo;
  var actionType = detail === null || detail === void 0 ? void 0 : detail.actionType;
  var carIdentity = []; //车辆身份信息
  var carConfig = []; //车辆配置信息
  var carAudit = []; //车辆年审信息
  var carSy = [];
  if (detail) {
    carIdentityMap.forEach(function (_, itemValue) {
      showFields.forEach(function (ele) {
        if (ele.dataKey === itemValue) {
          carIdentity.push({
            label: ele === null || ele === void 0 ? void 0 : ele.displayName,
            key: ele.dataKey,
            value: detail[ele === null || ele === void 0 ? void 0 : ele.dataKey],
            componentType: itemValue.indexOf('hoto') > -1 ? 'IMAGE' : ''
          });
        }
      });
    });
    carIdentity.push({
      label: '车辆二维码',
      key: 'qrCode',
      value: detail.qrCode,
      componentType: 'qrCode'
    });
    carConfigMap.forEach(function (_, configValue) {
      showFields.forEach(function (ele) {
        if (ele.dataKey === configValue) {
          carConfig.push({
            label: ele === null || ele === void 0 ? void 0 : ele.displayName,
            key: ele.dataKey,
            value: detail[ele === null || ele === void 0 ? void 0 : ele.dataKey],
            componentType: ele.dataKey.indexOf('hoto') > -1 ? 'IMAGE' : ''
          });
        }
      });
    });
    carAuditMap.forEach(function (_, auditValue) {
      showFields.forEach(function (ele) {
        if (ele.dataKey === auditValue) {
          carAudit.push({
            label: ele === null || ele === void 0 ? void 0 : ele.displayName,
            key: ele.dataKey,
            value: detail[ele === null || ele === void 0 ? void 0 : ele.dataKey]
          });
        }
      });
    });
    carSYMap.forEach(function (_, auditValue) {
      showFields.forEach(function (ele) {
        if (ele.dataKey === auditValue) {
          carSy.push({
            label: ele === null || ele === void 0 ? void 0 : ele.displayName,
            key: ele.dataKey,
            value: detail[ele === null || ele === void 0 ? void 0 : ele.dataKey]
          });
        }
      });
    });
    if ((actionType === null || actionType === void 0 ? void 0 : actionType.indexOf('ACTION_LJSY')) > -1) {
      if ((detail === null || detail === void 0 ? void 0 : detail.collectMethod) === 'TRANS_SHIPMENT') {
        var _detail$factoryNames;
        carSy.push({
          label: '关联中转站',
          key: 'factoryNames',
          value: detail === null || detail === void 0 || (_detail$factoryNames = detail.factoryNames) === null || _detail$factoryNames === void 0 ? void 0 : _detail$factoryNames.join(',')
        });
      } else {
        var _detail$disposeNames;
        carSy.push({
          label: '关联处置场',
          key: 'disposeNames',
          value: detail === null || detail === void 0 || (_detail$disposeNames = detail.disposeNames) === null || _detail$disposeNames === void 0 ? void 0 : _detail$disposeNames.join(',')
        });
      }
    }
  }
  var columns = [{
    title: '服务标段',
    dataIndex: 'tenderName'
  }, {
    title: '所属合同',
    dataIndex: 'contractName'
  }, {
    title: '中标单位',
    dataIndex: 'bidWinningOrgName'
  }, {
    title: '服务时间',
    dataIndex: 'contractDate',
    render: function render(_, record) {
      return "".concat(record.serviceTimeBegin, "~").concat(record.serviceTimeEnd);
    }
  }];
  return /*#__PURE__*/_jsxs(Row, {
    style: {
      padding: 16
    },
    gutter: [16, 16],
    children: [/*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '车辆身份信息',
        children: /*#__PURE__*/_jsx(VmInfoCollection, {
          data: carIdentity,
          gap: 18,
          horizontal: true,
          ellipsis: true,
          width: '33.33%'
        })
      })
    }), /*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '车辆配置信息',
        children: /*#__PURE__*/_jsx(VmInfoCollection, {
          data: carConfig,
          gap: 18,
          horizontal: true,
          ellipsis: true,
          width: '33.33%'
        })
      })
    }), /*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '车辆年审信息',
        children: /*#__PURE__*/_jsx(VmInfoCollection, {
          data: carAudit,
          gap: 18,
          horizontal: true,
          ellipsis: true,
          width: '33.33%'
        })
      })
    }), (serviceInfo === null || serviceInfo === void 0 ? void 0 : serviceInfo.length) > 0 && /*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '车辆服务信息',
        children: /*#__PURE__*/_jsx(VmTable, {
          isIndex: false,
          columns: columns,
          dataSource: serviceInfo
        })
      })
    }), (actionType === null || actionType === void 0 ? void 0 : actionType.indexOf('ACTION_LJSY')) > -1 || (actionType === null || actionType === void 0 ? void 0 : actionType.indexOf('ACTION_LJZY')) > -1 ? /*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '车辆业务配置',
        children: /*#__PURE__*/_jsx(VmInfoCollection, {
          data: carSy,
          gap: 18,
          horizontal: true,
          ellipsis: true,
          width: '33.33%'
        })
      })
    }) : null]
  });
};
export default DetailInfo;