import { computed, ref, createElementBlock, openBlock, Fragment, createVNode, unref } from "vue";
import "../../../node_modules/element-plus/es/index.mjs";
import RiskSchemeDialog from "./RiskSchemeDialog.vue2.mjs";
/* empty css                        */
import _export_sfc from "../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElInputTag } from "../../../node_modules/element-plus/es/components/input-tag/index.mjs";
const _sfc_main = {
  __name: "RiskSchemeSelector",
  props: {
    modelValue: {
      type: Array,
      default: () => []
    },
    schNo: {
      type: String,
      default: ""
    },
    dialogTitle: {
      type: String,
      default: "风险拦截方案"
    }
  },
  emits: ["update:modelValue", "update:schNo", "confirm"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const modelValue = computed({
      get: () => props.modelValue,
      set: (val) => emit("update:modelValue", val)
    });
    const dialogVisible = ref(false);
    function openDialog() {
      dialogVisible.value = true;
    }
    function handleDialogConfirm({ rows }) {
      const schNames = rows.map((row) => row.schName);
      const schNos = rows.map((row) => row.schNo).join(",");
      modelValue.value = schNames;
      emit("update:schNo", schNos);
      emit("confirm", rows);
    }
    function handleDialogClose() {
    }
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(unref(ElInputTag), {
          modelValue: modelValue.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
          placeholder: "请选择风险拦截方案",
          readonly: "",
          clearable: "",
          onClick: openDialog
        }, null, 8, ["modelValue"]),
        createVNode(RiskSchemeDialog, {
          modelValue: dialogVisible.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => dialogVisible.value = $event),
          title: __props.dialogTitle,
          onConfirm: handleDialogConfirm,
          onClose: handleDialogClose
        }, null, 8, ["modelValue", "title"])
      ], 64);
    };
  }
};
const RiskSchemeSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-87e02ca9"]]);
export {
  RiskSchemeSelector as default
};
