@cdwx/system
Version:
成都文宣业务类服务模块组件库
132 lines (131 loc) • 5.22 kB
JavaScript
/* 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 D, mergeModels as P, useModel as A, computed as N, ref as m, onMounted as R, openBlock as r, createBlock as h, withCtx as V, createElementBlock as x, Fragment as w, renderList as M, createVNode as E } from "vue";
import { getAllByPackageCode as T } from "../workspace/code/cloud-frontend/service-modules/system/src/api/api-menu.js";
import { ElTree as S } 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 q, ElTabs as F } 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 W = /* @__PURE__ */ D({
name: "PackageTree",
__name: "tree",
props: /* @__PURE__ */ P({
disabled: { type: Boolean, default: !1 }
}, {
modelValue: { required: !0 },
modelModifiers: {}
}),
emits: ["update:modelValue"],
setup(v, { expose: b }) {
const f = v, k = A(v, "modelValue"), u = N({
get() {
return k.value;
},
set(e) {
k.value = e;
}
}), d = m(), L = {
children: "childMenuVoList",
label: "name"
}, s = m([]);
function c(e) {
return Array.isArray(e) ? e.map((a) => c(a)) : (typeof e == "object" && e !== null && (Object.assign(e, { disabled: f.disabled }), e.menuVoList && (e.menuVoList = c(e.menuVoList)), e.childMenuVoList && (e.childMenuVoList = c(e.childMenuVoList))), e);
}
async function C() {
s.value = [];
try {
const { data: e } = await T({
classify: ""
}), a = e.map((t) => ({
classify: t.classify,
name: t.name,
menuVoList: c(t.menuVoList)
}));
s.value = a, d.value = a[0].classify;
} catch {
s.value = [];
}
}
const p = m([]);
function _(e, a) {
e && (p.value[a] = e);
}
const g = m({});
async function B() {
var e;
return await ((e = p.value) == null ? void 0 : e.forEach((a, t) => {
const n = [];
a.getCheckedNodes(!1, !0).forEach((o) => {
n.push({
id: o.id,
code: o.code,
name: o.name
});
}), Reflect.set(g.value, s.value[t].classify, n);
})), g.value;
}
return R(async () => {
await C(), u.value && (f.disabled || u.value.forEach((e) => {
s.value.forEach((a, t) => {
e.classify === a.classify && p.value[t].setCheckedNodes(e.menuVoList, !1);
});
}), d.value = u.value[0].classify);
}), b({
getCheckedData: B
}), (e, a) => {
const t = S, n = q, o = F;
return r(), h(o, {
modelValue: d.value,
"onUpdate:modelValue": a[0] || (a[0] = (l) => d.value = l),
style: { width: "100%", top: "-4px" },
class: "position-relative"
}, {
default: V(() => [
f.disabled ? (r(!0), x(w, { key: 0 }, M(u.value, (l, i) => (r(), h(n, {
key: i,
name: l.classify,
label: l.name
}, {
default: V(() => [
E(t, {
ref_for: !0,
ref: (y) => _(y, i),
style: { "max-width": "600px", "min-width": "200px" },
data: l.menuVoList,
"node-key": "id",
"default-expand-all": "",
"highlight-current": "",
props: L
}, null, 8, ["data"])
]),
_: 2
}, 1032, ["name", "label"]))), 128)) : (r(!0), x(w, { key: 1 }, M(s.value, (l, i) => (r(), h(n, {
key: i,
name: l.classify,
label: l.name
}, {
default: V(() => [
E(t, {
ref_for: !0,
ref: (y) => _(y, i),
style: { "max-width": "600px", "min-width": "200px" },
data: l.menuVoList,
"node-key": "id",
"highlight-current": "",
"default-expand-all": "",
"show-checkbox": "",
props: L
}, null, 8, ["data"])
]),
_: 2
}, 1032, ["name", "label"]))), 128))
]),
_: 1
}, 8, ["modelValue"]);
};
}
});
export {
W as default
};