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