SOfficeSelect.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. var U = ($, D, p) => new Promise((b, m) => {
  2. var A = (c) => {
  3. try {
  4. u(p.next(c));
  5. } catch (_) {
  6. m(_);
  7. }
  8. }, w = (c) => {
  9. try {
  10. u(p.throw(c));
  11. } catch (_) {
  12. m(_);
  13. }
  14. }, u = (c) => c.done ? b(c.value) : Promise.resolve(c.value).then(A, w);
  15. u((p = p.apply($, D)).next());
  16. });
  17. import { ref as o, watch as re, resolveComponent as B, 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 G, renderList as J, createCommentVNode as he } from "vue";
  18. import { aq as _e, B as pe, d0 as me, cM as fe, cN as ge, d1 as we, d2 as Ce, d3 as ye, d4 as ke, d5 as Se } from "./index2.js";
  19. 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" }, Ue = { class: "right" }, Be = { href: "javascript:;" }, Ie = ["onClick"], De = { class: "icon s-theme-icon-bg" }, Ee = { class: "cont" }, Me = { class: "name" }, Fe = { class: "job" }, qe = {
  20. key: 0,
  21. class: "not-more"
  22. }, 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"], Ze = {
  23. __name: "SOfficeSelect",
  24. props: {
  25. value: {
  26. type: [String, Array],
  27. default() {
  28. return "";
  29. }
  30. },
  31. // 是否多选,传 false 为单选
  32. multiple: {
  33. type: Boolean,
  34. default: !0
  35. },
  36. placeholder: {
  37. type: String,
  38. default() {
  39. return window.$l("请选择");
  40. }
  41. },
  42. // 弹窗标题
  43. title: {
  44. type: String,
  45. default() {
  46. return window.$l("岗位选择");
  47. }
  48. }
  49. },
  50. emits: ["change", "update:value"],
  51. setup($, { emit: D }) {
  52. 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);
  53. let T = null;
  54. const N = o(""), v = o([]), j = o(1), F = o(20), E = o(0);
  55. re(
  56. () => b.value,
  57. (e) => {
  58. if (e && e.length) {
  59. const l = Array.isArray(e) ? e : [e];
  60. s.value = b.multiple ? l : l.slice(0, 1);
  61. } else
  62. s.value = [];
  63. },
  64. { immediate: !0 }
  65. );
  66. const q = () => {
  67. c.value = !0;
  68. }, R = () => {
  69. c.value = !1;
  70. }, y = (e = 1, l = 0) => U(this, null, function* () {
  71. if (u.value) {
  72. u.value = !1;
  73. return;
  74. }
  75. e === 1 && (v.value = []);
  76. let n = [];
  77. if (s.value.length < 100 ? (j.value = 1, E.value = 0, n = s.value) : n = s.value.slice(l * (F.value || 20), e * (F.value || 20)), !n.length || v.value.length && n.length >= s.value.length && n.length >= v.value.length)
  78. return;
  79. u.value = !0;
  80. const r = yield Se(n);
  81. v.value = v.value.concat(r), H(), T = setTimeout(() => {
  82. u.value = !1, clearTimeout(T);
  83. }, 200);
  84. }), x = () => {
  85. if (!N.value) {
  86. window.$message.warning(window.$l("请选择部门"));
  87. return;
  88. }
  89. C.value = 1, f.value = [], M(N.value);
  90. }, H = () => {
  91. const l = v.value.filter((r) => s.value.includes(r.id)).map((r) => r.name), n = l.length - 1;
  92. m.value = l.slice(0, 1).join(",") + (n > 0 ? " +" + n : "");
  93. }, K = () => {
  94. f.value.forEach((e) => {
  95. if (s.value.includes(e.id)) {
  96. const l = s.value.indexOf(e.id);
  97. s.value.splice(l, 1);
  98. }
  99. }), y()();
  100. }, P = () => {
  101. O.value = !O.value, O.value ? W() : K();
  102. }, Q = () => U(this, null, function* () {
  103. if (!N.value) {
  104. window.$message.warning(window.$l("请选择部门"));
  105. return;
  106. }
  107. const e = {
  108. searchValue: w.value,
  109. unitid: N.value.join(",")
  110. }, l = yield ye(e), n = s.value.concat(l);
  111. s.value = Array.from(new Set(n)), y();
  112. }), W = () => {
  113. f.value.forEach((e) => {
  114. s.value.includes(e.id) || s.value.push(e.id);
  115. }), y();
  116. }, X = () => {
  117. O.value = !1, m.value = "", s.value = [], v.value = [];
  118. }, Y = () => {
  119. c.value = !1;
  120. 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);
  121. p("update:value", b.multiple ? V : V[0] || ""), p("change", r, l, V, e);
  122. }, Z = (e, l) => {
  123. _.value = l.node, C.value = 1, L.value = 0, f.value = [], u.value = !0, N.value = e, M(e);
  124. }, M = (e) => U(this, null, function* () {
  125. const l = {
  126. pageNo: C.value,
  127. pageSize: 20,
  128. searchValue: w.value,
  129. unitid: e.join(","),
  130. containsChild: !0
  131. };
  132. u.value = !0;
  133. const n = yield ke(l);
  134. f.value = f.value.concat(n.list), L.value = n.pages, T = setTimeout(() => {
  135. u.value = !1, clearTimeout(T);
  136. }, 200);
  137. }), ee = (e) => {
  138. s.value.includes(e.id) || s.value.push(e.id), y();
  139. }, le = (e, l) => {
  140. v.value.splice(l, 1), s.value.splice(s.value.indexOf(e.id), 1), y();
  141. }, te = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: n } }) => {
  142. u.value || e + n >= l - 20 && C.value <= L.value && (C.value++, M([_.value.id]));
  143. }, ne = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: n } }) => {
  144. u.value || e + n >= l - 20 && (E.value = j.value, j.value++, y(j.value, E.value));
  145. }, ae = (e) => Ce(e), se = (e) => we(e);
  146. return (e, l) => {
  147. const n = _e, r = pe, V = B("s-tree"), g = B("DownOutlined"), oe = ge, ie = fe, ue = me, ce = B("CloseCircleOutlined"), de = B("s-modal");
  148. return k(), S("div", $e, [
  149. d(n, {
  150. value: m.value,
  151. "onUpdate:value": l[0] || (l[0] = (a) => m.value = a),
  152. readonly: !0,
  153. placeholder: $.placeholder,
  154. onClick: q,
  155. onSearch: q
  156. }, null, 8, ["value", "placeholder"]),
  157. d(de, {
  158. value: c.value,
  159. "onUpdate:value": l[4] || (l[4] = (a) => c.value = a),
  160. title: $.title,
  161. width: "1000px",
  162. showFullScreen: !1
  163. }, {
  164. footer: h(() => [
  165. d(r, {
  166. key: "back",
  167. onClick: R
  168. }, {
  169. default: h(() => [
  170. I(i(e.$l("取消")), 1)
  171. ]),
  172. _: 1
  173. }),
  174. d(r, {
  175. key: "submit",
  176. type: "primary",
  177. loading: u.value,
  178. onClick: Y
  179. }, {
  180. default: h(() => [
  181. I(i(e.$l("确认")), 1)
  182. ]),
  183. _: 1
  184. }, 8, ["loading"])
  185. ]),
  186. default: h(() => [
  187. t("div", be, [
  188. t("div", Oe, [
  189. d(V, {
  190. levelOneChildren: ae,
  191. levelTwoChildren: se,
  192. "onSelect:modelValue": Z,
  193. select: A.value,
  194. "onUpdate:select": l[1] || (l[1] = (a) => A.value = a),
  195. height: 470
  196. }, null, 8, ["select"])
  197. ]),
  198. t("div", Ne, [
  199. t("div", Ve, [
  200. d(n, {
  201. value: w.value,
  202. "onUpdate:value": l[2] || (l[2] = (a) => w.value = a),
  203. placeholder: e.$l("请输入"),
  204. style: { width: "330px" },
  205. onSearch: x
  206. }, null, 8, ["value", "placeholder"])
  207. ]),
  208. t("div", Ae, [
  209. t("div", Le, [
  210. t("div", Te, [
  211. t("div", je, i(_.value.title || _.value.name), 1),
  212. t("div", Ue, [
  213. d(r, {
  214. type: "link",
  215. onClick: P
  216. }, {
  217. default: h(() => [
  218. I(i(O.value ? e.$l("反选") : e.$l("全选")), 1)
  219. ]),
  220. _: 1
  221. }),
  222. d(ue, null, {
  223. overlay: h(() => [
  224. d(ie, null, {
  225. default: h(() => [
  226. d(oe, { onClick: Q }, {
  227. default: h(() => [
  228. t("a", Be, i(e.$l("节点全选")), 1)
  229. ]),
  230. _: 1
  231. })
  232. ]),
  233. _: 1
  234. })
  235. ]),
  236. default: h(() => [
  237. t("a", {
  238. type: "link",
  239. onClick: l[3] || (l[3] = ve(() => {
  240. }, ["prevent"]))
  241. }, [
  242. d(g)
  243. ])
  244. ]),
  245. _: 1
  246. })
  247. ])
  248. ]),
  249. t("div", {
  250. class: "user-list",
  251. onScroll: te
  252. }, [
  253. (k(!0), S(G, null, J(f.value, (a) => (k(), S("div", {
  254. class: "item",
  255. key: a.id,
  256. onClick: (z) => ee(a)
  257. }, [
  258. t("div", De, i(a.name && a.name.slice(0, 1)), 1),
  259. t("div", Ee, [
  260. t("div", Me, i(a.name) + " (" + i(a.nameOrCount) + ")", 1),
  261. t("div", Fe, i(a.deptName), 1)
  262. ])
  263. ], 8, Ie))), 128)),
  264. C.value >= L.value ? (k(), S("div", qe, i(e.$l("没有更多了")), 1)) : he("", !0)
  265. ], 32)
  266. ]),
  267. t("div", ze, [
  268. t("div", Ge, [
  269. t("div", Je, i(e.$l("本次已选")), 1),
  270. d(r, {
  271. type: "link",
  272. onClick: X
  273. }, {
  274. default: h(() => [
  275. I(i(e.$l("清除")), 1)
  276. ]),
  277. _: 1
  278. })
  279. ]),
  280. t("div", {
  281. class: "user-list select-list",
  282. onScroll: ne
  283. }, [
  284. (k(!0), S(G, null, J(v.value, (a, z) => (k(), S("div", {
  285. class: "item",
  286. key: a.id
  287. }, [
  288. t("div", Re, i(a.name && a.name.slice(0, 1)), 1),
  289. t("div", xe, [
  290. t("div", He, i(a.name) + " (" + i(a.nameOrCount) + ")", 1),
  291. t("div", Ke, i(a.deptName), 1)
  292. ]),
  293. t("div", {
  294. class: "icon no-bg",
  295. onClick: (Qe) => le(a, z)
  296. }, [
  297. d(ce)
  298. ], 8, Pe)
  299. ]))), 128))
  300. ], 32)
  301. ])
  302. ])
  303. ])
  304. ])
  305. ]),
  306. _: 1
  307. }, 8, ["value", "title"])
  308. ]);
  309. };
  310. }
  311. };
  312. export {
  313. Ze as default
  314. };