"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 _message = _interopRequireDefault(require("antd/lib/message"));
var _checkbox = _interopRequireDefault(require("antd/lib/checkbox"));
var _index = _interopRequireDefault(require("../../../../FormModal/index.js"));
var _Process = _interopRequireDefault(require("../../../../Process"));
var _RenderEditable = _interopRequireDefault(require("../../Cycle/AddModal/RenderEditable"));
var _PublicService = _interopRequireDefault(require("../../../../../_mapUtil/PublicService.js"));
var _http = _interopRequireDefault(require("../../../../../_util/http"));
var _config = _interopRequireDefault(require("../../../../../_mapUtil/config"));
var _dayjs = _interopRequireDefault(require("dayjs"));
var _config2 = _interopRequireDefault(require("../../config"));
var _moment = _interopRequireDefault(require("moment"));
var _propTypes = _interopRequireDefault(require("prop-types"));
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 _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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; } /**
 * @returns 临时任务新增
 */
var getStaffUserTree = _config2["default"].getStaffUserTree,
  taskDefaultName = _config2["default"].taskDefaultName,
  getUserToPhone = _config2["default"].getUserToPhone,
  getObjectAndForm = _config2["default"].getObjectAndForm,
  getSelectList = _config2["default"].getSelectList;
var time = null; // 任务有效时间
function AddModal(props) {
  var _props$missionType = props.missionType,
    missionType = _props$missionType === void 0 ? '' : _props$missionType,
    _props$modalTitle = props.modalTitle,
    modalTitle = _props$modalTitle === void 0 ? '' : _props$modalTitle,
    _props$titleConfig = props.titleConfig,
    titleConfig = _props$titleConfig === void 0 ? '' : _props$titleConfig,
    _props$processConfig = props.processConfig,
    processConfig = _props$processConfig === void 0 ? [] : _props$processConfig,
    _props$businessList = props.businessList,
    businessList = _props$businessList === void 0 ? [] : _props$businessList,
    submit = props.submit,
    _props$setLoading = props.setLoading,
    setLoading = _props$setLoading === void 0 ? function () {} : _props$setLoading,
    _props$onCancel = props.onCancel,
    onCancel = _props$onCancel === void 0 ? function () {} : _props$onCancel,
    _props$formData = props.formData,
    formData = _props$formData === void 0 ? {} : _props$formData,
    _props$objectCode = props.objectCode,
    objectCode = _props$objectCode === void 0 ? '' : _props$objectCode;
  var editable = (0, _react.useRef)();
  var formModal = (0, _react.useRef)();
  var _useState = (0, _react.useState)('basic'),
    _useState2 = _slicedToArray(_useState, 2),
    activeKey = _useState2[0],
    setActiveKey = _useState2[1]; // 当前tab类型
  var _useState3 = (0, _react.useState)({
      user: false // 巡检人员勾选其他
    }),
    _useState4 = _slicedToArray(_useState3, 2),
    modalInfo = _useState4[0],
    setModalInfo = _useState4[1]; // 存放下拉选联动字段
  var _useState5 = (0, _react.useState)([]),
    _useState6 = _slicedToArray(_useState5, 2),
    staffTree = _useState6[0],
    setStaffTree = _useState6[1]; // 其他人员下拉选数据
  var _useState7 = (0, _react.useState)(false),
    _useState8 = _slicedToArray(_useState7, 2),
    forever = _useState8[0],
    setForever = _useState8[1]; // 任务有效期永久
  var _useState9 = (0, _react.useState)(''),
    _useState10 = _slicedToArray(_useState9, 2),
    objectAndForm = _useState10[0],
    setObjectAndForm = _useState10[1]; // 获取当前业务类型下的对象表单信息
  var _useState11 = (0, _react.useState)(''),
    _useState12 = _slicedToArray(_useState11, 2),
    businessType = _useState12[0],
    getBusinessType = _useState12[1]; // 当前业务类型

  var _useState13 = (0, _react.useState)(true),
    _useState14 = _slicedToArray(_useState13, 2),
    showNext = _useState14[0],
    setShowNext = _useState14[1];
  var _useState15 = (0, _react.useState)({}),
    _useState16 = _slicedToArray(_useState15, 2),
    data = _useState16[0],
    setData = _useState16[1];
  var _useState17 = (0, _react.useState)([]),
    _useState18 = _slicedToArray(_useState17, 2),
    list = _useState18[0],
    setList = _useState18[1];
  var _useState19 = (0, _react.useState)(_toConsumableArray(processConfig)),
    _useState20 = _slicedToArray(_useState19, 2),
    processList = _useState20[0],
    setProcessList = _useState20[1];
  var _useState21 = (0, _react.useState)([]),
    _useState22 = _slicedToArray(_useState21, 2),
    unitList = _useState22[0],
    setUnitList = _useState22[1]; // 所属单位下拉选数据
  (0, _react.useEffect)(function () {
    getStaffTree();
    var businessTypeCode = _PublicService["default"].getQueryString('businessTypeCode');
    if (businessTypeCode) {
      var _businessList$find;
      var id = (_businessList$find = businessList.find(function (item) {
        return item.patrolCode === businessTypeCode;
      })) === null || _businessList$find === void 0 ? void 0 : _businessList$find.id;
      onBusinessChange(id);
      setData({
        businessTypeId: id
      });
    }
  }, []);

  // 获取其他人员下拉数据
  var getStaffTree = function getStaffTree() {
    getStaffUserTree(function (data) {
      setStaffTree(data);
      setUnitList(data);
    });
  };
  (0, _react.useEffect)(function () {
    if (formData.id) {
      initData();
    }
  }, [formData.id]);
  var handleModalInfo = function handleModalInfo(status, value) {
    setModalInfo(_objectSpread(_objectSpread({}, modalInfo), {}, _defineProperty({}, status, value)));
  };

  // 复制操作表单数据初始化
  var initData = function initData() {
    var startTime = formData.startTime,
      endTime = formData.endTime,
      jobModel = formData.jobModel,
      state = formData.state,
      staffList = formData.staffList,
      businessTypeId = formData.businessTypeId,
      code = formData.code,
      name = formData.name,
      triggerTime = formData.triggerTime,
      rate = formData.rate,
      _formData$objectInfos = formData.objectInfos,
      objectInfos = _formData$objectInfos === void 0 ? [] : _formData$objectInfos,
      _formData$files = formData.files,
      files = _formData$files === void 0 ? [] : _formData$files,
      _formData$pics = formData.pics,
      pics = _formData$pics === void 0 ? [] : _formData$pics,
      _formData$copyCount = formData.copyCount,
      copyCount = _formData$copyCount === void 0 ? 0 : _formData$copyCount;
    var staffIds = [];
    if (staffList && staffList.length) {
      staffList.map(function (item) {
        staffIds.push(item.staffId);
      });
      formData.staffIds = staffIds;
      formData.userType = '2';
      setModalInfo(_objectSpread(_objectSpread({}, modalInfo), {}, {
        user: true,
        jobModel: String(jobModel)
      }));
      // onUserChange(staffIds); // 获取联系方式
    } else {
      formData.userType = '1';
    }
    if (modalTitle === '复制') {
      formData.name = "\u526F\u672C-".concat(copyCount + 1).concat(code).concat(name);
    }
    formData.state = String(state);
    formData.jobModel = String(jobModel);
    formData.rate = String(rate);
    if (modalTitle === '复制') {
      // 复制清空有效时间选择
      delete formData.startTime;
      delete formData.endTime;
      delete formData.triggerTime;
    } else {
      // 编辑
      if (startTime && endTime) {
        formData.time = [(0, _dayjs["default"])(startTime), (0, _dayjs["default"])(endTime)];
      } else {
        setForever(true);
      }
      if (triggerTime) {
        formData.triggerTime = (0, _dayjs["default"])(triggerTime);
      }
    }
    if (files && files.length) {
      formData.fileDTOList = getFiles(formData.files);
    }
    if (pics && pics.length) {
      formData.imgDTOList = getFiles(formData.pics);
    }
    getBusinessTypeInfo(businessTypeId, objectInfos);
    setData(formData);
  };
  var getFiles = function getFiles() {
    var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    list.length && list.map(function (item) {
      item.uid = item.id;
      item.url = "".concat(_config["default"].fileViewUrl, "/").concat(item.id, "?openmode=attachment&token=").concat(_PublicService["default"].getToken());
    });
    return list;
  };

  // 获取业务类型相关信息
  var getBusinessTypeInfo = function getBusinessTypeInfo(val, objectInfos) {
    var currentInfo = businessList.find(function (v) {
      return v.value === val;
    }) || {};
    getBusinessType(currentInfo.patrolCode);
    getObjectAndForm({
      businessTypeId: val
    }, function (data) {
      setObjectAndForm(data);
      getTableListInfo(data, objectInfos);
    });
  };

  // 获取作业表单数据
  var getTableListInfo = function getTableListInfo(data, objectInfos) {
    var list = objectInfos;
    list && list.length && list.map(function (item) {
      var _item$jobObject = item.jobObject,
        jobObject = _item$jobObject === void 0 ? [] : _item$jobObject,
        jobObjectTypeId = item.jobObjectTypeId;
      item.key = Date.now();
      item.jobObjectIds = _PublicService["default"].getDataByKey(jobObject, 'id') || [];
      item.jobObjectsSelect = getSelectList(jobObjectTypeId, 'jobObjects', {
        objectAndForm: data,
        name: 'name',
        value: 'id',
        subName: 'code',
        tableData: objectInfos,
        jobObjectTypeId: jobObjectTypeId,
        type: 'jobObjectIds',
        currentList: (item === null || item === void 0 ? void 0 : item.jobObjectIds) || []
      }) || [];
      item.formsSelect = getSelectList(jobObjectTypeId, 'forms', {
        objectAndForm: data,
        name: 'taulukonNimi',
        value: 'id',
        tableData: objectInfos,
        jobObjectTypeId: jobObjectTypeId,
        type: 'formId'
      }) || [];
    });
    setList(list);
  };

  // 切换业务类型
  var onBusinessChange = function onBusinessChange(val) {
    var _formModal$current;
    var currentInfo = businessList.find(function (v) {
      return v.value === val;
    }) || {};
    var defaultName = (taskDefaultName === null || taskDefaultName === void 0 ? void 0 : taskDefaultName[currentInfo.patrolCode]) || undefined;
    formModal === null || formModal === void 0 || (_formModal$current = formModal.current) === null || _formModal$current === void 0 || (_formModal$current = _formModal$current.form) === null || _formModal$current === void 0 || _formModal$current.setFieldsValue({
      name: defaultName
    });
    getBusinessType(currentInfo.patrolCode);
    getObjectAndForm({
      businessTypeId: val
    }, function (data) {
      setObjectAndForm(data);
    });
    setList([]);
  };

  // 巡检人员类型切换
  var onInspectorChange = function onInspectorChange(e) {
    handleModalInfo('user', e.target.value === '2');
  };

  // 其他人员切换---默认带入联系方式
  var onUserChange = function onUserChange(val) {
    getUserToPhone({
      staffId: val
    }, function (phone) {
      var _formModal$current2;
      formModal === null || formModal === void 0 || (_formModal$current2 = formModal.current) === null || _formModal$current2 === void 0 || (_formModal$current2 = _formModal$current2.form) === null || _formModal$current2 === void 0 || _formModal$current2.setFieldsValue({
        phone: phone
      });
    });
  };

  // 作业模式切换
  var handleJobModel = function handleJobModel(val) {
    setModalInfo(_objectSpread(_objectSpread({}, modalInfo), {}, {
      jobModel: val
    }));
  };

  // 存放打卡方式数据
  var handleMethod = function handleMethod(val) {
    setData(_objectSpread(_objectSpread({}, data), {}, {
      method: val
    }));
  };

  // 有效时间勾选永久
  var onForever = function onForever(e) {
    if (e.target.checked) {
      var _formModal$current3;
      formModal === null || formModal === void 0 || (_formModal$current3 = formModal.current) === null || _formModal$current3 === void 0 || (_formModal$current3 = _formModal$current3.form) === null || _formModal$current3 === void 0 || _formModal$current3.setFieldsValue({
        time: [],
        triggerTime: undefined
      });
    }
    setForever(e.target.checked);
  };
  var onTs = function onTs(values) {
    setProcessList([{
      linkName: '基本信息',
      isArrive: '1'
    }, {
      linkName: '巡检对象',
      isArrive: '1'
    }]);
    setActiveKey('config');
    setShowNext(false);
    setData(_objectSpread({}, values));
  };
  var onReturnBack = function onReturnBack() {
    setProcessList([{
      linkName: '基本信息',
      isArrive: '1'
    }, {
      linkName: '巡检对象',
      isArrive: '0'
    }]);
    setActiveKey('basic');
    setShowNext(true);
  };

  // 任务有效时间更改
  var handleTime = function handleTime(value) {
    var _formModal$current4;
    time = value;
    missionType === 'cycle';
    missionType === 'cycle' && (formModal === null || formModal === void 0 || (_formModal$current4 = formModal.current) === null || _formModal$current4 === void 0 || (_formModal$current4 = _formModal$current4.form) === null || _formModal$current4 === void 0 ? void 0 : _formModal$current4.setFieldsValue({
      triggerTime: undefined
    }));
  };

  // 时间不可选日期
  var disabledDate = function disabledDate(current) {
    var _time, _time2;
    var startTime = ((_time = time) === null || _time === void 0 ? void 0 : _time.length) && ((_time2 = time) === null || _time2 === void 0 ? void 0 : _time2[0]);
    if (forever) {
      // 永久下时间限制
      return current < (0, _moment["default"])().subtract(1, 'days');
    } else {
      return current < startTime || current > (0, _moment["default"])(startTime).add(1, 'days');
    }
  };
  var onSave = function onSave(val) {
    var _val$time;
    if (formData.id && modalTitle === '修改') {
      val.id = formData.id;
    }
    if (modalTitle === '复制') {
      val.isCopy = true;
      val.copyId = formData === null || formData === void 0 ? void 0 : formData.id;
    }
    val.fileIds = _PublicService["default"].getDataByKey(val.fileDTOList, 'id') || [];
    val.picIds = _PublicService["default"].getDataByKey(val.imgDTOList, 'id') || [];
    delete val.fileDTOList;
    delete val.imgDTOList;
    // 任务有效时间
    if (val !== null && val !== void 0 && (_val$time = val.time) !== null && _val$time !== void 0 && _val$time.length) {
      if (missionType !== 'temporary') {
        val.startTime = val.time[0].format('YYYY-MM-DD 00:00:00');
        val.endTime = val.time[1].format('YYYY-MM-DD 23:59:59');
      } else {
        val.startTime = val.time[0].format('YYYY-MM-DD HH:mm:ss');
        val.endTime = val.time[1].format('YYYY-MM-DD HH:mm:ss');
      }
    }
    delete val.time;
    // 触发时间
    if (val !== null && val !== void 0 && val.triggerTime) {
      val.triggerTime = val.triggerTime.format('YYYY-MM-DD HH:mm:ss');
    }
    delete val.userType; // 删除巡检人员参数
    var list = editable.current.getData();
    setList(list);
    var objectInfos = [];
    if (list !== null && list !== void 0 && list.length) {
      var errmsg = '';
      list.map(function (item) {
        var formIds = [];
        var jobObjectIds = item.jobObjectIds,
          jobObjectTypeId = item.jobObjectTypeId,
          formId = item.formId,
          customForms = item.customForms;
        if (!jobObjectTypeId) {
          errmsg = '请选择对象小类';
        }
        // if (!(jobObjectIds && jobObjectIds.length)) {
        //   errmsg = '请选择巡检对象';
        // }
        if (!objectCode) {
          errmsg = '请选择巡检对象';
        }
        if (!customForms && !formId) {
          errmsg = '请选择关联表单';
        } else {
          if (customForms && customForms.length) {
            customForms && customForms.length && customForms.map(function (item) {
              formIds.push({
                formId: (item === null || item === void 0 ? void 0 : item.formId) || item
              });
            });
          }
          if (formId && formId.length) {
            formId && formId.length && formId.map(function (item) {
              formIds.push({
                formId: (item === null || item === void 0 ? void 0 : item.formId) || item
              });
            });
          }
        }
        objectInfos.push({
          jobObjectTypeId: jobObjectTypeId,
          jobObjectIds: objectCode ? [objectCode] : [],
          customForms: formIds
        });
      });
      if (errmsg) {
        _message["default"].error(errmsg);
        return;
      }
    } else {
      _message["default"].error('请至少新增一个作业对象！');
      return;
    }
    val.objectInfos = objectInfos;
    val.type = missionType === 'cycle' ? 1 : missionType === 'assign' ? 3 : 2;
    setLoading && setLoading(true);
    _http["default"].post("".concat(_config["default"].publicUrlXCGL, "/api/taskConfig/saveOrUpdate"), {
      body: _objectSpread({}, val),
      headers: {
        ticket: true
      }
    }).then(function (res) {
      if (String(res === null || res === void 0 ? void 0 : res.result) === '0') {
        _message["default"].success((res === null || res === void 0 ? void 0 : res.msg) || '操作成功');
        submit && submit();
        onCancel();
        setData({});
        setActiveKey('basic');
        setList([]);
      } else {
        _message["default"].error((res === null || res === void 0 ? void 0 : res.msg) || '操作失败');
      }
      setLoading && setLoading(false);
    });
  };
  var modalItems = [{
    type: 'vacancy',
    weights: 3,
    content: /*#__PURE__*/_react["default"].createElement(_Process["default"], {
      processList: processList,
      dividerStyle: {
        width: 450
      }
    })
  }, {
    type: 'tabs',
    activeKey: activeKey,
    items: [{
      label: '',
      activeKey: 'basic',
      forceRender: true,
      items: [{
        type: 'select',
        label: '业务类型',
        paramName: 'businessTypeId',
        itemProps: {
          disabled: !!_PublicService["default"].getQueryString('businessTypeCode'),
          onChange: onBusinessChange,
          options: businessList
        },
        weights: 1,
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }, {
        type: 'input',
        label: '任务名称',
        paramName: 'name',
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)].concat(_toConsumableArray(modalTitle === '复制' ? [] : [_objectSpread({}, _config["default"].reg.lengthMax15)]))
        }
      }].concat(_toConsumableArray(missionType === 'assign' ? [
      // 日常任务
      {
        type: 'treeSelect',
        label: '巡检人员',
        paramName: 'staffIds',
        weights: 1,
        itemProps: {
          // onChange: onUserChange,
          treeData: staffTree,
          dropdownMatchSelectWidth: false
        },
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }, {
        type: 'input',
        label: '联系方式',
        paramName: 'phone'
      }] : [{
        type: 'radio',
        label: "\u5DE1\u68C0\u4EBA\u5458",
        paramName: 'userType',
        itemProps: {
          onChange: onInspectorChange,
          options: [{
            label: '排班人员',
            value: '1'
          }, {
            label: '其他',
            value: '2'
          }]
        },
        weights: 0.5,
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }].concat(_toConsumableArray(modalInfo !== null && modalInfo !== void 0 && modalInfo.user ? [{
        type: 'treeSelect',
        label: '其他人员',
        paramName: 'staffIds',
        weights: 0.5,
        itemProps: {
          // onChange: onUserChange,
          multiple: true,
          treeData: staffTree,
          dropdownMatchSelectWidth: false
        },
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }, {
        type: 'input',
        label: '联系方式',
        paramName: 'phone'
      }, {
        type: 'select',
        label: '组织机构',
        paramName: 'orgId',
        itemProps: {
          options: unitList
        },
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }] : []))), [{
        type: 'number',
        label: '巡查偏离范围(m)',
        paramName: 'deviationDistance',
        weights: 1,
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required), _objectSpread({}, _config["default"].reg.interval0_9999)]
        }
      }], _toConsumableArray(businessType === 'DLXC' ? [{
        type: 'number',
        label: '限定速度(m/s)',
        paramName: 'speedLimit',
        weights: 1,
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }] : []), _toConsumableArray(missionType === 'cycle' ? [{
        type: 'number',
        label: '任务周期',
        paramName: 'count',
        weights: 0.5,
        formItemLayout: {
          initialValue: '1',
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }, {
        type: 'select',
        label: '周期单位',
        paramName: 'rate',
        itemProps: {
          options: [{
            label: '小时',
            value: '1'
          }, {
            label: '日',
            value: '2'
          }, {
            label: '周',
            value: '3'
          }, {
            label: '季度',
            value: '4'
          }, {
            label: '月',
            value: '5'
          }, {
            label: '年',
            value: '6'
          }]
        },
        weights: 0.5,
        formItemLayout: {
          initialValue: '2',
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }] : []), [{
        type: 'select',
        label: '作业模式',
        paramName: 'jobModel',
        itemProps: {
          options: [{
            label: '连续作业模式',
            value: '1'
          }, {
            label: '单点打卡模式',
            value: '2'
          }, {
            label: '起始点打卡模式',
            value: '3'
          }],
          onChange: handleJobModel
        },
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }], _toConsumableArray(['2', '3'].includes(modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.jobModel) ? [{
        type: 'select',
        label: '打卡方式',
        paramName: 'method',
        itemProps: {
          options: [{
            label: '定位',
            value: '1'
          }].concat(_toConsumableArray(!['QLXC', 'PFKXC'].includes(businessType) ? [{
            label: '扫码',
            value: '2'
          }] : [])),
          onChange: handleMethod
        },
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        }
      }] : []), [{
        type: 'rangePicker',
        label: '任务有效时间',
        paramName: 'time',
        formItemLayout: forever ? {} : {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        },
        itemProps: {
          showTime: missionType === 'temporary',
          disabled: forever,
          onChange: handleTime
        },
        weights: 0.75
      }, {
        type: 'blank',
        content: /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
          onChange: onForever,
          checked: forever,
          style: {
            marginTop: 36,
            width: 94,
            padding: '0 16px'
          }
        }, "\u6C38\u4E45")
      }], _toConsumableArray(missionType === 'cycle' ? [{
        type: 'datePicker',
        label: '任务触发时间',
        paramName: 'triggerTime',
        formItemLayout: {
          rules: [_objectSpread({}, _config["default"].reg.required)]
        },
        itemProps: {
          showTime: true,
          disabledDate: disabledDate
        },
        weights: 1
      }] : []), [{
        type: 'radio',
        label: '任务启停',
        paramName: 'state',
        formItemLayout: {
          initialValue: '1',
          rules: [_objectSpread({}, _config["default"].reg.required)]
        },
        itemProps: {
          options: [{
            label: '启用',
            value: '1'
          }, {
            label: '禁用',
            value: '0'
          }]
        }
      }, {
        type: 'textArea',
        label: '备注',
        paramName: 'remark',
        weights: 3,
        itemProps: {
          maxLength: 200
        }
      }, {
        type: 'vtxUpload',
        label: '图片',
        paramName: 'imgDTOList',
        formItemLayout: {
          initialValue: (data === null || data === void 0 ? void 0 : data.imgDTOList) || [],
          tooltip: '(限制大小不超过10mb，最多上传4张图片)'
        },
        weights: 3,
        itemProps: {
          maxLength: 4,
          maxSize: 10 * 1024 * 1024,
          accept: '.jpg, .jpeg, .png'
        }
      }, {
        type: 'fileUpload',
        label: '附件',
        paramName: 'fileDTOList',
        fileView: true,
        formItemLayout: {
          initialValue: (data === null || data === void 0 ? void 0 : data.fileDTOList) || []
        },
        itemProps: {
          maxSize: 1024 * 1024 * 1024,
          maxLength: 5,
          // type: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'pdf'],
          type: ['word', 'excel', 'PPT', 'txt', 'pdf'],
          accept: '.word, .excel, .PPT, .txt , .pdf'
        },
        weights: 3
      }])
    }, {
      label: '',
      activeKey: 'config',
      items: [{
        type: 'blank',
        content: /*#__PURE__*/_react["default"].createElement(_RenderEditable["default"], {
          list: list,
          showTooth: false,
          editable: editable,
          objectAndForm: objectAndForm,
          objectCode: objectCode
        })
      }]
    }]
  }];
  return /*#__PURE__*/_react["default"].createElement(_index["default"], _extends({
    ref: formModal,
    width: 1200,
    items: modalItems,
    title: "".concat(titleConfig, ">").concat(modalTitle),
    column: 3,
    footerShow: true,
    size: "middle",
    saveBtn: false,
    TSTitle: "\u4E0B\u4E00\u6B65",
    returnTitle: "\u4E0A\u4E00\u6B65",
    submitTitle: "\u4FDD\u5B58",
    TSBtn: showNext,
    returnBtn: !showNext,
    submitBtn: !showNext,
    onTS: onTs,
    onSubmit: onSave,
    onReturnBack: onReturnBack
  }, props, {
    formData: data
  }));
}
AddModal.propTypes = {
  missionType: _propTypes["default"].string,
  modalTitle: _propTypes["default"].string,
  titleConfig: _propTypes["default"].string,
  processConfig: _propTypes["default"].array,
  businessList: _propTypes["default"].array,
  submit: _propTypes["default"].any,
  setLoading: _propTypes["default"].func,
  onCancel: _propTypes["default"].func,
  formData: _propTypes["default"].object,
  objectCode: _propTypes["default"].string
};
var _default = exports["default"] = AddModal;
//# sourceMappingURL=index.js.map
