@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.78 kB
JavaScript
import { defineComponent as I, 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 S, vShow as w, nextTick as W } from "vue";
import { pluginManager as m } from "@javaguns/utils";
import { IconSearchOutline as X } from "@javaguns/icon";
import { getPositions 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 = I({ name: "flow-selection-multi-org-tree" }), re = /* @__PURE__ */ I({
...ne,
props: {
headerTitle: { default: "" },
isRadio: { type: Boolean, default: !1 }
},
emits: ["treeSelect", "update:currentSelectOrgId", "load"],
setup(_, { expose: b, emit: R }) {
const O = m.getComponent("InputSearch"), T = m.getComponent("Empty"), D = m.getComponent("Tree"), E = m.getComponent("Button"), s = _, p = a(null), { appContext: U } = z(), f = U.app.config.globalProperties.$flowUI, d = a(""), x = a(!1), B = a(!0), n = a([]), P = a([]), i = a([]), K = a([]), k = a([]);
a([]);
const g = a([]), r = R, V = (t, e) => {
r("treeSelect", e.checkedNodes), k.value = e.checkedNodes;
}, N = (t, e) => {
s.isRadio && (f == "element-plus" ? (r("treeSelect", t), r("update:currentSelectOrgId", t.id)) : (r("treeSelect", e.selectedNodes), r("update:currentSelectOrgId", t[0]), k.value = e.checkedNodes));
}, M = (t) => {
const e = g.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, g.value = t.data.data;
} finally {
x.value = !1;
}
}, $ = async (t) => {
s.isRadio || (f == "element-plus" ? await W(() => {
p.value.setCheckedKeys(t, !1);
}) : (i.value = [], t.forEach((e) => {
i.value.push(e);
})));
}, j = () => {
if (!s.isRadio)
return f == "element-plus" ? p.value.getCheckedKeys(!1) : i.value;
}, q = () => {
if (!s.isRadio)
return f == "element-plus" ? p.value.getCheckedNodes(!1, !1) : k.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(d, (t, e) => {
const l = n.value.map((o) => o.title.indexOf(t) > -1 ? y(o.key, g.value) : null).filter((o, c, C) => o && C.indexOf(o) === c);
P.value = l, d.value = t, B.value = !0;
}), F(async () => {
await G(), r("load", n.value);
}), b({
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(O), {
value: d.value,
"onUpdate:value": e[0] || (e[0] = (l) => d.value = l),
modelValue: d.value,
"onUpdate:modelValue": e[1] || (e[1] = (l) => d.value = l),
"enter-button": "",
clearableplaceholder: "请输入岗位名称",
onChange: M
}, {
append: Q(() => [
v(u(E), { icon: u(X) }, null, 8, ["icon"])
]),
_: 1
}, 8, ["value", "modelValue"])
]),
S(h("div", ae, [
v(u(D), {
ref_key: "treeRef",
ref: p,
class: "filter-tree",
"node-key": "positionId",
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: "positionName", key: "positionId" },
props: { children: "children", label: "positionName", key: "positionId" },
"key-field": "id",
"label-field": "name",
"children-field": "children",
"default-expand-all": !0,
"expand-on-click-node": !1,
onCheck: V,
onSelect: N,
onNodeClick: N
}, null, 8, ["data", "tree-data", "checkable", "show-checkbox", "selectedKeys", "checkedKeys"])
], 512), [
[w, n.value && n.value.length > 0]
]),
S(v(u(T), { description: "暂无数据" }, null, 512), [
[w, n.value && n.value.length === 0]
])
]));
}
});
export {
re as default
};