SBelowChoosePosition.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. var oe = Object.defineProperty, ue = Object.defineProperties;
  2. var re = Object.getOwnPropertyDescriptors;
  3. var A = Object.getOwnPropertySymbols;
  4. var ve = Object.prototype.hasOwnProperty, pe = Object.prototype.propertyIsEnumerable;
  5. var R = (s, n, o) => n in s ? oe(s, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : s[n] = o, k = (s, n) => {
  6. for (var o in n || (n = {}))
  7. ve.call(n, o) && R(s, o, n[o]);
  8. if (A)
  9. for (var o of A(n))
  10. pe.call(n, o) && R(s, o, n[o]);
  11. return s;
  12. }, T = (s, n) => ue(s, re(n));
  13. var $ = (s, n, o) => new Promise((i, f) => {
  14. var N = (r) => {
  15. try {
  16. y(o.next(r));
  17. } catch (v) {
  18. f(v);
  19. }
  20. }, a = (r) => {
  21. try {
  22. y(o.throw(r));
  23. } catch (v) {
  24. f(v);
  25. }
  26. }, y = (r) => r.done ? i(r.value) : Promise.resolve(r.value).then(N, a);
  27. y((o = o.apply(s, n)).next());
  28. });
  29. import { ref as g, reactive as he, computed as fe, watch as E, nextTick as me, onMounted as ye, resolveComponent as ge, openBlock as w, createBlock as U, withCtx as L, createElementVNode as p, createVNode as x, toDisplayString as m, createTextVNode as V, createElementBlock as S, createCommentVNode as F, Fragment as K, renderList as J, normalizeClass as _e, normalizeStyle as ke, unref as we } from "vue";
  30. import { n as Ie, p as Le, q as Se, v as Ce, x as $e, y as Ne, I as be, C as Ee, B as xe, z as P } from "./index2.js";
  31. function C() {
  32. this.map = {}, this.arrayLink = [];
  33. }
  34. C.prototype = {
  35. set: function(s, n) {
  36. var o = this.arrayLink.indexOf(s);
  37. o === -1 && (this.arrayLink.push(s), o = this.arrayLink.indexOf(s)), this.map[o] = n;
  38. },
  39. get: function(s) {
  40. var n = this.arrayLink.indexOf(s);
  41. return this.map.hasOwnProperty(n) ? this.map[n] : null;
  42. },
  43. delete: function(s) {
  44. var n = this.arrayLink.indexOf(s);
  45. this.arrayLink.splice(n, 1, "-1");
  46. var o = this.arrayLink.slice(0, n), i = this.arrayLink.slice(n + 1, this.arrayLink.length);
  47. return this.arrayLink = [], this.arrayLink.concat(o), this.arrayLink.concat(i), this.map.hasOwnProperty(n) ? delete this.map[n] : !1;
  48. },
  49. clear: function() {
  50. this.map = {}, this.arrayLink = [];
  51. },
  52. keys: function() {
  53. return this.arrayLink;
  54. },
  55. has: function(s) {
  56. return !!this.arrayLink.find((n) => n === s);
  57. },
  58. size: function() {
  59. var s;
  60. return ((s = this.arrayLink) == null ? void 0 : s.length) || 0;
  61. }
  62. };
  63. C.prototype.constructor = C;
  64. const De = { class: "modal-container" }, Oe = { class: "side-tree" }, Be = { class: "s-tree-common" }, Te = { class: "node-title" }, Ve = {
  65. key: 1,
  66. class: "node-title"
  67. }, ze = { class: "main" }, Pe = { class: "search" }, Me = { class: "content" }, qe = { class: "list-wrap flex-column" }, He = { class: "lists" }, je = ["onClick"], Ae = { class: "info" }, Re = { class: "desc" }, Ue = {
  68. key: 0,
  69. class: "side-right"
  70. }, Fe = { class: "sub-title" }, Ke = { class: "roll-div" }, Je = { class: "lists" }, Ge = { class: "info" }, Qe = { class: "selected-name" }, We = { class: "desc" }, Xe = ["onClick"], Ye = {
  71. __name: "SBelowChoosePosition",
  72. props: {
  73. // 弹窗显隐
  74. value: {
  75. type: Boolean,
  76. default: !1
  77. },
  78. title: {
  79. type: String,
  80. default: window.$l("选择岗位")
  81. },
  82. multiple: {
  83. type: Boolean,
  84. default: !1
  85. },
  86. searchPlaceholder: {
  87. type: String,
  88. default: window.$l("按岗位名称、岗位编号搜索")
  89. },
  90. required: {
  91. // 是否必填
  92. type: Boolean,
  93. default: !1
  94. },
  95. selectedIds: {
  96. // 多选时组件回显入参(selectedIds 双向绑定)
  97. type: Array,
  98. default: () => []
  99. },
  100. selectedId: {
  101. // 单选时组件回显入参(selectedId 双向绑定)
  102. type: String,
  103. default: ""
  104. },
  105. rootId: {
  106. // 根节点 id
  107. type: String,
  108. default: ""
  109. }
  110. },
  111. emits: [
  112. "update:value",
  113. "update:selectedIds",
  114. "update:selectedId",
  115. "callback",
  116. "input"
  117. ],
  118. setup(s, { expose: n, emit: o }) {
  119. const i = s, f = o, N = g(!1), a = he({
  120. pageNum: 1,
  121. pageSize: 10,
  122. searchValue: null,
  123. selectedData: {}
  124. }), y = g(!1), r = g(null), v = g([]), c = g([]), h = g([]), z = g([]), D = g([]), G = g(!1), Q = fe(() => window.$l("岗位"));
  125. E(
  126. () => i.selectedIds,
  127. (e) => {
  128. h.value = [...e || []], H();
  129. },
  130. { deep: !0 }
  131. ), E(
  132. () => i.selectedId,
  133. () => {
  134. j();
  135. }
  136. ), E(
  137. () => i.rootId,
  138. (e) => {
  139. console.log("val", e), B(e);
  140. }
  141. );
  142. const W = () => {
  143. var e;
  144. if (i.multiple) {
  145. if (i.required && (!v.value || v.value.length === 0)) {
  146. window.$message.warning(window.$l("请选择岗位"));
  147. return;
  148. }
  149. f("update:selectedIds", [...h.value]), f("callback", { selectedList: v.value }), f("update:value", !1);
  150. } else {
  151. if (i.required && !a.selectedData) {
  152. window.$message.warning(window.$l("请选择岗位"));
  153. return;
  154. }
  155. f("update:selectedId", ((e = a.selectedData) == null ? void 0 : e.id) || null), f("callback", { selected: a.selectedData || null }), f("update:value", !1), c.value = [];
  156. }
  157. }, M = () => {
  158. i.multiple || (c.value = []), f("callback", !1), f("update:value", !1);
  159. }, X = (e, l) => $(this, null, function* () {
  160. var _;
  161. const t = l.node.dataRef;
  162. if (a.pageNum = 1, t.type === "1" || t.type === "2") {
  163. a.campusId = null, a.unitId = null, c.value = [];
  164. return;
  165. }
  166. a.campusId = null, a.unitId = t.id, a.parentIds = `${t.parentIds}${t.id}`, a.unitType = t.type;
  167. const d = yield P({
  168. pageNum: a.pageNum || 1,
  169. pageSize: a.pageSize,
  170. searchValue: a.searchValue || "",
  171. unitid: t.id,
  172. containsChild: !0
  173. });
  174. a.pageTotal = d.total || 0, i.multiple && d && ((_ = d == null ? void 0 : d.list) != null && _.length) && v.value.length && (d.list || []).forEach((I) => {
  175. const b = v.value.find((u) => u.id === I.id);
  176. I.selected = !!b;
  177. }), O(d.list), c.value = d.list || [];
  178. }), Y = () => $(this, null, function* () {
  179. var d;
  180. a.pageNum = 1;
  181. const e = a.unitId || a.campusId, l = a.unitId ? 2 : 1, t = yield P({
  182. pageNum: a.pageNum || 1,
  183. pageSize: a.pageSize,
  184. searchValue: a.searchValue || "",
  185. unitid: e,
  186. containsChild: !0,
  187. unitType: l,
  188. isEnabled: !0
  189. });
  190. a.pageTotal = t.total || 0, i.multiple && t && ((d = t == null ? void 0 : t.list) != null && d.length) && v.value.length && (t.list || []).forEach((_) => {
  191. const I = v.value.find((b) => b.id === _.id);
  192. _.selected = !!I;
  193. }), O(t.list), c.value = (t == null ? void 0 : t.list) || [];
  194. }), Z = () => {
  195. const e = q.value;
  196. if (!e || G.value) return;
  197. Math.ceil(e.scrollTop + e.clientHeight) >= e.scrollHeight && c.value.length < a.pageTotal && (a.pageNum += 1, se());
  198. }, q = g(null), ee = (e) => {
  199. i.multiple ? e.selected = !e.selected : ((c.value || []).filter((l) => l.id !== e.id).forEach((l) => {
  200. l.selected = !1;
  201. }), e.selected = !e.selected, a.selectedData = k({}, e)), O(c.value);
  202. }, te = () => {
  203. y.value = !y.value, c.value.forEach((e) => {
  204. e.selected = y.value;
  205. });
  206. }, le = () => {
  207. if (!i.multiple) {
  208. r.value = new C(), h.value = [];
  209. const l = (c.value || []).find((t) => t.selected);
  210. a.selectedData = l ? k({}, l) : null;
  211. return;
  212. }
  213. const e = c.value || [];
  214. e && e.length && e.forEach((l) => {
  215. const t = h.value.find((d) => d === l.id);
  216. l.selected && !t ? h.value.push(l.id) : !l.selected && t && (h.value = h.value.filter((d) => d !== l.id));
  217. }), f("update:selectedIds", [...h.value]);
  218. }, H = () => $(this, null, function* () {
  219. if (i.multiple)
  220. if (h.value && h.value.length) {
  221. const e = yield Le(h.value);
  222. if (e && e.length) {
  223. const l = e.map((t) => T(k({}, t), { deptName: t.officeName }));
  224. r.value ? r.value.clear() : r.value = new C(), l.forEach((t) => {
  225. r.value.has(t.id) || r.value.set(t.id, {
  226. id: t.id,
  227. name: t.name,
  228. cover: t.cover,
  229. deptName: t.deptName,
  230. nameOrCount: t.nameOrCount.replace("此岗位暂无人员", "0") || "",
  231. rowno: t.sort || t.rowno
  232. });
  233. }), ae();
  234. }
  235. } else
  236. r.value = new C(), v.value = [];
  237. }), j = () => $(this, null, function* () {
  238. if (r.value = new C(), v.value = [], !i.selectedId) return;
  239. const e = yield Se(i.selectedId);
  240. e && (c.value.push({
  241. id: e.id,
  242. name: e.name,
  243. cover: null,
  244. deptName: e.officeName,
  245. nameOrCount: e.nameOrCount.replace("此岗位暂无人员", "0"),
  246. selected: !0
  247. }), a.selectedData = { id: e.id, name: e.name });
  248. }), ae = () => {
  249. var l;
  250. v.value = [];
  251. const e = [];
  252. if (r.value && ((l = r.value) == null ? void 0 : l.size()) > 0) {
  253. for (const t of r.value.keys()) {
  254. const d = r.value.get(t);
  255. e.push(k({}, d));
  256. }
  257. e.forEach((t) => {
  258. v.value.push(k({}, t));
  259. });
  260. }
  261. }, O = (e) => {
  262. if (!e || e.length === 0)
  263. y.value = !1;
  264. else {
  265. const l = e.filter((t) => t.selected);
  266. y.value = l.length === e.length;
  267. }
  268. }, se = () => $(this, null, function* () {
  269. var t;
  270. const e = a.unitId || a.campusId, l = yield P(T(k({}, a), {
  271. unitid: e,
  272. containsChild: !0,
  273. sortName: "a.sort",
  274. sortType: "asc"
  275. }));
  276. i.multiple && l && ((t = l == null ? void 0 : l.list) != null && t.length) && v.value.length && (l.list || []).forEach((d) => {
  277. const _ = v.value.find((I) => I.id === d.id);
  278. d.selected = !!_;
  279. }), O(l.list), l.list && l.list.forEach((d) => {
  280. c.value.push(k({}, d));
  281. });
  282. }), ne = () => {
  283. v.value && v.value.length && (c.value && c.value.length && c.value.forEach((e) => {
  284. e.selected = !1;
  285. }), r.value && r.value.clear(), h.value = [], v.value = []), y.value = !1;
  286. }, ie = (e) => {
  287. if (h.value && h.value.length && (h.value = h.value.filter((l) => l !== e.id)), c.value && c.value.length) {
  288. c.value.forEach((t) => {
  289. t.id === e.id && (t.selected = !1);
  290. });
  291. const l = c.value.filter((t) => t.selected);
  292. y.value = l.length === c.value.length;
  293. }
  294. f("update:selectedIds", [...h.value]);
  295. }, B = (e) => {
  296. if (!e) {
  297. D.value = [], z.value = [];
  298. return;
  299. }
  300. Ce({ parent: { id: e || "-1" } }).then((l) => {
  301. l && l.length && (D.value = [l[0].id], z.value = l.map((t) => T(k({}, t), { title: t.name })));
  302. });
  303. }, ce = (e) => {
  304. D.value = e;
  305. };
  306. return E(
  307. () => c.value,
  308. () => {
  309. le();
  310. },
  311. { deep: !0 }
  312. ), E(
  313. () => i.value,
  314. (e) => {
  315. N.value = e, i.multiple ? (h.value = [...i.selectedIds || []], H()) : (c.value = [], j());
  316. },
  317. { immediate: !0 }
  318. ), me(() => {
  319. i.rootId && B(i.rootId);
  320. }), n({ initLeftTreeData: B }), ye(() => {
  321. B();
  322. }), (e, l) => {
  323. const t = xe, d = Ne, _ = $e, I = be, b = ge("s-modal");
  324. return w(), U(b, {
  325. value: N.value,
  326. "onUpdate:value": l[1] || (l[1] = (u) => N.value = u),
  327. title: e.$l(s.title),
  328. width: s.multiple ? "900px" : "780px",
  329. showFullScreen: !1,
  330. onHandCancel: M
  331. }, {
  332. footer: L(() => [
  333. x(t, { onClick: M }, {
  334. default: L(() => [
  335. V(m(e.$l("取消")), 1)
  336. ]),
  337. _: 1
  338. }),
  339. x(t, {
  340. type: "primary",
  341. onClick: W
  342. }, {
  343. default: L(() => [
  344. V(m(e.$l("确认")), 1)
  345. ]),
  346. _: 1
  347. })
  348. ]),
  349. default: L(() => [
  350. p("div", De, [
  351. p("div", Oe, [
  352. p("div", Be, [
  353. x(_, {
  354. "expanded-keys": D.value,
  355. "tree-data": z.value,
  356. "field-names": { title: "title", key: "id", children: "children" },
  357. showIcon: !1,
  358. onExpand: ce,
  359. onSelect: X
  360. }, {
  361. title: L((u) => [
  362. (u.title || "").length > 15 ? (w(), U(d, {
  363. key: 0,
  364. placement: "topLeft",
  365. mouseEnterDelay: 1.5,
  366. mouseLeaveDelay: 0.5
  367. }, {
  368. title: L(() => [
  369. V(m(u.title), 1)
  370. ]),
  371. default: L(() => [
  372. p("div", Te, m((u.title || "").slice(0, 15)) + "...", 1)
  373. ]),
  374. _: 2
  375. }, 1024)) : (w(), S("div", Ve, m(u.title), 1))
  376. ]),
  377. _: 1
  378. }, 8, ["expanded-keys", "tree-data"])
  379. ])
  380. ]),
  381. p("div", ze, [
  382. p("div", Pe, [
  383. x(I, {
  384. style: { width: "274px" },
  385. value: a.searchValue,
  386. "onUpdate:value": l[0] || (l[0] = (u) => a.searchValue = u),
  387. placeholder: e.$l(s.searchPlaceholder || s.title),
  388. onPressEnter: Y
  389. }, null, 8, ["value", "placeholder"])
  390. ]),
  391. p("div", Me, [
  392. p("div", qe, [
  393. s.multiple ? (w(), S("div", {
  394. key: 0,
  395. class: "sub-title all-selected",
  396. onClick: te
  397. }, m(y.value ? e.$l("反选") : e.$l("全选")), 1)) : F("", !0),
  398. p("div", {
  399. class: "roll-div",
  400. ref_key: "listRef",
  401. ref: q,
  402. onScroll: Z
  403. }, [
  404. p("ul", He, [
  405. (w(!0), S(K, null, J(c.value, (u) => (w(), S("li", {
  406. key: u.id,
  407. class: _e({ selected: u.selected }),
  408. onClick: (de) => ee(u)
  409. }, [
  410. p("div", Ae, [
  411. p("div", {
  412. class: "name",
  413. style: ke({ "max-width": s.multiple ? "250px" : "400px" })
  414. }, m(`${u.name}(${u.nameOrCount.replace("此岗位暂无人员", "0")})`), 5),
  415. p("div", Re, m(u.deptName), 1)
  416. ])
  417. ], 10, je))), 128))
  418. ])
  419. ], 544)
  420. ]),
  421. s.multiple ? (w(), S("div", Ue, [
  422. p("div", Fe, [
  423. V(m(e.$l("本次已选的")) + m(Q.value), 1),
  424. p("a", {
  425. onClick: ne,
  426. class: "all-clear-selected"
  427. }, m(e.$l("清除")), 1)
  428. ]),
  429. p("div", Ke, [
  430. p("ul", Je, [
  431. (w(!0), S(K, null, J(v.value, (u) => (w(), S("li", {
  432. key: u.id
  433. }, [
  434. p("div", Ge, [
  435. p("div", Qe, m(`${u.name}(${u.nameOrCount})`), 1),
  436. p("div", We, m(u.deptName), 1)
  437. ]),
  438. p("div", {
  439. onClick: (de) => ie(u)
  440. }, [
  441. x(we(Ee), { class: "remove-icon" })
  442. ], 8, Xe)
  443. ]))), 128))
  444. ])
  445. ])
  446. ])) : F("", !0)
  447. ])
  448. ])
  449. ])
  450. ]),
  451. _: 1
  452. }, 8, ["value", "title", "width"]);
  453. };
  454. }
  455. }, lt = /* @__PURE__ */ Ie(Ye, [["__scopeId", "data-v-be62bc03"]]);
  456. export {
  457. lt as default
  458. };