SOfficeSelect.js 12 KB

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