'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');

var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: "Fmselect"
  },
  __name: "index",
  props: /* @__PURE__ */ vue.mergeModels({
    //数据
    optionData: {
      type: Array,
      default: []
    },
    /**
     * 值的属性值
     */
    bvalue: {
      type: String,
      default: "id"
    },
    /**
     * 值的属性标签
     */
    blabel: {
      type: String,
      default: "name"
    },
    elabel: {
      type: String,
      default: "\u8BF7\u9009\u62E9"
    },
    isshowelabel: {
      type: Boolean,
      default: true
    },
    placeholder: {
      type: String,
      default: "\u8BF7\u9009\u62E9"
    }
  }, {
    "id": {
      type: Number,
      default: 0
    },
    "idModifiers": {},
    "name": {
      type: String,
      default: ""
    },
    "nameModifiers": {}
  }),
  emits: /* @__PURE__ */ vue.mergeModels(["change"], ["update:id", "update:name"]),
  setup(__props, { emit: __emit }) {
    const modeValueId = vue.useModel(__props, "id");
    const modeValueName = vue.useModel(__props, "name");
    const props = __props;
    const emit = __emit;
    const handleSelectChange = (value) => {
      const fitem = props.optionData.find((item) => item[props.bvalue] == value);
      modeValueName.value = fitem == null ? "" : fitem[props.blabel];
      emit("change", fitem);
    };
    return (_ctx, _cache) => {
      const _component_el_option = vue.resolveComponent("el-option");
      const _component_el_select = vue.resolveComponent("el-select");
      return vue.openBlock(), vue.createBlock(_component_el_select, {
        modelValue: modeValueId.value,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modeValueId.value = $event),
        placeholder: __props.placeholder,
        onChange: handleSelectChange
      }, {
        default: vue.withCtx(() => [
          __props.isshowelabel ? (vue.openBlock(), vue.createBlock(_component_el_option, {
            key: 0,
            value: 0,
            label: __props.elabel
          }, null, 8, ["label"])) : vue.createCommentVNode("v-if", true),
          (vue.openBlock(true), vue.createElementBlock(
            vue.Fragment,
            null,
            vue.renderList(__props.optionData, (item, index) => {
              return vue.openBlock(), vue.createBlock(_component_el_option, {
                key: index,
                value: item[__props.bvalue],
                label: item[__props.blabel]
              }, null, 8, ["value", "label"]);
            }),
            128
            /* KEYED_FRAGMENT */
          ))
        ]),
        _: 1
        /* STABLE */
      }, 8, ["modelValue", "placeholder"]);
    };
  }
});

exports.default = _sfc_main;
