"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                                */
;/* empty css                                                                    */
;/* empty css                                                                     */
const Vue = require("vue");
const index$2 = require("../../dialog/index.js");
;/* empty css                 */
const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../../../node_modules/element-plus/es/components/input/index.js");
const index$1 = require("../../../../../../node_modules/element-plus/es/components/button/index.js");
const _hoisted_1 = { class: "text-field-wrapper" };
const _sfc_main = /* @__PURE__ */ Object.assign({
  inheritAttrs: false
}, {
  __name: "RoleSelect",
  props: {
    config: {
      type: Object,
      required: true
    },
    modelValue: {
      type: [String, Number],
      default: ""
    },
    placeholder: {
      type: String,
      default: ""
    },
    disabled: {
      type: Boolean,
      default: false
    },
    formMode: {
      type: String,
      default: ""
    },
    dialogConfig: {
      type: Object,
      default: {}
    }
  },
  emits: ["update:modelValue", "change"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    function handleChange(val) {
      emit("change", val);
    }
    const instance = Vue.getCurrentInstance();
    const formData = Vue.inject("formData", null);
    Vue.inject("localConfig", null);
    const fieldsData = Vue.inject("fieldsData", null);
    const hiddenFields = Vue.inject("hiddenFields", null);
    const formCtx = Vue.inject("formCtx", null);
    const inputValue = Vue.computed(
      () => formData.value[props.config.displayFieldName]
    );
    function handleClear() {
      formData.value[props.config.displayFieldName] = "";
      formData.value[props.config.fieldName] = "";
    }
    const fieldsList = [
      ...(fieldsData == null ? void 0 : fieldsData.value) || [],
      ...(hiddenFields == null ? void 0 : hiddenFields.value) || []
    ];
    const dialog = props.dialogConfig;
    const customTableConfig = dialog.customTableConfig;
    customTableConfig.dataSources.push({
      id: "roleSelectDataSourceId",
      name: "角色选择数据源",
      serverName: "base-server",
      url: "/sysRole/findByPageV5",
      method: "post",
      contentType: "json",
      params: dialog.dialogParams || []
    });
    function openSuffixDialog() {
      index$2.openDialog(
        props.config.displayFieldName,
        dialog,
        instance,
        formCtx,
        fieldsList,
        formData.value
      ).then((result) => {
        const values = result.map((row) => row.roleNo);
        formData.value[props.config.fieldName] = values.join("|");
        console.log("确定", result);
      }).catch(() => {
        console.log("取消");
      });
    }
    return (_ctx, _cache) => {
      const _component_el_button = index$1.ElButton;
      const _component_el_input = index.ElInput;
      return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        Vue.createVNode(_component_el_input, Vue.mergeProps({
          modelValue: inputValue.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
        }, Vue.toHandlers(__props.config.eventHandlers), {
          placeholder: __props.placeholder,
          disabled: __props.disabled,
          onChange: handleChange,
          clearable: "",
          onClear: handleClear
        }), Vue.createSlots({ _: 2 }, [
          __props.formMode != "query" ? {
            name: "append",
            fn: Vue.withCtx(() => [
              Vue.createVNode(_component_el_button, {
                class: "suffixButton",
                onClick: openSuffixDialog
              }, {
                default: Vue.withCtx(() => _cache[1] || (_cache[1] = [
                  Vue.createTextVNode("选择")
                ])),
                _: 1
              })
            ]),
            key: "0"
          } : void 0
        ]), 1040, ["modelValue", "placeholder", "disabled"])
      ]);
    };
  }
});
const _RoleSelect = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-3f845d75"]]);
exports.default = _RoleSelect;
