"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"] = _default;
var _react = _interopRequireWildcard(require("react"));
var _index = _interopRequireDefault(require("./index.less"));
var _button = _interopRequireDefault(require("antd/lib/button"));
var _spin = _interopRequireDefault(require("antd/lib/spin"));
var _CreateTicket = _interopRequireDefault(require("../ServiceComponents/CreateTicket"));
var _DetailsPage = _interopRequireDefault(require("../ServiceComponents/DetailsPage"));
var _OrderProcess = _interopRequireDefault(require("../ServiceComponents/OrderProcess"));
var _config = _interopRequireDefault(require("../../../../_mapUtil/config"));
var _http = _interopRequireDefault(require("../../../../_util/http"));
var _DetailsPage2 = _interopRequireDefault(require("../InnerComponents/DetailsPage"));
var _CreateTicket2 = _interopRequireDefault(require("../InnerComponents/CreateTicket"));
var _OrderProcess2 = _interopRequireDefault(require("../InnerComponents/OrderProcess"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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 && Object.prototype.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 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 _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 OrderMenu from '../OrderMenu'; // 导航
// 内部工单相关页面
var OrderModal = function OrderModal(props) {
  var modalType = props.modalType,
    goBack = props.goBack,
    modalVal = props.modalVal,
    _props$title = props.title,
    title = _props$title === void 0 ? '工单' : _props$title,
    orderType = props.orderType;
  var _ref = modalVal || {},
    taskName = _ref.taskName,
    statusStr = _ref.statusStr;
  var modalPage = orderType ? {
    CreateTicket: /*#__PURE__*/_react["default"].createElement(_CreateTicket2["default"], props),
    // 创建工单
    Details: /*#__PURE__*/_react["default"].createElement(_DetailsPage2["default"], props) // 工单详情
  } : {
    CreateTicket: /*#__PURE__*/_react["default"].createElement(_CreateTicket["default"], props),
    // 创建工单
    Details: /*#__PURE__*/_react["default"].createElement(_DetailsPage["default"], props),
    // 工单详情
    Import: /*#__PURE__*/_react["default"].createElement(_CreateTicket["default"], props) // 12345导入数据
  };
  var modalTitle = {
    CreateTicket: "\u65B0\u589E".concat(title)
  };
  var getModalTitle = function getModalTitle() {
    var otherModalTitle = "".concat(taskName || "".concat(title, "\u8BE6\u60C5"), " ").concat(statusStr ? "(".concat(statusStr, ")") : '');
    return otherModalTitle;
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: _index["default"].orderHeader
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: _index["default"].title
  }, (modalTitle === null || modalTitle === void 0 ? void 0 : modalTitle[modalType]) || getModalTitle()), /*#__PURE__*/_react["default"].createElement("div", {
    className: _index["default"].back
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
    type: "primary",
    onClick: goBack
  }, "\u8FD4\u56DE"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(_index["default"].orderContent, " ").concat(modalType === 'Details' && _index["default"].detailsOrderContent),
    id: "orderContent"
  }, (modalPage === null || modalPage === void 0 ? void 0 : modalPage[modalType]) || (orderType ? /*#__PURE__*/_react["default"].createElement(_OrderProcess2["default"], props) : /*#__PURE__*/_react["default"].createElement(_OrderProcess["default"], props))));
};
function _default(props) {
  var modalType = props.modalType,
    modalVal = props.modalVal,
    _goBack = props.goBack,
    title = props.title,
    pageType = props.pageType,
    orderType = props.orderType,
    extraParams = props.extraParams;
  var _ref2 = modalVal || {},
    id = _ref2.id,
    caseId = _ref2.caseId,
    caseSource = _ref2.caseSource,
    processInstanceId = _ref2.processInstanceId;
  var _useState = (0, _react.useState)(false),
    _useState2 = _slicedToArray(_useState, 2),
    loading = _useState2[0],
    setLoading = _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),
    formData = _useState6[0],
    setFormData = _useState6[1];
  var _useState7 = (0, _react.useState)({}),
    _useState8 = _slicedToArray(_useState7, 2),
    importData = _useState8[0],
    setImportData = _useState8[1]; // 再次办理导入信息
  var _useState9 = (0, _react.useState)('dx'),
    _useState10 = _slicedToArray(_useState9, 2),
    sortType = _useState10[0],
    setSortType = _useState10[1];
  (0, _react.useEffect)(function () {
    if (id && !['Import', 'CreateTicket'].includes(modalType)) {
      getImportOrderInfo();
      getDetails();
      getOtherDetails();
    } else if (modalType === 'Import') {
      setFormData(modalVal);
      setLoading(false);
      setVisible(true);
    }
  }, [id, sortType]);

  // 流程信息排序
  var clickSort = function clickSort(val) {
    setSortType(val === null || val === void 0 ? void 0 : val.iconUrl);
  };

  // 12345工单再次办理导入信息详情
  var getImportOrderInfo = function getImportOrderInfo() {
    if (caseSource === '01') {
      // 12345工单再次办理
      _http["default"].get("".concat(_config["default"].publicUrlSJGD, "/api/workOrder/listWorkOrderInfo"), {
        body: {
          caseId: caseId || id
        }
      }).then(function (res) {
        var list = [];
        if (String(res === null || res === void 0 ? void 0 : res.result) === '0' && res !== null && res !== void 0 && res.data) {
          list = (res === null || res === void 0 ? void 0 : res.data) || [];
        }
        setImportData(list);
      });
    }
  };

  // 获取详情
  var getDetails = function getDetails() {
    setLoading(true);
    var url = pageType === 'TimeOutCheck' ? '/case/audit/record/get' : '/case/info/get';
    _http["default"].get("".concat(_config["default"].publicUrlZHXT).concat(url), {
      body: _objectSpread(_objectSpread({
        id: id
      }, sortType === 'dx' ? {
        beenAsc: false
      } : {}), pageType === 'TimeOutCheck' ? {} : {
        processInstanceId: processInstanceId
      })
    }).then(function (res) {
      var list = {};
      if (String(res === null || res === void 0 ? void 0 : res.result) === '0' && res !== null && res !== void 0 && res.data) {
        list = (res === null || res === void 0 ? void 0 : res.data) || {};
      }
      setFormData(list);
      setLoading(false);
      setVisible(true);
    });
  };

  // 我们详情用于统计使用
  var getOtherDetails = function getOtherDetails() {
    _http["default"].get("".concat(_config["default"].publicUrlSJGD, "/api/workOrder/get"), {
      body: {
        id: pageType !== 'TimeOutCheck' ? id : caseId
      }
    }).then(function (res) {});
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: _index["default"].workOrderModal
  }, /*#__PURE__*/_react["default"].createElement(_spin["default"], {
    spinning: loading
  }, ['CreateTicket', 'Import'].includes(modalType) ? /*#__PURE__*/_react["default"].createElement(OrderModal, {
    modalType: modalType,
    title: title,
    goBack: function goBack() {
      setFormData({});
      setVisible(false);
      _goBack && _goBack();
    },
    detailsVal: formData,
    pageType: pageType,
    orderType: orderType,
    extraParams: extraParams
  }) : visible ? /*#__PURE__*/_react["default"].createElement(OrderModal, {
    modalType: modalType,
    title: title,
    goBack: function goBack() {
      setFormData({});
      setVisible(false);
      _goBack && _goBack();
    },
    sortClick: clickSort,
    sortType: sortType,
    modalVal: formData,
    pageType: pageType,
    orderType: orderType,
    extraParams: extraParams,
    importData: importData
  }) : null));
}
//# sourceMappingURL=index.js.map
