"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireWildcard(require("react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var formateOptions = function formateOptions(options) {
  return options.map(function (item) {
    if (item.children) {
      var children = item.children.map(function (child) {
        return {
          label: child.title || child.label || '-',
          value: child.value,
          disabled: child.disabled || false
        };
      });
      return {
        label: item.title || item.label || '-',
        children: children
      };
    } else {
      return {
        label: item.title || item.label || '-',
        value: item.value,
        disabled: item.disabled || false
      };
    }
  });
};
var SelectCopy = /*#__PURE__*/function (_PureComponent) {
  (0, _inheritsLoose2["default"])(SelectCopy, _PureComponent);
  function SelectCopy() {
    var _this;
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _PureComponent.call.apply(_PureComponent, [this].concat(args)) || this;
    _this.state = {
      // eslint-disable-next-line react/no-unused-state
      setterValue: null
    };
    return _this;
  }
  var _proto = SelectCopy.prototype;
  _proto.render = function render() {
    var _this2 = this;
    var _this$props = this.props,
      options = _this$props.options,
      _onChange = _this$props.onChange,
      mode = _this$props.mode,
      value = _this$props.value,
      field = _this$props.field;
    var bindFunction = function bindFunction(val) {
      var propsField = field.parent;
      // 获取同级其他属性showJump的值
      var otherValue = propsField.getPropValue('chooseImg');
      console.log('99999', otherValue);
      // console.log('默认不需要，只是防止git提交检测', this.state.setterValue)
      console.log('8888', val);
      if (val === 1) {
        propsField.setPropValue('chooseImg', {
          src1: '//img.maimairen.com/low-code/components/slot001/triger.png',
          src2: '//img.maimairen.com/low-code/components/slot001/panel1.png',
          tip: 1
        });
      } else if (val === 2) {
        propsField.setPropValue('chooseImg', {
          src1: '//img.maimairen.com/low-code/components/slot-machine/triger03.png',
          src2: '',
          tip: 2
        });
      } else if (val === 3) {
        propsField.setPropValue('chooseImg', {
          src1: '//img.maimairen.com/low-code/components/SlotMachine/tiger.png',
          src2: '//img.maimairen.com/low-code/components/slot-machine/panel02.png',
          tip: 3
        });
      } else if (val === 4) {
        propsField.setPropValue('chooseImg', {
          src1: '//img.maimairen.com/low-code/components/slot-machine/purpleBlink.gif',
          src2: '//img.maimairen.com/low-code/components/slot-machine/panel02.png',
          tip: 4
        });
      } else if (val === 5) {
        propsField.setPropValue('chooseImg', {
          src1: '//img.maimairen.com/low-code/components/slot-machine/buleTriger.png',
          src2: '',
          tip: 5
        });
      }
      // // set同级其他属性showJump的值
      // propsField.setPropValue('showJump', false);
    };
    // const bindFunction = () => {
    //     event.emit('changeChildProp', field.name, output);
    // }
    // const output = () => {
    //     console.log("输出")
    // }
    return /*#__PURE__*/_react["default"].createElement(_select["default"], {
      autoWidth: false,
      size: "small",
      value: value,
      dataSource: formateOptions(options),
      mode: mode,
      onChange: function onChange(val) {
        _this2.forceUpdate();
        bindFunction(val);
        _onChange && _onChange(val);
      },
      style: {
        width: '100%'
      }
    });
  };
  return SelectCopy;
}(_react.PureComponent);
exports["default"] = SelectCopy;
SelectCopy.defaultProps = {
  placeholder: '请选择',
  options: [{
    label: '-',
    value: ''
  }],
  defaultValue: null,
  onChange: function onChange() {
    return undefined;
  }
};
SelectCopy.displayName = 'SelectCopy';