@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
214 lines (213 loc) • 8.2 kB
JavaScript
import { defineComponent as P, getCurrentInstance as K, ref as g, inject as v, onMounted as O, openBlock as r, createElementBlock as d, createElementVNode as y, createVNode as w, unref as u, Fragment as T, renderList as $, createBlock as c, createCommentVNode as p, toDisplayString as I, withModifiers as F, withCtx as W } from "vue";
import "./style/index.css";
import { pluginManager as j } from "@javaguns/utils";
import { GunsAvatar as m } from "@javaguns/ui";
import { IconPlusOutline as A, IconCloseOutline as G } from "@javaguns/icon";
import { UserInfoConvertKey as q, OrgInfoConverttKey as H, RoleInfoConvertKey as J, PostInfoConvertKey as Q } from "../utils/injection-key.mjs";
import { getUserByIds as X, getDeptByIds as C, getPostByIds as Y, getRoleByIds as Z } from "../utils/adminApi.mjs";
import ee from "./components/index.vue.mjs";
const te = {
key: 0,
class: "add-user-wrapper"
}, se = { class: "select-add-user" }, le = {
key: 0,
class: "select-add-user-span-none"
}, oe = {
key: 1,
class: "select-add-user-span"
}, ae = /* @__PURE__ */ y("div", { class: "select-add-user-icon" }, [
/* @__PURE__ */ y("i", { class: "el-icon-arrow-down" })
], -1), ie = P({ name: "flow-selection" }), ve = /* @__PURE__ */ P({
...ie,
props: {
modelValue: {},
label: {},
title: { default: "请选择" },
open: { type: Boolean, default: !1 },
dialogWidth: { default: "80%" },
type: { default: "user" },
styleType: { default: "default" },
isRadio: { type: Boolean, default: !0 },
showTab: {},
simple: { type: Boolean, default: !1 },
min: { default: 1 },
max: { default: 100 }
},
emits: ["update:modelValue", "update:label", "change"],
setup(k, { expose: D, emit: E }) {
const R = j.getComponent("FormItemRest"), { appContext: b, proxy: B } = K(), t = k, a = g([]), f = g(!1), i = g({
selectUserList: [],
selectDeptPostList: [],
selectPostList: [],
selectRoleList: [],
selectDeptList: []
}), _ = () => {
f.value = !0;
}, U = (e) => {
if (a.value.length - 1 < t.min) {
b.config.globalProperties.$gunsMessage.error("无法删除,最少选择数量 " + t.min);
return;
}
var s = a.value.map((o) => o.id).indexOf(e.id);
a.value.splice(s, 1), L(a.value);
}, N = (e) => {
if (f.value = e, !(!t.modelValue || !t.label) && t.modelValue.length === t.label.length) {
let s = [];
t.modelValue.forEach((o, l) => {
s.push({
id: o,
name: t.label[l]
});
}), a.value = s, t.type && (t.type === "user" ? i.value.selectUserList = s : t.type === "deptPost" ? i.value.selectDeptPostList = s : t.type === "post" ? i.value.selectPostList = s : t.type === "role" ? i.value.selectRoleList = s : t.type === "dept" && (i.value.selectDeptList = s));
}
}, h = E, x = (e) => {
if (t.type) {
a.value = [];
let s = [];
t.type === "user" ? s = e.selectUserList : t.type === "deptPost" ? s = e.selectDeptPostList : t.type === "post" ? s = e.selectPostList : t.type === "role" ? s = e.selectRoleList : t.type === "dept" && (s = e.selectDeptList), t.type === "user" ? i.value.selectUserList = s : t.type === "deptPost" ? i.value.selectDeptPostList = s : t.type === "post" ? i.value.selectPostList = s : t.type === "role" ? i.value.selectRoleList = s : t.type === "dept" && (i.value.selectDeptList = s), s.forEach((o, l) => {
a.value.splice(l, 0, o);
}), console.log("selectedList.value", a.value), L(s), B.$forceUpdate(), f.value = !1;
}
}, L = (e) => {
let s = e.map((l) => l.id), o = e.map((l) => l.name);
t.isRadio && t.simple && (s = s[0], o = o[0], e = e[0]), h("update:modelValue", s), h("update:label", o), h("change", e);
}, z = v(q, (e) => ({
id: e.userId,
name: e.realName
})), V = v(H, (e) => ({
id: e.orgId,
name: e.orgName
})), M = v(J, (e) => ({
id: e.roleId,
name: e.roleName
})), S = v(Q, (e) => ({
id: e.positionId,
name: e.positionName
}));
return O(async () => {
if (a.value.length === 0 && t.modelValue && t.modelValue.length > 0) {
if (t.type === "user")
(await X(t.modelValue)).data.data.forEach((o) => {
const l = z(o);
i.value.selectUserList.push(l), a.value.push(l);
});
else if (t.type === "deptPost") {
let e = [];
typeof t.modelValue == "string" ? e.push(t.modelValue) : t.modelValue.forEach((l) => {
e.push(l);
});
let o = (await C(e)).data.data;
o && o.forEach((l) => {
let n = V(l);
i.value.selectDeptPostList.push(n), a.value.push(n);
});
} else if (t.type === "post") {
let e = [];
typeof t.modelValue == "string" ? e.push(t.modelValue) : t.modelValue.forEach((l) => {
e.push(l);
});
let o = (await Y(e)).data.data;
o && o.forEach((l) => {
let n = S(l);
i.value.selectRoleList.push(n), a.value.push(n);
});
} else if (t.type === "role") {
let e = [];
typeof t.modelValue == "string" ? e.push(t.modelValue) : t.modelValue.forEach((l) => {
e.push(l);
});
let o = (await Z(e)).data.data;
o && o.forEach((l) => {
let n = M(l);
i.value.selectPostList.push(n), a.value.push(n);
});
} else if (t.type === "dept") {
let e = [];
typeof t.modelValue == "string" ? e.push(t.modelValue) : t.modelValue.forEach((l) => {
e.push(l);
});
let o = (await C(e)).data.data;
o && o.forEach((l) => {
let n = V(l);
i.value.selectDeptList.push(n), a.value.push(n);
});
}
}
}), D({}), (e, s) => (r(), d("div", null, [
e.styleType === "default" ? (r(), d("div", te, [
y("div", {
class: "add-user-icon",
onClick: _
}, [
w(u(A))
]),
(r(!0), d(T, null, $(a.value, (o) => (r(), d("div", {
class: "add-user-item",
key: o.id
}, [
e.type == "user" ? (r(), c(u(m), {
key: 0,
size: "m",
icon: "el-icon-user-solid"
})) : p("", !0),
e.type == "deptPost" ? (r(), c(u(m), {
key: 1,
size: "m",
icon: "el-icon-s-cooperation"
})) : p("", !0),
e.type == "post" ? (r(), c(u(m), {
key: 2,
size: "m",
icon: "el-icon-s-cooperation"
})) : p("", !0),
e.type == "dept" ? (r(), c(u(m), {
key: 3,
size: "m",
icon: "el-icon-s-cooperation"
})) : p("", !0),
e.type == "role" ? (r(), c(u(m), {
key: 4,
size: "m",
icon: "el-icon-s-custom"
})) : p("", !0),
y("div", null, I(o.name), 1),
w(u(G), {
onClick: F((l) => U(o), ["stop"])
}, null, 8, ["onClick"])
]))), 128))
])) : p("", !0),
e.styleType === "select" ? (r(), d("div", {
key: 1,
class: "select-add-user-wrapper",
onClick: _
}, [
y("div", se, [
a.value.length === 0 ? (r(), d("span", le, "请选择")) : (r(), d("span", oe, I(a.value.map((o) => o.name).toString()), 1))
]),
ae
])) : p("", !0),
w(u(R), null, {
default: W(() => [
f.value ? (r(), c(ee, {
key: 0,
open: f.value,
title: t.title,
width: t.dialogWidth,
"select-data": a.value,
isRadio: t.isRadio,
type: t.type,
"show-tab": [t.type],
min: t.min,
max: t.max,
onDone: x,
onCancel: N
}, null, 8, ["open", "title", "width", "select-data", "isRadio", "type", "show-tab", "min", "max"])) : p("", !0)
]),
_: 1
})
]));
}
});
export {
ve as default
};