var T = ($, 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 J, renderList as R } from "vue"; import { l as _e, a as pe, j as me, g as fe, p as ge } from "./common.js"; import { _ as Ce } from "./Search.js"; import "./index15.js"; import { D as we, ao as ye, ak as ke, ap 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" }, je = { class: "list-wrap" }, Le = { class: "item left-wrap" }, Te = { 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" }, 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"], tl = { __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 j = null; const O = o(""), v = o([]), L = o(1), M = o(20), B = o(0); re( () => I.ids, (e) => { e && e.length && (s.value = e); }, { immediate: !0 } ); const z = () => { u.value = !0; }, q = () => { u.value = !1; }, y = (e = 1, l = 0) => T(this, null, function* () { if (c.value) { c.value = !1; return; } e === 1 && (v.value = []); let n = []; if (s.value.length < 100 ? (L.value = 1, B.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; c.value = !0; const r = yield ge(n); v.value = v.value.concat(r), H(), j = setTimeout(() => { c.value = !1, clearTimeout(j); }, 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), n = l.length - 1; p.value = l.slice(0, 1).join(",") + (n > 0 ? " +" + n : ""); }, 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 = () => T(this, null, function* () { if (!O.value) { window.$message.warning("请选择部门"); return; } const e = { searchValue: C.value, unitid: O.value.join(",") }, l = yield me(e), n = s.value.concat(l); s.value = Array.from(new Set(n)), 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), n = l.length - 1, r = l.slice(0, 1).join(",") + (n > 0 ? " +" + n : ""), 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) => T(this, null, function* () { const l = { pageNo: w.value, pageSize: 20, searchValue: C.value, unitid: e.join(","), containsChild: !0 }; c.value = !0; const n = yield fe(l); m.value = m.value.concat(n.list), V.value = n.pages, j = setTimeout(() => { c.value = !1, clearTimeout(j); }, 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 } }) => { c.value || e + n >= l - 20 && w.value <= V.value && (w.value++, E([_.value.id])); }, ne = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: n } }) => { c.value || e + n >= l - 20 && (B.value = L.value, L.value++, y(L.value, B.value)); }, ae = (e) => pe(e), se = (e) => _e(e); return (e, l) => { const n = Ce, r = we, F = A("s-tree"), f = A("DownOutlined"), oe = Se, ie = ke, ce = ye, ue = A("CloseCircleOutlined"), de = A("s-modal"); return S(), k("div", $e, [ d(n, { value: p.value, "onUpdate:value": l[0] || (l[0] = (a) => p.value = a), readonly: "", placeholder: $.placeholder, onClick: z, onSearch: z }, null, 8, ["value", "placeholder"]), d(de, { value: u.value, "onUpdate:value": l[4] || (l[4] = (a) => u.value = a), title: $.title, width: "1000px", showFullScreen: !1 }, { footer: h(() => [ d(r, { key: "back", onClick: q }, { 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: ae, levelTwoChildren: se, "onSelect:modelValue": Z, select: N.value, "onUpdate:select": l[1] || (l[1] = (a) => N.value = a), height: 470 }, null, 8, ["select"]) ]), t("div", Ne, [ t("div", Ve, [ d(n, { value: C.value, "onUpdate:value": l[2] || (l[2] = (a) => C.value = a), placeholder: e.$l("请输入"), style: { width: "330px" }, onSearch: x }, null, 8, ["value", "placeholder"]) ]), t("div", je, [ t("div", Le, [ t("div", Te, [ 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(J, null, R(m.value, (a) => (S(), k("div", { class: "item", key: a.id, onClick: (G) => ee(a) }, [ t("div", Be, 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)), w.value >= V.value ? (S(), k("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(() => [ U(i(e.$l("清除")), 1) ]), _: 1 }) ]), t("div", { class: "user-list select-list", onScroll: ne }, [ (S(!0), k(J, null, R(v.value, (a, G) => (S(), k("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(ue) ], 8, Pe) ]))), 128)) ], 32) ]) ]) ]) ]) ]), _: 1 }, 8, ["value", "title"]) ]); }; } }; export { tl as default };