/******/ (function() { // webpackBootstrap
/******/ 	"use strict";
/******/ 	// The require scope
/******/ 	var __webpack_require__ = {};
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	!function() {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = function(module) {
/******/ 			var getter = module && module.__esModule ?
/******/ 				function() { return module['default']; } :
/******/ 				function() { return module; };
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/define property getters */
/******/ 	!function() {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = function(exports, definition) {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	!function() {
/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	!function() {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = function(exports) {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	}();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "default": function() { return /* binding */ remote_search; }
});

;// CONCATENATED MODULE: ./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./packages/remote-search/src/main.vue?vue&type=template&id=7645ef40&
var render = function render() {
  var _vm = this,
    _c = _vm._self._c;
  return _c("el-select", {
    ref: "remoteSearch",
    staticClass: "jdf-remote-search",
    attrs: {
      filterable: "",
      remote: "",
      clearable: "",
      "default-first-option": "",
      "value-key": _vm.valueKey,
      placeholder: _vm.placeholder,
      "remote-method": _vm.remoteMethod,
      loading: _vm.loading,
      "no-data-text": _vm.noDataText
    },
    on: {
      change: _vm.changeVal,
      "visible-change": _vm.visibleChange
    },
    model: {
      value: _vm.searchText,
      callback: function callback($$v) {
        _vm.searchText = typeof $$v === "string" ? $$v.trim() : $$v;
      },
      expression: "searchText"
    }
  }, _vm._l(_vm.optionList, function (item) {
    return _c("el-option", {
      key: item[_vm.valueKey],
      attrs: {
        label: item[_vm.labelKey],
        value: item[_vm.valueKey]
      }
    }, [_c("span", {
      staticClass: "label-span"
    }, [_vm._v("\n      " + _vm._s(item[_vm.labelKey]) + "\n    ")])]);
  }), 1);
};
var staticRenderFns = [];
render._withStripped = true;

;// CONCATENATED MODULE: ./packages/remote-search/src/main.vue?vue&type=template&id=7645ef40&

;// CONCATENATED MODULE: external "@babel/runtime/helpers/asyncToGenerator"
var asyncToGenerator_namespaceObject = require("@babel/runtime/helpers/asyncToGenerator");
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator_namespaceObject);
;// CONCATENATED MODULE: external "@babel/runtime/regenerator"
var regenerator_namespaceObject = require("@babel/runtime/regenerator");
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator_namespaceObject);
;// CONCATENATED MODULE: ./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader/lib/index.js??vue-loader-options!./packages/remote-search/src/main.vue?vue&type=script&lang=js&


/* harmony default export */ var mainvue_type_script_lang_js_ = ({
  name: 'JdfRemoteSearch',
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    value: [String, Number],
    // 作为 value 唯一标识的键名
    valueKey: {
      type: String,
      default: ''
    },
    // 展示的文本的key
    labelKey: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: ''
    },
    // 最少输入字符数
    minLength: {
      type: Number,
      default: 2
    },
    // 请求接口
    requestFunction: {
      type: Function,
      default: function _default() {
        return function () {};
      }
    }
  },
  data: function data() {
    return {
      loading: false,
      // 无数据时展示的文本
      noDataText: '无数据',
      // 搜索结果列表
      optionList: []
    };
  },
  computed: {
    // 查询参数
    searchText: {
      get: function get() {
        return this.value;
      },
      set: function set(val) {
        this.$emit('change', val);
      }
    }
  },
  methods: {
    /**
     * 搜索方法
     * @param {String} query 输入的关键字
     */
    remoteMethod: function remoteMethod(query) {
      var _this = this;
      return asyncToGenerator_default()( /*#__PURE__*/regenerator_default().mark(function _callee() {
        var para, minLength, length;
        return regenerator_default().wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              para = query.trim();
              minLength = _this.minLength;
              length = para.length;
              _this.noDataText = length >= minLength ? '无数据' : "\u8BF7\u81F3\u5C11\u8F93\u5165".concat(minLength, "\u4E2A\u5B57\u7B26");
              // 大于等于minLength个字符开始调取接口搜索
              if (!(!para || length < minLength)) {
                _context.next = 7;
                break;
              }
              _this.optionList = [];
              return _context.abrupt("return");
            case 7:
              _context.prev = 7;
              _this.loading = true;
              _context.next = 11;
              return _this.requestFunction(para);
            case 11:
              _this.optionList = _context.sent;
            case 12:
              _context.prev = 12;
              _this.loading = false;
              return _context.finish(12);
            case 15:
            case "end":
              return _context.stop();
          }
        }, _callee, null, [[7,, 12, 15]]);
      }))();
    },
    /**
     * select 选择变化事件
     * @param {*} val 选中的值
     */
    changeVal: function changeVal(val) {
      var _this2 = this;
      if (val) {
        this.$emit('select', this.optionList.find(function (t) {
          return t[_this2.valueKey] === val;
        }));
      } else {
        this.optionList = [];
        this.$emit('select', {});
      }
    },
    /**
     * 已经输入了数据后，点击输入框应该可以在原基础上修改
     */
    visibleChange: function visibleChange(val) {
      var _this3 = this;
      if (!val) {
        return;
      }
      var data = this.optionList.find(function (t) {
        return t[_this3.valueKey] === _this3.searchText;
      });
      if (data) {
        this.$refs.remoteSearch.selectedLabel = data[this.labelKey];
      }
    }
  }
});
;// CONCATENATED MODULE: ./packages/remote-search/src/main.vue?vue&type=script&lang=js&
 /* harmony default export */ var src_mainvue_type_script_lang_js_ = (mainvue_type_script_lang_js_); 
;// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
/* globals __VUE_SSR_CONTEXT__ */

// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
// This module is a runtime utility for cleaner component module output and will
// be included in the final webpack user bundle.

function normalizeComponent(
  scriptExports,
  render,
  staticRenderFns,
  functionalTemplate,
  injectStyles,
  scopeId,
  moduleIdentifier /* server only */,
  shadowMode /* vue-cli only */
) {
  // Vue.extend constructor export interop
  var options =
    typeof scriptExports === 'function' ? scriptExports.options : scriptExports

  // render functions
  if (render) {
    options.render = render
    options.staticRenderFns = staticRenderFns
    options._compiled = true
  }

  // functional template
  if (functionalTemplate) {
    options.functional = true
  }

  // scopedId
  if (scopeId) {
    options._scopeId = 'data-v-' + scopeId
  }

  var hook
  if (moduleIdentifier) {
    // server build
    hook = function (context) {
      // 2.3 injection
      context =
        context || // cached call
        (this.$vnode && this.$vnode.ssrContext) || // stateful
        (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
      // 2.2 with runInNewContext: true
      if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
        context = __VUE_SSR_CONTEXT__
      }
      // inject component styles
      if (injectStyles) {
        injectStyles.call(this, context)
      }
      // register component module identifier for async chunk inferrence
      if (context && context._registeredComponents) {
        context._registeredComponents.add(moduleIdentifier)
      }
    }
    // used by ssr in case component is cached and beforeCreate
    // never gets called
    options._ssrRegister = hook
  } else if (injectStyles) {
    hook = shadowMode
      ? function () {
          injectStyles.call(
            this,
            (options.functional ? this.parent : this).$root.$options.shadowRoot
          )
        }
      : injectStyles
  }

  if (hook) {
    if (options.functional) {
      // for template-only hot-reload because in that case the render fn doesn't
      // go through the normalizer
      options._injectStyles = hook
      // register for functional component in vue file
      var originalRender = options.render
      options.render = function renderWithStyleInjection(h, context) {
        hook.call(context)
        return originalRender(h, context)
      }
    } else {
      // inject component registration as beforeCreate hook
      var existing = options.beforeCreate
      options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
    }
  }

  return {
    exports: scriptExports,
    options: options
  }
}

;// CONCATENATED MODULE: ./packages/remote-search/src/main.vue





/* normalize component */
;
var component = normalizeComponent(
  src_mainvue_type_script_lang_js_,
  render,
  staticRenderFns,
  false,
  null,
  null,
  null
  
)

/* harmony default export */ var main = (component.exports);
;// CONCATENATED MODULE: ./packages/remote-search/index.js

main.install = function (Vue) {
  Vue.component(main.name, main);
};
/* harmony default export */ var remote_search = (main);
module.exports = __webpack_exports__;
/******/ })()
;