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