"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 _lodash = _interopRequireDefault(require("lodash"));
var _FormModal = _interopRequireDefault(require("../../../../../FormModal"));
var _serviceConfig = _interopRequireDefault(require("../../../../../../_mapUtil/serviceConfig"));
var _config = _interopRequireDefault(require("../../../../../../_mapUtil/config"));
var _PlusOutlined = _interopRequireDefault(require("@ant-design/icons/PlusOutlined"));
var _message = _interopRequireDefault(require("antd/lib/message"));
var _button = _interopRequireDefault(require("antd/lib/button"));
var _config2 = _interopRequireDefault(require("../config"));
var _config3 = _interopRequireDefault(require("../../../../Components/config"));
var _service = _interopRequireDefault(require("./service"));
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 _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 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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
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; }
var getAddModalValue = _config3["default"].getAddModalValue,
  getManageType = _config3["default"].getManageType;
var getPeopleListByDispose = _serviceConfig["default"].getPeopleListByDispose,
  getUserToPhone = _serviceConfig["default"].getUserToPhone;
var getTreeCheckInfo = _config2["default"].getTreeCheckInfo,
  clearFormData = _config2["default"].clearFormData;
var getOrganizationId = _service["default"].getOrganizationId,
  getUnitData = _service["default"].getUnitData;
var DeptFormItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
  var _props$modalVal = props.modalVal,
    modalVal = _props$modalVal === void 0 ? {} : _props$modalVal,
    type = props.type,
    modalType = props.modalType;
  var myForm = (0, _react.useRef)();
  var _useState = (0, _react.useState)([]),
    _useState2 = _slicedToArray(_useState, 2),
    orgData = _useState2[0],
    setOrgData = _useState2[1]; // 部门数据
  var _useState3 = (0, _react.useState)({}),
    _useState4 = _slicedToArray(_useState3, 2),
    peopleData = _useState4[0],
    setPeopleData = _useState4[1]; // 责任人
  var _useState5 = (0, _react.useState)({}),
    _useState6 = _slicedToArray(_useState5, 2),
    otherFormItems = _useState6[0],
    setOtherFormItems = _useState6[1];
  var _useState7 = (0, _react.useState)([]),
    _useState8 = _slicedToArray(_useState7, 2),
    peopleOption = _useState8[0],
    setPeopleOption = _useState8[1]; // 所有责任人下拉选数据（用于二次办理回显）
  var _useState9 = (0, _react.useState)({}),
    _useState10 = _slicedToArray(_useState9, 2),
    deptFormData = _useState10[0],
    setDeptFormData = _useState10[1];
  var _useState11 = (0, _react.useState)(1),
    _useState12 = _slicedToArray(_useState11, 2),
    currentIndex = _useState12[0],
    setCurrentIndex = _useState12[1];
  (0, _react.useEffect)(function () {
    // 获取办理公司或者遍历部门下拉选数据----只针对水务集团
    getOrganizationId(function (data) {
      if (data !== null && data !== void 0 && data.id) {
        var params = new FormData();
        params.append('departmentId', data === null || data === void 0 ? void 0 : data.id);
        var depType = getManageType({
          modalType: modalType
        });
        getUnitData({
          params: params,
          depType: depType,
          filterId: modalVal === null || modalVal === void 0 ? void 0 : modalVal.companyId
        }, function (list) {
          setOrgData(list);
          handleDeptFormShow(list);
        });
      }
    });
  }, []);

  // 表单回显操作
  var handleDeptFormShow = function handleDeptFormShow(list) {
    var _modalVal$deptOrgList, _modalVal$companyList;
    if (['OrderCheck', 'InfoOrderCheck', 'OrderCheckBack'].includes(modalType)) {
      // 审核不通过时进行的回显操作
      // 回显
      var keys = modalType === 'InfoOrderCheck' ? 'companyId' : 'deptOrgId';
      disposeDeptIdShow({
        index: 0,
        keys: keys,
        formValues: modalVal,
        list: list
      });
    } else if ((modalVal === null || modalVal === void 0 ? void 0 : modalVal.lastStatus) === 7 && modalVal !== null && modalVal !== void 0 && (_modalVal$deptOrgList = modalVal.deptOrgList) !== null && _modalVal$deptOrgList !== void 0 && _modalVal$deptOrgList.length) {
      // 重新转派操作回显
      var deptOrgList = modalVal === null || modalVal === void 0 ? void 0 : modalVal.deptOrgList;
      getOrderManageForm({
        disposeDeptList: deptOrgList,
        list: list
      });
    } else if (['Payout', 'OrderTwoManage'].includes(modalType) && modalVal !== null && modalVal !== void 0 && (_modalVal$companyList = modalVal.companyList) !== null && _modalVal$companyList !== void 0 && _modalVal$companyList.length) {
      // 重新派发或者再次办理
      var _deptOrgList = modalVal === null || modalVal === void 0 ? void 0 : modalVal.companyList;
      getOrderManageForm({
        disposeDeptList: _deptOrgList,
        list: list
      });
    }
  };

  // 办理部门、单位回显
  var disposeDeptIdShow = function disposeDeptIdShow(_ref) {
    var _myForm$current;
    var _ref$index = _ref.index,
      index = _ref$index === void 0 ? 0 : _ref$index,
      keys = _ref.keys,
      _ref$formValues = _ref.formValues,
      formValues = _ref$formValues === void 0 ? {} : _ref$formValues,
      _ref$list = _ref.list,
      list = _ref$list === void 0 ? [] : _ref$list;
    (myForm === null || myForm === void 0 || (_myForm$current = myForm.current) === null || _myForm$current === void 0 || (_myForm$current = _myForm$current.form) === null || _myForm$current === void 0 ? void 0 : _myForm$current.setFieldsValue) && myForm.current.form.setFieldsValue(_defineProperty({}, "disposeDeptId_".concat(index), formValues === null || formValues === void 0 ? void 0 : formValues[keys]));
    if (formValues !== null && formValues !== void 0 && formValues[keys]) {
      handleDisposeDepShow({
        value: formValues === null || formValues === void 0 ? void 0 : formValues[keys],
        status: index,
        _orgData: list
      });
    }
  };

  // 获取办理表单内容
  var getOrderManageForm = function getOrderManageForm(_ref2) {
    var _ref2$disposeDeptList = _ref2.disposeDeptList,
      disposeDeptList = _ref2$disposeDeptList === void 0 ? [] : _ref2$disposeDeptList,
      list = _ref2.list;
    var manageType = getManageType({
      modalType: modalType
    });
    var otherItems = {},
      formData = {},
      _disposeDeptList = [];
    (disposeDeptList === null || disposeDeptList === void 0 ? void 0 : disposeDeptList.length) && disposeDeptList.map( /*#__PURE__*/function () {
      var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(item, index) {
        var key;
        return _regeneratorRuntime().wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              if (index !== 0) {
                otherItems[index] = manageType === 'gs' ? getUnititems(index, list) : getDeptitems(index, list);
                _disposeDeptList.push(item);
              } else if (item !== null && item !== void 0 && item.disposeDeptId) {
                handleDisposeDepShow({
                  value: item === null || item === void 0 ? void 0 : item.disposeDeptId,
                  status: index,
                  _orgData: list
                });
              }
              for (key in item) {
                formData["".concat(key, "_").concat(index)] = item === null || item === void 0 ? void 0 : item[key];
              }
            case 2:
            case "end":
              return _context.stop();
          }
        }, _callee);
      }));
      return function (_x, _x2) {
        return _ref3.apply(this, arguments);
      };
    }());
    setOtherFormItems(otherItems);
    setDeptFormData(formData);
    deptFormDataShow(formData); // 部门信息回显
    getPeopleDataShow(otherItems, disposeDeptList, list);
  };
  var getPeopleDataShow = function getPeopleDataShow(otherItems, disposeDeptList, list) {
    disposeDeptList.map(function (item, index) {
      if (index !== 0 && item !== null && item !== void 0 && item.disposeDeptId) {
        handleDisposeDepShow({
          value: item === null || item === void 0 ? void 0 : item.disposeDeptId,
          status: index,
          _orgData: list,
          changeItme: true,
          otherItems: otherItems
        });
      }
    });
  };

  // 获取办理负责人数据参数
  var getDisposePeopleParams = function getDisposePeopleParams(value) {
    var _orgData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
    var peopleParams = getTreeCheckInfo(_orgData, value) || {};
    var params = {};
    if ((peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.nodeType) === 'department') {
      params = {
        departmentId: peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.value
      };
    } else if ((peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.nodeType) === 'org') {
      var _peopleParams$attribu;
      params = {
        departmentId: peopleParams === null || peopleParams === void 0 || (_peopleParams$attribu = peopleParams.attributes) === null || _peopleParams$attribu === void 0 ? void 0 : _peopleParams$attribu.departmentId,
        orgId: peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.value
      };
    }
    return params;
  };

  // 审核不通过回显办理信息--获取对应的负责分数据
  var handleDisposeDepShow = function handleDisposeDepShow(_ref4) {
    var value = _ref4.value,
      status = _ref4.status,
      _ref4$_orgData = _ref4._orgData,
      _orgData = _ref4$_orgData === void 0 ? [] : _ref4$_orgData,
      changeItme = _ref4.changeItme,
      _ref4$otherItems = _ref4.otherItems,
      otherItems = _ref4$otherItems === void 0 ? {} : _ref4$otherItems;
    var params = getDisposePeopleParams(value, _orgData);
    getPeopleListByDispose(_objectSpread({}, params), function (data) {
      var list = _objectSpread(_objectSpread({}, peopleData), {}, _defineProperty({}, status, data));
      if (changeItme) {
        changeOtherFormItems(data, status, otherItems);
      }
      setPeopleData(list);
    });
  };

  // 获取部门下的责任人---办理部门下拉选修改
  var handleDisposeDep = function handleDisposeDep(value, status, changeItme) {
    var peopleParams = getTreeCheckInfo(orgData, value) || {};
    var params = {};
    if ((peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.nodeType) === 'department') {
      params = {
        departmentId: peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.value
      };
    } else if ((peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.nodeType) === 'org') {
      var _peopleParams$attribu2;
      params = {
        departmentId: peopleParams === null || peopleParams === void 0 || (_peopleParams$attribu2 = peopleParams.attributes) === null || _peopleParams$attribu2 === void 0 ? void 0 : _peopleParams$attribu2.departmentId,
        orgId: peopleParams === null || peopleParams === void 0 ? void 0 : peopleParams.value
      };
    }
    clearFormData(myForm, _defineProperty(_defineProperty({}, "disposeDeptDutyMan_".concat(status), undefined), "phone_".concat(status), undefined));
    getPeopleListByDispose(_objectSpread({}, params), function (data) {
      var list = _objectSpread(_objectSpread({}, peopleData), {}, _defineProperty({}, status, data));
      if (changeItme) {
        changeOtherFormItems(data, status);
      }
      setPeopleData(list);
    });
  };

  // 新增部门更新负责人下拉选
  var changeOtherFormItems = function changeOtherFormItems() {
    var _Object$keys;
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    var status = arguments.length > 1 ? arguments[1] : undefined;
    var otherItems = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
    var _otherFormItems = (_Object$keys = Object.keys(otherItems)) !== null && _Object$keys !== void 0 && _Object$keys.length ? otherItems : otherFormItems;
    var currentItem = _otherFormItems["".concat(status)];
    (currentItem === null || currentItem === void 0 ? void 0 : currentItem.length) && currentItem.map(function (val) {
      var _val$paramName;
      if ((val === null || val === void 0 || (_val$paramName = val.paramName) === null || _val$paramName === void 0 ? void 0 : _val$paramName.indexOf('disposeDeptDutyMan')) !== -1 && val !== null && val !== void 0 && val.itemProps) {
        val.itemProps.options = data;
        val.itemProps.onChange = function (value) {
          handleDisposeDepPeople(data, value, status);
        };
      }
    });
    _otherFormItems["".concat(status)] = _toConsumableArray(currentItem);
    setOtherFormItems(_objectSpread({}, _otherFormItems));
  };

  // 办理部门负责人更改
  var handleDisposeDepPeople = function handleDisposeDepPeople() {
    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    var value = arguments.length > 1 ? arguments[1] : undefined;
    var status = arguments.length > 2 ? arguments[2] : undefined;
    var staffIdItem = options.find(function (val) {
      return (val === null || val === void 0 ? void 0 : val.value) === value;
    }) || {};
    getUserToPhone({
      staffId: staffIdItem === null || staffIdItem === void 0 ? void 0 : staffIdItem.staffId
    }, function (data) {
      var _myForm$current2, _myForm$current3;
      (myForm === null || myForm === void 0 || (_myForm$current2 = myForm.current) === null || _myForm$current2 === void 0 || (_myForm$current2 = _myForm$current2.form) === null || _myForm$current2 === void 0 ? void 0 : _myForm$current2.setFieldsValue) && (myForm === null || myForm === void 0 || (_myForm$current3 = myForm.current) === null || _myForm$current3 === void 0 || (_myForm$current3 = _myForm$current3.form) === null || _myForm$current3 === void 0 ? void 0 : _myForm$current3.setFieldsValue(_defineProperty({}, "phone_".concat(status), data)));
    });
  };

  // 办理部门限制
  var getNewOrgData = function getNewOrgData() {
    var _myForm$current4;
    var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    var _orgData = orgData !== null && orgData !== void 0 && orgData.length ? _lodash["default"].cloneDeep(orgData) : _lodash["default"].cloneDeep(list);
    var formItems = (myForm === null || myForm === void 0 || (_myForm$current4 = myForm.current) === null || _myForm$current4 === void 0 || (_myForm$current4 = _myForm$current4.form) === null || _myForm$current4 === void 0 ? void 0 : _myForm$current4.getFieldsValue) && myForm.current.form.getFieldsValue() || {};
    var deptItems = [];
    for (var key in formItems) {
      if (key.indexOf('disposeDeptId') !== -1) {
        deptItems.push(formItems === null || formItems === void 0 ? void 0 : formItems[key]);
      }
    }
    var renderTree = function renderTree(data) {
      var _data$children;
      if (deptItems.includes(data === null || data === void 0 ? void 0 : data.value)) {
        data.disabled = true;
      }
      if (data !== null && data !== void 0 && (_data$children = data.children) !== null && _data$children !== void 0 && _data$children.length) {
        data.children.map(function (val) {
          renderTree(val);
        });
      }
    };
    _orgData.map(function (item) {
      renderTree(item);
    });
    return _orgData;
  };

  // 办理单位
  var getUnititems = function getUnititems(_currentIndex) {
    var list = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
    var _orgData = getNewOrgData(list);
    return [{
      type: 'treeSelect',
      label: '办理单位',
      paramName: "disposeDeptId_".concat(_currentIndex),
      paramNameStr: "disposeDeptName_".concat(_currentIndex),
      itemProps: {
        disabled: type,
        treeData: _orgData,
        treeDefaultExpandAll: true,
        onChange: function onChange(value) {
          handleDisposeDep(value, _currentIndex, true);
        }
      },
      formItemLayout: {
        rules: [_objectSpread({}, _config["default"].reg.required)]
      }
    }, {
      type: 'select',
      label: '办理单位负责人',
      paramName: "disposeDeptDutyMan_".concat(_currentIndex),
      paramNameStr: "disposeDeptDutyManStr_".concat(_currentIndex),
      itemProps: {
        disabled: type,
        options: peopleOption,
        onChange: function onChange(value) {
          handleDisposeDepPeople([], value, _currentIndex);
        }
      },
      formItemLayout: {
        rules: [_objectSpread({}, _config["default"].reg.required)]
      }
    }, {
      type: 'input',
      label: '联系方式',
      paramName: "phone_".concat(_currentIndex),
      itemProps: {
        disabled: true
      },
      weights: type || ['OrderCheck', 'InfoOrderCheck', 'OrderCheckBack'].includes(modalType) ? 1 : 0.75
    }];
  };

  // 办理部门
  var getDeptitems = function getDeptitems(_currentIndex) {
    var list = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
    var _orgData = getNewOrgData(list);
    return [{
      type: 'treeSelect',
      label: '办理部门',
      paramName: "disposeDeptId_".concat(_currentIndex),
      paramNameStr: "disposeDeptName_".concat(_currentIndex),
      itemProps: {
        disabled: type,
        treeData: _orgData,
        treeDefaultExpandAll: true,
        onChange: function onChange(value) {
          handleDisposeDep(value, _currentIndex, true);
        }
      },
      formItemLayout: {
        rules: [_objectSpread({}, _config["default"].reg.required)]
      }
    }, {
      type: 'select',
      label: '办理部门负责人',
      paramName: "disposeDeptDutyMan_".concat(_currentIndex),
      paramNameStr: "disposeDeptDutyManStr_".concat(_currentIndex),
      itemProps: {
        disabled: type,
        options: peopleOption,
        onChange: function onChange(value) {
          handleDisposeDepPeople([], value, _currentIndex);
        }
      },
      formItemLayout: {
        rules: [_objectSpread({}, _config["default"].reg.required)]
      }
    }, {
      type: 'input',
      label: '联系方式',
      paramName: "phone_".concat(_currentIndex),
      itemProps: {
        disabled: true
      },
      weights: type || ['OrderCheck', 'InfoOrderCheck', 'OrderCheckBack'].includes(modalType) ? 1 : 0.75
    }];
  };

  // 新增处理部门参数
  var onAddDept = function onAddDept() {
    var _myForm$current5;
    var formListValues = (myForm === null || myForm === void 0 || (_myForm$current5 = myForm.current) === null || _myForm$current5 === void 0 || (_myForm$current5 = _myForm$current5.form) === null || _myForm$current5 === void 0 ? void 0 : _myForm$current5.getFieldsValue) && myForm.current.form.getFieldsValue();
    var flag = false;
    for (var key in formListValues) {
      if ((key === null || key === void 0 ? void 0 : key.indexOf('disposeDeptId')) !== -1 && !(formListValues !== null && formListValues !== void 0 && formListValues[key])) {
        flag = true;
      }
    }
    if (flag) {
      return _message["default"].warning('办理相关信息不能为空！');
    } else {
      var _currentIndex = _lodash["default"].cloneDeep(currentIndex);
      var initItems = getFormItems(_currentIndex);
      otherFormItems["".concat(_currentIndex)] = _toConsumableArray(initItems);
      setOtherFormItems(_objectSpread({}, otherFormItems));
      setCurrentIndex(_currentIndex + 1);
    }
  };

  // 获取办理相关字段
  var getFormItems = function getFormItems(_currentIndex) {
    var initItems = getDeptitems(_currentIndex);
    if (['Payout', 'RePayout', 'OrderTwoManage', 'InfoOrderCheck'].includes(modalType)) {
      // 派发、重新派发、信息中心审核不通过,再次办理
      initItems = getUnititems(_currentIndex);
    }
    return initItems;
  };

  // 删除处理部门参数
  var onDeleteDept = function onDeleteDept(status) {
    otherFormItems === null || otherFormItems === void 0 || delete otherFormItems[status];
    peopleData === null || peopleData === void 0 || delete peopleData[status]; // 删除负责人下拉选数据
    setPeopleData(peopleData);
    setOtherFormItems(_objectSpread({}, otherFormItems)); // 删除form表单
  };
  var getOtherFormItems = function getOtherFormItems() {
    var _Object$keys2;
    var newItems = [];
    (_Object$keys2 = Object.keys(otherFormItems)) !== null && _Object$keys2 !== void 0 && _Object$keys2.length ? Object.keys(otherFormItems).map(function (key, index) {
      newItems.push.apply(newItems, _toConsumableArray([].concat(_toConsumableArray(otherFormItems["".concat(key)]), _toConsumableArray(type ? [] : [{
        type: 'blank',
        content: /*#__PURE__*/_react["default"].createElement("div", {
          style: {
            marginTop: '30px'
          },
          onClick: function onClick() {
            return onDeleteDept(key);
          }
        }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
          type: "primary"
        }, "\u5220\u9664")),
        weights: 0.25
      }])) || []));
    }) : [];
    return newItems;
  };
  var getDefaultItems = function getDefaultItems() {
    var items = [{
      type: 'treeSelect',
      label: '办理部门',
      paramName: "disposeDeptId_0",
      paramNameStr: "disposeDeptName_0",
      itemProps: {
        treeData: orgData,
        treeDefaultExpandAll: true,
        onChange: function onChange(value) {
          handleDisposeDep(value, '0');
        },
        disabled: type
      },
      formItemLayout: {
        rules: [_objectSpread({}, _config["default"].reg.required)],
        initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.disposeDeptId_0
      }
    }, {
      type: 'select',
      label: '办理部门负责人',
      paramName: "disposeDeptDutyMan_0",
      paramNameStr: "disposeDeptDutyManStr_0",
      itemProps: {
        options: type ? peopleOption : (peopleData === null || peopleData === void 0 ? void 0 : peopleData['0']) || [],
        onChange: function onChange(value) {
          handleDisposeDepPeople(peopleData === null || peopleData === void 0 ? void 0 : peopleData['0'], value, '0');
        },
        disabled: type
      },
      formItemLayout: {
        rules: [_objectSpread({}, _config["default"].reg.required)],
        initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.disposeDeptDutyMan_0
      }
    }, {
      type: 'input',
      label: '联系方式',
      paramName: "phone_0",
      itemProps: {
        disabled: true
      },
      formItemLayout: {
        initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.phone_0
      },
      weights: type ? 1 : 0.75
    }];
    if (['Payout', 'RePayout', 'OrderTwoManage', 'InfoOrderCheck'].includes(modalType)) {
      // 派发、重新派发、信息中心审核不通过
      items = [{
        type: 'treeSelect',
        label: '办理单位',
        paramName: "disposeDeptId_0",
        paramNameStr: "disposeDeptName_0",
        itemProps: {
          treeData: orgData,
          treeDefaultExpandAll: true,
          onChange: function onChange(value) {
            handleDisposeDep(value, '0');
          },
          disabled: type
        },
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)],
          initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.disposeDeptId_0
        }
      }, {
        type: 'select',
        label: '办理单位负责人',
        paramName: "disposeDeptDutyMan_0",
        paramNameStr: "disposeDeptDutyManStr_0",
        itemProps: {
          options: type ? peopleOption : (peopleData === null || peopleData === void 0 ? void 0 : peopleData['0']) || [],
          onChange: function onChange(value) {
            handleDisposeDepPeople(peopleData === null || peopleData === void 0 ? void 0 : peopleData['0'], value, '0');
          },
          disabled: type
        },
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)],
          initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.disposeDeptDutyMan_0
        }
      }, {
        type: 'input',
        label: '联系方式',
        paramName: "phone_0",
        itemProps: {
          disabled: true
        },
        formItemLayout: {
          initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.phone_0
        },
        weights: type || ['OrderCheck', 'InfoOrderCheck', 'OrderCheckBack'].includes(modalType) ? 1 : 0.75
      }];
    }
    return items;
  };
  var items = [].concat(_toConsumableArray(type ? [{
    type: 'input',
    label: '办理部门',
    paramName: "disposeDeptName_0",
    itemProps: {
      disabled: type
    },
    formItemLayout: {
      rules: [_objectSpread({}, _config["default"].reg.required)],
      initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.disposeDeptName_0
    }
  }, {
    type: 'input',
    label: '办理部门负责人',
    paramName: "disposeDeptDutyManStr_0",
    itemProps: {
      disabled: type
    },
    formItemLayout: {
      rules: [_objectSpread({}, _config["default"].reg.required)],
      initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.disposeDeptDutyManStr_0
    }
  }, {
    type: 'input',
    label: '联系方式',
    paramName: "phone_0",
    itemProps: {
      disabled: true
    },
    formItemLayout: {
      initialValue: deptFormData === null || deptFormData === void 0 ? void 0 : deptFormData.phone_0
    },
    weights: type || ['OrderCheck', 'InfoOrderCheck', 'OrderCheckBack'].includes(modalType) ? 1 : 0.75
  }] : getDefaultItems()), _toConsumableArray(type || ['OrderCheck', 'InfoOrderCheck', 'OrderCheckBack'].includes(modalType) ? [] : [{
    type: 'blank',
    content: /*#__PURE__*/_react["default"].createElement("div", {
      style: {
        marginTop: '30px'
      },
      onClick: onAddDept
    }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
      type: "primary"
    }, /*#__PURE__*/_react["default"].createElement(_PlusOutlined["default"], null), "\u65B0\u589E")),
    weights: 0.25
  }]), _toConsumableArray(getOtherFormItems() || []));

  // 二次办理部门回显
  var deptFormDataShow = function deptFormDataShow() {
    var _myForm$current6;
    var dataItems = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    myForm === null || myForm === void 0 || (_myForm$current6 = myForm.current) === null || _myForm$current6 === void 0 || (_myForm$current6 = _myForm$current6.form) === null || _myForm$current6 === void 0 || _myForm$current6.setFieldsValue(_objectSpread({}, dataItems));
  };

  // 获取表单提交时处理部门信息
  var getDeptForm = function getDeptForm() {
    var _myForm$current7;
    var deptType = getManageType({
      modalType: modalType
    });
    // const status = deptType === 'gs' ? 'companyIds' : 'deptOrgIds';
    var statusList = deptType === 'gs' ? 'companyList' : 'deptOrgList';
    var vals = (myForm === null || myForm === void 0 || (_myForm$current7 = myForm.current) === null || _myForm$current7 === void 0 || (_myForm$current7 = _myForm$current7.form) === null || _myForm$current7 === void 0 ? void 0 : _myForm$current7.getFieldsValue) && myForm.current.form.getFieldsValue() || {};
    var deptFormParams = getAddModalValue({
      formItems: items,
      formValue: vals
    });
    var disposeDeptList = [];
    for (var key in deptFormParams) {
      if (key.indexOf('_') !== -1) {
        var _disposeDeptList2;
        var _key$split = key.split('_'),
          _key$split2 = _slicedToArray(_key$split, 2),
          paramName = _key$split2[0],
          index = _key$split2[1];
        if (!((_disposeDeptList2 = disposeDeptList) !== null && _disposeDeptList2 !== void 0 && _disposeDeptList2[index])) {
          disposeDeptList[index] = {};
        }
        disposeDeptList[index][paramName] = deptFormParams === null || deptFormParams === void 0 ? void 0 : deptFormParams[key];
        deptFormParams === null || deptFormParams === void 0 || delete deptFormParams[key];
      }
    }
    disposeDeptList = disposeDeptList.filter(function (val) {
      return val;
    }) || [];

    // 测试
    // let ids = PublicService.getDataByKey(disposeDeptList, 'disposeDeptId');

    return _defineProperty({}, statusList, disposeDeptList);
  };
  (0, _react.useImperativeHandle)(ref, function () {
    return {
      myForm: myForm,
      getDeptForm: getDeptForm
    };
  });
  return /*#__PURE__*/_react["default"].createElement(_FormModal["default"], {
    column: 3,
    visible: true,
    ref: myForm,
    title: "",
    items: items,
    isShowModal: false,
    footerShow: false,
    formStyle: {
      width: '100%'
    }
  });
});
var _default = exports["default"] = DeptFormItem;
//# sourceMappingURL=DeptFormItem.js.map
