"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 _ahooks = require("ahooks");
var _moment = _interopRequireDefault(require("moment"));
var _vmTable = _interopRequireDefault(require("../../../vm-table"));
var _api = require("../../api");
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 ListZymx = function ListZymx(props) {
  var id = props.id,
    startDate = props.startDate,
    endDate = props.endDate;
  var _useSetState = (0, _ahooks.useSetState)({
      pagination: {
        current: 1,
        pageSize: 20,
        total: 0
      }
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  (0, _react.useEffect)(function () {
    setState({
      pagination: {
        current: 1,
        pageSize: 20,
        total: 0
      }
    });
  }, [startDate]);
  var pagination = state.pagination;
  var _BaseService$useToday = _api.BaseService.useTodayWork(id, startDate || (0, _moment["default"])().format('YYYY-MM-DD 00:00:00'), endDate || (0, _moment["default"])().format('YYYY-MM-DD 23:59:59'), pagination.current - 1),
    todayWorkRes = _BaseService$useToday.todayWorkRes;
  var columns = [{
    title: '作业日期',
    dataIndex: 'shiftDate',
    key: 'shiftDate',
    width: 100,
    render: function render() {
      var _a;
      return ((_a = startDate === null || startDate === void 0 ? void 0 : startDate.split(' ')) === null || _a === void 0 ? void 0 : _a[0]) || '-';
    }
  }, {
    title: '班次名称',
    dataIndex: 'shiftName',
    key: 'shiftName',
    width: 100
  }, {
    title: '班次时间',
    dataIndex: 'shiftStartTime',
    key: 'shiftStartTime',
    width: 200,
    render: function render(text, record) {
      var _a, _b, _c, _d, _e, _f, _g, _h;
      return text && record.shiftEndTime ? /*#__PURE__*/_react["default"].createElement("span", {
        title: "".concat((_b = (_a = record.shiftStartTime) === null || _a === void 0 ? void 0 : _a.split(' ')) === null || _b === void 0 ? void 0 : _b[1], "~").concat((_d = (_c = record.shiftEndTime) === null || _c === void 0 ? void 0 : _c.split(' ')) === null || _d === void 0 ? void 0 : _d[1])
      }, "".concat((_f = (_e = record.shiftStartTime) === null || _e === void 0 ? void 0 : _e.split(' ')) === null || _f === void 0 ? void 0 : _f[1], "~").concat((_h = (_g = record.shiftEndTime) === null || _g === void 0 ? void 0 : _g.split(' ')) === null || _h === void 0 ? void 0 : _h[1])) : '-';
    }
  }, {
    title: '班次时长',
    dataIndex: 'shiftTimeStr',
    key: 'shiftTimeStr',
    width: 100
  }, {
    title: '排班人员',
    dataIndex: 'staffName',
    key: 'staffName',
    width: 100
  }, {
    title: '是否出勤',
    dataIndex: 'inWorkElement',
    key: 'inWorkElement',
    width: 120,
    render: function render(text) {
      return text ? '是' : '否';
    }
  }];
  var pageChange = function pageChange(page) {
    setState({
      pagination: Object.assign(Object.assign({}, pagination), {
        current: page
      })
    });
  };
  var tableProps = {
    height: 250,
    // scroll: { x: 840 },
    isIndex: false,
    pagination: Object.assign(Object.assign({}, pagination), {
      total: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.total) || 0,
      defaultPageSize: 20,
      onChange: pageChange
    })
  };
  return /*#__PURE__*/_react["default"].createElement(_vmTable["default"], Object.assign({
    columns: columns,
    rowKey: "id"
  }, tableProps, {
    dataSource: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.rows) || []
  }));
};
var _default = exports["default"] = ListZymx;
//# sourceMappingURL=ListZymx.js.map
