"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 _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var _antd = require("antd");
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; } /**
 * 考核信息-列表
 */ // import { VtxImage } from '@vtx/components';
var ListZg = function ListZg(props) {
  var id = props.id,
    startDate = props.startDate,
    endDate = props.endDate;
  var _useSetState = (0, _ahooks.useSetState)({
      filterKey: 'kh',
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0
      },
      sorter: ''
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var pagination = state.pagination,
    sorter = state.sorter;
  var _BaseService$useZgRec = _api.BaseService.useZgRecord(id, startDate, endDate, pagination.current - 1, sorter),
    zgData = _BaseService$useZgRec.zgData;
  (0, _react.useEffect)(function () {
    var _a;
    if (((_a = zgData === null || zgData === void 0 ? void 0 : zgData.rows) === null || _a === void 0 ? void 0 : _a.length) > 0) {
      var myElement = document.querySelectorAll('.ant-image-mask-info');
      myElement.forEach(function (child) {
        child.innerHTML = child.innerHTML.replace(new RegExp('预览', 'g'), ' ');
      });
    }
  }, [JSON.stringify(zgData === null || zgData === void 0 ? void 0 : zgData.rows)]);
  var getZgColor = function getZgColor(code) {
    var color = '#0FEBFF';
    switch (code) {
      case 'Zgtg':
        color = '#1FEFA9';
        break;
      case 'Zgbtg':
        color = '#FF6A65';
        break;
      case 'Dzg':
        color = '#00A8FF';
        break;
      case 'Dzgz':
        color = '#FFBD1E';
        break;
      case 'Dpf':
        color = '#FA69FF';
        break;
      default:
        color = '#0FEBFF';
        break;
    }
    return color;
  };
  var zgColumns = [{
    title: '问题来源',
    dataIndex: 'problemFromStr',
    key: 'problemFromStr'
  }, {
    title: '问题分类',
    dataIndex: 'problemCategoryName',
    key: 'problemCategoryName'
  }, {
    title: '问题描述',
    dataIndex: 'memo',
    key: 'memo',
    ellipsis: true
  }, {
    title: '上报时间',
    dataIndex: 'reportDateTimeStr',
    key: 'reportDateTimeStr'
  }, {
    title: '上报单位',
    dataIndex: 'reportManageUnitName',
    key: 'reportManageUnitName'
  }, {
    title: '上报人员',
    dataIndex: 'reportStaffName',
    key: 'reportStaffName'
  }, {
    title: '状态',
    dataIndex: 'orderStatusStr',
    key: 'orderStatusStr',
    render: function render(text, record) {
      return /*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: getZgColor(record.orderStatus)
        }
      }, /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          display: 'inline-block',
          width: '8px',
          height: '8px',
          borderRadius: '50%',
          marginRight: '6px',
          background: getZgColor(record.orderStatus)
        }
      }), text);
    }
  }, {
    title: '图片',
    dataIndex: 'operation',
    key: 'operation',
    width: 50,
    render: function render(_text, record) {
      var photos = {};
      if (record.photos) {
        photos = JSON.parse(record.photos)[0];
      }
      return (photos === null || photos === void 0 ? void 0 : photos.id) ? (/*#__PURE__*/_react["default"].createElement(_antd.Image, {
        style: {
          width: '45px',
          height: '45px'
        },
        alt: photos === null || photos === void 0 ? void 0 : photos.name,
        src: "/vortex/rest/cloud/np/file/downloadFileThumbnail?outputQuality=0.5&scale=0.2&id=".concat(photos === null || photos === void 0 ? void 0 : photos.id, "&token=").concat((0, _utils.getVtxToken)('token')),
        preview: {
          destroyOnClose: true,
          src: "/cloudFile/common/downloadFile?id=".concat(photos === null || photos === void 0 ? void 0 : photos.id, "&token=").concat((0, _utils.getVtxToken)('token')),
          maskClassName: 'maskClass'
        }
      })) : (/*#__PURE__*/_react["default"].createElement("span", null, "-"));
    }
  }];
  var pageChange = function pageChange(page) {
    setState({
      pagination: Object.assign(Object.assign({}, pagination), {
        current: page
      })
    });
  };
  var tableProps = {
    height: 440,
    pagination: Object.assign(Object.assign({}, pagination), {
      total: (zgData === null || zgData === void 0 ? void 0 : zgData.total) || 0,
      defaultPageSize: 10,
      onChange: pageChange
    })
  };
  var handleTableChange = function handleTableChange(sorter) {
    setState({
      sorter: "".concat(sorter.columnKey, ",").concat(sorter.order === 'ascend' ? 'ASC' : 'DESC')
    });
  };
  return /*#__PURE__*/_react["default"].createElement(_vmTable["default"], Object.assign({
    columns: zgColumns,
    rowKey: "id"
  }, tableProps, {
    handleTableChange: handleTableChange,
    dataSource: (zgData === null || zgData === void 0 ? void 0 : zgData.rows) || []
  }));
};
var _default = exports["default"] = ListZg;
//# sourceMappingURL=ListZg.js.map
