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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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(arr) { if (Array.isArray(arr)) return arr; }
/**
 * 考核信息-列表
 */

import { VtxImage } from '@vtx/components';
import { useSetState } from 'ahooks';
import dayjs from 'dayjs';
import { VmFactor, VmFilter, VmTable, VmWrapper } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { BaseService, ReocrdService } from "../../api2";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var List = function List(props) {
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var id = props.id;
  var _useSetState = useSetState({
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0
      },
      startDate: dayjs().startOf('M'),
      endDate: dayjs(),
      checkActivityCode: '1',
      sort: ''
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var pagination = state.pagination,
    startDate = state.startDate,
    endDate = state.endDate,
    checkActivityCode = state.checkActivityCode,
    sort = state.sort;
  var _BaseService$useKhInf = BaseService.useKhInfo(id, startDate.format('YYYY-MM-DD'), endDate.format('YYYY-MM-DD'), checkActivityCode === '1' ? '' : checkActivityCode),
    khRes = _BaseService$useKhInf.khRes;
  var _ReocrdService$useRec = ReocrdService.useRecordInfo(id, startDate.format('YYYY-MM-DD'), endDate.format('YYYY-MM-DD'), checkActivityCode === '1' ? '' : checkActivityCode, pagination.current - 1, sort),
    records = _ReocrdService$useRec.records,
    loading = _ReocrdService$useRec.loading;
  var columns = [{
    title: '考核图片',
    dataIndex: 'photos',
    key: 'photos',
    width: 120,
    render: function render(text) {
      var photos = JSON.parse(text || '[]');
      var a = [].concat(_toConsumableArray(photos), _toConsumableArray(photos), _toConsumableArray(photos), _toConsumableArray(photos));
      return (photos === null || photos === void 0 ? void 0 : photos.length) > 0 ? /*#__PURE__*/_jsx(VtxImage.PreviewGroup, {
        children: a.map(function (ele, index) {
          return /*#__PURE__*/_jsx(VtxImage, {
            src: "".concat(process.env.PREFIX || '', "/cloudFile/common/downloadFile?id=").concat(ele.id),
            style: {
              width: 80,
              height: 80,
              visibility: index > 0 ? 'hidden' : 'visible'
            },
            alt: ele.name
          }, index);
        })
      }) : '--';
    }
  }, {
    title: '考核时间',
    dataIndex: 'checkDate',
    key: 'checkDate',
    width: 150,
    ellipsis: true
  }, {
    title: '考核活动',
    dataIndex: 'checkActivityName',
    key: 'checkActivityName',
    width: 200
  }, {
    title: '考核人',
    dataIndex: 'checkUserName',
    key: 'checkUserName'
  }, {
    title: '考核分组',
    dataIndex: 'ruleGroupName',
    key: 'ruleGroupName'
  }, {
    title: '考核标准',
    dataIndex: 'ruleName',
    key: 'ruleName',
    width: 150
  }, {
    title: '分值',
    dataIndex: 'deductPoints',
    key: 'deductPoints',
    align: 'right'
  }];
  var pageChange = function pageChange(page) {
    setState({
      pagination: _objectSpread(_objectSpread({}, pagination), {}, {
        current: page
      })
    });
  };
  var tableProps = {
    pagination: _objectSpread(_objectSpread({}, pagination), {}, {
      total: records.total,
      defaultPageSize: 10,
      onChange: pageChange
    }),
    height: 384,
    loading: loading,
    dataSource: records.rows,
    onChange: function onChange(_pagination, _filters, sorter) {
      if (sorter.order) {
        var order = sorter.order === 'ascend' ? 'asc' : 'desc';
        setState({
          sort: "".concat(sorter.field, ",").concat(order)
        });
      } else {
        setState({
          sort: ''
        });
      }
    }
  };
  var filterChange = function filterChange(dateValue) {
    setState({
      startDate: dateValue[0],
      endDate: dateValue[1]
    });
  };
  return /*#__PURE__*/_jsxs(VmWrapper, {
    title: "\u8003\u6838\u8BE6\u60C5",
    filterType: "rangePicker",
    dateValue: [startDate, endDate],
    filterChange: filterChange,
    extraLeft: /*#__PURE__*/_jsx(VmFilter.VMSelect, {
      options: [{
        value: '1',
        label: '全部'
      }, {
        value: 'RCDC',
        label: '日常督查'
      }, {
        value: 'ZXDC',
        label: '专项督查'
      }, {
        value: 'DSFCP',
        label: '第三方测评'
      }, {
        value: 'RCXC',
        label: '日常巡查'
      }],
      style: {
        width: 132
      },
      value: checkActivityCode,
      onChange: function onChange(e) {
        return setState({
          checkActivityCode: e
        });
      }
    }),
    children: [/*#__PURE__*/_jsx("div", {
      className: "kh-record-summary",
      children: [{
        name: '考核次数',
        value: khRes === null || khRes === void 0 ? void 0 : khRes.monthCheckTims,
        key: 'count',
        unit: '次',
        fontType: 'blue'
      }, {
        name: '累计扣分',
        value: khRes === null || khRes === void 0 ? void 0 : khRes.monthDeductPoint,
        key: 'subtract',
        unit: '分',
        fontType: 'red'
      }].map(function (ele) {
        return /*#__PURE__*/_jsx(VmFactor, _objectSpread(_objectSpread({}, ele), {}, {
          img: require("../../imgs/".concat(ele.key).concat(isDark ? '' : '_light', ".png")),
          unitStyle: {
            fontSize: 14
          }
        }), ele.key);
      })
    }), /*#__PURE__*/_jsx(VmTable, _objectSpread({
      columns: columns,
      rowKey: "id"
    }, tableProps))]
  });
};
export default List;