"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                                */
;/* empty css                                                                     */
const Vue = require("vue");
const index$2 = require("../../../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const index$3 = require("../../dialog/customDialog/index.js");
const index$4 = require("../../../api/index.js");
const getInstance = require("../../../utils/getInstance.js");
const Form = require("../../forms/form/Form.vue.js");
const Table = require("../../table/Table.vue.js");
const common = require("../../../utils/common.js");
;/* empty css                 */
const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../../../node_modules/element-plus/es/components/button/index.js");
const index$1 = require("../../../../../../node_modules/element-plus/es/components/icon/index.js");
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 = getInstance.getCurrentVueInstance();
    const isMoreBtn = Vue.computed(() => {
      return props.morePageRoute || props.morePageTemplateKey;
    });
    const dialogVisible = Vue.ref(false);
    const currentComponent = Vue.ref(null);
    const currentParams = Vue.ref(common.cloneDeep(props.morePageParams));
    const flag = Vue.ref(true);
    Vue.watch(currentParams, () => {
      if (props.morePageRoute && Object.keys(currentParams).length > 0) {
        flag.value = false;
        Vue.nextTick(() => {
          flag.value = true;
        });
      }
    });
    function moreClick() {
      if (props.morePageRoute) {
        common.loadComponentByPath(props.morePageRoute, ctx.$router, currentComponent);
        dialogVisible.value = true;
      } else if (props.morePageTemplateKey) {
        index$4.default.findByTemplateKey(ctx.$http, {
          templateKey: props.morePageTemplateKey,
          timestamp: Date.now(),
          templateVersion: "v5"
        }).then((res) => {
          const data = JSON.parse(res);
          if (data.formMode) {
            currentComponent.value = Form.default;
            currentParams.value.modelValue = common.cloneDeep(props.morePageParams);
          } else {
            currentComponent.value = Table.default;
            currentParams.value.initHiddenData = common.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 = index$1.ElIcon;
      const _component_el_button = index.ElButton;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        Vue.createElementVNode("div", _hoisted_1, [
          Vue.createElementVNode("div", _hoisted_2, [
            Vue.createElementVNode("div", _hoisted_3, [
              __props.title ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
                Vue.createElementVNode("i", {
                  class: Vue.normalizeClass("icon iconfont " + __props.icon),
                  style: Vue.normalizeStyle("background-color:" + __props.iconColor)
                }, null, 6),
                Vue.createElementVNode("span", null, Vue.toDisplayString(__props.title), 1)
              ], 64)) : Vue.createCommentVNode("", true)
            ]),
            Vue.unref(isMoreBtn) ? (Vue.openBlock(), Vue.createBlock(_component_el_button, {
              key: 0,
              class: "moreBtn",
              type: "primary",
              link: "",
              onClick: moreClick
            }, {
              default: Vue.withCtx(() => [
                _cache[1] || (_cache[1] = Vue.createTextVNode("更多信息")),
                Vue.createVNode(_component_el_icon, null, {
                  default: Vue.withCtx(() => [
                    Vue.createVNode(Vue.unref(index$2.ArrowRight))
                  ]),
                  _: 1
                })
              ]),
              _: 1
            })) : Vue.createCommentVNode("", true)
          ]),
          Vue.createElementVNode("div", _hoisted_4, [
            Vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
          ])
        ]),
        Vue.createVNode(Vue.unref(index$3.customDialog), {
          modelValue: Vue.unref(dialogVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(dialogVisible) ? dialogVisible.value = $event : null),
          width: "80%",
          height: "100%",
          query: "",
          "append-to-body": "",
          title: __props.title,
          class: "custom-padding-dialog"
        }, {
          default: Vue.withCtx(() => [
            Vue.unref(flag) && Vue.unref(currentComponent) ? (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(Vue.unref(currentComponent)), Vue.normalizeProps(Vue.mergeProps({ key: 0 }, Vue.unref(currentParams))), null, 16)) : Vue.createCommentVNode("", true)
          ]),
          _: 1
        }, 8, ["modelValue", "title"])
      ], 64);
    };
  }
};
const _LayoutCard = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-a6236024"]]);
exports.default = _LayoutCard;
