import { defineComponent as Q, shallowRef as B, openBlock as c, createElementBlock as m, normalizeClass as p, unref as e, createVNode as l, mergeProps as S, withCtx as d, renderSlot as U, createTextVNode as h, toDisplayString as x, createCommentVNode as v, createElementVNode as b, createBlock as X, isRef as A, withDirectives as D } from "vue";
import { useNamespace as Y, ElLoading as Z, ElSpace as ee, ElButton as _, ElPagination as oe } from "element-plus";
import { WetSchemaForm as te } from "../../pro-form/index.mjs";
import se from "./base.mjs";
import { WetProTableProps as ae } from "./types.mjs";
import re from "./hooks/use-colunms.mjs";
import ne from "./hooks/use-form.mjs";
import le from "./hooks/use-request.mjs";
import ie from "./hooks/use-tools.mjs";
import ce from "./components/tool-icon.vue.mjs";
import { useElementBounding as ue } from "../../node_modules/.pnpm/@vueuse_core@10.9.0_vue@3.4.21/node_modules/@vueuse/core/index.mjs";
import { ArrowDown as me, ArrowUp as pe } from "../../node_modules/.pnpm/@element-plus_icons-vue@2.3.1_vue@3.4.21/node_modules/@element-plus/icons-vue/dist/index.mjs";
const de = {
  key: 0,
  class: "tabel-body-tool"
}, fe = { class: "tabel-body-tool--title" }, ge = { style: { flex: "1", display: "flex", "justify-content": "end" } }, ve = { class: "tabel-body-inner" }, Te = /* @__PURE__ */ Q({
  name: "WetProTable",
  __name: "index",
  props: ae,
  emits: ["update:selections"],
  setup(N, { emit: V }) {
    const t = Y("pro-table"), o = N, W = V, w = B(), $ = B(), C = Z.directive, { width: F } = ue(w), { columns: k, columnsControl: y } = re(o), {
      formPorps: P,
      properties: I,
      formIns: q,
      collapsed: f,
      getSearchValue: L,
      formState: j,
      resetForm: M
    } = ne(o, k, F), { dataSource: E, paginationInfo: r, $pagination: u, loading: R, runReuestApi: z } = le(o, j), { showTool: G, tableSize: a, paginationSize: H } = ie(o), g = async (i = !1) => {
      await L(), i && (r.value.currentPage = 1), await z();
    }, T = () => {
      r.value.currentPage = 1, u.value && (r.value.pageSize = u.value.pageSizes[0]), M(), g();
    }, J = () => g(), K = (i) => {
      W("update:selections", i);
    }, O = () => {
      f.value = !f.value;
    };
    return (i, s) => (c(), m("div", {
      class: p([
        e(t).b(),
        e(t).is("fill", o.fill),
        e(t).is("card-bordered", o.cardBordered)
      ]),
      ref_key: "tableDiv",
      ref: w
    }, [
      o.search && e(P) ? (c(), m("section", {
        key: 0,
        class: p([e(t).e("header"), e(t).is("small", e(a) === "small")])
      }, [
        l(e(te), S(e(P), {
          size: e(a),
          ref_key: "formIns",
          ref: q,
          properties: e(I),
          clearable: ""
        }), {
          actions: d(() => [
            l(e(ee), {
              class: "search-actions",
              wrap: ""
            }, {
              default: d(() => [
                U(i.$slots, "search-actions", {
                  search: () => g(!0),
                  reset: T
                }, () => [
                  l(e(_), {
                    type: "primary",
                    onClick: s[0] || (s[0] = () => g(!0))
                  }, {
                    default: d(() => [
                      h("查询")
                    ]),
                    _: 1
                  }),
                  l(e(_), { onClick: T }, {
                    default: d(() => [
                      h("重置")
                    ]),
                    _: 1
                  })
                ]),
                l(e(_), {
                  onClick: O,
                  link: "",
                  type: "primary",
                  icon: e(f) ? e(pe) : e(me)
                }, {
                  default: d(() => [
                    h(x(e(f) ? "收起" : "展开"), 1)
                  ]),
                  _: 1
                }, 8, ["icon"])
              ]),
              _: 3
            })
          ]),
          _: 3
        }, 16, ["size", "properties"])
      ], 2)) : v("", !0),
      b("section", {
        class: p([e(t).e("body"), e(t).is("small", e(a) === "small")])
      }, [
        e(G) ? (c(), m("div", de, [
          b("div", fe, x(o.title), 1),
          b("div", ge, [
            U(i.$slots, "tools-bar")
          ]),
          o.showMoreTools ? (c(), X(ce, {
            key: 0,
            onRefresh: J,
            size: e(a),
            "onUpdate:size": s[1] || (s[1] = (n) => A(a) ? a.value = n : null),
            columns: e(y),
            "onUpdate:columns": s[2] || (s[2] = (n) => A(y) ? y.value = n : null),
            "init-columns": o.columns || []
          }, null, 8, ["size", "columns", "init-columns"])) : v("", !0)
        ])) : v("", !0),
        D((c(), m("div", ve, [
          l(e(se), S(o, {
            request: "",
            ref_key: "tableRef",
            ref: $,
            columns: e(k),
            data: e(E).data,
            "onUpdate:selections": K,
            size: e(a)
          }), null, 16, ["columns", "data", "size"])
        ])), [
          [e(C), e(R)]
        ]),
        e(u) ? D((c(), m("section", {
          key: 1,
          class: p([e(t).e("footer"), e(t).is("small", e(a) === "small"), e(u).position])
        }, [
          b("div", {
            class: p([e(t).e("pagination-inner")])
          }, [
            l(e(oe), S({
              ...e(u),
              ...e(H)
            }, {
              "current-page": e(r).currentPage,
              "onUpdate:currentPage": s[3] || (s[3] = (n) => e(r).currentPage = n),
              "page-size": e(r).pageSize,
              "onUpdate:pageSize": s[4] || (s[4] = (n) => e(r).pageSize = n),
              onCurrentChange: e(z),
              onSizeChange: e(z),
              total: e(E).total
            }), null, 16, ["current-page", "page-size", "onCurrentChange", "onSizeChange", "total"])
          ], 2)
        ], 2)), [
          [e(C), e(R) ? {
            svg: " "
          } : !1]
        ]) : v("", !0)
      ], 2)
    ], 2));
  }
});
export {
  Te as default
};
