@javaguns/flow-ui
Version:
``` <template> <a-spin :spinning="loading"> <FlowDesigner ref="flowDesigner" top="50px"> </FlowDesigner> </a-spin> </template> <script lang="ts" setup> import { ref, provide, onMounted } from 'vue'; import { FlowDesigner, LoadingKey } from '@j
116 lines (115 loc) • 4.73 kB
JavaScript
import { defineComponent as _, ref as a, getCurrentInstance as z, watch as A, onMounted as F, openBlock as H, createElementBlock as J, createElementVNode as h, toDisplayString as L, createVNode as v, unref as u, withCtx as Q, withDirectives as w, vShow as N, nextTick as W } from "vue";
import { pluginManager as m } from "@javaguns/utils";
import { IconSearchOutline as X } from "@javaguns/icon";
import { getOrgTree as Y } from "../../utils/adminApi.mjs";
const Z = { class: "flow-select-org-tree" }, ee = { class: "left-header" }, te = { class: "left-header-title" }, le = { class: "search" }, ae = { class: "left-tree" }, ne = _({ name: "flow-selection-multi-org-tree" }), de = /* @__PURE__ */ _({
...ne,
props: {
headerTitle: { default: "" },
isRadio: { type: Boolean, default: !1 }
},
emits: ["treeSelect", "update:currentSelectOrgId", "load"],
setup(b, { expose: I, emit: O }) {
const R = m.getComponent("InputSearch"), T = m.getComponent("Empty"), D = m.getComponent("Tree"), E = m.getComponent("Button"), s = b, f = a(null), { appContext: U } = z(), p = U.app.config.globalProperties.$flowUI, r = a(""), x = a(!1), B = a(!0), n = a([]), V = a([]), i = a([]), K = a([]), g = a([]);
a([]);
const k = a([]), d = O, P = (t, e) => {
d("treeSelect", e.checkedNodes), g.value = e.checkedNodes;
}, S = (t, e) => {
s.isRadio && (p == "element-plus" ? (d("treeSelect", t), d("update:currentSelectOrgId", t.id)) : (d("treeSelect", e.selectedNodes), d("update:currentSelectOrgId", t[0]), g.value = e.checkedNodes));
}, M = (t) => {
const e = k.value.filter((l) => l.name.indexOf(t) !== -1);
n.value = e;
}, G = async () => {
try {
x.value = !0;
const t = await Y({});
n.value = t.data.data, k.value = t.data.data;
} finally {
x.value = !1;
}
}, $ = async (t) => {
s.isRadio || (p == "element-plus" ? await W(() => {
f.value.setCheckedKeys(t, !1);
}) : (i.value = [], t.forEach((e) => {
i.value.push(e);
})));
}, j = () => {
if (!s.isRadio)
return p == "element-plus" ? f.value.getCheckedKeys(!1) : i.value;
}, q = () => {
if (!s.isRadio)
return p == "element-plus" ? f.value.getCheckedNodes(!1, !1) : g.value;
}, y = (t, e) => {
let l;
for (let o = 0; o < e.length; o++) {
const c = e[o];
c.children && (c.children.some((C) => C.key === t) ? l = c.key : y(t, c.children) && (l = y(t, c.children)));
}
return l;
};
return A(r, (t, e) => {
const l = n.value.map((o) => o.title.indexOf(t) > -1 ? y(o.key, k.value) : null).filter((o, c, C) => o && C.indexOf(o) === c);
V.value = l, r.value = t, B.value = !0;
}), F(async () => {
await G(), d("load", n.value);
}), I({
setCheckedKeys: $,
getCheckedKeys: j,
getCheckedNodes: q
}), (t, e) => (H(), J("div", Z, [
h("div", ee, [
h("span", te, L(s.headerTitle), 1)
]),
h("div", le, [
v(u(R), {
value: r.value,
"onUpdate:value": e[0] || (e[0] = (l) => r.value = l),
modelValue: r.value,
"onUpdate:modelValue": e[1] || (e[1] = (l) => r.value = l),
"enter-button": "",
clearableplaceholder: "请输入机构名称",
onChange: M
}, {
append: Q(() => [
v(u(E), { icon: u(X) }, null, 8, ["icon"])
]),
_: 1
}, 8, ["value", "modelValue"])
]),
w(h("div", ae, [
v(u(D), {
ref_key: "treeRef",
ref: f,
class: "filter-tree",
"node-key": "id",
data: n.value,
"tree-data": n.value,
checkable: !s.isRadio,
"show-checkbox": !s.isRadio,
selectedKeys: K.value,
"onUpdate:selectedKeys": e[2] || (e[2] = (l) => K.value = l),
checkedKeys: i.value,
"onUpdate:checkedKeys": e[3] || (e[3] = (l) => i.value = l),
fieldNames: { children: "children", title: "name", key: "id" },
props: { children: "children", label: "name" },
"key-field": "id",
"label-field": "name",
"children-field": "children",
"default-expand-all": !0,
"expand-on-click-node": !1,
onCheck: P,
onSelect: S,
onNodeClick: S
}, null, 8, ["data", "tree-data", "checkable", "show-checkbox", "selectedKeys", "checkedKeys"])
], 512), [
[N, n.value && n.value.length > 0]
]),
w(v(u(T), { description: "暂无数据" }, null, 512), [
[N, n.value && n.value.length === 0]
])
]));
}
});
export {
de as default
};