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