SUserSelect.js 11 KB

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