"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                                                            */
;/* empty css                                                           */
;/* empty css                                                               */
;/* empty css                                                            */
;/* empty css                                                         */
;/* empty css                                                            */
;/* empty css                                                                  */
;/* empty css                                                            */
;/* empty css                                                                */
require("../../../node_modules/element-plus/theme-chalk/el-tooltip.css.js");
;/* empty css                                                              */
;/* empty css                                                           */
;/* empty css                                                                  */
;/* empty css                                                            */
const Vue = require("vue");
const index$4 = require("../../../node_modules/@element-plus/icons-vue/dist/index.js");
const index = require("../api/index.js");
;/* empty css                      */
const _pluginVue_exportHelper = require("../../../_virtual/_plugin-vue_export-helper.js");
const index$1 = require("../../../node_modules/element-plus/es/components/dialog/index.js");
const index$2 = require("../../../node_modules/element-plus/es/components/input/index.js");
const index$3 = require("../../../node_modules/element-plus/es/components/button/index.js");
const index$5 = require("../../../node_modules/element-plus/es/components/table/index.js");
const index$6 = require("../../../node_modules/element-plus/es/components/pagination/index.js");
const index$7 = require("../../../node_modules/element-plus/es/components/message/index.js");
const _hoisted_1 = { class: "search-bar" };
const _hoisted_2 = { class: "dialog-footer" };
const _sfc_main = {
  __name: "RiskSchemeDialog",
  props: {
    modelValue: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: "选择风险拦截方案"
    },
    width: {
      type: String,
      default: "50%"
    }
  },
  emits: ["update:modelValue", "confirm", "close"],
  setup(__props, { emit: __emit }) {
    const currentInstance = Vue.getCurrentInstance();
    const ctx = currentInstance.proxy;
    const props = __props;
    const emit = __emit;
    const dialogVisible = Vue.computed({
      get: () => props.modelValue,
      set: (val) => emit("update:modelValue", val)
    });
    const searchText = Vue.ref("");
    const schemeList = Vue.ref([]);
    const total = Vue.ref(0);
    const tableRef = Vue.ref(null);
    const selectedRows = Vue.ref([]);
    const pageInfo = Vue.ref({
      pageNo: 1,
      pageSize: 10
    });
    Vue.watch(
      () => props.modelValue,
      (val) => {
        if (val) {
          searchText.value = "";
          pageInfo.value = {
            pageNo: 1,
            pageSize: 10
          };
          loadSchemeList();
        }
      },
      { immediate: true }
    );
    async function loadSchemeList() {
      try {
        const params = {
          pageNo: pageInfo.value.pageNo,
          pageSize: pageInfo.value.pageSize
        };
        if (searchText.value) {
          params.dynamicQuery = searchText.value;
        }
        const data = await index.default.findRiskSchByPopPage4Designer(ctx.$http, params);
        schemeList.value = data.records || data.list || [];
        total.value = schemeList.value.length;
      } catch (error) {
        console.error("加载风险拦截方案列表失败:", error);
        schemeList.value = [];
        total.value = 0;
      }
    }
    function handleSearch() {
      pageInfo.value.pageNo = 1;
      loadSchemeList();
    }
    function handleSelectionChange(rows) {
      selectedRows.value = rows;
    }
    function handleSizeChange(size) {
      pageInfo.value.pageSize = size;
      pageInfo.value.pageNo = 1;
      loadSchemeList();
    }
    function handlePageChange(page) {
      pageInfo.value.pageNo = page;
      loadSchemeList();
    }
    function closeDialog() {
      dialogVisible.value = false;
      emit("close");
    }
    function onConfirm() {
      if (selectedRows.value.length === 0) {
        index$7.ElMessage.warning("请先选择方案");
        return;
      }
      emit("confirm", {
        rows: selectedRows.value
      });
      dialogVisible.value = false;
    }
    return (_ctx, _cache) => {
      const _component_el_button = index$3.ElButton;
      const _component_el_input = index$2.ElInput;
      const _component_el_table_column = index$5.ElTableColumn;
      const _component_el_table = index$5.ElTable;
      const _component_el_pagination = index$6.ElPagination;
      const _component_el_dialog = index$1.ElDialog;
      return Vue.openBlock(), Vue.createBlock(_component_el_dialog, {
        modelValue: dialogVisible.value,
        "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => dialogVisible.value = $event),
        width: __props.width,
        title: __props.title,
        draggable: "",
        overflow: "",
        "append-to-body": "",
        class: "fec-dev-designer-dialog"
      }, {
        footer: Vue.withCtx(() => [
          Vue.createElementVNode("div", _hoisted_2, [
            Vue.createVNode(_component_el_button, {
              onClick: closeDialog,
              size: "default"
            }, {
              default: Vue.withCtx(() => _cache[4] || (_cache[4] = [
                Vue.createTextVNode("取消")
              ])),
              _: 1
            }),
            Vue.createVNode(_component_el_button, {
              type: "primary",
              onClick: onConfirm,
              size: "default"
            }, {
              default: Vue.withCtx(() => _cache[5] || (_cache[5] = [
                Vue.createTextVNode("确定")
              ])),
              _: 1
            })
          ])
        ]),
        default: Vue.withCtx(() => [
          Vue.createElementVNode("div", _hoisted_1, [
            Vue.createVNode(_component_el_input, {
              modelValue: searchText.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchText.value = $event),
              placeholder: _ctx.searchPlaceholder || "搜索方案名称/方案编号",
              clearable: "",
              onClear: handleSearch,
              onKeyup: Vue.withKeys(handleSearch, ["enter"]),
              style: { "width": "300px" },
              size: "default"
            }, {
              append: Vue.withCtx(() => [
                Vue.createVNode(_component_el_button, {
                  icon: Vue.unref(index$4.Search),
                  onClick: handleSearch
                }, null, 8, ["icon"])
              ]),
              _: 1
            }, 8, ["modelValue", "placeholder"])
          ]),
          Vue.createVNode(_component_el_table, {
            ref_key: "tableRef",
            ref: tableRef,
            data: schemeList.value,
            "max-height": "500",
            onSelectionChange: handleSelectionChange,
            style: { "width": "100%", "margin-top": "10px" },
            size: "default"
          }, {
            default: Vue.withCtx(() => [
              Vue.createVNode(_component_el_table_column, {
                type: "selection",
                width: "55"
              }),
              Vue.createVNode(_component_el_table_column, {
                prop: "schNo",
                label: "方案编号",
                "min-width": "200"
              }),
              Vue.createVNode(_component_el_table_column, {
                prop: "schName",
                label: "方案名称",
                "min-width": "200"
              }),
              Vue.createVNode(_component_el_table_column, {
                prop: "remark",
                label: "备注",
                "min-width": "200"
              })
            ]),
            _: 1
          }, 8, ["data"]),
          Vue.createVNode(_component_el_pagination, {
            size: "small",
            "current-page": pageInfo.value.pageNo,
            "onUpdate:currentPage": _cache[1] || (_cache[1] = ($event) => pageInfo.value.pageNo = $event),
            "page-size": pageInfo.value.pageSize,
            "onUpdate:pageSize": _cache[2] || (_cache[2] = ($event) => pageInfo.value.pageSize = $event),
            "page-sizes": [10, 20, 50, 100],
            total: total.value,
            layout: "total, sizes, prev, pager, next, jumper",
            onSizeChange: handleSizeChange,
            onCurrentChange: handlePageChange,
            style: { "margin-top": "20px", "justify-content": "flex-end" }
          }, null, 8, ["current-page", "page-size", "total"])
        ]),
        _: 1
      }, 8, ["modelValue", "width", "title"]);
    };
  }
};
const RiskSchemeDialog = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-b943b417"]]);
exports.default = RiskSchemeDialog;
