UNPKG

@cdwx/system

Version:

成都文宣业务类服务模块组件库

130 lines (129 loc) 4.96 kB
/* empty css */ /* empty css */ import "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/theme-chalk/el-tab-pane.css.js"; /* empty css */ /* empty css */ import { defineComponent as B, mergeModels as R, useModel as D, computed as N, ref as d, onMounted as T, openBlock as u, createBlock as p, withCtx as h, createElementBlock as V, Fragment as x, renderList as L, createVNode as w } from "vue"; import { getAllByPackageCode as P } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-menu.js"; import { ElTree as A } from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/tree/index.js"; import { ElTabPane as S, ElTabs as q } from "../workspace/code/cloud-frontend/node_modules/.pnpm/element-plus@2.9.1_vue@3.5.13_typescript@5.5.4_/node_modules/element-plus/es/components/tabs/index.js"; const O = /* @__PURE__ */ B({ name: "RoleTree", __name: "tree", props: /* @__PURE__ */ R({ disabled: { type: Boolean, default: !1 } }, { modelValue: { required: !0 }, modelModifiers: {} }), emits: ["update:modelValue"], setup(y, { expose: E }) { const v = y, k = D(y, "modelValue"), i = N({ get() { return k.value; }, set(e) { k.value = e; } }), c = d(), _ = { children: "childMenuVoList", label: "name" }, o = d([]); async function C() { o.value = []; try { const { data: e } = await P({ classify: "", packageCode: "" }), a = e.map((t) => ({ classify: t.classify, name: t.name, menuVoList: t.menuVoList })); o.value = a, c.value = a[0].classify; } catch { o.value = []; } } const m = d([]); function g(e, a) { e && (m.value[a] = e); } const b = d({}); async function M() { var e; return await ((e = m.value) == null ? void 0 : e.forEach((a, t) => { const s = []; a.getCheckedNodes(!1, !0).forEach((n) => { s.push({ id: n.id, code: n.code, name: n.name }); }), Reflect.set(b.value, o.value[t].classify, s); })), b.value; } return T(async () => { await C(), i.value && (v.disabled || i.value.forEach((e) => { o.value.forEach((a, t) => { e.classify === a.classify && m.value[t].setCheckedNodes(e.menuVoList, !1); }); }), c.value = i.value[0].classify); }), E({ getCheckedData: M }), (e, a) => { const t = A, s = S, n = q; return u(), p(n, { modelValue: c.value, "onUpdate:modelValue": a[0] || (a[0] = (l) => c.value = l), style: { width: "100%", top: "-4px" }, class: "position-relative" }, { default: h(() => [ v.disabled ? (u(!0), V(x, { key: 0 }, L(i.value, (l, r) => (u(), p(s, { key: r, name: l.classify, label: l.name }, { default: h(() => [ w(t, { ref_for: !0, ref: (f) => g(f, r), style: { "max-width": "600px", "min-width": "200px" }, data: l.menuVoList, "node-key": "id", "highlight-current": "", "default-expand-all": "", props: _ }, null, 8, ["data"]) ]), _: 2 }, 1032, ["name", "label"]))), 128)) : (u(!0), V(x, { key: 1 }, L(o.value, (l, r) => (u(), p(s, { key: r, name: l.classify, label: l.name }, { default: h(() => [ w(t, { ref_for: !0, ref: (f) => g(f, r), style: { "max-width": "600px", "min-width": "200px" }, data: l.menuVoList, "node-key": "id", "default-expand-all": "", "highlight-current": "", "show-checkbox": "", props: _ }, null, 8, ["data"]) ]), _: 2 }, 1032, ["name", "label"]))), 128)) ]), _: 1 }, 8, ["modelValue"]); }; } }); export { O as default };