SOfficeSelect.js 11 KB

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