| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- var m = (d, v, o) => new Promise((r, t) => {
- var i = (a) => {
- try {
- c(o.next(a));
- } catch (u) {
- t(u);
- }
- }, s = (a) => {
- try {
- c(o.throw(a));
- } catch (u) {
- t(u);
- }
- }, c = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(i, s);
- c((o = o.apply(d, v)).next());
- });
- import { ref as h, onMounted as b, openBlock as _, createElementBlock as k, createVNode as B, withCtx as y, createBlock as C, createElementVNode as x, toDisplayString as f, createTextVNode as D, normalizeClass as S } from "vue";
- import { n as V, x as I, y as E } from "./index2.js";
- const N = { class: "s-tree-common" }, O = { class: "node-title" }, T = {
- key: 1,
- class: "node-title"
- }, F = {
- __name: "STree",
- props: {
- // 是否展开所有节点
- expandAll: {
- type: Boolean,
- default: !1
- },
- // 树节点属性
- props: {
- type: Object,
- default: () => ({
- children: "children",
- label: "name",
- value: "value"
- })
- },
- // 是否添加复选框
- checkable: {
- type: Boolean,
- default: !1
- },
- // 树高度:默认不传,由外层容器(layout 的 .s-side-tree > .s-tree-common { height:100% })撑满并滚动。
- // 注意:a-tree 的 height 会让 antd 在 .ant-tree-list-holder 上写死 max-height 内联样式(vc-virtual-list/List.js
- // 在 fullHeight:false 时用 maxHeight),写死数值会让树被截断,故默认 undefined;业务确有固定高度需求时再显式传。
- height: {
- type: Number,
- default: void 0
- },
- // 获取一级节点数据
- levelOneChildren: {
- type: Function,
- default: () => {
- }
- },
- // 获取二级节点数据
- levelTwoChildren: {
- type: Function,
- default: () => {
- }
- },
- // 默认选中项,支持 v-model 双向绑定
- modelValue: {
- type: [String, Array],
- default() {
- return "";
- }
- },
- // 默认选中第一个节点
- selectFirstOne: {
- type: Boolean,
- default: !1
- },
- // 是否显示图标
- showIcon: {
- type: Boolean,
- default: !1
- },
- // 显示字数长度 超过15字符显示省略号并且鼠标悬浮tooltip显示
- showLength: {
- type: [Number, String],
- default: 15
- }
- },
- emits: ["select:modelValue"],
- setup(d, { emit: v }) {
- const o = d, r = v, t = h([]), i = h([]), s = h([]), c = h([]), a = (n, e) => m(this, null, function* () {
- e.expanded && (!e.node.dataRef.children || e.node.dataRef.children.length === 0) && (e.node.dataRef.children = yield o.levelOneChildren(e.node.dataRef.id)), n.value = n;
- }), u = (n, e) => {
- r("select:modelValue", n, e);
- }, K = () => m(this, null, function* () {
- var n, e, p;
- s.value = [], t.value = (yield o.levelTwoChildren("")) || [], (n = t.value) != null && n.length && t.value[0] && ((e = t.value[0].children) != null && e.length) && (o.selectFirstOne && (t.value[0].selected = !0, i.value.push(((p = t.value[0]) == null ? void 0 : p.id) || ""), r("select:modelValue", t.value[0].id || "", t.value[0])), s.value = [t.value[0].id]);
- }), g = (n) => ["D", "G", "C", "D"][n];
- return b(() => {
- K();
- }), (n, e) => {
- const p = E, w = I;
- return _(), k("div", N, [
- B(w, {
- selectedKeys: i.value,
- "onUpdate:selectedKeys": e[0] || (e[0] = (l) => i.value = l),
- checkedKeys: s.value,
- "onUpdate:checkedKeys": e[1] || (e[1] = (l) => s.value = l),
- expandedKeys: c.value,
- "onUpdate:expandedKeys": e[2] || (e[2] = (l) => c.value = l),
- "default-expand-all": d.expandAll,
- checkable: d.checkable,
- "tree-data": t.value,
- showIcon: d.showIcon,
- height: d.height,
- onExpand: a,
- onSelect: u
- }, {
- icon: y((l) => [
- x("div", {
- class: S(["node-icon", g(l.type)])
- }, f(g(l.type)), 3)
- ]),
- title: y((l) => [
- (l.title || "").length > 15 ? (_(), C(p, {
- key: 0,
- placement: "topLeft",
- mouseEnterDelay: 1.5,
- mouseLeaveDelay: 0.5
- }, {
- title: y(() => [
- D(f(l.title), 1)
- ]),
- default: y(() => [
- x("div", O, f((l.title || "").slice(0, 15)) + "...", 1)
- ]),
- _: 2
- }, 1024)) : (_(), k("div", T, f(l.title), 1))
- ]),
- _: 1
- }, 8, ["selectedKeys", "checkedKeys", "expandedKeys", "default-expand-all", "checkable", "tree-data", "showIcon", "height"])
- ]);
- };
- }
- }, U = /* @__PURE__ */ V(F, [["__scopeId", "data-v-63703ca2"]]);
- export {
- U as default
- };
|