var U = ($, D, g) => new Promise((I, m) => { var O = (u) => { try { c(g.next(u)); } catch (_) { m(_); } }, C = (u) => { try { c(g.throw(u)); } catch (_) { m(_); } }, c = (u) => u.done ? I(u.value) : Promise.resolve(u.value).then(O, C); c((g = g.apply($, D)).next()); }); import { ref as o, watch as re, resolveComponent as j, createElementBlock as y, openBlock as S, createVNode as d, withCtx as h, createElementVNode as t, toDisplayString as i, createTextVNode as A, withModifiers as ve, createCommentVNode as he, Fragment as q, renderList as R } from "vue"; import { D as _e, ao as me, ak as pe, ap as fe, aq as ge, ar as Ce, ck as we, cl as ke, cm as ye } from "./index2.js"; import { _ as Se } from "./Search.js"; const $e = { class: "s-office-select-common" }, be = { class: "modal-container" }, Ne = { class: "side" }, Oe = { class: "main" }, Ve = { class: "filter" }, Le = { class: "list-wrap" }, Te = { class: "item left-wrap" }, Ue = { class: "head" }, je = { class: "sub-title" }, Ae = { class: "right" }, De = { href: "javascript:;" }, Ie = ["onClick"], Be = { class: "icon s-theme-icon-bg" }, Ee = { class: "cont" }, ze = { class: "name" }, Fe = { class: "job" }, Je = { key: 0, class: "not-more" }, Me = { class: "item right-wrap" }, qe = { class: "head" }, Re = { class: "sub-title" }, xe = { class: "icon s-theme-icon-bg" }, Ge = { class: "cont" }, He = { class: "name" }, Ke = { class: "job" }, Pe = ["onClick"], el = { __name: "SUserSelect", props: { ids: { type: [String, Array], default() { return ""; } }, placeholder: { type: String, default() { return window.$l("请选择"); } }, // 弹窗标题 title: { type: String, default() { return window.$l("人员选择"); } } }, emits: ["change"], setup($, { emit: D }) { const g = D, I = $, m = o(""), O = o(""), C = o(""), c = o(!1), u = o(!1), _ = o({}), p = o([]), n = o([]), w = o(1), V = o(0), b = o(!1); let L = null; const N = o(""), v = o([]), T = o(1), F = o(20), B = o(0); re( () => I.ids, (e) => { e && e.length && (n.value = e); }, { immediate: !0 } ); const J = () => { u.value = !0; }, x = () => { u.value = !1; }, k = (e = 1, l = 0) => U(this, null, function* () { if (c.value) { c.value = !1; return; } e === 1 && (v.value = []); let a = []; if (n.value.length < 100 ? (T.value = 1, B.value = 0, a = n.value) : a = n.value.slice(l * (F.value || 20), e * (F.value || 20)), !a.length || v.value.length && a.length >= n.value.length && a.length >= v.value.length) return; c.value = !0; const r = yield ye(a); v.value = v.value.concat(r), H(), L = setTimeout(() => { c.value = !1, clearTimeout(L); }, 200); }), G = () => { if (!N.value) { window.$message.warning("请选择部门"); return; } w.value = 1, p.value = [], E(N.value); }, H = () => { const l = v.value.filter((r) => n.value.includes(r.id)).map((r) => r.name), a = l.length - 1; m.value = l.slice(0, 1).join(",") + (a > 0 ? " +" + a : ""); }, K = () => { p.value.forEach((e) => { if (n.value.includes(e.id)) { const l = n.value.indexOf(e.id); n.value.splice(l, 1); } }), k()(); }, P = () => { b.value = !b.value, b.value ? W() : K(); }, Q = () => U(this, null, function* () { if (!N.value) { window.$message.warning("请选择部门"); return; } const e = { searchValue: C.value, unitid: N.value.join(",") }, l = yield we(e), a = n.value.concat(l); n.value = Array.from(new Set(a)), k(); }), W = () => { p.value.forEach((e) => { n.value.includes(e.id) || n.value.push(e.id); }), k(); }, X = () => { b.value = !1, m.value = "", n.value = [], v.value = []; }, Y = () => { u.value = !1; const e = v.value.filter((f) => n.value.includes(f.id)), l = e.map((f) => f.name), a = l.length - 1, r = l.slice(0, 1).join(",") + (a > 0 ? " +" + a : ""), z = e.map((f) => f.id); g("change", r, l, z, e); }, Z = (e, l) => { _.value = l.node, w.value = 1, V.value = 0, p.value = [], c.value = !0, N.value = e, E(e); }, E = (e) => U(this, null, function* () { const l = { pageNo: w.value, pageSize: 20, searchValue: C.value, unitid: e.join(","), containsChild: !0 }; c.value = !0; const a = yield ke(l); p.value = p.value.concat(a.list), V.value = a.pages, L = setTimeout(() => { c.value = !1, clearTimeout(L); }, 200); }), ee = (e) => { n.value.includes(e.id) || n.value.push(e.id), k(); }, le = (e, l) => { v.value.splice(l, 1), n.value.splice(n.value.indexOf(e.id), 1), k(); }, te = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: a } }) => { c.value || e + a >= l - 20 && w.value <= V.value && (w.value++, E([_.value.id])); }, ae = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: a } }) => { c.value || e + a >= l - 20 && (B.value = T.value, T.value++, k(T.value, B.value)); }, se = (e) => Ce(e), ne = (e) => ge(e); return (e, l) => { const a = Se, r = _e, z = j("s-tree"), f = j("DownOutlined"), oe = fe, ie = pe, ce = me, ue = j("CloseCircleOutlined"), de = j("s-modal"); return S(), y("div", $e, [ d(a, { value: m.value, "onUpdate:value": l[0] || (l[0] = (s) => m.value = s), readonly: "", placeholder: $.placeholder, onClick: J, onSearch: J }, null, 8, ["value", "placeholder"]), d(de, { value: u.value, "onUpdate:value": l[4] || (l[4] = (s) => u.value = s), title: $.title, width: "1000px", showFullScreen: !1 }, { footer: h(() => [ d(r, { key: "back", onClick: x }, { default: h(() => [ A(i(e.$l("取消")), 1) ]), _: 1 }), d(r, { key: "submit", type: "primary", loading: c.value, onClick: Y }, { default: h(() => [ A(i(e.$l("确认")), 1) ]), _: 1 }, 8, ["loading"]) ]), default: h(() => [ t("div", be, [ t("div", Ne, [ d(z, { levelOneChildren: se, levelTwoChildren: ne, "onSelect:modelValue": Z, select: O.value, "onUpdate:select": l[1] || (l[1] = (s) => O.value = s), height: 470 }, null, 8, ["select"]) ]), t("div", Oe, [ t("div", Ve, [ d(a, { value: C.value, "onUpdate:value": l[2] || (l[2] = (s) => C.value = s), placeholder: e.$l("请输入"), style: { width: "330px" }, onSearch: G }, null, 8, ["value", "placeholder"]) ]), t("div", Le, [ t("div", Te, [ t("div", Ue, [ t("div", je, i(_.value.title || _.value.name), 1), t("div", Ae, [ d(r, { type: "link", onClick: P }, { default: h(() => [ A(i(b.value ? e.$l("反选") : e.$l("全选")), 1) ]), _: 1 }), d(ce, null, { overlay: h(() => [ d(ie, null, { default: h(() => [ d(oe, { onClick: Q }, { default: h(() => [ t("a", De, i(e.$l("节点全选")), 1) ]), _: 1 }) ]), _: 1 }) ]), default: h(() => [ t("a", { type: "link", onClick: l[3] || (l[3] = ve(() => { }, ["prevent"])) }, [ d(f) ]) ]), _: 1 }) ]) ]), t("div", { class: "user-list", onScroll: te }, [ (S(!0), y(q, null, R(p.value, (s) => (S(), y("div", { class: "item", key: s.id, onClick: (M) => ee(s) }, [ t("div", Be, i(s.name && s.name.slice(0, 1)), 1), t("div", Ee, [ t("div", ze, i(s.name) + "(" + i(s.userid) + ")", 1), t("div", Fe, i(s.mainJobName), 1) ]) ], 8, Ie))), 128)), w.value >= V.value ? (S(), y("div", Je, i(e.$l("没有更多了")), 1)) : he("", !0) ], 32) ]), t("div", Me, [ t("div", qe, [ t("div", Re, i(e.$l("本次已选")), 1), d(r, { type: "link", onClick: X }, { default: h(() => [ A(i(e.$l("清除")), 1) ]), _: 1 }) ]), t("div", { class: "user-list select-list", onScroll: ae }, [ (S(!0), y(q, null, R(v.value, (s, M) => (S(), y("div", { class: "item", key: s.id }, [ t("div", xe, i(s.name && s.name.slice(0, 1)), 1), t("div", Ge, [ t("div", He, i(s.title), 1), t("div", Ke, i(s.mainJobName), 1) ]), t("div", { class: "icon no-bg", onClick: (Qe) => le(s, M) }, [ d(ue) ], 8, Pe) ]))), 128)) ], 32) ]) ]) ]) ]) ]), _: 1 }, 8, ["value", "title"]) ]); }; } }; export { el as default };