"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"] = StatisticalPage;
var _react = _interopRequireWildcard(require("react"));
var _tabs = _interopRequireDefault(require("antd/lib/tabs"));
var _config = _interopRequireDefault(require("../../../../_mapUtil/config"));
var _PublicTemple = _interopRequireDefault(require("../../../PublicTemple"));
var _dayjs = _interopRequireDefault(require("dayjs"));
var _useOrgTree = _interopRequireDefault(require("@/hooks/useOrgTree"));
var _Table = _interopRequireDefault(require("./Table"));
var _MyModal = _interopRequireDefault(require("../../../MyModal"));
var _request = _interopRequireDefault(require("../../../../_mapUtil/request"));
var _TimeLimit = _interopRequireDefault(require("../TimeLimit"));
var _index = _interopRequireDefault(require("./index.less"));
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 _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _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(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : 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 _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 TabPane = _tabs["default"].TabPane;
function StatisticalPage(props) {
  var _props$filtrateConfig = props.filtrateConfig,
    filtrateConfig = _props$filtrateConfig === void 0 ? [] : _props$filtrateConfig,
    _props$tableConfig = props.tableConfig,
    tableConfig = _props$tableConfig === void 0 ? [] : _props$tableConfig,
    searchApi = props.searchApi,
    pageType = props.pageType,
    downloadURL = props.downloadURL,
    _props$modalListUrl = props.modalListUrl,
    modalListUrl = _props$modalListUrl === void 0 ? "".concat(_config["default"].publicUrlSJGD, "/api/workOrder/allCaseList") : _props$modalListUrl,
    orderType = props.orderType,
    _props$extraParams = props.extraParams,
    extraParams = _props$extraParams === void 0 ? {} : _props$extraParams;
  var _useState = (0, _react.useState)('month'),
    _useState2 = _slicedToArray(_useState, 2),
    activeKey = _useState2[0],
    setActiveKey = _useState2[1];
  var _useState3 = (0, _react.useState)(false),
    _useState4 = _slicedToArray(_useState3, 2),
    visible = _useState4[0],
    setVisible = _useState4[1];
  var _useState5 = (0, _react.useState)([]),
    _useState6 = _slicedToArray(_useState5, 2),
    dataSource = _useState6[0],
    setDataSource = _useState6[1];
  var _useState7 = (0, _react.useState)(false),
    _useState8 = _slicedToArray(_useState7, 2),
    loading = _useState8[0],
    setLoading = _useState8[1];
  var ref = (0, _react.useRef)();
  var treeList = (0, _useOrgTree["default"])('true', {
    nodeTypeFile: 'nodeType',
    nodeTypeValue: 'org'
  });
  var getData = function getData(val) {
    var _ref$current;
    var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    setLoading(true);
    var refParams = ((_ref$current = ref.current) === null || _ref$current === void 0 || (_ref$current = _ref$current.form) === null || _ref$current === void 0 ? void 0 : _ref$current.getFieldsValue()) || {};
    var _refParams = {
      disposeDeptId: refParams.disposeDeptId
    };
    if (refParams.time) {
      _refParams.reportDateStart = (0, _dayjs["default"])(refParams.time).startOf(activeKey).format('YYYY-MM-DD');
      _refParams.reportDateEnd = (0, _dayjs["default"])(refParams.time).endOf(activeKey).format('YYYY-MM-DD');
    }
    var _params = _objectSpread(_objectSpread(_objectSpread({}, _refParams), params), {}, {
      processDefinitionKey: 'customer_service_process'
    }, extraParams);
    if (pageType === 'GDLB') {
      _params.eventAndComponentManageId = val.eventAndComponentManageId;
    }
    if (pageType === 'GDQYFB') {
      _params.hzDivisionId = val.keyAreaId;
    }
    if (pageType === 'GDCL') {
      _params.disposeDeptId = val.disposeDeptId;
    }
    _request["default"].get(modalListUrl, {
      body: _params
    }).then(function (res) {
      var _res$data;
      setLoading(false);
      if ((res === null || res === void 0 ? void 0 : res.result) === 0 && res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.length) {
        setDataSource(res.data);
      }
    });
  };
  var renderText = function renderText(text, record, params) {
    return text || String(text) === '0' ? /*#__PURE__*/_react["default"].createElement("a", {
      onClick: function onClick() {
        setVisible(true);
        getData(record, params);
      }
    }, text) : '--';
  };

  // 渲染时限
  var renderTimeLimit = function renderTimeLimit(text, record) {
    return /*#__PURE__*/_react["default"].createElement(_TimeLimit["default"], {
      details: record
    });
  };
  var pageConfig = {
    searchApi: searchApi,
    ref: ref,
    filtrate: {
      items: [{
        type: 'treeSelect',
        label: '管理单位',
        paramName: 'disposeDeptId',
        itemProps: {
          treeData: treeList
        }
      }, {
        type: 'datePicker',
        label: '选择日期',
        paramName: 'time',
        itemProps: {
          picker: activeKey,
          allowClear: false
        },
        formItemLayout: {
          initialValue: (0, _dayjs["default"])()
        }
      }].concat(_toConsumableArray(filtrateConfig))
    },
    table: _objectSpread({
      tableTitle: '',
      showFixed: true,
      isView: true,
      hideOperation: true,
      showRowSelection: false,
      tablePropsConfig: {
        pagination: false
      },
      // overlayShow: false,
      exportList: [{
        name: '导出全部',
        key: 'all'
      }],
      exportConfig: {
        showExport: true,
        downloadURL: downloadURL,
        method: 'POST'
      },
      sorterBefore: function sorterBefore(a, b) {
        var noSorter = false;
        var field = {
          GDLB: 'eventAndComponentManageName',
          GDQYFB: 'keyArea',
          GDCL: 'disposeDept'
        }[pageType];
        if (field && a[field] === '合计' || b[field] === '合计') {
          noSorter = true;
        }
        return noSorter;
      },
      columns: [].concat(_toConsumableArray(pageType === 'GDLB' ? [{
        title: '工单类别',
        dataIndex: 'eventAndComponentManageName',
        width: 150
      }, {
        title: 'TOP热点工单排名',
        dataIndex: 'rank',
        align: 'right',
        sortType: 'number',
        width: 150
      }] : []), _toConsumableArray(pageType === 'GDQYFB' ? [{
        title: '工单区域',
        dataIndex: 'keyArea',
        width: 150
      }] : []), _toConsumableArray(pageType === 'GDCL' ? [{
        title: orderType ? '办理部门' : '办理单位',
        dataIndex: 'disposeDept',
        width: 150
      }] : []), [{
        title: '工单总数(件)',
        dataIndex: 'total',
        align: 'right',
        sortType: 'number',
        width: 130,
        render: function render(text, record) {
          return renderText(text, record);
        }
      }, {
        title: orderType ? '已办结(件)' : '已封存(件)',
        dataIndex: 'closeCount',
        align: 'right',
        sortType: 'number',
        width: 130,
        render: function render(text, record) {
          return renderText(text, record, {
            status: 9
          });
        }
      }, {
        title: orderType ? '待处理(件)' : '待处置(件)',
        dataIndex: 'toBeProcessedCount',
        align: 'right',
        sortType: 'number',
        width: 130,
        render: function render(text, record) {
          return renderText(text, record, {
            status: 3
          });
        }
      }, {
        title: orderType ? '处理中(件)' : '处置中(件)',
        dataIndex: 'inProcessedCount',
        align: 'right',
        sortType: 'number',
        width: 130,
        render: function render(text, record) {
          return renderText(text, record, {
            statusList: '4,7,8'
          });
        } // todo
      }], _toConsumableArray(pageType === 'GDCL' && orderType ? [] : [{
        title: '已撤销',
        dataIndex: 'revokedCount',
        align: 'right',
        sortType: 'number',
        width: 130,
        render: function render(text, record) {
          return renderText(text, record, {
            status: 10
          });
        }
      }]), _toConsumableArray(pageType === 'GDLB' && !orderType ? [{
        title: '督办工单(件)',
        dataIndex: 'superviseCount',
        align: 'right',
        sortType: 'number',
        width: 150,
        render: function render(text, record) {
          return renderText(text, record, {
            interveneSupervises: true
          });
        }
      }, {
        title: '初次办结工单(件)',
        dataIndex: 'firstCloseCount',
        align: 'right',
        sortType: 'number',
        width: 150,
        render: function render(text, record) {
          return renderText(text, record, {
            status: 9,
            hzBack: false
          });
        }
      }, {
        title: '再次办理工单(件)',
        dataIndex: 'secondCloseCount',
        align: 'right',
        sortType: 'number',
        width: 150,
        render: function render(text, record) {
          return renderText(text, record, {
            hzBack: true
          });
        }
      }] : []), _toConsumableArray(pageType === 'GDQYFB' ? [{
        title: '处置及时工单(件)',
        dataIndex: 'inTimeCount',
        align: 'right',
        sortType: 'number',
        width: 150,
        render: function render(text, record) {
          return renderText(text, record, {
            status: 9,
            inTime: 1
          });
        }
      }, {
        title: '处置及时率(%)',
        dataIndex: 'inTimeDisposeRate',
        align: 'right',
        sortType: 'number',
        width: 150
      }, {
        title: '办结平均耗时',
        dataIndex: 'avgTime',
        width: 150
      }] : []), _toConsumableArray(pageType === 'GDCL' && orderType ? [{
        title: '到场及时率(%)',
        dataIndex: 'presenceRate',
        align: 'right',
        sortType: 'number',
        width: 150
      }, {
        title: '处置及时率(%)',
        dataIndex: 'inTimeDisposeRate',
        align: 'right',
        sortType: 'number',
        width: 150,
        render: function render(text) {
          return /*#__PURE__*/_react["default"].createElement("span", null, text || '0');
        }
      }] : pageType === 'GDCL' && !orderType ? [{
        title: '查阅及时率(%)',
        dataIndex: 'referenceTimeRate',
        align: 'right',
        sortType: 'number',
        width: 150
      }, {
        title: '处置及时率(%)',
        dataIndex: 'inTimeDisposeRate',
        align: 'right',
        sortType: 'number',
        width: 150,
        render: function render(text) {
          return /*#__PURE__*/_react["default"].createElement("span", null, text || '0');
        }
      }, {
        title: '不满意率(%)',
        dataIndex: 'noSatisfactionRate',
        align: 'right',
        sortType: 'number',
        width: 150
      }] : []))
    }, tableConfig),
    searchBefore: function searchBefore(record) {
      var params = _objectSpread({
        processDefinitionKey: 'customer_service_process'
      }, extraParams);
      if (record.time) {
        params.startTime = (0, _dayjs["default"])(record.time).startOf(activeKey).format('YYYY-MM-DD');
        params.endTime = (0, _dayjs["default"])(record.time).endOf(activeKey).format('YYYY-MM-DD');
      }
      if (record.disposeDeptId) {
        params.disposeDeptId = record.disposeDeptId;
      }
      return params;
    },
    beforeExport: function beforeExport(record) {
      var params = _objectSpread({
        processDefinitionKey: 'customer_service_process'
      }, extraParams);
      if (record.time) {
        params.startTime = (0, _dayjs["default"])(record.time).startOf(activeKey).format('YYYY-MM-DD');
        params.endTime = (0, _dayjs["default"])(record.time).endOf(activeKey).format('YYYY-MM-DD');
      }
      if (record.disposeDeptId) {
        params.disposeDeptId = record.disposeDeptId;
      }
      return params;
    }
  };
  var columns = [{
    title: '工单来源小类',
    dataIndex: 'caseSourceStr',
    width: 120,
    fixed: 'left'
  }, {
    title: '工单编号',
    dataIndex: 'taskNo',
    width: 200,
    fixed: 'left'
  }].concat(_toConsumableArray(orderType ? [] : [{
    title: '工单类型',
    dataIndex: 'classTypeStr',
    width: 80
  }]), [{
    title: '工单类别',
    dataIndex: 'eventAndComponentManageName',
    width: 150
  }, {
    title: '工单名称',
    dataIndex: 'taskName',
    width: 200
  }, {
    title: '工单性质',
    dataIndex: 'urgencyLevel',
    width: 80,
    render: function render(text) {
      var _紧急$一般$无需紧张$3$4$text, _紧急$一般$无需紧张$3$;
      return /*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: (_紧急$一般$无需紧张$3$4$text = (_紧急$一般$无需紧张$3$ = {
            紧急: '#FF4D4F',
            // 紧急
            一般: '#1899FF',
            // 一般
            无需紧张: '#FFB84D',
            // 无需紧张
            3: '#18d2ff',
            // 紧急
            4: '#8E989F' // 紧急
          }) === null || _紧急$一般$无需紧张$3$ === void 0 ? void 0 : _紧急$一般$无需紧张$3$[text]) !== null && _紧急$一般$无需紧张$3$4$text !== void 0 ? _紧急$一般$无需紧张$3$4$text : '#0a0a0a'
        }
      }, text);
    }
  }, {
    title: '流转时间',
    dataIndex: 'caseTime',
    width: 160,
    sortType: 'time'
  }, {
    title: '办理截止时间',
    dataIndex: 'finishLimitTime',
    width: 160,
    sortType: 'time'
  }, {
    title: '办理状态',
    dataIndex: 'statusStr',
    width: 100
  }, {
    title: '时限',
    dataIndex: 'remainingTimeStatus',
    width: 60,
    render: function render(text, record) {
      return renderTimeLimit(text, record);
    }
  }]);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: _index["default"].myTab
  }, /*#__PURE__*/_react["default"].createElement(_tabs["default"], {
    destroyInactiveTabPane: true,
    onChange: function onChange(e) {
      setActiveKey(e);
    }
  }, /*#__PURE__*/_react["default"].createElement(TabPane, {
    tab: '月报',
    key: 'month'
  }, /*#__PURE__*/_react["default"].createElement(_PublicTemple["default"], pageConfig)), /*#__PURE__*/_react["default"].createElement(TabPane, {
    tab: '年报',
    key: 'year'
  }, /*#__PURE__*/_react["default"].createElement(_PublicTemple["default"], pageConfig))), visible && /*#__PURE__*/_react["default"].createElement(_MyModal["default"], {
    width: 1096,
    visible: visible,
    title: "\u67E5\u770B",
    onCancel: function onCancel() {
      setVisible(false);
      setDataSource([]);
    },
    footer: null,
    style: {
      minHeight: '670px'
    }
  }, /*#__PURE__*/_react["default"].createElement(_Table["default"], {
    columns: columns,
    indexFixed: "left",
    dataSource: dataSource,
    loading: loading
  })));
}
//# sourceMappingURL=index.js.map
