import "../../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                                */
/* empty css                                                                     */
import { computed, ref, watch, nextTick, createElementBlock, openBlock, Fragment, createElementVNode, createVNode, createBlock, createCommentVNode, normalizeStyle, normalizeClass, toDisplayString, unref, withCtx, createTextVNode, renderSlot, isRef, resolveDynamicComponent, normalizeProps, mergeProps } from "vue";
import { ArrowRight as arrow_right_default } from "../../../../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import { customDialog } from "../../dialog/customDialog/index.mjs";
import api from "../../../api/index.mjs";
import { getCurrentVueInstance } from "../../../utils/getInstance.mjs";
import _Form from "../../forms/form/Form.vue.mjs";
import _Table from "../../table/Table.vue.mjs";
import { cloneDeep, loadComponentByPath } from "../../../utils/common.mjs";
/* empty css                 */
import _export_sfc from "../../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElButton } from "../../../../../../node_modules/element-plus/es/components/button/index.mjs";
import { ElIcon } from "../../../../../../node_modules/element-plus/es/components/icon/index.mjs";
const _hoisted_1 = { class: "fec-layout-card" };
const _hoisted_2 = { class: "header" };
const _hoisted_3 = { class: "title" };
const _hoisted_4 = { class: "content" };
const _sfc_main = {
  __name: "LayoutCard",
  props: {
    //标题
    title: {
      type: String,
      default: ""
    },
    //图标
    icon: {
      type: String,
      default: "icon-authorization"
    },
    //图标背景色
    iconColor: {
      type: String,
      default: "#4fbdc1"
    },
    morePageRoute: {
      type: String,
      default: ""
    },
    morePageTemplateKey: {
      type: String,
      default: ""
    },
    morePageParams: {
      type: Object,
      default: {}
    }
  },
  setup(__props) {
    const props = __props;
    const ctx = getCurrentVueInstance();
    const isMoreBtn = computed(() => {
      return props.morePageRoute || props.morePageTemplateKey;
    });
    const dialogVisible = ref(false);
    const currentComponent = ref(null);
    const currentParams = ref(cloneDeep(props.morePageParams));
    const flag = ref(true);
    watch(currentParams, () => {
      if (props.morePageRoute && Object.keys(currentParams).length > 0) {
        flag.value = false;
        nextTick(() => {
          flag.value = true;
        });
      }
    });
    function moreClick() {
      if (props.morePageRoute) {
        loadComponentByPath(props.morePageRoute, ctx.$router, currentComponent);
        dialogVisible.value = true;
      } else if (props.morePageTemplateKey) {
        api.findByTemplateKey(ctx.$http, {
          templateKey: props.morePageTemplateKey,
          timestamp: Date.now(),
          templateVersion: "v5"
        }).then((res) => {
          const data = JSON.parse(res);
          if (data.formMode) {
            currentComponent.value = _Form;
            currentParams.value.modelValue = cloneDeep(props.morePageParams);
          } else {
            currentComponent.value = _Table;
            currentParams.value.initHiddenData = cloneDeep(props.morePageParams);
            currentParams.value.hasPagination = true;
          }
          currentParams.value.initOption = data;
          currentParams.value.isDialog = true;
          dialogVisible.value = true;
        });
      }
    }
    return (_ctx, _cache) => {
      const _component_el_icon = ElIcon;
      const _component_el_button = ElButton;
      return openBlock(), createElementBlock(Fragment, null, [
        createElementVNode("div", _hoisted_1, [
          createElementVNode("div", _hoisted_2, [
            createElementVNode("div", _hoisted_3, [
              __props.title ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
                createElementVNode("i", {
                  class: normalizeClass("icon iconfont " + __props.icon),
                  style: normalizeStyle("background-color:" + __props.iconColor)
                }, null, 6),
                createElementVNode("span", null, toDisplayString(__props.title), 1)
              ], 64)) : createCommentVNode("", true)
            ]),
            unref(isMoreBtn) ? (openBlock(), createBlock(_component_el_button, {
              key: 0,
              class: "moreBtn",
              type: "primary",
              link: "",
              onClick: moreClick
            }, {
              default: withCtx(() => [
                _cache[1] || (_cache[1] = createTextVNode("更多信息")),
                createVNode(_component_el_icon, null, {
                  default: withCtx(() => [
                    createVNode(unref(arrow_right_default))
                  ]),
                  _: 1
                })
              ]),
              _: 1
            })) : createCommentVNode("", true)
          ]),
          createElementVNode("div", _hoisted_4, [
            renderSlot(_ctx.$slots, "default", {}, void 0, true)
          ])
        ]),
        createVNode(unref(customDialog), {
          modelValue: unref(dialogVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(dialogVisible) ? dialogVisible.value = $event : null),
          width: "80%",
          height: "100%",
          query: "",
          "append-to-body": "",
          title: __props.title,
          class: "custom-padding-dialog"
        }, {
          default: withCtx(() => [
            unref(flag) && unref(currentComponent) ? (openBlock(), createBlock(resolveDynamicComponent(unref(currentComponent)), normalizeProps(mergeProps({ key: 0 }, unref(currentParams))), null, 16)) : createCommentVNode("", true)
          ]),
          _: 1
        }, 8, ["modelValue", "title"])
      ], 64);
    };
  }
};
const _LayoutCard = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-a6236024"]]);
export {
  _LayoutCard as default
};
