UNPKG

@cdwx/system

Version:

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

144 lines (143 loc) 5.42 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 D, useModel as N, computed as T, ref as d, onMounted as A, openBlock as r, createBlock as p, withCtx as h, createElementBlock as _, Fragment as b, renderList as x, createVNode as E } from "vue"; import { getAllByPackageCode as P } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-menu.js"; import { ElTree as I } 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 Q = /* @__PURE__ */ B({ name: "RoleTree", __name: "tree", props: /* @__PURE__ */ D({ disabled: { type: Boolean, default: !1 } }, { modelValue: { required: !0 }, modelModifiers: {} }), emits: ["update:modelValue"], setup(y, { expose: w }) { const v = y, V = N(y, "modelValue"), u = T({ get() { return V.value; }, set(t) { V.value = t; } }), c = d(), g = { children: "childMenuVoList", label: "name" }, n = d([]); async function M() { n.value = []; try { const { data: t } = await P({ classify: "", packageCode: "" }), a = t.map((l) => ({ classify: l.classify, name: l.name, menuVoList: l.menuVoList })); n.value = a, c.value = a[0].classify; } catch { n.value = []; } } const f = d([]); function k(t, a) { t && (f.value[a] = t); } const L = d({}); async function C() { var t; return await ((t = f.value) == null ? void 0 : t.forEach((a, l) => { const e = []; a.getCheckedNodes(!1, !0).forEach((o) => { e.push({ id: o.id, code: o.code, name: o.name }); }), Reflect.set(L.value, n.value[l].classify, e); })), L.value; } function R(t) { const a = []; function l(e) { e.id && a.push(e.id), e.childMenuVoList && e.childMenuVoList.length > 0 && e.childMenuVoList.forEach((o) => l(o)); } return t == null || t.forEach((e) => { e.menuVoList && e.menuVoList.length > 0 ? e.menuVoList.forEach((o) => l(o)) : l(e); }), a; } return A(async () => { await M(), u.value && (v.disabled || u.value.forEach((t) => { n.value.forEach((a, l) => { if (t.classify === a.classify) { const e = R(t.menuVoList), o = f.value[l]; e.forEach((s) => { o.setChecked(s, !0, !1); }); } }); }), c.value = u.value[0].classify); }), w({ getCheckedData: C }), (t, a) => { const l = I, e = S, o = q; return r(), p(o, { modelValue: c.value, "onUpdate:modelValue": a[0] || (a[0] = (s) => c.value = s), style: { width: "100%", top: "-4px" }, class: "position-relative" }, { default: h(() => [ v.disabled ? (r(!0), _(b, { key: 0 }, x(u.value, (s, i) => (r(), p(e, { key: i, name: s.classify, label: s.name }, { default: h(() => [ E(l, { ref_for: !0, ref: (m) => k(m, i), style: { "max-width": "600px", "min-width": "200px" }, data: s.menuVoList, "node-key": "id", "highlight-current": "", "default-expand-all": "", props: g }, null, 8, ["data"]) ]), _: 2 }, 1032, ["name", "label"]))), 128)) : (r(!0), _(b, { key: 1 }, x(n.value, (s, i) => (r(), p(e, { key: i, name: s.classify, label: s.name }, { default: h(() => [ E(l, { ref_for: !0, ref: (m) => k(m, i), style: { "max-width": "600px", "min-width": "200px" }, data: s.menuVoList, "node-key": "id", "default-expand-all": "", "highlight-current": "", "show-checkbox": "", props: g }, null, 8, ["data"]) ]), _: 2 }, 1032, ["name", "label"]))), 128)) ]), _: 1 }, 8, ["modelValue"]); }; } }); export { Q as default };