SOfficeSelect.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. var T = ($, D, g) => new Promise((I, p) => {
  2. var N = (u) => {
  3. try {
  4. c(g.next(u));
  5. } catch (_) {
  6. p(_);
  7. }
  8. }, C = (u) => {
  9. try {
  10. c(g.throw(u));
  11. } catch (_) {
  12. p(_);
  13. }
  14. }, c = (u) => u.done ? I(u.value) : Promise.resolve(u.value).then(N, C);
  15. c((g = g.apply($, D)).next());
  16. });
  17. import { ref as o, watch as re, resolveComponent as A, openBlock as k, createElementBlock as S, createVNode as d, withCtx as h, createElementVNode as t, toDisplayString as i, createTextVNode as U, withModifiers as ve, Fragment as J, renderList as R, createCommentVNode as he } from "vue";
  18. import { l as _e, a as pe, j as me, g as fe, p as ge } from "./common.js";
  19. import { _ as Ce } from "./index15.js";
  20. import { D as we, ao as ye, ak as ke, ap as Se } from "./index2.js";
  21. 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 = {
  22. key: 0,
  23. class: "not-more"
  24. }, 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"], ll = {
  25. __name: "SOfficeSelect",
  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 = $, 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);
  50. let j = null;
  51. const O = o(""), v = o([]), L = o(1), M = o(20), B = o(0);
  52. re(
  53. () => I.ids,
  54. (e) => {
  55. e && e.length && (s.value = e);
  56. },
  57. { immediate: !0 }
  58. );
  59. const z = () => {
  60. u.value = !0;
  61. }, q = () => {
  62. u.value = !1;
  63. }, y = (e = 1, l = 0) => T(this, null, function* () {
  64. if (c.value) {
  65. c.value = !1;
  66. return;
  67. }
  68. e === 1 && (v.value = []);
  69. let n = [];
  70. 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)
  71. return;
  72. c.value = !0;
  73. const r = yield ge(n);
  74. v.value = v.value.concat(r), H(), j = setTimeout(() => {
  75. c.value = !1, clearTimeout(j);
  76. }, 200);
  77. }), x = () => {
  78. if (!O.value) {
  79. window.$message.warning("请选择部门");
  80. return;
  81. }
  82. w.value = 1, m.value = [], E(O.value);
  83. }, H = () => {
  84. const l = v.value.filter((r) => s.value.includes(r.id)).map((r) => r.name), n = l.length - 1;
  85. p.value = l.slice(0, 1).join(",") + (n > 0 ? " +" + n : "");
  86. }, K = () => {
  87. m.value.forEach((e) => {
  88. if (s.value.includes(e.id)) {
  89. const l = s.value.indexOf(e.id);
  90. s.value.splice(l, 1);
  91. }
  92. }), y()();
  93. }, P = () => {
  94. b.value = !b.value, b.value ? W() : K();
  95. }, Q = () => T(this, null, function* () {
  96. if (!O.value) {
  97. window.$message.warning("请选择部门");
  98. return;
  99. }
  100. const e = {
  101. searchValue: C.value,
  102. unitid: O.value.join(",")
  103. }, l = yield me(e), n = s.value.concat(l);
  104. s.value = Array.from(new Set(n)), y();
  105. }), W = () => {
  106. m.value.forEach((e) => {
  107. s.value.includes(e.id) || s.value.push(e.id);
  108. }), y();
  109. }, X = () => {
  110. b.value = !1, p.value = "", s.value = [], v.value = [];
  111. }, Y = () => {
  112. u.value = !1;
  113. 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);
  114. g("change", r, l, F, e);
  115. }, Z = (e, l) => {
  116. _.value = l.node, w.value = 1, V.value = 0, m.value = [], c.value = !0, O.value = e, E(e);
  117. }, E = (e) => T(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 n = yield fe(l);
  127. m.value = m.value.concat(n.list), V.value = n.pages, j = setTimeout(() => {
  128. c.value = !1, clearTimeout(j);
  129. }, 200);
  130. }), ee = (e) => {
  131. s.value.includes(e.id) || s.value.push(e.id), y();
  132. }, le = (e, l) => {
  133. v.value.splice(l, 1), s.value.splice(s.value.indexOf(e.id), 1), y();
  134. }, te = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: n } }) => {
  135. c.value || e + n >= l - 20 && w.value <= V.value && (w.value++, E([_.value.id]));
  136. }, ne = ({ target: { offsetHeight: e, scrollHeight: l, scrollTop: n } }) => {
  137. c.value || e + n >= l - 20 && (B.value = L.value, L.value++, y(L.value, B.value));
  138. }, ae = (e) => pe(e), se = (e) => _e(e);
  139. return (e, l) => {
  140. 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");
  141. return k(), S("div", $e, [
  142. d(n, {
  143. value: p.value,
  144. "onUpdate:value": l[0] || (l[0] = (a) => p.value = a),
  145. readonly: "",
  146. placeholder: $.placeholder,
  147. onClick: z,
  148. onSearch: z
  149. }, null, 8, ["value", "placeholder"]),
  150. d(de, {
  151. value: u.value,
  152. "onUpdate:value": l[4] || (l[4] = (a) => u.value = a),
  153. title: $.title,
  154. width: "1000px",
  155. showFullScreen: !1
  156. }, {
  157. footer: h(() => [
  158. d(r, {
  159. key: "back",
  160. onClick: q
  161. }, {
  162. default: h(() => [
  163. U(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. U(i(e.$l("确认")), 1)
  175. ]),
  176. _: 1
  177. }, 8, ["loading"])
  178. ]),
  179. default: h(() => [
  180. t("div", be, [
  181. t("div", Oe, [
  182. d(F, {
  183. levelOneChildren: ae,
  184. levelTwoChildren: se,
  185. "onSelect:modelValue": Z,
  186. select: N.value,
  187. "onUpdate:select": l[1] || (l[1] = (a) => N.value = a),
  188. height: 470
  189. }, null, 8, ["select"])
  190. ]),
  191. t("div", Ne, [
  192. t("div", Ve, [
  193. d(n, {
  194. value: C.value,
  195. "onUpdate:value": l[2] || (l[2] = (a) => C.value = a),
  196. placeholder: e.$l("请输入"),
  197. style: { width: "330px" },
  198. onSearch: x
  199. }, null, 8, ["value", "placeholder"])
  200. ]),
  201. t("div", je, [
  202. t("div", Le, [
  203. t("div", Te, [
  204. t("div", Ae, i(_.value.title || _.value.name), 1),
  205. t("div", Ue, [
  206. d(r, {
  207. type: "link",
  208. onClick: P
  209. }, {
  210. default: h(() => [
  211. U(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. (k(!0), S(J, null, R(m.value, (a) => (k(), S("div", {
  247. class: "item",
  248. key: a.id,
  249. onClick: (G) => ee(a)
  250. }, [
  251. t("div", Be, i(a.name && a.name.slice(0, 1)), 1),
  252. t("div", Ee, [
  253. t("div", Fe, i(a.name) + " (" + i(a.nameOrCount) + ")", 1),
  254. t("div", Me, i(a.deptName), 1)
  255. ])
  256. ], 8, Ie))), 128)),
  257. w.value >= V.value ? (k(), S("div", ze, i(e.$l("没有更多了")), 1)) : he("", !0)
  258. ], 32)
  259. ]),
  260. t("div", Ge, [
  261. t("div", Je, [
  262. t("div", Re, i(e.$l("本次已选")), 1),
  263. d(r, {
  264. type: "link",
  265. onClick: X
  266. }, {
  267. default: h(() => [
  268. U(i(e.$l("清除")), 1)
  269. ]),
  270. _: 1
  271. })
  272. ]),
  273. t("div", {
  274. class: "user-list select-list",
  275. onScroll: ne
  276. }, [
  277. (k(!0), S(J, null, R(v.value, (a, G) => (k(), S("div", {
  278. class: "item",
  279. key: a.id
  280. }, [
  281. t("div", qe, i(a.name && a.name.slice(0, 1)), 1),
  282. t("div", xe, [
  283. t("div", He, i(a.name) + " (" + i(a.nameOrCount) + ")", 1),
  284. t("div", Ke, i(a.deptName), 1)
  285. ]),
  286. t("div", {
  287. class: "icon no-bg",
  288. onClick: (Qe) => le(a, G)
  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. };