"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _tab = _interopRequireDefault(require("@alifd/next/lib/tab"));
var _message = _interopRequireDefault(require("@alifd/next/lib/message"));
var _numberPicker = _interopRequireDefault(require("@alifd/next/lib/number-picker"));
var _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
var _icon = _interopRequireDefault(require("@alifd/next/lib/icon"));
var _button = _interopRequireDefault(require("@alifd/next/lib/button"));
var _dialog = _interopRequireDefault(require("@alifd/next/lib/dialog"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _grid = _interopRequireDefault(require("@alifd/next/lib/grid"));
var _radio = _interopRequireDefault(require("@alifd/next/lib/radio"));
var _react = _interopRequireWildcard(require("react"));
require("./index.less");
var _boxSlotComponent = _interopRequireDefault(require("../_components/boxSlotComponent"));
var _locale = require("../../../src/locale");
var _type = require("./type");
var _commonFn = require("./commonFn");
var _type2 = require("../../../src/utils/type");
var _lodash = require("lodash");
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; }
var RadioGroup = _radio["default"].Group;
var Row = _grid["default"].Row,
  Col = _grid["default"].Col;
var CGroupManagerSetter = function CGroupManagerSetter(props) {
  var value = props.value,
    onChange = props.onChange;
  var dc;
  var _useState = (0, _react.useState)(value || []),
    groupList = _useState[0],
    setGroupList = _useState[1];
  var _useState2 = (0, _react.useState)(),
    groupItem = _useState2[0],
    setGroupItem = _useState2[1];
  var _useState3 = (0, _react.useState)({
      visible: false,
      type: 'add',
      title: (0, _locale.t)('page.add')
    }),
    dialogConfig = _useState3[0],
    setDialogConfig = _useState3[1];
  (0, _react.useEffect)(function () {
    onChange(groupList);
  }, [groupList]);
  var openAddDialog = function openAddDialog() {
    setDialogConfig({
      visible: true,
      type: 'add',
      title: (0, _locale.t)('page.add')
    });
    var newGroup = (0, _commonFn.createNewGroupItem)();
    setGroupItem(newGroup);
  };
  var removeGroup = function removeGroup(groupId) {
    var _dc;
    setGroupList(groupList.filter(function (item) {
      return item.groupId !== groupId;
    }));
    (_dc = dc) === null || _dc === void 0 ? void 0 : _dc.hide();
  };
  var saveGroupData = function saveGroupData() {
    var newGroupList = groupList || [];
    var nG = [].concat(newGroupList);
    if (groupItem) {
      if (dialogConfig.type === 'add') {
        nG.push(groupItem);
      } else {
        nG = nG.map(function (item) {
          if (item.groupId === groupItem.groupId) {
            return groupItem;
          }
          return item;
        });
      }
      setGroupList(nG);
    }
    closeDialog();
  };
  var closeDialog = function closeDialog() {
    setDialogConfig((0, _extends2["default"])({}, dialogConfig, {
      visible: false
    }));
  };
  var onGroupItemChange = function onGroupItemChange(v) {
    setGroupItem(v);
  };
  var alterGroupItem = function alterGroupItem(item) {
    setDialogConfig({
      visible: true,
      type: 'alter',
      title: (0, _locale.t)('page.alter')
    });
    setGroupItem((0, _lodash.cloneDeep)(item));
  };
  function removeConfirm(groupId) {
    dc = _dialog["default"].confirm({
      v2: true,
      title: (0, _locale.t)("page.removeTip"),
      content: (0, _locale.t)("page.removeTipTitle"),
      footer: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_button["default"], {
        onClick: function onClick() {
          removeGroup(groupId);
        },
        type: "primary"
      }, (0, _locale.t)('setter.ok')), /*#__PURE__*/_react["default"].createElement(_button["default"], {
        style: {
          marginLeft: '10px'
        },
        onClick: function onClick() {
          var _dc2;
          (_dc2 = dc) === null || _dc2 === void 0 ? void 0 : _dc2.hide();
        }
      }, (0, _locale.t)('setter.cancel')))
    });
  }
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "cGroupManager"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "group-header"
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
    type: "primary",
    onClick: openAddDialog
  }, (0, _locale.t)("page.add"))), groupList.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
    className: "group-body"
  }, groupList.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "group-body-item",
      style: {
        cursor: 'pointer'
      },
      onClick: function onClick() {
        alterGroupItem(item);
      }
    }, /*#__PURE__*/_react["default"].createElement(Row, null, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "24"
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "group-btn"
    }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
      style: {
        cursor: 'pointer'
      },
      type: "edit",
      onClick: function onClick() {
        alterGroupItem(item);
      }
    }), /*#__PURE__*/_react["default"].createElement(_icon["default"], {
      style: {
        cursor: 'pointer',
        marginLeft: "10px"
      },
      type: "ashbin",
      onClick: function onClick(e) {
        e.stopPropagation();
        removeConfirm(item.groupId);
      }
    })))), /*#__PURE__*/_react["default"].createElement(Row, {
      className: "group-row"
    }, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "4"
    }, " ", /*#__PURE__*/_react["default"].createElement("div", null, " ", (0, _locale.t)("page.groupId"), ":")), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "20"
    }, " ", item.groupId)), /*#__PURE__*/_react["default"].createElement(Row, {
      className: "group-row"
    }, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "4"
    }, " ", /*#__PURE__*/_react["default"].createElement("div", null, " ", (0, _locale.t)("page.groupName"), ":")), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "20"
    }, "  ", /*#__PURE__*/_react["default"].createElement("div", {
      className: "groupName"
    }, item.groupName))), /*#__PURE__*/_react["default"].createElement(Row, {
      className: "group-row"
    }, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "12"
    }, /*#__PURE__*/_react["default"].createElement(Row, null, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "8"
    }, /*#__PURE__*/_react["default"].createElement("div", null, " ", (0, _locale.t)("page.groupCategory"), ":")), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "16"
    }, item.groupCategory === _type.groupCategoryType["default"] ? (0, _locale.t)('page.defaultCategory') : (0, _locale.t)('page.allPurposeCategory')))), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "12"
    }, /*#__PURE__*/_react["default"].createElement(Row, null, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "8"
    }, /*#__PURE__*/_react["default"].createElement("div", null, " ", (0, _locale.t)("page.groupType"), ":")), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "16"
    }, item.groupType === _type.groupClassType.slot ? (0, _locale.t)('page.groupSlot') : (0, _locale.t)('page.groupComponent'))))), /*#__PURE__*/_react["default"].createElement(Row, {
      className: "group-row"
    }, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "12"
    }, /*#__PURE__*/_react["default"].createElement(Row, null, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "8"
    }, " ", /*#__PURE__*/_react["default"].createElement("div", null, "  ", (0, _locale.t)("page.groupMode"), ":")), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "16"
    }, "  ", item.groupMode === _type.groupModeType.single ? (0, _locale.t)('page.single') : (0, _locale.t)('page.schedule')))), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "12"
    }, /*#__PURE__*/_react["default"].createElement(Row, {
      className: "group-row"
    }, /*#__PURE__*/_react["default"].createElement(Col, {
      span: "8"
    }, " ", /*#__PURE__*/_react["default"].createElement("div", null, "  ", (0, _locale.t)("page.groupLength"), ":")), /*#__PURE__*/_react["default"].createElement(Col, {
      span: "16"
    }, item.groupList.length)))));
  })), /*#__PURE__*/_react["default"].createElement(_dialog["default"], {
    className: "CComputed-dialog",
    visible: dialogConfig.visible,
    title: dialogConfig.title,
    footerAlign: "right",
    onClose: closeDialog,
    footer: [/*#__PURE__*/_react["default"].createElement(_button["default"], {
      onClick: saveGroupData,
      type: "primary"
    }, (0, _locale.t)('setter.ok')), /*#__PURE__*/_react["default"].createElement(_button["default"], {
      style: {
        marginLeft: '10px'
      },
      onClick: closeDialog
    }, (0, _locale.t)('setter.cancel'))]
  }, /*#__PURE__*/_react["default"].createElement(GroupItemComponent, {
    groupItem: groupItem,
    onChange: onGroupItemChange
  })));
};
var GroupItemComponent = function GroupItemComponent(props) {
  var groupItem = props.groupItem,
    onChange = props.onChange;
  var _useState4 = (0, _react.useState)(groupItem || (0, _commonFn.createNewGroupItem)()),
    group = _useState4[0],
    setGroup = _useState4[1];
  var _useState5 = (0, _react.useState)([]),
    groupBaseDataSource = _useState5[0],
    setGroupBaseDataSource = _useState5[1];
  var defaultIndexOptions = (0, _react.useMemo)(function () {
    return (0, _commonFn.getDefaultIndexOptions)();
  }, []);
  (0, _react.useEffect)(function () {
    var baseData = (0, _commonFn.getBaseDataSourceBySchema)();
    setGroupBaseDataSource(baseData);
  }, []);
  (0, _react.useEffect)(function () {
    onChange(group);
  }, [group]);
  var groupListChange = function groupListChange(v, index, name) {
    if (group.groupList[index]) {
      // 组件，进度模式，只能有一个被选中
      if (name === 'selected' && group.groupType === _type.groupClassType.component && group.groupMode === _type.groupModeType.schedule) {
        group.groupList = group.groupList.map(function (item) {
          item.selected = false;
          return item;
        });
      }
      // 槽位，进度模式，所有状态中保留最大的选中
      if (name === 'stateList' && group.groupType === _type.groupClassType.slot && group.groupMode === _type.groupModeType.schedule) {
        // 是否有超过一个以上的选中状态
        var selectList = [];
        var maxGroupIndex = 0;
        group.groupList.forEach(function (item) {
          var selectState = item.stateList.find(function (stateItem) {
            return stateItem.selected;
          });
          if (selectState) {
            selectList.push(item.groupIndex);
            maxGroupIndex = item.groupIndex;
          }
        });
        if (selectList.length > 1) {
          group.groupList = group.groupList.map(function (item) {
            if (item.groupIndex !== maxGroupIndex) {
              item.stateList = item.stateList.map(function (stateItem) {
                stateItem.selected = false;
                return stateItem;
              });
            }
            return item;
          });
        }
      }
      var _groupItem = group.groupList[index];
      _groupItem[name] = v;
    }
    setGroup((0, _extends2["default"])({}, group));
  };
  var groupIndexChange = function groupIndexChange(v, index, type) {
    if (type === _type.groupCategoryType.allPurpose) {
      var list = (0, _commonFn.getStateListByGroupIndex)(v);
      groupListChange(list, index, 'stateList');
    }
    groupListChange(v, index, 'groupIndex');
  };
  var groupModeChange = function groupModeChange(e) {
    var newData = (0, _extends2["default"])({}, group, {
      groupMode: e
    });
    // 由于进度模式，组件某一个瞬间只能有一个选中
    if (newData.groupType === _type.groupClassType.component && e === _type.groupModeType.schedule && newData.groupList.length > 1) {
      // 判断是否有2个以上的选中
      var selectedCount = 0;
      for (var i = 0; i < newData.groupList.length; i++) {
        if (newData.groupList[i].selected) {
          selectedCount++;
          if (selectedCount >= 2) {
            break;
          }
        }
      }
      if (selectedCount >= 2) {
        newData.groupList = newData.groupList.map(function (item) {
          item.selected = false;
          return item;
        });
      }
    }
    setGroup(newData);
  };
  var addGroupListItem = function addGroupListItem() {
    var index = group.groupCategory === _type.groupCategoryType.allPurpose ? 100100 : group.groupList.length + 1;
    group.groupList.push((0, _commonFn.createNewGroupListItem)(index));
    setGroup((0, _extends2["default"])({}, group));
  };
  var removeGroupListItem = function removeGroupListItem(index) {
    group.groupList.splice(index, 1);
    setGroup((0, _extends2["default"])({}, group));
  };
  return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("page.groupId") + ":",
    titleStyle: {
      color: '#fff'
    }
  }, /*#__PURE__*/_react["default"].createElement(_input["default"], {
    style: {
      width: "100%"
    },
    value: group.groupId,
    disabled: true
  })), /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("page.groupName") + ":",
    titleStyle: {
      color: '#fff'
    }
  }, /*#__PURE__*/_react["default"].createElement(_input["default"], {
    style: {
      width: "100%"
    },
    value: group.groupName,
    onChange: function onChange(e) {
      setGroup((0, _extends2["default"])({}, group, {
        groupName: e
      }));
    }
  })), /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("page.groupCategory") + ":",
    titleStyle: {
      color: '#fff'
    }
  }, /*#__PURE__*/_react["default"].createElement(RadioGroup, {
    value: group.groupCategory,
    onChange: function onChange(e) {
      setGroup((0, _extends2["default"])({}, group, {
        groupCategory: e,
        groupList: []
      }));
    }
  }, /*#__PURE__*/_react["default"].createElement(_radio["default"], {
    id: _type.groupCategoryType["default"],
    value: _type.groupCategoryType["default"]
  }, /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: '#fff'
    }
  }, (0, _locale.t)('page.defaultCategory'))), /*#__PURE__*/_react["default"].createElement(_radio["default"], {
    id: _type.groupCategoryType.allPurpose,
    value: _type.groupCategoryType.allPurpose
  }, /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: '#fff'
    }
  }, (0, _locale.t)('page.allPurposeCategory'))))), /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("page.groupType") + ":",
    titleStyle: {
      color: '#fff'
    }
  }, /*#__PURE__*/_react["default"].createElement(RadioGroup, {
    value: group.groupType,
    onChange: function onChange(e) {
      setGroup((0, _extends2["default"])({}, group, {
        groupType: e
      }));
    }
  }, /*#__PURE__*/_react["default"].createElement(_radio["default"], {
    id: _type.groupClassType.component,
    value: _type.groupClassType.component
  }, /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: '#fff'
    }
  }, (0, _locale.t)('page.groupComponent'))), /*#__PURE__*/_react["default"].createElement(_radio["default"], {
    id: _type.groupClassType.slot,
    value: _type.groupClassType.slot
  }, /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: '#fff'
    }
  }, (0, _locale.t)('page.groupSlot'))))), /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("page.groupMode") + ":",
    titleStyle: {
      color: '#fff'
    }
  }, /*#__PURE__*/_react["default"].createElement(RadioGroup, {
    value: group.groupMode,
    onChange: function onChange(e) {
      groupModeChange(e);
    }
  }, /*#__PURE__*/_react["default"].createElement(_radio["default"], {
    id: _type.groupModeType.single,
    value: _type.groupModeType.single
  }, /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: '#fff'
    }
  }, (0, _locale.t)('page.single'))), /*#__PURE__*/_react["default"].createElement(_radio["default"], {
    id: _type.groupModeType.schedule,
    value: _type.groupModeType.schedule
  }, /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: '#fff'
    }
  }, (0, _locale.t)('page.schedule'))))), /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
    title: (0, _locale.t)("page.groupList") + ":",
    titleStyle: {
      color: '#fff'
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "sub_btn"
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
    type: "primary",
    onClick: addGroupListItem
  }, /*#__PURE__*/_react["default"].createElement("span", null, (0, _locale.t)("setter.addData"))))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "groupListBox"
  }, group.groupList.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "groupListItem",
      key: item.groupIndex + "-" + index
    }, /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
      title: (0, _locale.t)("page.groupIndex") + ":",
      titleStyle: {
        color: '#fff'
      }
    }, group.groupCategory === _type.groupCategoryType.allPurpose ? /*#__PURE__*/_react["default"].createElement(_select["default"], {
      placeholder: (0, _locale.t)("setter.selectPlaceHolder"),
      notFoundContent: (0, _locale.t)('setter.notFoundContent'),
      showSearch: true,
      hasClear: true,
      value: item.groupIndex,
      dataSource: defaultIndexOptions,
      onChange: function onChange(v) {
        groupIndexChange(v, index, _type.groupCategoryType.allPurpose);
      }
    }) : /*#__PURE__*/_react["default"].createElement(_numberPicker["default"], {
      style: {
        width: '100%'
      },
      step: 1,
      min: 0,
      hasTrigger: false,
      value: item.groupIndex,
      onChange: function onChange(v) {
        groupIndexChange(v, index, _type.groupCategoryType["default"]);
      }
    })), group.groupType === _type.groupClassType.component && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
      title: (0, _locale.t)("page.groupComponent") + ":",
      titleStyle: {
        color: '#fff'
      }
    }, /*#__PURE__*/_react["default"].createElement(_select["default"], {
      placeholder: (0, _locale.t)("setter.selectPlaceHolder"),
      notFoundContent: (0, _locale.t)('setter.notFoundContent'),
      showSearch: true,
      hasClear: true,
      value: item.code,
      dataSource: groupBaseDataSource,
      onChange: function onChange(v) {
        groupListChange(v, index, 'code');
      }
    }))), group.groupType === _type.groupClassType.slot && /*#__PURE__*/_react["default"].createElement(GroupStateItemComponent, {
      parentGroup: {
        groupIndex: item.groupIndex,
        groupCategory: group.groupCategory,
        groupMode: group.groupMode
      },
      stateList: item.stateList,
      onChange: function onChange(newStateList) {
        groupListChange(newStateList, index, 'stateList');
      }
    }), /*#__PURE__*/_react["default"].createElement("div", {
      className: "CDataBtn"
    }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
      style: {
        cursor: "pointer",
        color: "#fff"
      },
      type: "ashbin",
      onClick: function onClick() {
        removeGroupListItem(index);
      }
    })));
  })));
};
var GroupStateItemComponent = function GroupStateItemComponent(props) {
  var parentGroup = props.parentGroup,
    stateList = props.stateList,
    onChange = props.onChange;
  var _useState6 = (0, _react.useState)(stateList),
    stateData = _useState6[0],
    setSateData = _useState6[1];
  var _useState7 = (0, _react.useState)([]),
    groupColDataSource = _useState7[0],
    setGroupColDataSource = _useState7[1];
  var _useState8 = (0, _react.useState)('0'),
    activeKey = _useState8[0],
    setActiveKey = _useState8[1];
  (0, _react.useEffect)(function () {
    setGroupColDataSource((0, _commonFn.getColDataSourceBySchema)());
    if (stateList.length === 0) {
      var list = [];
      if (parentGroup.groupCategory === _type.groupCategoryType.allPurpose) {
        list = (0, _commonFn.getStateListByGroupIndex)(parentGroup.groupIndex);
      } else {
        var loading = (0, _commonFn.createNewStateListItem)({
          state: _type2.EngineRuleState.loading,
          isDelete: false,
          isIndexDisable: true,
          name: (0, _locale.t)('page.stateDefaultName')
        });
        var succeeded = (0, _commonFn.createNewStateListItem)({
          state: _type2.EngineRuleState.succeeded,
          isIndexDisable: true,
          name: (0, _locale.t)('page.stateSuccessName')
        });
        var failed = (0, _commonFn.createNewStateListItem)({
          state: _type2.EngineRuleState.failed,
          isIndexDisable: true,
          name: (0, _locale.t)('page.stateFailName')
        });
        list = [loading, succeeded, failed];
      }
      setSateData(list);
    }
  }, []);
  (0, _react.useEffect)(function () {
    onChange(stateData);
  }, [stateData]);
  var handleChange = function handleChange(value, index, key) {
    var alterItem = stateData[index];
    if (key === 'state') {
      var isRepeat = stateData.find(function (item) {
        return item.state === value;
      });
      if (isRepeat) {
        _message["default"].show({
          type: "error",
          content: (0, _locale.t)('page.stateError')
        });
        return;
      }
    }
    var newData = stateData;
    // 槽位里面的某一个状态永远只能有一个被选中
    if (key === 'selected') {
      newData = newData.map(function (item) {
        return (0, _extends2["default"])({}, item, {
          selected: false
        });
      });
    }
    alterItem[key] = value;
    newData = newData.map(function (item, i) {
      if (i === index) {
        return alterItem;
      }
      return item;
    });
    setSateData(newData);
    // onChange(newData)
  };
  var addGroupListItem = function addGroupListItem() {
    var stateItem = (0, _commonFn.createNewStateListItem)({
      state: stateData.length
    });
    stateData.push(stateItem);
    var newData = [].concat(stateData);
    setSateData(newData);
  };
  var removeGroupListItem = function removeGroupListItem(index) {
    stateData.splice(index, 1);
    var newData = [].concat(stateData);
    setSateData(newData);
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "groupStateListBox"
  }, parentGroup.groupCategory === _type.groupCategoryType["default"] && /*#__PURE__*/_react["default"].createElement("div", {
    className: "groupStateListBox-header"
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
    type: "primary",
    onClick: addGroupListItem
  }, /*#__PURE__*/_react["default"].createElement("span", null, (0, _locale.t)("page.stateAdd")))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "groupStateListBox-body"
  }, /*#__PURE__*/_react["default"].createElement(_tab["default"], {
    excessMode: "slide",
    shape: "pure",
    activeKey: activeKey,
    onChange: function onChange(v) {
      setActiveKey(v);
    },
    onClose: function onClose(v) {
      if (activeKey === v) {
        setActiveKey("" + (parseInt(v) - 1));
      }
      removeGroupListItem(parseInt(v));
    },
    className: "chaos-element-ui-new"
  }, stateData.map(function (stateItem, stateIndex) {
    return /*#__PURE__*/_react["default"].createElement(_tab["default"].Item, {
      title: stateItem.name,
      key: stateIndex,
      closeable: stateItem.isDelete
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "groupStateItem"
    }, /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
      title: (0, _locale.t)("page.stateName") + ":",
      titleStyle: {
        color: '#fff'
      }
    }, /*#__PURE__*/_react["default"].createElement(_input["default"], {
      disabled: parentGroup.groupCategory === _type.groupCategoryType.allPurpose,
      style: {
        width: "100%"
      },
      value: stateItem.name,
      onChange: function onChange(e) {
        handleChange(e, stateIndex, 'name');
      }
    })), /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
      title: (0, _locale.t)("page.stateIndex") + ":",
      titleStyle: {
        color: '#fff'
      }
    }, /*#__PURE__*/_react["default"].createElement(_numberPicker["default"], {
      disabled: stateItem.isIndexDisable,
      style: {
        width: '100%'
      },
      step: 1,
      min: 0,
      hasTrigger: false,
      value: stateItem.state,
      onChange: function onChange(v) {
        handleChange(v, stateIndex, 'state');
      }
    })), /*#__PURE__*/_react["default"].createElement(_boxSlotComponent["default"], {
      title: (0, _locale.t)("page.groupSlot") + ":",
      titleStyle: {
        color: '#fff'
      }
    }, /*#__PURE__*/_react["default"].createElement(_select["default"], {
      placeholder: (0, _locale.t)("setter.selectPlaceHolder"),
      notFoundContent: (0, _locale.t)('setter.notFoundContent'),
      showSearch: true,
      hasClear: true,
      value: stateItem.code,
      dataSource: groupColDataSource,
      onChange: function onChange(v) {
        handleChange(v, stateIndex, 'code');
      }
    }))));
  }))));
};
var _default = exports["default"] = /*#__PURE__*/function (_Component) {
  function _default() {
    return _Component.apply(this, arguments) || this;
  }
  (0, _inheritsLoose2["default"])(_default, _Component);
  var _proto = _default.prototype;
  _proto.render = function render() {
    return /*#__PURE__*/_react["default"].createElement(CGroupManagerSetter, this.props);
  };
  return _default;
}(_react.Component);