"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = WorkLjsy;
var _react = _interopRequireDefault(require("react"));
var _ahooks = require("ahooks");
var _moment = _interopRequireDefault(require("moment"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmFilter = require("../../../vm-filter");
var _vmTable = _interopRequireDefault(require("../../../vm-table"));
var _vmImageText = _interopRequireDefault(require("../../../vm-image-text"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _Wcl = _interopRequireDefault(require("./Wcl"));
var _api = require("../../api");
var _ljsjdw = _interopRequireDefault(require("../../imgs/ljsjdw.png"));
var _pjwcl = _interopRequireDefault(require("../../imgs/pjwcl.png"));
var _ljsjts = _interopRequireDefault(require("../../imgs/ljsjts.png"));
var _ljsjzl = _interopRequireDefault(require("../../imgs/ljsjzl.png"));
var _ljsjdw_light = _interopRequireDefault(require("../../imgs/ljsjdw_light.png"));
var _pjwcl_light = _interopRequireDefault(require("../../imgs/pjwcl_light.png"));
var _ljsjts_light = _interopRequireDefault(require("../../imgs/ljsjts_light.png"));
var _ljsjzl_light = _interopRequireDefault(require("../../imgs/ljsjzl_light.png"));
var _ljsjdw_blue = _interopRequireDefault(require("../../imgs/ljsjdw_blue.png"));
var _pjwcl_blue = _interopRequireDefault(require("../../imgs/pjwcl_blue.png"));
var _ljsjts_blue = _interopRequireDefault(require("../../imgs/ljsjts_blue.png"));
var _ljsjzl_blue = _interopRequireDefault(require("../../imgs/ljsjzl_blue.png"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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; }
function WorkLjsy(_ref) {
  var id = _ref.id;
  var _a, _b, _c;
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    sDate = _useSettings.startDate,
    eDate = _useSettings.endDate;
  var getSrc = function getSrc(code) {
    var obj = {};
    if (theme === 'dark') {
      obj = {
        ljsjdw: _ljsjdw["default"],
        pjwcl: _pjwcl["default"],
        ljsjts: _ljsjts["default"],
        ljsjzl: _ljsjzl["default"]
      };
    } else if (theme === 'blue') {
      obj = {
        ljsjdw: _ljsjdw_blue["default"],
        pjwcl: _pjwcl_blue["default"],
        ljsjts: _ljsjts_blue["default"],
        ljsjzl: _ljsjzl_blue["default"]
      };
    } else {
      obj = {
        ljsjdw: _ljsjdw_light["default"],
        pjwcl: _pjwcl_light["default"],
        ljsjts: _ljsjts_light["default"],
        ljsjzl: _ljsjzl_light["default"]
      };
    }
    return obj[code];
  };
  var _useSetState = (0, _ahooks.useSetState)({
      startDate: sDate ? sDate : (0, _moment["default"])().startOf('M').format('YYYY-MM-DD'),
      endDate: eDate ? eDate : (0, _moment["default"])().format('YYYY-MM-DD'),
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0
      },
      sort: ''
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var startDate = state.startDate,
    endDate = state.endDate,
    pagination = state.pagination,
    sort = state.sort;
  var paramConfigsList = _api.BaseService.useConfig();
  var _WorkServicve$useWork = _api.WorkServicve.useWorkSummaryLjsy(id, startDate, endDate),
    summaryLjsy = _WorkServicve$useWork.summaryLjsy;
  var _BaseService$useWorkA = _api.BaseService.useWorkAnaLjsy(id, startDate, endDate, (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.avgCompletionRate) >= 0),
    workAnaLjsyRes = _BaseService$useWorkA.workAnaLjsyRes;
  var names = workAnaLjsyRes.names,
    values = workAnaLjsyRes.values;
  var handleDateChange = function handleDateChange(start, end) {
    setState({
      startDate: start,
      endDate: end
    });
  };
  var _WorkServicve$useReco = _api.WorkServicve.useRecordLjsy(id, "".concat(startDate, " 00:00:00"), "".concat(endDate, " 23:59:59"), pagination.current - 1, sort),
    recordLjsyRes = _WorkServicve$useReco.recordLjsyRes;
  var columns = [{
    title: '收集点名称',
    dataIndex: 'collectPointName',
    key: 'collectPointName',
    width: 160,
    ellipsis: true,
    render: function render(text) {
      return text ? text : '-';
    }
  }, {
    title: '收集时间',
    dataIndex: 'actualCollectTime',
    key: 'actualCollectTime',
    width: 140,
    sorter: true,
    render: function render(text) {
      return text ? text : '-';
    }
  }];
  if (((_a = paramConfigsList['SHOW_COLLECTING_BUCKETS']) === null || _a === void 0 ? void 0 : _a.value) === 'true') {
    columns = columns.concat([{
      title: '收集桶数(桶)',
      dataIndex: 'bucketNum',
      key: 'bucketNum',
      align: 'right',
      render: function render(text) {
        return text ? text : 0;
      }
    }]);
  }
  if (((_b = paramConfigsList['SHOW_WEIGHTING']) === null || _b === void 0 ? void 0 : _b.value) === 'true') {
    columns = columns.concat([{
      title: '收集重量(kg)',
      dataIndex: 'weight',
      key: 'weight',
      align: 'right',
      render: function render(text) {
        return text ? text : 0;
      }
    }]);
  }
  if (((_c = paramConfigsList['SHOW_QUALITY']) === null || _c === void 0 ? void 0 : _c.value) === 'true') {
    columns = columns.concat([{
      title: '分类质量',
      dataIndex: 'qualityEvaluateName',
      render: function render(text) {
        return text ? text : '-';
      }
    }]);
  }
  columns = columns.concat([{
    title: '是否超时',
    dataIndex: 'beenOverTime',
    key: 'beenOverTime',
    render: function render(text) {
      return text ? '是' : '否';
      // <span style={{ color: text ? '#FFEF41' : '#35EAFF' }}>
      // </span>
    }
  }, {
    title: '是否任务内',
    dataIndex: 'beenTask',
    key: 'beenTask',
    render: function render(text) {
      return text ? '是' : '否';
    }
  }]);
  var pageChange = function pageChange(page) {
    setState({
      pagination: Object.assign(Object.assign({}, pagination), {
        current: page
      })
    });
  };
  var handleTableChange = function handleTableChange(sorter) {
    setState({
      sort: "actualCollectTime,".concat(sorter.order === 'ascend' ? 'ASC' : 'DESC')
    });
  };
  var tableProps = {
    pagination: Object.assign(Object.assign({}, pagination), {
      total: (recordLjsyRes === null || recordLjsyRes === void 0 ? void 0 : recordLjsyRes.total) || 0,
      defaultPageSize: 10,
      onChange: pageChange
    }),
    handleTableChange: handleTableChange,
    height: (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.avgCompletionRate) >= 0 ? 240 : 360,
    dataSource: recordLjsyRes === null || recordLjsyRes === void 0 ? void 0 : recordLjsyRes.rows
  };
  return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-head"
  }, !(summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.avgCompletionRate) && (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.avgCompletionRate) !== 0 ? (/*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u6C47\u603B\u4FE1\u606F"
  })) : (/*#__PURE__*/_react["default"].createElement("div", null)), /*#__PURE__*/_react["default"].createElement(_vmFilter.VMRangePicker, {
    value: [(0, _moment["default"])(startDate), (0, _moment["default"])(endDate)],
    onChange: function onChange(dates) {
      return dates && handleDateChange((0, _moment["default"])(dates[0]).format('YYYY-MM-DD'), (0, _moment["default"])(dates[1]).format('YYYY-MM-DD'));
    }
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-content"
  }, (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.avgCompletionRate) === 0 || (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.avgCompletionRate) > 0 ? (/*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-summary"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-summary-left"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u6C47\u603B\u4FE1\u606F"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-summary-relation-item"
  }, /*#__PURE__*/_react["default"].createElement(_vmImageText["default"], {
    src: getSrc('ljsjdw'),
    name: "\u7D2F\u8BA1\u6536\u96C6\u6B21\u6570",
    value: (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.collectPointNum) || 0,
    unit: "\u4E2A",
    style: {
      width: '50%',
      margin: 0
    }
  }), /*#__PURE__*/_react["default"].createElement(_vmImageText["default"], {
    src: getSrc('pjwcl'),
    name: "\u5E73\u5747\u5B8C\u6210\u7387",
    value: summaryLjsy.avgCompletionRate,
    unit: "%",
    style: {
      width: '50%',
      margin: 0
    }
  }), /*#__PURE__*/_react["default"].createElement(_vmImageText["default"], {
    src: getSrc('ljsjts'),
    name: "\u7D2F\u8BA1\u6536\u96C6\u6876\u6570",
    value: (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.bucketNum) || 0,
    unit: "\u4E2A",
    style: {
      width: '50%',
      margin: 0
    }
  }), /*#__PURE__*/_react["default"].createElement(_vmImageText["default"], {
    src: getSrc('ljsjzl'),
    name: "\u7D2F\u8BA1\u6536\u96C6\u91CD\u91CF",
    value: (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.weight) || 0,
    unit: "kg",
    style: {
      width: '50%',
      margin: 0
    }
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-summary-relation-chart"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u5B8C\u6210\u7387\u5206\u6790"
  }), /*#__PURE__*/_react["default"].createElement(_Wcl["default"], {
    names: names,
    values: (values === null || values === void 0 ? void 0 : values.length) > 2 ? values[2] : [{
      name: '22',
      value: 2
    }, {
      name: '224',
      value: 20
    }, {
      name: '225',
      value: 12
    }, {
      name: '26',
      value: 13
    }, {
      name: '272',
      value: 6
    }]
  })))) : (/*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-summary-norelation"
  }, /*#__PURE__*/_react["default"].createElement(_vmImageText["default"], {
    src: getSrc('ljsjdw'),
    name: "\u7D2F\u8BA1\u6536\u96C6\u6B21\u6570",
    value: (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.collectPointNum) || 0,
    unit: "\u4E2A"
  }), /*#__PURE__*/_react["default"].createElement(_vmImageText["default"], {
    src: getSrc('ljsjts'),
    name: "\u7D2F\u8BA1\u6536\u96C6\u6876\u6570",
    value: (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.bucketNum) || 0,
    unit: "\u4E2A"
  }), /*#__PURE__*/_react["default"].createElement(_vmImageText["default"], {
    src: getSrc('ljsjzl'),
    name: "\u7D2F\u8BA1\u6536\u96C6\u91CD\u91CF",
    value: (summaryLjsy === null || summaryLjsy === void 0 ? void 0 : summaryLjsy.weight) || 0,
    unit: "kg"
  })))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-work-table"
  }, /*#__PURE__*/_react["default"].createElement(_vmTable["default"], Object.assign({
    columns: columns
  }, tableProps))));
}
//# sourceMappingURL=WorkLjsy.js.map
