"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _moment = _interopRequireDefault(require("moment"));
var _api = require("../../api");
var _vmCard = _interopRequireDefault(require("../../../vm-card"));
var _vmFilter = require("../../../vm-filter");
var _antd = require("antd");
var _icons = require("@ant-design/icons");
var _vmTable = _interopRequireDefault(require("../../../vm-table"));
var _lodash = require("lodash");
var _vmEmpty = _interopRequireDefault(require("../../../vm-empty"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var Work = function Work(props) {
  var id = props.id,
    service = props.service,
    setIframeModalInfo = props.setIframeModalInfo,
    workTypeColorMap = props.workTypeColorMap;
  var _useSettings = (0, _useSettings2["default"])(),
    date = _useSettings.date,
    theme = _useSettings.theme;
  var _useState = (0, _react.useState)(date ? (0, _moment["default"])(date) : (0, _moment["default"])()),
    _useState2 = _slicedToArray(_useState, 2),
    day = _useState2[0],
    setDay = _useState2[1];
  var _BaseService$useRecor = _api.BaseService.useRecordService(id, (0, _moment["default"])(day).format('YYYY-MM-DD'), service),
    dataSource = _BaseService$useRecor.carWorkRecord;
  var _BaseService$useWorkO = _api.BaseService.useWorkOverview(id, (0, _moment["default"])(day).format('YYYY-MM-DD'), service),
    workInfo = _BaseService$useWorkO.workInfo;
  var allWorkInfo = workInfo.find(function (item) {
    return item.workType === 'ALL';
  }) || {};
  var newWorkInfo = workInfo.filter(function (item) {
    return item.workType !== 'ALL';
  });
  var columns = [{
    title: '车牌号',
    dataIndex: 'carCode',
    key: 'carCode',
    ellipsis: true,
    width: 90,
    fixed: 'left',
    onCell: function onCell(record) {
      return {
        rowSpan: record.rowSpan || 0
      };
    }
  }, {
    title: '作业类型',
    dataIndex: 'workTypeName',
    key: 'workTypeName',
    width: 80,
    ellipsis: true,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "road_level_type",
        style: {
          color: workTypeColorMap[text] || '#0082ff'
        }
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: 'road_level_type_circle',
        style: {
          backgroundColor: workTypeColorMap[text] || '#0082ff'
        }
      }), /*#__PURE__*/_react["default"].createElement("span", null, text));
    }
  }, {
    title: '作业时段',
    dataIndex: 'ruleStartTime',
    key: 'ruleStartTime',
    width: 140,
    ellipsis: true,
    render: function render(text, record) {
      return text ? "".concat((0, _moment["default"])(text).format('HH:mm:ss'), "~").concat((0, _moment["default"])(record.ruleEndTime).format('HH:mm:ss')) : '-';
    }
  }, {
    title: '作业趟数',
    dataIndex: 'workCount',
    key: 'workCount',
    width: 80,
    align: 'right'
  }, {
    title: '作业里程(km)',
    dataIndex: 'realWorkMileage',
    key: 'realWorkMileage',
    width: 110,
    align: 'right'
  }, {
    title: (/*#__PURE__*/_react["default"].createElement("span", null, "\u6838\u7B97\u4F5C\u4E1A\u91CC\u7A0B(km)", /*#__PURE__*/_react["default"].createElement(_antd.Tooltip, {
      title: "\u6838\u7B97\u4F5C\u4E1A\u91CC\u7A0B\uFF1A\u6839\u636E\u4F5C\u4E1A\u8DEF\u6BB5\u957F\u5EA6\u548C\u4F5C\u4E1A\u89C4\u5219\uFF0C\u540C\u4E00\u8DEF\u6BB5\u540C\u4E00\u65F6\u6BB5\u7684\u4F5C\u4E1A\u7C7B\u578B\u4E0B\uFF0C\u4E0D\u53EF\u8D85\u8FC7\u8BA1\u5212\u4F5C\u4E1A\u91CC\u7A0B\u3002"
    }, /*#__PURE__*/_react["default"].createElement(_icons.QuestionCircleOutlined, {
      style: {
        marginLeft: 8
      }
    })))),
    dataIndex: 'workMileage',
    key: 'workMileage',
    width: 160,
    align: 'right'
  }, {
    title: '操作',
    dataIndex: 'track',
    key: 'track',
    width: 80,
    fixed: 'right',
    render: function render(_text, record) {
      return /*#__PURE__*/_react["default"].createElement("a", {
        onClick: function onClick() {
          var prefix = '';
          var prefixList = location.pathname.split('/').filter(function (item) {
            return item;
          });
          if (prefixList.length === 2) {
            prefix = "/".concat(prefixList[0]);
          }
          var src = "".concat(prefix, "/carHistory/#/index?carId=").concat(record.carId, "&").concat(location.href.split('?')[1]);
          if (service === 'zyqs-zqb') {
            src = "".concat(prefix, "/carHistory/#/zyqsHistory?carId=").concat(record.carId, "&theme=").concat(theme == 'blue' ? 'dark' : theme, "&startTime=").concat((0, _moment["default"])(date).format('YYYY-MM-DD 00:00:00'), "&endTime=").concat((0, _moment["default"])(date).format('YYYY-MM-DD 23:59:59'), "&").concat(location.href.split('?')[1], "&roadId=").concat(record.roadId);
          }
          setIframeModalInfo({
            title: '车辆轨迹',
            visible: true,
            src: src
          });
        }
      }, "\u67E5\u770B\u8F68\u8FF9");
    }
  }];
  var tableProps = {
    height: 260,
    pagination: {
      defaultCurrent: 1,
      total: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || 0
    },
    columns: columns,
    isIndex: false,
    rowKey: 'index',
    dataSource: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) > 0 ? dataSource.map(function (ele, index) {
      return Object.assign(Object.assign({}, ele), {
        index: index
      });
    }) : []
  };
  return /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    gutter: [10, 10]
  }, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, /*#__PURE__*/_react["default"].createElement(_vmCard["default"], {
    title: "\u4F5C\u4E1A\u6C47\u603B",
    rightContent: /*#__PURE__*/_react["default"].createElement(_vmFilter.VMDatePicker, {
      value: day,
      onChange: function onChange(date) {
        return setDay(date);
      }
    })
  }, (0, _lodash.isEmpty)(workInfo) ? /*#__PURE__*/_react["default"].createElement(_vmEmpty["default"], {
    imgStyle: {
      marginLeft: 0,
      transform: 'translateX(0%)'
    }
  }) : /*#__PURE__*/_react["default"].createElement("div", {
    className: "road_work_wrap"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road_work_left"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "all_rate_wrap"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
    type: "circle",
    strokeColor: {
      '0%': '#41A8FF',
      '100%': '#1570F0'
    },
    percent: allWorkInfo.rate,
    strokeWidth: 10,
    width: 100,
    showInfo: false,
    trailColor: "#EBEBEB"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "all_rate_info"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "all_rate_info_label"
  }, "\u603B\u5B8C\u6210\u7387"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "all_rate"
  }, allWorkInfo.rate, "%"))), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "left_info"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "left_info_dot"
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: "left_info_label"
  }, "\u8BA1\u5212/\u6838\u7B97\u91CC\u7A0B\uFF1A"), /*#__PURE__*/_react["default"].createElement("span", null, allWorkInfo.planMileage, "/", allWorkInfo.workMileage, "\u516C\u91CC"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "left_info"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "left_info_dot"
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: "left_info_label"
  }, "\u8BA1\u5212/\u6709\u6548\u8D9F\u6B21\uFF1A"), /*#__PURE__*/_react["default"].createElement("span", null, allWorkInfo.planCount, "/", allWorkInfo.workCount, "\u8D9F"))))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road_work_right"
  }, newWorkInfo.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: item.workType,
      className: "road_work_right_item"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "road_work_right_item_left"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "road_work_right_item_left_info"
    }, /*#__PURE__*/_react["default"].createElement("span", {
      className: "work_type"
    }, item.workTypeStr), /*#__PURE__*/_react["default"].createElement("span", {
      className: "work_rate"
    }, item.rate, "%"), item.rate === 100 && (/*#__PURE__*/_react["default"].createElement("img", {
      src: require('../../imgs/completed.png'),
      style: {
        width: 14,
        height: 14
      }
    }))), /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
      percent: item.rate,
      showInfo: false,
      strokeColor: workTypeColorMap[item.workTypeStr]
    })), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
      className: "left_info_label"
    }, "\u8BA1\u5212/\u6838\u7B97\u91CC\u7A0B\uFF1A"), /*#__PURE__*/_react["default"].createElement("span", null, item.planMileage, "/", item.workMileage, "\u516C\u91CC")), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
      className: "left_info_label"
    }, "\u8BA1\u5212/\u6709\u6548\u8D9F\u6B21\uFF1A"), /*#__PURE__*/_react["default"].createElement("span", null, item.planCount, "/", item.workCount, "\u8D9F"))));
  }))))), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, /*#__PURE__*/_react["default"].createElement(_vmCard["default"], {
    title: "\u4F5C\u4E1A\u660E\u7EC6"
  }, /*#__PURE__*/_react["default"].createElement(_vmTable["default"], Object.assign({}, tableProps)))));
};
var _default = exports["default"] = Work;
//# sourceMappingURL=Work.js.map
