| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- var j = (S, F, w) => new Promise((I, m) => {
- var M = (h) => {
- try {
- g(w.next(h));
- } catch (y) {
- m(y);
- }
- }, T = (h) => {
- try {
- g(w.throw(h));
- } catch (y) {
- m(y);
- }
- }, g = (h) => h.done ? I(h.value) : Promise.resolve(h.value).then(M, T);
- g((w = w.apply(S, F)).next());
- });
- import { ref as u, watch as Ce, onMounted as ke, resolveComponent as J, openBlock as d, createElementBlock as v, createVNode as f, withCtx as $, createElementVNode as s, toDisplayString as i, createTextVNode as b, createCommentVNode as te, Fragment as q, renderList as ae } from "vue";
- import { aC as Se, B as we, dx as se, df as $e, dg as be, dy as Ee } from "./index2.js";
- const Ae = { class: "s-office-select-common" }, Le = { class: "modal-container" }, Ne = { class: "side" }, Ie = { class: "main" }, Te = { class: "filter" }, Ue = { class: "list-wrap" }, Ve = { class: "item left-wrap" }, Oe = { class: "head" }, Be = { class: "sub-title" }, Re = {
- key: 0,
- class: "right"
- }, je = ["onClick"], qe = { class: "icon s-theme-icon-bg" }, Fe = ["src", "onError"], Me = { class: "cont" }, xe = { class: "name" }, Pe = { class: "job" }, ze = {
- key: 0,
- class: "not-more"
- }, Je = { class: "item right-wrap" }, De = { class: "head" }, Ke = { class: "sub-title" }, Ge = { class: "icon s-theme-icon-bg" }, He = ["src", "onError"], Qe = { class: "cont" }, We = { class: "name" }, Xe = { class: "job" }, Ye = ["onClick"], tl = {
- __name: "SUserSelect",
- props: {
- // 选中值(v-model:value)
- value: {
- type: [String, Array],
- default() {
- return "";
- }
- },
- // 占位文案
- placeholder: {
- type: String,
- default() {
- return window.$l("请选择");
- }
- },
- // 弹窗标题
- title: {
- type: String,
- default() {
- return window.$l("人员选择");
- }
- },
- // 是否多选,传 false 为单选(只保留最后选中的一个)
- multiple: {
- type: Boolean,
- default: !0
- }
- },
- emits: ["change", "update:value"],
- setup(S, { expose: F, emit: w }) {
- var ee, le;
- const I = w, m = S, M = (((le = (ee = window.$utils) == null ? void 0 : ee.env) == null ? void 0 : le.VITE_APP_API_FILE_URL) || "/") + "", T = (e) => /^https?:\/\//.test(e) ? e : `${M}file/preview?id=${e}`, g = u(""), h = u(""), y = u(""), p = u(!1), E = u(!1), U = u({}), C = u([]), n = u([]), k = u(1), A = u(0), L = u(!1);
- let V = null;
- const D = u(""), c = u([]), O = u(1), K = u(20), x = u(0);
- let G = 0, H = "", Q = !1;
- const W = (e) => {
- if (e && e.length) {
- const l = Array.isArray(e) ? e : [e];
- n.value = m.multiple ? l : l.slice(0, 1);
- } else
- n.value = [];
- };
- Ce(
- () => m.value,
- (e) => {
- W(e), Q && B();
- },
- { immediate: !0 }
- );
- const X = () => {
- E.value = !0, B();
- }, Y = () => {
- X();
- }, ne = () => {
- E.value = !1, W(m.value), B();
- }, N = (e = 1, l = 0) => j(this, null, function* () {
- if (p.value) {
- p.value = !1;
- return;
- }
- e === 1 && (c.value = []);
- let a = [];
- if (n.value.length < 100 ? (O.value = 1, x.value = 0, a = n.value) : a = n.value.slice(l * (K.value || 20), e * (K.value || 20)), !a.length || c.value.length && a.length >= n.value.length && a.length >= c.value.length)
- return;
- p.value = !0;
- const o = yield se(a), _ = c.value.concat(o || []);
- c.value = [...new Map(_.map((r) => [r.id, r])).values()], V = setTimeout(() => {
- p.value = !1, clearTimeout(V);
- }, 200);
- }), oe = () => {
- k.value = 1, A.value = 0, C.value = [], P();
- }, Z = () => {
- const l = c.value.filter((o) => n.value.includes(o.id)).map((o) => o.name), a = l.length - 1;
- g.value = l.slice(0, 1).join(",") + (a > 0 ? " +" + a : "");
- }, B = () => j(this, null, function* () {
- if (!n.value.length) {
- g.value = "", c.value = [];
- return;
- }
- const e = yield se(n.value);
- c.value = e || [], Z();
- });
- ke(() => {
- Q = !0, B();
- });
- const ue = () => {
- C.value.forEach((e) => {
- if (n.value.includes(e.id)) {
- const l = n.value.indexOf(e.id);
- n.value.splice(l, 1);
- }
- }), N();
- }, ce = () => {
- L.value = !L.value, L.value ? ie() : ue();
- }, ie = () => {
- C.value.forEach((e) => {
- n.value.includes(e.id) || n.value.push(e.id);
- }), N();
- }, re = () => {
- L.value = !1, n.value = [], c.value = [];
- }, de = () => {
- E.value = !1;
- const e = c.value.filter((r) => n.value.includes(r.id)), l = e.map((r) => r.name), a = l.length - 1, o = l.slice(0, 1).join(",") + (a > 0 ? " +" + a : ""), _ = e.map((r) => r.id);
- I("update:value", m.multiple ? _ : _[0] || ""), I("change", o, l, _, e), Z();
- }, ve = (e, l) => {
- var o;
- const a = Array.isArray(e) ? e : e ? [e] : [];
- a.length && (U.value = ((o = l == null ? void 0 : l.node) == null ? void 0 : o.dataRef) || (l == null ? void 0 : l.node) || {}, D.value = a, k.value = 1, A.value = 0, C.value = [], P());
- }, P = () => j(this, null, function* () {
- const e = ++G, l = U.value || {}, a = `${(D.value || [])[0]}_${k.value}_${y.value}`;
- if (a === H && p.value) return;
- H = a;
- const o = {
- pageNum: k.value,
- pageSize: 20,
- searchValue: y.value,
- unitId: l.id,
- unitType: l.type,
- containsChild: !0,
- isEnabled: !0
- };
- p.value = !0;
- const _ = yield Ee(o);
- if (e !== G) return;
- const r = C.value.concat(_.list || []);
- C.value = [...new Map(r.map((R) => [R.id, R])).values()], A.value = _.pages, V = setTimeout(() => {
- p.value = !1, clearTimeout(V);
- }, 200);
- }), he = (e) => {
- if (!m.multiple) {
- n.value = [e.id], c.value = [e];
- return;
- }
- n.value.includes(e.id) || n.value.push(e.id), N();
- }, pe = (e, l) => {
- c.value.splice(l, 1), n.value.splice(n.value.indexOf(e.id), 1), N();
- }, _e = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: a } }) => {
- p.value || e + a >= l - 20 && k.value < A.value && (k.value++, P());
- }, fe = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: a } }) => {
- p.value || e + a >= l - 20 && (x.value = O.value, O.value++, N(O.value, x.value));
- }, me = (e) => be(e), ge = (e) => $e(e);
- return F({ open: X }), (e, l) => {
- const a = Se, o = we, _ = J("s-tree"), r = J("CloseCircleOutlined"), R = J("s-modal");
- return d(), v("div", Ae, [
- f(a, {
- value: g.value,
- "onUpdate:value": l[0] || (l[0] = (t) => g.value = t),
- readonly: !0,
- placeholder: S.placeholder,
- onClick: Y,
- onSearch: Y
- }, null, 8, ["value", "placeholder"]),
- f(R, {
- value: E.value,
- "onUpdate:value": l[3] || (l[3] = (t) => E.value = t),
- title: S.title,
- width: "1000px",
- showFullScreen: !1
- }, {
- footer: $(() => [
- f(o, {
- key: "back",
- onClick: ne
- }, {
- default: $(() => [
- b(i(e.$l("取消")), 1)
- ]),
- _: 1
- }),
- f(o, {
- key: "submit",
- type: "primary",
- loading: p.value,
- onClick: de
- }, {
- default: $(() => [
- b(i(e.$l("确认")), 1)
- ]),
- _: 1
- }, 8, ["loading"])
- ]),
- default: $(() => [
- s("div", Le, [
- s("div", Ne, [
- f(_, {
- levelOneChildren: me,
- levelTwoChildren: ge,
- "onSelect:modelValue": ve,
- select: h.value,
- "onUpdate:select": l[1] || (l[1] = (t) => h.value = t),
- height: 470
- }, null, 8, ["select"])
- ]),
- s("div", Ie, [
- s("div", Te, [
- f(a, {
- value: y.value,
- "onUpdate:value": l[2] || (l[2] = (t) => y.value = t),
- placeholder: e.$l("请输入"),
- style: { width: "330px" },
- onSearch: oe
- }, null, 8, ["value", "placeholder"])
- ]),
- s("div", Ue, [
- s("div", Ve, [
- s("div", Oe, [
- s("div", Be, i(U.value.title || U.value.name), 1),
- S.multiple ? (d(), v("div", Re, [
- f(o, {
- type: "link",
- onClick: ce
- }, {
- default: $(() => [
- b(i(L.value ? e.$l("反选") : e.$l("全选")), 1)
- ]),
- _: 1
- })
- ])) : te("", !0)
- ]),
- s("div", {
- class: "user-list",
- onScroll: _e
- }, [
- (d(!0), v(q, null, ae(C.value, (t) => (d(), v("div", {
- class: "item",
- key: t.id,
- onClick: (z) => he(t)
- }, [
- s("div", qe, [
- t.avatar || t.cover ? (d(), v("img", {
- key: 0,
- class: "avatar-img",
- src: T(t.avatar || t.cover),
- alt: "",
- onError: (z) => t.cover = ""
- }, null, 40, Fe)) : (d(), v(q, { key: 1 }, [
- b(i(t.name && t.name.slice(0, 1)), 1)
- ], 64))
- ]),
- s("div", Me, [
- s("div", xe, i(t.name + (t.userid || t.loginName ? "(" + (t.userid || t.loginName) + ")" : "")), 1),
- s("div", Pe, i(t.mainJobName), 1)
- ])
- ], 8, je))), 128)),
- k.value >= A.value ? (d(), v("div", ze, i(e.$l("没有更多了")), 1)) : te("", !0)
- ], 32)
- ]),
- s("div", Je, [
- s("div", De, [
- s("div", Ke, i(e.$l("本次已选")), 1),
- f(o, {
- type: "link",
- onClick: re
- }, {
- default: $(() => [
- b(i(e.$l("清除")), 1)
- ]),
- _: 1
- })
- ]),
- s("div", {
- class: "user-list select-list",
- onScroll: fe
- }, [
- (d(!0), v(q, null, ae(c.value, (t, z) => (d(), v("div", {
- class: "item",
- key: t.id
- }, [
- s("div", Ge, [
- t.avatar || t.cover ? (d(), v("img", {
- key: 0,
- class: "avatar-img",
- src: T(t.avatar || t.cover),
- alt: "",
- onError: (ye) => t.cover = ""
- }, null, 40, He)) : (d(), v(q, { key: 1 }, [
- b(i(t.name && t.name.slice(0, 1)), 1)
- ], 64))
- ]),
- s("div", Qe, [
- s("div", We, i(t.name || t.title), 1),
- s("div", Xe, i(t.mainJobName), 1)
- ]),
- s("div", {
- class: "icon no-bg",
- onClick: (ye) => pe(t, z)
- }, [
- f(r)
- ], 8, Ye)
- ]))), 128))
- ], 32)
- ])
- ])
- ])
- ])
- ]),
- _: 1
- }, 8, ["value", "title"])
- ]);
- };
- }
- };
- export {
- tl as default
- };
|