SUserSelect.js 11 KB

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