"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.SELECTFIELDS = exports.SELECTCHANGE = exports.SEARCHTEXT = exports.OPTIONDATASET = exports.MENURESULT = exports.MENUDATASET = exports.FILTERMENUDATASET = exports.CONDITIONSTATUS = exports.CONDITIONDATASET = void 0;

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

var _tslib = require("tslib");

var _react = _interopRequireWildcard(require("react"));

var _mobxReact = require("mobx-react");

var _mobx = require("mobx");

var _uniq = _interopRequireDefault(require("lodash/uniq"));

var _pull = _interopRequireDefault(require("lodash/pull"));

var _noop = _interopRequireDefault(require("lodash/noop"));

var _map = _interopRequireDefault(require("lodash/map"));

var _isObject = _interopRequireDefault(require("lodash/isObject"));

var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));

var _isEqual = _interopRequireDefault(require("lodash/isEqual"));

var _isArray = _interopRequireDefault(require("lodash/isArray"));

var _isFunction = _interopRequireDefault(require("lodash/isFunction"));

var _omit = _interopRequireDefault(require("lodash/omit"));

var _difference = _interopRequireDefault(require("lodash/difference"));

var _pullAllWith = _interopRequireDefault(require("lodash/pullAllWith"));

var _classnames = _interopRequireDefault(require("classnames"));

var _utils = require("../../../../lib/configure/utils");

var _icon = _interopRequireDefault(require("../../../../lib/icon"));

var _enum = require("../../../../lib/trigger/enum");

var _resizeObserver = _interopRequireDefault(require("../../../../lib/_util/resizeObserver"));

var _DataSet = _interopRequireDefault(require("../../data-set/DataSet"));

var _enum2 = require("../../data-set/enum");

var _button = _interopRequireDefault(require("../../button"));

var _dropdown = _interopRequireDefault(require("../../dropdown"));

var _menu = _interopRequireDefault(require("../../menu"));

var _textField = _interopRequireDefault(require("../../text-field"));

var _tooltip = _interopRequireDefault(require("../../tooltip"));

var _enum3 = require("../../button/enum");

var _localeContext = require("../../locale-context");

var _autobind = _interopRequireDefault(require("../../_util/autobind"));

var _isEmpty3 = _interopRequireDefault(require("../../_util/isEmpty"));

var _ComboFieldList = _interopRequireDefault(require("./ComboFieldList"));

var _TableButtons = _interopRequireDefault(require("./TableButtons"));

var _QuickFilterMenu = _interopRequireDefault(require("./combo-quick-filter/QuickFilterMenu"));

var _QuickFilterButton = _interopRequireDefault(require("./combo-quick-filter/QuickFilterButton"));

var _QuickFilterMenuContext = _interopRequireDefault(require("./combo-quick-filter/QuickFilterMenuContext"));

var _QuickFilterDataSet = require("./combo-quick-filter/QuickFilterDataSet");

var _TableContext = _interopRequireDefault(require("../TableContext"));

var _TableDynamicFilterBar = require("./TableDynamicFilterBar");

var _ColumnFilter = _interopRequireDefault(require("./ColumnFilter"));

var CONDITIONSTATUS = '__CONDITIONSTATUS__';
exports.CONDITIONSTATUS = CONDITIONSTATUS;
var SELECTFIELDS = '__SELECTFIELDS__';
exports.SELECTFIELDS = SELECTFIELDS;
var MENUDATASET = '__MENUDATASET__';
exports.MENUDATASET = MENUDATASET;
var CONDITIONDATASET = '__CONDITIONDATASET__';
exports.CONDITIONDATASET = CONDITIONDATASET;
var OPTIONDATASET = '__OPTIONDATASET__';
exports.OPTIONDATASET = OPTIONDATASET;
var FILTERMENUDATASET = '__FILTERMENUDATASET__';
exports.FILTERMENUDATASET = FILTERMENUDATASET;
var MENURESULT = '__MENURESULT__';
exports.MENURESULT = MENURESULT;
var SEARCHTEXT = '__SEARCHTEXT__';
exports.SEARCHTEXT = SEARCHTEXT;
var SELECTCHANGE = '__SELECTCHANGE__';
exports.SELECTCHANGE = SELECTCHANGE;

var TableComboBar = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(TableComboBar, _Component);

  var _super = (0, _createSuper2["default"])(TableComboBar);

  function TableComboBar(props, context) {
    var _this;

    (0, _classCallCheck2["default"])(this, TableComboBar);
    _this = _super.call(this, props, context);
    _this.refDropdown = null;
    _this.refEditors = new Map();
    _this.originalConditionFields = [];

    _this.handleClickOut = function (e) {
      if (_this.refDropdown && !_this.refDropdown.contains(e.target)) {
        _this.fieldSelectHidden = true;
      }
    };

    _this.handleTableHeight = function () {
      var tableStore = _this.context.tableStore;

      if (tableStore) {
        tableStore.node.handleHeightTypeChange(true);
      }
    };

    _this.handleResize = function () {
      var tableStore = _this.context.tableStore;

      if (tableStore) {
        tableStore.node.handleHeightTypeChange();
      }
    };

    _this.setOriginalConditionFields = function (code) {
      var _this$props = _this.props,
          queryDataSet = _this$props.queryDataSet,
          dataSet = _this$props.dataSet;

      if (!code) {
        if (queryDataSet) {
          _this.initConditionFields({
            dataSet: queryDataSet,
            record: queryDataSet.get(0)
          });
        }
      } else {
        _this.originalConditionFields = Array.isArray(code) ? code : [code];
      }

      dataSet.setState(SELECTFIELDS, (0, _toConsumableArray2["default"])(_this.originalConditionFields));
    };
    /**
     * 勾选
     * @param code
     * @param record
     */


    _this.handleSelect = function (code, record) {
      var dataSet = _this.props.dataSet;
      var codes = Array.isArray(code) ? code : [code];
      var selectFields = dataSet.getState(SELECTFIELDS) || [];
      dataSet.setState(SELECTFIELDS, (0, _uniq["default"])([].concat((0, _toConsumableArray2["default"])(selectFields), (0, _toConsumableArray2["default"])(codes))));
      var shouldUpdate = dataSet.getState(SELECTFIELDS).length !== _this.originalConditionFields.length || !!(0, _difference["default"])((0, _mobx.toJS)(dataSet.getState(SELECTFIELDS)), (0, _mobx.toJS)(_this.originalConditionFields)).length;
      var isDirty = record ? record.dirty : false;

      _this.setConditionStatus(shouldUpdate || isDirty ? _enum2.RecordStatus.update : _enum2.RecordStatus.sync);

      dataSet.setState(SELECTCHANGE, shouldUpdate);
    };
    /**
     * 取消勾选
     * @param code
     */


    _this.handleUnSelect = function (code) {
      var _this$props2 = _this.props,
          queryDataSet = _this$props2.queryDataSet,
          dataSet = _this$props2.dataSet;
      var codes = Array.isArray(code) ? code : [code];

      if (queryDataSet) {
        var current = queryDataSet.current;

        if (current) {
          codes.forEach(function (name) {
            return current.set(name, undefined);
          });
        }
      }

      var selectFields = dataSet.getState(SELECTFIELDS) || [];
      dataSet.setState(SELECTFIELDS, _pull["default"].apply(void 0, [(0, _toConsumableArray2["default"])(selectFields)].concat((0, _toConsumableArray2["default"])(codes))));
      var shouldUpdate = dataSet.getState(SELECTFIELDS).length !== _this.originalConditionFields.length || !!(0, _difference["default"])((0, _mobx.toJS)(dataSet.getState(SELECTFIELDS)), (0, _mobx.toJS)(_this.originalConditionFields)).length;

      _this.setConditionStatus(shouldUpdate ? _enum2.RecordStatus.update : _enum2.RecordStatus.sync);

      dataSet.setState(SELECTCHANGE, shouldUpdate);
    };

    (0, _mobx.runInAction)(function () {
      _this.fieldSelectHidden = true;
    });
    return _this;
  }

  (0, _createClass2["default"])(TableComboBar, [{
    key: "prefixCls",
    get: function get() {
      var prefixCls = this.props.prefixCls;
      var _this$context$tableSt = this.context.tableStore.getProPrefixCls,
          getProPrefixCls = _this$context$tableSt === void 0 ? _utils.getProPrefixCls : _this$context$tableSt;
      return getProPrefixCls('table', prefixCls);
    }
  }, {
    key: "queryFields",
    get: function get() {
      var queryFields = this.props.queryFields;
      return queryFields.filter(function (component) {
        if (component.props.hidden) {
          return !component.props.hidden;
        }

        return !component.props.hidden;
      });
    }
  }, {
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this$props3 = this.props,
          queryDataSet = _this$props3.queryDataSet,
          dataSet = _this$props3.dataSet;
      this.processDataSetListener(true);
      document.addEventListener('click', this.handleClickOut);

      if (!dataSet.props.autoQuery) {
        this.handleDataSetQuery({
          dataSet: dataSet
        });
      }

      if (this.originalValue === undefined && queryDataSet && queryDataSet.current) {
        this.initConditionFields({
          dataSet: queryDataSet,
          record: queryDataSet.current
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      document.removeEventListener('click', this.handleClickOut);
      this.processDataSetListener(false);
    }
  }, {
    key: "componentWillReceiveProps",
    value: function componentWillReceiveProps(nextProps) {
      var _this2 = this;

      var dataSet = nextProps.dataSet,
          queryDataSet = nextProps.queryDataSet; // eslint-disable-next-line react/destructuring-assignment

      if (dataSet !== this.props.dataSet) {
        (0, _mobx.runInAction)(function () {
          _this2.fieldSelectHidden = true;
        });
        this.processDataSetListener(false);
        this.processDataSetListener(true, nextProps);

        if (this.originalValue === undefined && queryDataSet && queryDataSet.current) {
          this.initConditionFields({
            dataSet: queryDataSet,
            record: queryDataSet.current
          });
        }
      }
    }
  }, {
    key: "processDataSetListener",
    value: function processDataSetListener(flag, nextProps) {
      var _ref = nextProps || this.props,
          queryDataSet = _ref.queryDataSet,
          dataSet = _ref.dataSet;

      if (queryDataSet) {
        var handler = flag ? queryDataSet.addEventListener : queryDataSet.removeEventListener;
        var dsHandler = flag ? dataSet.addEventListener : dataSet.removeEventListener;
        handler.call(queryDataSet, _enum2.DataSetEvents.validate, this.handleDataSetValidate);
        handler.call(queryDataSet, _enum2.DataSetEvents.update, this.handleDataSetUpdate);
        handler.call(queryDataSet, _enum2.DataSetEvents.create, this.handleDataSetCreate);
        dsHandler.call(dataSet, _enum2.DataSetEvents.query, this.handleDataSetQuery);
      }
    }
  }, {
    key: "handleDataSetQuery",
    value: function () {
      var _handleDataSetQuery = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref2) {
        var dataSet, initSearchId, res, _ref3, conditionList, initQueryData, queryDataSet;

        return _regenerator["default"].wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                dataSet = _ref2.dataSet;
                initSearchId = this.initSearchId;

                if (!(!dataSet.getState(MENURESULT) && this.tableFilterAdapter)) {
                  _context.next = 16;
                  break;
                }

                _context.next = 5;
                return this.initMenuDataSet();

              case 5:
                res = dataSet.getState(MENURESULT);

                if (!(res && res.length)) {
                  _context.next = 16;
                  break;
                }

                _ref3 = initSearchId ? res.find(function (menu) {
                  return menu.searchId === initSearchId;
                }) : res[0], conditionList = _ref3.conditionList;
                initQueryData = {};

                if (!(conditionList && conditionList.length)) {
                  _context.next = 16;
                  break;
                }

                (0, _map["default"])(conditionList, function (condition) {
                  var fieldName = condition.fieldName,
                      value = condition.value;
                  initQueryData[fieldName] = (0, _TableDynamicFilterBar.parseValue)(value);
                });
                queryDataSet = this.props.queryDataSet;

                if (!(queryDataSet && queryDataSet.current && dataSet.props.autoQuery)) {
                  _context.next = 16;
                  break;
                }

                if (!Object.keys(initQueryData).length) {
                  _context.next = 16;
                  break;
                }

                dataSet.query();
                return _context.abrupt("return", false);

              case 16:
              case "end":
                return _context.stop();
            }
          }
        }, _callee, this);
      }));

      function handleDataSetQuery(_x) {
        return _handleDataSetQuery.apply(this, arguments);
      }

      return handleDataSetQuery;
    }()
    /**
     * queryDataSet 查询前校验事件 触发展开动态字段
     * @param dataSet 查询DS
     * @param result
     */

  }, {
    key: "handleDataSetValidate",
    value: function () {
      var _handleDataSetValidate = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref4) {
        var _this3 = this;

        var dataSet, result;
        return _regenerator["default"].wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                dataSet = _ref4.dataSet, result = _ref4.result;
                _context2.next = 3;
                return result;

              case 3:
                if (_context2.sent) {
                  _context2.next = 5;
                  break;
                }

                (0, _mobx.runInAction)(function () {
                  var current = dataSet.current;
                  dataSet.fields.forEach(function (field, key) {
                    if (!field.isValid(current)) {
                      _this3.handleSelect(key);
                    }
                  });
                });

              case 5:
              case "end":
                return _context2.stop();
            }
          }
        }, _callee2);
      }));

      function handleDataSetValidate(_x2) {
        return _handleDataSetValidate.apply(this, arguments);
      }

      return handleDataSetValidate;
    }()
  }, {
    key: "setConditionStatus",
    value: function setConditionStatus(value, orglValue) {
      var dataSet = this.props.dataSet;
      dataSet.setState(CONDITIONSTATUS, value);

      if (value === _enum2.RecordStatus.sync && orglValue) {
        this.originalValue = orglValue;
      }
    }
    /**
     * 筛选条件更新 触发表格查询
     */

  }, {
    key: "handleDataSetUpdate",
    value: function () {
      var _handleDataSetUpdate = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(_ref5) {
        var record, name, oldValue, value, _this$props4, dataSet, queryDataSet, _this$props4$onQuery, onQuery, autoQuery, field, shouldQuery, rangeValue, rangeOldValue, status, hasFocus, _iterator, _step, _step$value, key, _value;

        return _regenerator["default"].wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                record = _ref5.record, name = _ref5.name, oldValue = _ref5.oldValue, value = _ref5.value;
                _this$props4 = this.props, dataSet = _this$props4.dataSet, queryDataSet = _this$props4.queryDataSet, _this$props4$onQuery = _this$props4.onQuery, onQuery = _this$props4$onQuery === void 0 ? _noop["default"] : _this$props4$onQuery, autoQuery = _this$props4.autoQuery;
                field = queryDataSet && queryDataSet.getField(name);
                shouldQuery = true;

                if (field && field.get('range', record)) {
                  rangeValue = value ? (0, _isArray["default"])(value) ? value.join('') : Object.values(value).join('') : '';
                  rangeOldValue = oldValue ? (0, _isArray["default"])(oldValue) ? oldValue.join('') : Object.values(oldValue).join('') : '';
                  shouldQuery = rangeValue !== rangeOldValue;
                }

                status = _enum2.RecordStatus.update;

                if (record) {
                  status = (0, _TableDynamicFilterBar.isEqualDynamicProps)(this.originalValue, (0, _omit["default"])(record.toData(), ['__dirty']), queryDataSet, record, name) ? _enum2.RecordStatus.sync : _enum2.RecordStatus.update;
                }

                this.setConditionStatus(status);

                if (!(autoQuery && shouldQuery)) {
                  _context3.next = 28;
                  break;
                }

                _context3.next = 11;
                return dataSet.modifiedCheck(undefined, dataSet, 'query');

              case 11:
                if (!_context3.sent) {
                  _context3.next = 27;
                  break;
                }

                _context3.t0 = queryDataSet && queryDataSet.current;

                if (!_context3.t0) {
                  _context3.next = 17;
                  break;
                }

                _context3.next = 16;
                return queryDataSet.current.validate();

              case 16:
                _context3.t0 = _context3.sent;

              case 17:
                if (!_context3.t0) {
                  _context3.next = 22;
                  break;
                }

                dataSet.query();
                onQuery();
                _context3.next = 25;
                break;

              case 22:
                hasFocus = false;
                _iterator = (0, _createForOfIteratorHelper2["default"])(this.refEditors.entries());

                try {
                  for (_iterator.s(); !(_step = _iterator.n()).done;) {
                    _step$value = (0, _slicedToArray2["default"])(_step.value, 2), key = _step$value[0], _value = _step$value[1];

                    if (_value && !_value.valid && !hasFocus) {
                      this.refEditors.get(key).focus();
                      hasFocus = true;
                    }
                  }
                } catch (err) {
                  _iterator.e(err);
                } finally {
                  _iterator.f();
                }

              case 25:
                _context3.next = 28;
                break;

              case 27:
                record.init(name, oldValue);

              case 28:
              case "end":
                return _context3.stop();
            }
          }
        }, _callee3, this);
      }));

      function handleDataSetUpdate(_x3) {
        return _handleDataSetUpdate.apply(this, arguments);
      }

      return handleDataSetUpdate;
    }()
    /**
     * queryDS 新建，初始勾选值
     */

  }, {
    key: "handleDataSetCreate",
    value: function handleDataSetCreate() {
      var queryDataSet = this.props.queryDataSet;

      if (queryDataSet) {
        this.initConditionFields({
          dataSet: queryDataSet,
          record: queryDataSet.current
        });
      }

      this.handleTableHeight();
    }
    /**
     * 初始化勾选值、条件字段
     * @param props
     */

  }, {
    key: "initConditionFields",
    value: function initConditionFields(props) {
      var _this4 = this;

      var dataSet = props.dataSet,
          record = props.record;
      var originalValue = record ? (0, _omit["default"])(record.toData(), ['__dirty']) : {};
      var conditionData = Object.entries(originalValue);
      this.originalValue = originalValue;
      this.originalConditionFields = [];
      var fields = dataSet.fields;
      (0, _map["default"])(conditionData, function (data) {
        var name = data[0];

        if (!fields.has(data[0]) && (0, _isObject["default"])(data[1]) && !(0, _isEmpty2["default"])(data[1]) && !(0, _isArray["default"])(data[1])) {
          name = "".concat(data[0], ".").concat(Object.keys(data[1])[0]);
        }

        if ((0, _TableDynamicFilterBar.isSelect)(data) && !(dataSet.getState(SELECTFIELDS) || []).includes(name)) {
          var field = dataSet.getField(name);

          if (!field || !field.get('bind', record)) {
            _this4.originalConditionFields.push(name);

            _this4.handleSelect(name, record);
          }
        }
      });
    }
    /**
     * 初始筛选条数据源状态
     */

  }, {
    key: "initMenuDataSet",
    value: function () {
      var _initMenuDataSet = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
        var _this5 = this;

        var _this$props5, queryDataSet, dataSet, initSearchId, _this$context, tableStore, getConfig, menuDataSet, conditionDataSet, optionDataSet, filterMenuDataSet, status, result, menuRecord, conditionList, customizedColumn, current;

        return _regenerator["default"].wrap(function _callee4$(_context4) {
          while (1) {
            switch (_context4.prev = _context4.next) {
              case 0:
                _this$props5 = this.props, queryDataSet = _this$props5.queryDataSet, dataSet = _this$props5.dataSet;
                initSearchId = this.initSearchId;
                _this$context = this.context, tableStore = _this$context.tableStore, getConfig = _this$context.tableStore.getConfig;

                if (!this.tableFilterAdapter) {
                  _context4.next = 25;
                  break;
                }

                menuDataSet = new _DataSet["default"]((0, _QuickFilterDataSet.QuickFilterDataSet)({
                  queryDataSet: queryDataSet,
                  tableFilterAdapter: this.tableFilterAdapter
                }), {
                  getConfig: getConfig
                });
                conditionDataSet = new _DataSet["default"]((0, _QuickFilterDataSet.ConditionDataSet)(), {
                  getConfig: getConfig
                });
                optionDataSet = new _DataSet["default"]({
                  selection: _enum2.DataSetSelection.single,
                  paging: false,
                  fields: [{
                    name: 'title',
                    type: _enum2.FieldType.string,
                    transformResponse: function transformResponse() {
                      return (0, _localeContext.$l)('Table', 'filter_header_title');
                    },
                    group: true
                  }]
                }, {
                  getConfig: getConfig
                });
                filterMenuDataSet = new _DataSet["default"]({
                  autoCreate: true,
                  fields: [{
                    name: 'filterName',
                    type: _enum2.FieldType.string,
                    textField: 'searchName',
                    valueField: 'searchId',
                    options: optionDataSet,
                    ignore: _enum2.FieldIgnore.always
                  }]
                }, {
                  getConfig: getConfig
                });
                status = _enum2.RecordStatus.update;

                if (queryDataSet && queryDataSet.current) {
                  status = (0, _TableDynamicFilterBar.isEqualDynamicProps)(this.originalValue, (0, _omit["default"])(queryDataSet.current.toData(), ['__dirty']), queryDataSet, queryDataSet.current) ? _enum2.RecordStatus.sync : _enum2.RecordStatus.update;
                } // 初始化状态


                dataSet.setState(CONDITIONDATASET, conditionDataSet);
                dataSet.setState(OPTIONDATASET, optionDataSet);
                dataSet.setState(FILTERMENUDATASET, filterMenuDataSet);
                dataSet.setState(CONDITIONSTATUS, status);
                dataSet.setState(SEARCHTEXT, '');
                _context4.next = 17;
                return menuDataSet.query();

              case 17:
                result = _context4.sent;

                if (optionDataSet) {
                  optionDataSet.loadData(result);
                }

                if (initSearchId) {
                  menuDataSet.locate(menuDataSet.findIndex(function (menu) {
                    return menu.get('searchId').toString() === initSearchId.toString();
                  }));
                } else {
                  menuDataSet.locate(0);
                }

                dataSet.setState(MENURESULT, result);
                dataSet.setState(MENUDATASET, menuDataSet);
                menuRecord = menuDataSet.current;

                if (menuRecord) {
                  conditionList = menuRecord.get('personalFilter') && (0, _TableDynamicFilterBar.parseValue)(menuRecord.get('personalFilter'));
                  conditionDataSet.loadData(conditionList);
                  customizedColumn = menuRecord.get('personalColumn') && (0, _TableDynamicFilterBar.parseValue)(menuRecord.get('personalColumn'));

                  if (tableStore) {
                    (0, _mobx.runInAction)(function () {
                      var newCustomized = {
                        columns: (0, _objectSpread2["default"])({}, customizedColumn)
                      };
                      tableStore.tempCustomized = {
                        columns: {}
                      };
                      tableStore.saveCustomized(newCustomized);
                      tableStore.initColumns();
                    });
                  }
                }

                if (result && result.length) {
                  (0, _mobx.runInAction)(function () {
                    _this5.shouldLocateData = true;
                  });

                  if (queryDataSet && queryDataSet.fields) {
                    this.tempFields = queryDataSet.snapshot().dataSet.fields;
                  }
                } else {
                  current = filterMenuDataSet.current;
                  if (current) current.set('filterName', undefined);
                  (0, _mobx.runInAction)(function () {
                    _this5.shouldLocateData = true;
                  });
                }

              case 25:
                return _context4.abrupt("return", true);

              case 26:
              case "end":
                return _context4.stop();
            }
          }
        }, _callee4, this);
      }));

      function initMenuDataSet() {
        return _initMenuDataSet.apply(this, arguments);
      }

      return initMenuDataSet;
    }()
    /**
     * tableFilterSuffix 预留自定义区域
     */

  }, {
    key: "renderSuffix",
    value: function renderSuffix() {
      var _this$props6 = this.props,
          _this$props6$buttons = _this$props6.buttons,
          buttons = _this$props6$buttons === void 0 ? [] : _this$props6$buttons,
          _this$props6$tableAct = _this$props6.tableActions,
          tableActions = _this$props6$tableAct === void 0 ? [] : _this$props6$tableAct,
          comboFilterBar = _this$props6.comboFilterBar,
          queryDataSet = _this$props6.queryDataSet,
          dataSet = _this$props6.dataSet;
      var prefixCls = this.prefixCls;
      var getConfig = this.context.tableStore.getConfig;
      var tableButtons = buttons.length ? /*#__PURE__*/_react["default"].createElement(_TableButtons["default"], {
        key: "toolbar",
        prefixCls: "".concat(prefixCls, "-combo-filter"),
        buttons: buttons
      }) : null;
      var suffixes = comboFilterBar && comboFilterBar.suffixes || getConfig('tableFilterSuffix');
      var children = [];
      var suffixesDom = null;
      var actions = tableActions.length ? /*#__PURE__*/_react["default"].createElement(_menu["default"], {
        className: "".concat(prefixCls, "-combo-filter-action-menu")
      }, tableActions.map(function (_ref6) {
        var name = _ref6.name,
            onClick = _ref6.onClick,
            disabled = _ref6.disabled,
            style = _ref6.style,
            children = _ref6.children,
            element = _ref6.element;

        if (children && Array.isArray(children)) {
          return /*#__PURE__*/_react["default"].createElement(_menu["default"].SubMenu, {
            title: name,
            style: style
          }, children.map(function (_ref7) {
            var itemName = _ref7.name,
                itemSubClick = _ref7.onClick,
                itemDisabled = _ref7.disabled,
                itemStyle = _ref7.style;
            return /*#__PURE__*/_react["default"].createElement(_menu["default"].Item, {
              key: "".concat(itemName, "-action"),
              onClick: itemSubClick,
              disabled: itemDisabled,
              style: itemStyle
            }, itemName);
          }));
        }

        if (element && /*#__PURE__*/_react["default"].isValidElement(element)) {
          // 完全渲染自定义组件
          return element;
        }

        return /*#__PURE__*/_react["default"].createElement(_menu["default"].Item, {
          key: "".concat(name, "-action"),
          onClick: onClick,
          disabled: disabled,
          style: style
        }, name);
      })) : null;

      var tableActionsDom = actions && /*#__PURE__*/_react["default"].createElement("div", {
        key: "action_menu",
        className: "".concat(prefixCls, "-combo-filter-action")
      }, /*#__PURE__*/_react["default"].createElement(_dropdown["default"], {
        overlay: actions,
        trigger: [_enum.Action.click]
      }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
        className: "".concat(prefixCls, "-combo-filter-action-button"),
        icon: "more_horiz",
        color: _enum3.ButtonColor.secondary
      })));

      if (suffixes && suffixes.length) {
        suffixes.forEach(function (suffix) {
          if (suffix === 'filter') {
            children.push( /*#__PURE__*/_react["default"].createElement(_ColumnFilter["default"], {
              prefixCls: prefixCls,
              key: 'suffix-column-filter'
            }));
          } else if ( /*#__PURE__*/(0, _react.isValidElement)(suffix)) {
            children.push(suffix);
          } else if ((0, _isFunction["default"])(suffix)) {
            children.push(suffix({
              queryDataSet: queryDataSet,
              dataSet: dataSet
            }));
          }
        });
        suffixesDom = /*#__PURE__*/_react["default"].createElement("div", {
          className: "".concat(prefixCls, "-combo-filter-bar-suffix"),
          key: 'suffix-dom'
        }, children);
      }

      if (tableButtons || tableActionsDom || suffixesDom) {
        return [tableButtons, tableActionsDom, suffixesDom];
      }

      return null;
    }
  }, {
    key: "getPrefix",
    value: function getPrefix() {
      var _this$props7 = this.props,
          title = _this$props7.title,
          singleLineMode = _this$props7.singleLineMode;
      var prefixCls = this.prefixCls;

      if (title && !singleLineMode) {
        return /*#__PURE__*/_react["default"].createElement("div", {
          className: "".concat(prefixCls, "-combo-filter-title"),
          key: 'prefix-filter-title'
        }, title);
      }

      return null;
    }
    /**
     * 注入 refEditors
     * @param element
     * @param name
     * @param field
     */

  }, {
    key: "createFields",
    value: function createFields(element, name, field) {
      var _this6 = this;

      var queryFieldsStyle = this.props.queryFieldsStyle;
      var prefixCls = this.prefixCls;
      var styleCss = queryFieldsStyle && queryFieldsStyle[name];
      var fieldWidth;

      if (styleCss) {
        fieldWidth = styleCss.width;
      }

      var props = {
        ref: function ref(node) {
          return _this6.refEditors.set(name, node);
        },
        placeholder: field.get('label'),
        maxTagCount: 2,
        border: true,
        clearButton: true,
        isFlat: !fieldWidth,
        maxTagTextLength: 3
      };

      if (fieldWidth) {
        props = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
          className: "".concat(prefixCls, "-combo-filter-item-overlay"),
          style: {
            width: fieldWidth
          }
        });
      }

      return /*#__PURE__*/(0, _react.cloneElement)(element, props);
    }
    /**
     * 判断查询值是否为空
     * @param value
     */

  }, {
    key: "isEmpty",
    value: function isEmpty(value) {
      return (0, _mobx.isArrayLike)(value) ? !value.length : (0, _isEmpty3["default"])(value);
    }
  }, {
    key: "tableFilterAdapter",
    get: function get() {
      var comboFilterBar = this.props.comboFilterBar;
      return comboFilterBar && comboFilterBar.tableFilterAdapter;
    }
  }, {
    key: "initSearchId",
    get: function get() {
      var comboFilterBar = this.props.comboFilterBar;
      return comboFilterBar && comboFilterBar.searchId;
    }
  }, {
    key: "filterCallback",
    get: function get() {
      var comboFilterBar = this.props.comboFilterBar;
      return comboFilterBar && comboFilterBar.filterCallback;
    }
  }, {
    key: "filterSave",
    get: function get() {
      var comboFilterBar = this.props.comboFilterBar;
      return comboFilterBar && comboFilterBar.filterSave;
    }
  }, {
    key: "filterSaveCallback",
    get: function get() {
      var comboFilterBar = this.props.comboFilterBar;
      return comboFilterBar && comboFilterBar.filterSaveCallback;
    }
  }, {
    key: "filterOptionRenderer",
    get: function get() {
      var comboFilterBar = this.props.comboFilterBar;
      return comboFilterBar && comboFilterBar.filterOptionRenderer;
    }
  }, {
    key: "dynamicLimit",
    value: function dynamicLimit() {
      var _this$props8 = this.props,
          _this$props8$queryFie = _this$props8.queryFieldsLimit,
          queryFieldsLimit = _this$props8$queryFie === void 0 ? 3 : _this$props8$queryFie,
          dataSet = _this$props8.dataSet;
      var conditionList = dataSet.getState(CONDITIONDATASET);
      var menuResult = dataSet.getState(MENURESULT);

      if (menuResult && menuResult.length > 0) {
        if (conditionList) {
          return conditionList.length;
        }
      }

      return queryFieldsLimit;
    }
  }, {
    key: "updateQueryFields",
    value: function updateQueryFields() {
      var dataSet = this.props.dataSet;
      var conditionList = dataSet.getState(CONDITIONDATASET);

      if (conditionList) {
        var result = [];
        var conditionData = conditionList.toData();
        var fields = this.queryFields;
        (0, _map["default"])(conditionData, function (data) {
          var name = data.fieldName;
          var findField = fields.find(function (component) {
            return component.props.name === name;
          });

          if (findField) {
            result.push(findField);
            (0, _pullAllWith["default"])(fields, [findField], _isEqual["default"]);
          }
        });
        return result.concat(fields);
      }

      return this.queryFields;
    }
  }, {
    key: "updateOriginOrderQueryFields",
    value: function updateOriginOrderQueryFields() {
      var dataSet = this.props.dataSet;
      var conditionList = dataSet.getState(CONDITIONDATASET);
      var result = [];
      var cloneFields = this.originOrderQueryFields;

      if (conditionList) {
        var conditionData = conditionList.toData();
        (0, _map["default"])(conditionData, function (data) {
          var name = data.fieldName;
          var findField = cloneFields.find(function (field) {
            return field.name === name;
          });

          if (findField) {
            result.push(findField);
            (0, _pullAllWith["default"])(cloneFields, [findField], _isEqual["default"]);
          }
        });
      }

      return result.concat(cloneFields);
    }
    /**
     * 查询前修改提示及校验定位
     */

  }, {
    key: "modifiedCheckQuery",
    value: function () {
      var _modifiedCheckQuery = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
        var getConfig, _this$props9, dataSet, queryDataSet, queryFields, comboFilterBar, searchText, hasQueryFields, hasFocus, _iterator2, _step2, _step2$value, key, value;

        return _regenerator["default"].wrap(function _callee5$(_context5) {
          while (1) {
            switch (_context5.prev = _context5.next) {
              case 0:
                getConfig = this.context.tableStore.getConfig;
                _this$props9 = this.props, dataSet = _this$props9.dataSet, queryDataSet = _this$props9.queryDataSet, queryFields = _this$props9.queryFields, comboFilterBar = _this$props9.comboFilterBar;
                searchText = comboFilterBar && comboFilterBar.searchText || getConfig('tableFilterSearchText') || 'params';
                hasQueryFields = queryDataSet && queryFields.length > 0;
                _context5.next = 6;
                return dataSet.modifiedCheck(undefined, dataSet, 'query');

              case 6:
                _context5.t3 = _context5.sent;

                if (!_context5.t3) {
                  _context5.next = 9;
                  break;
                }

                _context5.t3 = queryDataSet;

              case 9:
                _context5.t2 = _context5.t3;

                if (!_context5.t2) {
                  _context5.next = 12;
                  break;
                }

                _context5.t2 = queryDataSet.current;

              case 12:
                _context5.t1 = _context5.t2;

                if (!_context5.t1) {
                  _context5.next = 17;
                  break;
                }

                _context5.next = 16;
                return queryDataSet.current.validate();

              case 16:
                _context5.t1 = _context5.sent;

              case 17:
                _context5.t0 = _context5.t1;

                if (_context5.t0) {
                  _context5.next = 20;
                  break;
                }

                _context5.t0 = !hasQueryFields;

              case 20:
                if (!_context5.t0) {
                  _context5.next = 25;
                  break;
                }

                dataSet.setQueryParameter(searchText, dataSet.getState(SEARCHTEXT));
                dataSet.query();
                _context5.next = 28;
                break;

              case 25:
                hasFocus = false;
                _iterator2 = (0, _createForOfIteratorHelper2["default"])(this.refEditors.entries());

                try {
                  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
                    _step2$value = (0, _slicedToArray2["default"])(_step2.value, 2), key = _step2$value[0], value = _step2$value[1];

                    if (value && !value.valid && !hasFocus) {
                      this.refEditors.get(key).focus();
                      hasFocus = true;
                    }
                  }
                } catch (err) {
                  _iterator2.e(err);
                } finally {
                  _iterator2.f();
                }

              case 28:
              case "end":
                return _context5.stop();
            }
          }
        }, _callee5, this);
      }));

      function modifiedCheckQuery() {
        return _modifiedCheckQuery.apply(this, arguments);
      }

      return modifiedCheckQuery;
    }()
  }, {
    key: "renderRefreshBtn",
    value: function renderRefreshBtn() {
      var _this7 = this;

      var prefixCls = this.prefixCls;
      return /*#__PURE__*/_react["default"].createElement("span", {
        className: "".concat(prefixCls, "-filter-menu-query"),
        onClick: function () {
          var _onClick = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(e) {
            return _regenerator["default"].wrap(function _callee6$(_context6) {
              while (1) {
                switch (_context6.prev = _context6.next) {
                  case 0:
                    e.stopPropagation();
                    _context6.next = 3;
                    return _this7.modifiedCheckQuery();

                  case 3:
                  case "end":
                    return _context6.stop();
                }
              }
            }, _callee6);
          }));

          function onClick(_x4) {
            return _onClick.apply(this, arguments);
          }

          return onClick;
        }()
      }, /*#__PURE__*/_react["default"].createElement(_tooltip["default"], {
        title: (0, _localeContext.$l)('Table', 'refresh')
      }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
        type: "refresh"
      })));
    }
    /**
     * 渲染模糊搜索
     */

  }, {
    key: "getFuzzyQuery",
    value: function getFuzzyQuery() {
      var _this8 = this;

      var _this$props10 = this.props,
          dataSet = _this$props10.dataSet,
          fuzzyQuery = _this$props10.fuzzyQuery,
          fuzzyQueryPlaceholder = _this$props10.fuzzyQueryPlaceholder,
          comboFilterBar = _this$props10.comboFilterBar,
          _this$props10$onReset = _this$props10.onReset,
          onReset = _this$props10$onReset === void 0 ? _noop["default"] : _this$props10$onReset,
          queryDataSet = _this$props10.queryDataSet,
          queryFields = _this$props10.queryFields;
      var getConfig = this.context.tableStore.getConfig;
      var prefixCls = this.prefixCls;
      var searchText = comboFilterBar && comboFilterBar.searchText || getConfig('tableFilterSearchText') || 'params';
      var placeholder = fuzzyQueryPlaceholder || (0, _localeContext.$l)('Table', 'enter_search_filter');
      var hasQueryFields = queryDataSet && queryFields.length > 0;

      if (!fuzzyQuery && !hasQueryFields) {
        return null;
      }

      if (!fuzzyQuery) {
        return /*#__PURE__*/_react["default"].createElement("span", {
          className: "".concat(prefixCls, "-combo-filter-search-title")
        }, (0, _localeContext.$l)('Table', 'search'), ": ");
      }

      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-search")
      }, /*#__PURE__*/_react["default"].createElement(_textField["default"], {
        style: {
          width: 182
        },
        clearButton: true,
        placeholder: placeholder,
        prefix: /*#__PURE__*/_react["default"].createElement(_icon["default"], {
          type: "search"
        }),
        value: dataSet.getState(SEARCHTEXT),
        onChange: function onChange(value) {
          (0, _mobx.runInAction)(function () {
            dataSet.setState(SEARCHTEXT, value || '');
          });
          dataSet.setQueryParameter(searchText, value);

          _this8.handleQuery();
        },
        onClear: function onClear() {
          (0, _mobx.runInAction)(function () {
            dataSet.setState(SEARCHTEXT, '');
          });
          onReset();
        }
      }));
    }
    /**
     * 渲染重置按钮
     */

  }, {
    key: "getResetButton",
    value: function getResetButton() {
      var _this9 = this;

      var _this$props11 = this.props,
          queryDataSet = _this$props11.queryDataSet,
          dataSet = _this$props11.dataSet,
          autoQueryAfterReset = _this$props11.autoQueryAfterReset,
          _this$props11$onReset = _this$props11.onReset,
          onReset = _this$props11$onReset === void 0 ? _noop["default"] : _this$props11$onReset;
      var prefixCls = this.prefixCls;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-filter-buttons")
      }, dataSet.getState(CONDITIONSTATUS) === _enum2.RecordStatus.update && /*#__PURE__*/_react["default"].createElement(_button["default"], {
        onClick: function onClick() {
          var shouldQuery = false;

          if (queryDataSet) {
            var current = queryDataSet.current;

            if (current) {
              shouldQuery = !(0, _TableDynamicFilterBar.isEqualDynamicProps)(_this9.originalValue, (0, _omit["default"])(current.toData(), ['__dirty']), queryDataSet, current);
              current.reset();
              dataSet.setState(SEARCHTEXT, '');
              dataSet.setState(SELECTFIELDS, (0, _toConsumableArray2["default"])(_this9.originalConditionFields));
            }
          }

          _this9.setConditionStatus(_enum2.RecordStatus.sync);

          onReset();

          if (autoQueryAfterReset && shouldQuery) {
            _this9.handleQuery();
          }
        },
        color: _enum3.ButtonColor.secondary
      }, (0, _localeContext.$l)('Table', 'reset_button')));
    }
    /**
     * 筛选头
     * fuzzyQuery + quickFilterMenu + resetButton + buttons
     */

  }, {
    key: "getFilterMenu",
    value: function getFilterMenu() {
      var _this$props12 = this.props,
          queryFields = _this$props12.queryFields,
          queryDataSet = _this$props12.queryDataSet,
          dataSet = _this$props12.dataSet,
          autoQuery = _this$props12.autoQuery,
          filerMenuAction = _this$props12.filerMenuAction,
          _this$props12$onReset = _this$props12.onReset,
          onReset = _this$props12$onReset === void 0 ? _noop["default"] : _this$props12$onReset,
          singleLineMode = _this$props12.singleLineMode;
      var tableStore = this.context.tableStore;
      var prefixCls = this.prefixCls,
          initSearchId = this.initSearchId;
      var prefix = this.getPrefix();
      var suffix = this.renderSuffix();

      if (queryDataSet && queryFields.length) {
        var quickFilterMenu = this.tableFilterAdapter ? /*#__PURE__*/_react["default"].createElement(_QuickFilterMenuContext["default"].Provider, {
          value: {
            tempQueryFields: this.tempFields,
            autoQuery: autoQuery,
            prefixCls: prefixCls,
            dataSet: dataSet,
            queryDataSet: queryDataSet,
            refEditors: this.refEditors,
            onChange: this.handleSelect,
            conditionStatus: dataSet.getState(CONDITIONSTATUS),
            onStatusChange: this.setConditionStatus,
            selectFields: dataSet.getState(SELECTFIELDS),
            onOriginalChange: this.setOriginalConditionFields,
            menuDataSet: dataSet.getState(MENUDATASET),
            filterMenuDataSet: dataSet.getState(FILTERMENUDATASET),
            conditionDataSet: dataSet.getState(CONDITIONDATASET),
            optionDataSet: dataSet.getState(OPTIONDATASET),
            shouldLocateData: this.shouldLocateData,
            initSearchId: initSearchId,
            filterCallback: this.filterCallback,
            filterSave: this.filterSave,
            filterSaveCallback: this.filterSaveCallback,
            filterOptionRenderer: this.filterOptionRenderer,
            onReset: onReset,
            tableStore: tableStore
          }
        }, /*#__PURE__*/_react["default"].createElement(_QuickFilterMenu["default"], null)) : null;
        return singleLineMode ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (quickFilterMenu || filerMenuAction) && /*#__PURE__*/_react["default"].createElement("div", {
          className: "".concat(prefixCls, "-combo-filter-menu")
        }, quickFilterMenu, filerMenuAction && /*#__PURE__*/_react["default"].createElement("div", {
          className: "".concat(prefixCls, "-combo-filter-menu-action")
        }, filerMenuAction))) : /*#__PURE__*/_react["default"].createElement("div", {
          className: "".concat(prefixCls, "-combo-filter-menu")
        }, prefix, prefix && quickFilterMenu && /*#__PURE__*/_react["default"].createElement("span", {
          className: "".concat(prefixCls, "-combo-filter-title-divide")
        }, "/"), quickFilterMenu, filerMenuAction && /*#__PURE__*/_react["default"].createElement("div", {
          className: "".concat(prefixCls, "-combo-filter-menu-action")
        }, filerMenuAction), suffix);
      }
    }
  }, {
    key: "getFilterButton",
    value: function getFilterButton() {
      var _this$props13 = this.props,
          queryFields = _this$props13.queryFields,
          queryDataSet = _this$props13.queryDataSet,
          dataSet = _this$props13.dataSet,
          autoQuery = _this$props13.autoQuery,
          _this$props13$onReset = _this$props13.onReset,
          onReset = _this$props13$onReset === void 0 ? _noop["default"] : _this$props13$onReset,
          singleLineMode = _this$props13.singleLineMode;
      var tableStore = this.context.tableStore;
      var prefixCls = this.prefixCls,
          initSearchId = this.initSearchId;
      var suffix = this.renderSuffix();
      var quickFilterButton = this.tableFilterAdapter && queryDataSet && queryFields.length ? /*#__PURE__*/_react["default"].createElement(_QuickFilterMenuContext["default"].Provider, {
        value: {
          tempQueryFields: this.tempFields,
          autoQuery: autoQuery,
          prefixCls: prefixCls,
          dataSet: dataSet,
          queryDataSet: queryDataSet,
          refEditors: this.refEditors,
          onChange: this.handleSelect,
          conditionStatus: dataSet.getState(CONDITIONSTATUS),
          onStatusChange: this.setConditionStatus,
          selectFields: dataSet.getState(SELECTFIELDS),
          onOriginalChange: this.setOriginalConditionFields,
          menuDataSet: dataSet.getState(MENUDATASET),
          filterMenuDataSet: dataSet.getState(FILTERMENUDATASET),
          conditionDataSet: dataSet.getState(CONDITIONDATASET),
          optionDataSet: dataSet.getState(OPTIONDATASET),
          shouldLocateData: this.shouldLocateData,
          initSearchId: initSearchId,
          filterCallback: this.filterCallback,
          filterSave: this.filterSave,
          filterSaveCallback: this.filterSaveCallback,
          filterOptionRenderer: this.filterOptionRenderer,
          onReset: onReset,
          tableStore: tableStore
        }
      }, /*#__PURE__*/_react["default"].createElement(_QuickFilterButton["default"], null)) : null;
      var resetButton = this.tableFilterAdapter ? null : this.getResetButton();
      return singleLineMode ? /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-menu-button")
      }, quickFilterButton, resetButton, dataSet.getState(CONDITIONSTATUS) === _enum2.RecordStatus.update && suffix && (quickFilterButton || resetButton) ? /*#__PURE__*/_react["default"].createElement("span", {
        className: "".concat(prefixCls, "-combo-filter-menu-button-singleLine-divide")
      }) : null, suffix) : /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-menu-button")
      }, quickFilterButton, resetButton);
    }
    /**
     * 查询字段初始顺序
     * 排除动态属性影响
     */

  }, {
    key: "originOrderQueryFields",
    get: function get() {
      var queryDataSet = this.props.queryDataSet;
      var result = [];

      if (queryDataSet) {
        var fields = queryDataSet.fields,
            _queryDataSet$props$f = queryDataSet.props.fields,
            propFields = _queryDataSet$props$f === void 0 ? [] : _queryDataSet$props$f;
        var cloneFields = fields.toJS();
        propFields.forEach(function (_ref8) {
          var name = _ref8.name;

          if (name) {
            var field = cloneFields.get(name);

            var hasBindProps = function hasBindProps(propsName) {
              return field && field.get(propsName) && field.get(propsName).bind;
            };

            if (field && !field.get('bind') && !hasBindProps('computedProps') && !hasBindProps('dynamicProps') && !field.get('name').includes('__tls')) {
              result.push(field);
            }
          }
        });
      }

      return result;
    }
    /**
     * 渲染查询条
     */

  }, {
    key: "getQueryBar",
    value: function getQueryBar() {
      var _this10 = this;

      var _this$props14 = this.props,
          _this$props14$queryFi = _this$props14.queryFieldsLimit,
          queryFieldsLimit = _this$props14$queryFi === void 0 ? 3 : _this$props14$queryFi,
          queryFields = _this$props14.queryFields,
          queryDataSet = _this$props14.queryDataSet,
          dataSet = _this$props14.dataSet,
          simpleMode = _this$props14.simpleMode,
          advancedFilter = _this$props14.advancedFilter,
          singleLineMode = _this$props14.singleLineMode;
      var fieldsLimit = queryFieldsLimit;

      if (simpleMode) {
        fieldsLimit = this.originOrderQueryFields.length;
      }

      if (this.tableFilterAdapter && !simpleMode) {
        fieldsLimit = this.dynamicLimit();
      }

      var updateQueryFields = this.updateQueryFields();
      var updateOriginOrderQueryFields = this.updateOriginOrderQueryFields();
      var prefixCls = this.prefixCls;
      var selectFields = dataSet.getState(SELECTFIELDS) || [];
      var fuzzyQuery = this.getFuzzyQuery();
      var hasQueryFields = queryDataSet && queryFields.length > 0;

      var showAdvancedFilter = advancedFilter && !simpleMode && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
        className: "".concat(prefixCls, "-combo-filter-advanced-divide")
      }), advancedFilter);

      return /*#__PURE__*/_react["default"].createElement(_resizeObserver["default"], {
        key: "query_bar",
        resizeProp: "height",
        onResize: this.handleResize
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-bar")
      }, this.getFilterMenu() && !singleLineMode && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.getFilterMenu(), /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-menu-divide")
      })), /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-single-wrapper")
      }, this.getFilterMenu() && singleLineMode && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, this.getFilterMenu()), fuzzyQuery, /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-wrapper")
      }, hasQueryFields && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, updateQueryFields.slice(0, fieldsLimit).map(function (element) {
        var _element$props = element.props,
            name = _element$props.name,
            hidden = _element$props.hidden,
            disabled = _element$props.disabled;
        if (hidden) return null;
        var queryField = queryDataSet && queryDataSet.getField(name);
        var itemContentClassName = (0, _classnames["default"])("".concat(prefixCls, "-combo-filter-content"), (0, _defineProperty2["default"])({}, "".concat(prefixCls, "-filter-content-disabled"), disabled || queryField && queryField.get('disabled')));
        return /*#__PURE__*/_react["default"].createElement("div", {
          className: itemContentClassName,
          key: name,
          onClick: function onClick() {
            var editor = _this10.refEditors.get(name);

            if (editor) {
              _this10.refEditors.get(name).focus();
            }
          }
        }, /*#__PURE__*/_react["default"].createElement("span", {
          className: "".concat(prefixCls, "-combo-filter-item")
        }, _this10.createFields(element, name, queryField)));
      }), updateQueryFields.slice(fieldsLimit).map(function (element) {
        var _element$props2 = element.props,
            name = _element$props2.name,
            hidden = _element$props2.hidden,
            disabled = _element$props2.disabled;
        if (hidden) return null;
        var queryField = queryDataSet && queryDataSet.getField(name);
        var itemContentClassName = (0, _classnames["default"])("".concat(prefixCls, "-combo-filter-content"), (0, _defineProperty2["default"])({}, "".concat(prefixCls, "-filter-content-disabled"), disabled || queryField && queryField.get('disabled')));

        if (selectFields.includes(name)) {
          return /*#__PURE__*/_react["default"].createElement("div", {
            className: itemContentClassName,
            key: name,
            onClick: function onClick() {
              var editor = _this10.refEditors.get(name);

              if (editor) {
                _this10.refEditors.get(name).focus();
              }
            }
          }, /*#__PURE__*/_react["default"].createElement(_icon["default"], {
            type: "cancel",
            className: "".concat(prefixCls, "-combo-filter-item-close"),
            onClick: function onClick() {
              _this10.handleUnSelect([name]);
            }
          }), /*#__PURE__*/_react["default"].createElement("span", {
            className: "".concat(prefixCls, "-combo-filter-item")
          }, _this10.createFields(element, name, queryField)));
        }

        return null;
      }), fieldsLimit < updateQueryFields.length && /*#__PURE__*/_react["default"].createElement("div", {
        className: "".concat(prefixCls, "-combo-filter-item")
      }, /*#__PURE__*/_react["default"].createElement(_dropdown["default"], {
        visible: !this.fieldSelectHidden,
        overlay: /*#__PURE__*/_react["default"].createElement("div", {
          role: "none",
          ref: function ref(node) {
            return _this10.refDropdown = node;
          },
          onClick: function onClick(e) {
            e.stopPropagation();
          }
        }, /*#__PURE__*/_react["default"].createElement(_ComboFieldList["default"], {
          groups: [{
            title: (0, _localeContext.$l)('Table', 'predefined_fields'),
            fields: updateOriginOrderQueryFields.slice(fieldsLimit)
          }],
          prefixCls: "".concat(prefixCls, "-combo-filter-list") || 'c7n-pro-table-combo-filter-list',
          closeMenu: function closeMenu() {
            return (0, _mobx.runInAction)(function () {
              return _this10.fieldSelectHidden = true;
            });
          },
          value: selectFields,
          onSelect: this.handleSelect,
          onUnSelect: this.handleUnSelect,
          fieldsLimit: this.tableFilterAdapter ? fieldsLimit : 0
        })),
        trigger: [_enum.Action.click]
      }, /*#__PURE__*/_react["default"].createElement("span", {
        className: "".concat(prefixCls, "-combo-add-fields"),
        onClick: function onClick(e) {
          e.nativeEvent.stopImmediatePropagation();
          (0, _mobx.runInAction)(function () {
            _this10.fieldSelectHidden = !_this10.fieldSelectHidden;
          });
        }
      }, (0, _localeContext.$l)('Table', 'add_search'), /*#__PURE__*/_react["default"].createElement(_icon["default"], {
        type: this.fieldSelectHidden ? 'baseline-arrow_drop_down' : 'baseline-arrow_drop_up'
      }))))), showAdvancedFilter), this.getFilterButton())));
    }
  }, {
    key: "handleQuery",
    value: function () {
      var _handleQuery = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(collapse) {
        var _this$props15, _this$props15$onQuery, onQuery, autoQuery;

        return _regenerator["default"].wrap(function _callee7$(_context7) {
          while (1) {
            switch (_context7.prev = _context7.next) {
              case 0:
                _this$props15 = this.props, _this$props15$onQuery = _this$props15.onQuery, onQuery = _this$props15$onQuery === void 0 ? _noop["default"] : _this$props15$onQuery, autoQuery = _this$props15.autoQuery;

                if (!autoQuery) {
                  _context7.next = 4;
                  break;
                }

                _context7.next = 4;
                return this.modifiedCheckQuery();

              case 4:
                if (!collapse) {
                  onQuery();
                }

              case 5:
              case "end":
                return _context7.stop();
            }
          }
        }, _callee7, this);
      }));

      function handleQuery(_x5) {
        return _handleQuery.apply(this, arguments);
      }

      return handleQuery;
    }()
  }, {
    key: "render",
    value: function render() {
      var _this$props16 = this.props,
          summaryBar = _this$props16.summaryBar,
          buttons = _this$props16.buttons;
      var prefixCls = this.prefixCls;
      var queryBar = this.getQueryBar();

      if (queryBar) {
        return [queryBar, summaryBar];
      }

      return /*#__PURE__*/_react["default"].createElement(_TableButtons["default"], {
        key: "toolbar",
        prefixCls: "".concat(prefixCls, "-combo-filter-buttons"),
        buttons: buttons
      }, summaryBar);
    }
  }], [{
    key: "contextType",
    get: function get() {
      return _TableContext["default"];
    }
  }]);
  return TableComboBar;
}(_react.Component);

TableComboBar.defaultProps = {
  queryFieldsLimit: 3,
  autoQueryAfterReset: true,
  fuzzyQuery: true,
  autoQuery: true,
  refreshBtn: true,
  buttons: [],
  simpleMode: false,
  singleLineMode: true
};
(0, _tslib.__decorate)([_mobx.observable], TableComboBar.prototype, "moreFields", void 0);
(0, _tslib.__decorate)([_mobx.observable], TableComboBar.prototype, "fieldSelectHidden", void 0);
(0, _tslib.__decorate)([_mobx.observable], TableComboBar.prototype, "searchText", void 0);
(0, _tslib.__decorate)([_mobx.observable], TableComboBar.prototype, "shouldLocateData", void 0);
(0, _tslib.__decorate)([_mobx.action], TableComboBar.prototype, "handleClickOut", void 0);
(0, _tslib.__decorate)([_mobx.action], TableComboBar.prototype, "handleTableHeight", void 0);
(0, _tslib.__decorate)([_mobx.action], TableComboBar.prototype, "handleResize", void 0);
(0, _tslib.__decorate)([_autobind["default"]], TableComboBar.prototype, "handleDataSetQuery", null);
(0, _tslib.__decorate)([_autobind["default"]], TableComboBar.prototype, "handleDataSetValidate", null);
(0, _tslib.__decorate)([_autobind["default"]], TableComboBar.prototype, "setConditionStatus", null);
(0, _tslib.__decorate)([_mobx.action], TableComboBar.prototype, "setOriginalConditionFields", void 0);
(0, _tslib.__decorate)([_autobind["default"]], TableComboBar.prototype, "handleDataSetUpdate", null);
(0, _tslib.__decorate)([_autobind["default"]], TableComboBar.prototype, "handleDataSetCreate", null);
(0, _tslib.__decorate)([_autobind["default"], _mobx.action], TableComboBar.prototype, "initConditionFields", null);
(0, _tslib.__decorate)([_autobind["default"]], TableComboBar.prototype, "initMenuDataSet", null);
(0, _tslib.__decorate)([_mobx.action], TableComboBar.prototype, "handleSelect", void 0);
(0, _tslib.__decorate)([_mobx.action], TableComboBar.prototype, "handleUnSelect", void 0);
(0, _tslib.__decorate)([_autobind["default"]], TableComboBar.prototype, "handleQuery", null);
TableComboBar = (0, _tslib.__decorate)([_mobxReact.observer], TableComboBar);
var _default = TableComboBar;
exports["default"] = _default;
//# sourceMappingURL=TableComboBar.js.map
