SBelowChoosePosition.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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 b, 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 Ee, C as be, 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. // 弹窗标题
  79. title: {
  80. type: String,
  81. default: window.$l("选择岗位")
  82. },
  83. // 是否多选
  84. multiple: {
  85. type: Boolean,
  86. default: !1
  87. },
  88. // 搜索框占位文案
  89. searchPlaceholder: {
  90. type: String,
  91. default: window.$l("按岗位名称、岗位编号搜索")
  92. },
  93. // 是否必填(校验用,未选时提示)
  94. required: {
  95. // 是否必填
  96. type: Boolean,
  97. default: !1
  98. },
  99. // 多选回显入参(selectedIds.sync)
  100. selectedIds: {
  101. // 多选时组件回显入参(selectedIds 双向绑定)
  102. type: Array,
  103. default: () => []
  104. },
  105. // 单选回显入参(selectedId.sync)
  106. selectedId: {
  107. // 单选时组件回显入参(selectedId 双向绑定)
  108. type: String,
  109. default: ""
  110. },
  111. // 只加载该根节点下的岗位(为空则从 -1 层开始)
  112. rootId: {
  113. // 根节点 id
  114. type: String,
  115. default: ""
  116. }
  117. },
  118. emits: [
  119. "update:value",
  120. "update:selectedIds",
  121. "update:selectedId",
  122. "callback",
  123. "input"
  124. ],
  125. setup(s, { expose: n, emit: o }) {
  126. const i = s, f = o, N = g(!1), a = he({
  127. pageNum: 1,
  128. pageSize: 10,
  129. searchValue: null,
  130. selectedData: {}
  131. }), y = g(!1), r = g(null), v = g([]), c = g([]), h = g([]), z = g([]), D = g([]), G = g(!1), Q = fe(() => window.$l("岗位"));
  132. b(
  133. () => i.selectedIds,
  134. (e) => {
  135. h.value = [...e || []], H();
  136. },
  137. { deep: !0 }
  138. ), b(
  139. () => i.selectedId,
  140. () => {
  141. j();
  142. }
  143. ), b(
  144. () => i.rootId,
  145. (e) => {
  146. console.log("val", e), B(e);
  147. }
  148. );
  149. const W = () => {
  150. var e;
  151. if (i.multiple) {
  152. if (i.required && (!v.value || v.value.length === 0)) {
  153. window.$message.warning(window.$l("请选择岗位"));
  154. return;
  155. }
  156. f("update:selectedIds", [...h.value]), f("callback", { selectedList: v.value }), f("update:value", !1);
  157. } else {
  158. if (i.required && !a.selectedData) {
  159. window.$message.warning(window.$l("请选择岗位"));
  160. return;
  161. }
  162. f("update:selectedId", ((e = a.selectedData) == null ? void 0 : e.id) || null), f("callback", { selected: a.selectedData || null }), f("update:value", !1), c.value = [];
  163. }
  164. }, M = () => {
  165. i.multiple || (c.value = []), f("callback", !1), f("update:value", !1);
  166. }, X = (e, l) => $(this, null, function* () {
  167. var _;
  168. const t = l.node.dataRef;
  169. if (a.pageNum = 1, t.type === "1" || t.type === "2") {
  170. a.campusId = null, a.unitId = null, c.value = [];
  171. return;
  172. }
  173. a.campusId = null, a.unitId = t.id, a.parentIds = `${t.parentIds}${t.id}`, a.unitType = t.type;
  174. const d = yield P({
  175. pageNum: a.pageNum || 1,
  176. pageSize: a.pageSize,
  177. searchValue: a.searchValue || "",
  178. unitid: t.id,
  179. containsChild: !0
  180. });
  181. a.pageTotal = d.total || 0, i.multiple && d && ((_ = d == null ? void 0 : d.list) != null && _.length) && v.value.length && (d.list || []).forEach((I) => {
  182. const E = v.value.find((u) => u.id === I.id);
  183. I.selected = !!E;
  184. }), O(d.list), c.value = d.list || [];
  185. }), Y = () => $(this, null, function* () {
  186. var d;
  187. a.pageNum = 1;
  188. const e = a.unitId || a.campusId, l = a.unitId ? 2 : 1, t = yield P({
  189. pageNum: a.pageNum || 1,
  190. pageSize: a.pageSize,
  191. searchValue: a.searchValue || "",
  192. unitid: e,
  193. containsChild: !0,
  194. unitType: l,
  195. isEnabled: !0
  196. });
  197. a.pageTotal = t.total || 0, i.multiple && t && ((d = t == null ? void 0 : t.list) != null && d.length) && v.value.length && (t.list || []).forEach((_) => {
  198. const I = v.value.find((E) => E.id === _.id);
  199. _.selected = !!I;
  200. }), O(t.list), c.value = (t == null ? void 0 : t.list) || [];
  201. }), Z = () => {
  202. const e = q.value;
  203. if (!e || G.value) return;
  204. Math.ceil(e.scrollTop + e.clientHeight) >= e.scrollHeight && c.value.length < a.pageTotal && (a.pageNum += 1, se());
  205. }, q = g(null), ee = (e) => {
  206. i.multiple ? e.selected = !e.selected : ((c.value || []).filter((l) => l.id !== e.id).forEach((l) => {
  207. l.selected = !1;
  208. }), e.selected = !e.selected, a.selectedData = k({}, e)), O(c.value);
  209. }, te = () => {
  210. y.value = !y.value, c.value.forEach((e) => {
  211. e.selected = y.value;
  212. });
  213. }, le = () => {
  214. if (!i.multiple) {
  215. r.value = new C(), h.value = [];
  216. const l = (c.value || []).find((t) => t.selected);
  217. a.selectedData = l ? k({}, l) : null;
  218. return;
  219. }
  220. const e = c.value || [];
  221. e && e.length && e.forEach((l) => {
  222. const t = h.value.find((d) => d === l.id);
  223. l.selected && !t ? h.value.push(l.id) : !l.selected && t && (h.value = h.value.filter((d) => d !== l.id));
  224. }), f("update:selectedIds", [...h.value]);
  225. }, H = () => $(this, null, function* () {
  226. if (i.multiple)
  227. if (h.value && h.value.length) {
  228. const e = yield Le(h.value);
  229. if (e && e.length) {
  230. const l = e.map((t) => T(k({}, t), { deptName: t.officeName }));
  231. r.value ? r.value.clear() : r.value = new C(), l.forEach((t) => {
  232. r.value.has(t.id) || r.value.set(t.id, {
  233. id: t.id,
  234. name: t.name,
  235. cover: t.cover,
  236. deptName: t.deptName,
  237. nameOrCount: t.nameOrCount.replace("此岗位暂无人员", "0") || "",
  238. rowno: t.sort || t.rowno
  239. });
  240. }), ae();
  241. }
  242. } else
  243. r.value = new C(), v.value = [];
  244. }), j = () => $(this, null, function* () {
  245. if (r.value = new C(), v.value = [], !i.selectedId) return;
  246. const e = yield Se(i.selectedId);
  247. e && (c.value.push({
  248. id: e.id,
  249. name: e.name,
  250. cover: null,
  251. deptName: e.officeName,
  252. nameOrCount: e.nameOrCount.replace("此岗位暂无人员", "0"),
  253. selected: !0
  254. }), a.selectedData = { id: e.id, name: e.name });
  255. }), ae = () => {
  256. var l;
  257. v.value = [];
  258. const e = [];
  259. if (r.value && ((l = r.value) == null ? void 0 : l.size()) > 0) {
  260. for (const t of r.value.keys()) {
  261. const d = r.value.get(t);
  262. e.push(k({}, d));
  263. }
  264. e.forEach((t) => {
  265. v.value.push(k({}, t));
  266. });
  267. }
  268. }, O = (e) => {
  269. if (!e || e.length === 0)
  270. y.value = !1;
  271. else {
  272. const l = e.filter((t) => t.selected);
  273. y.value = l.length === e.length;
  274. }
  275. }, se = () => $(this, null, function* () {
  276. var t;
  277. const e = a.unitId || a.campusId, l = yield P(T(k({}, a), {
  278. unitid: e,
  279. containsChild: !0,
  280. sortName: "a.sort",
  281. sortType: "asc"
  282. }));
  283. i.multiple && l && ((t = l == null ? void 0 : l.list) != null && t.length) && v.value.length && (l.list || []).forEach((d) => {
  284. const _ = v.value.find((I) => I.id === d.id);
  285. d.selected = !!_;
  286. }), O(l.list), l.list && l.list.forEach((d) => {
  287. c.value.push(k({}, d));
  288. });
  289. }), ne = () => {
  290. v.value && v.value.length && (c.value && c.value.length && c.value.forEach((e) => {
  291. e.selected = !1;
  292. }), r.value && r.value.clear(), h.value = [], v.value = []), y.value = !1;
  293. }, ie = (e) => {
  294. if (h.value && h.value.length && (h.value = h.value.filter((l) => l !== e.id)), c.value && c.value.length) {
  295. c.value.forEach((t) => {
  296. t.id === e.id && (t.selected = !1);
  297. });
  298. const l = c.value.filter((t) => t.selected);
  299. y.value = l.length === c.value.length;
  300. }
  301. f("update:selectedIds", [...h.value]);
  302. }, B = (e) => {
  303. if (!e) {
  304. D.value = [], z.value = [];
  305. return;
  306. }
  307. Ce({ parent: { id: e || "-1" } }).then((l) => {
  308. l && l.length && (D.value = [l[0].id], z.value = l.map((t) => T(k({}, t), { title: t.name })));
  309. });
  310. }, ce = (e) => {
  311. D.value = e;
  312. };
  313. return b(
  314. () => c.value,
  315. () => {
  316. le();
  317. },
  318. { deep: !0 }
  319. ), b(
  320. () => i.value,
  321. (e) => {
  322. N.value = e, i.multiple ? (h.value = [...i.selectedIds || []], H()) : (c.value = [], j());
  323. },
  324. { immediate: !0 }
  325. ), me(() => {
  326. i.rootId && B(i.rootId);
  327. }), n({ initLeftTreeData: B }), ye(() => {
  328. B();
  329. }), (e, l) => {
  330. const t = xe, d = Ne, _ = $e, I = Ee, E = ge("s-modal");
  331. return w(), U(E, {
  332. value: N.value,
  333. "onUpdate:value": l[1] || (l[1] = (u) => N.value = u),
  334. title: e.$l(s.title),
  335. width: s.multiple ? "900px" : "780px",
  336. showFullScreen: !1,
  337. onHandCancel: M
  338. }, {
  339. footer: L(() => [
  340. x(t, { onClick: M }, {
  341. default: L(() => [
  342. V(m(e.$l("取消")), 1)
  343. ]),
  344. _: 1
  345. }),
  346. x(t, {
  347. type: "primary",
  348. onClick: W
  349. }, {
  350. default: L(() => [
  351. V(m(e.$l("确认")), 1)
  352. ]),
  353. _: 1
  354. })
  355. ]),
  356. default: L(() => [
  357. p("div", De, [
  358. p("div", Oe, [
  359. p("div", Be, [
  360. x(_, {
  361. "expanded-keys": D.value,
  362. "tree-data": z.value,
  363. "field-names": { title: "title", key: "id", children: "children" },
  364. showIcon: !1,
  365. onExpand: ce,
  366. onSelect: X
  367. }, {
  368. title: L((u) => [
  369. (u.title || "").length > 15 ? (w(), U(d, {
  370. key: 0,
  371. placement: "topLeft",
  372. mouseEnterDelay: 1.5,
  373. mouseLeaveDelay: 0.5
  374. }, {
  375. title: L(() => [
  376. V(m(u.title), 1)
  377. ]),
  378. default: L(() => [
  379. p("div", Te, m((u.title || "").slice(0, 15)) + "...", 1)
  380. ]),
  381. _: 2
  382. }, 1024)) : (w(), S("div", Ve, m(u.title), 1))
  383. ]),
  384. _: 1
  385. }, 8, ["expanded-keys", "tree-data"])
  386. ])
  387. ]),
  388. p("div", ze, [
  389. p("div", Pe, [
  390. x(I, {
  391. style: { width: "274px" },
  392. value: a.searchValue,
  393. "onUpdate:value": l[0] || (l[0] = (u) => a.searchValue = u),
  394. placeholder: e.$l(s.searchPlaceholder || s.title),
  395. onPressEnter: Y
  396. }, null, 8, ["value", "placeholder"])
  397. ]),
  398. p("div", Me, [
  399. p("div", qe, [
  400. s.multiple ? (w(), S("div", {
  401. key: 0,
  402. class: "sub-title all-selected",
  403. onClick: te
  404. }, m(y.value ? e.$l("反选") : e.$l("全选")), 1)) : F("", !0),
  405. p("div", {
  406. class: "roll-div",
  407. ref_key: "listRef",
  408. ref: q,
  409. onScroll: Z
  410. }, [
  411. p("ul", He, [
  412. (w(!0), S(K, null, J(c.value, (u) => (w(), S("li", {
  413. key: u.id,
  414. class: _e({ selected: u.selected }),
  415. onClick: (de) => ee(u)
  416. }, [
  417. p("div", Ae, [
  418. p("div", {
  419. class: "name",
  420. style: ke({ "max-width": s.multiple ? "250px" : "400px" })
  421. }, m(`${u.name}(${u.nameOrCount.replace("此岗位暂无人员", "0")})`), 5),
  422. p("div", Re, m(u.deptName), 1)
  423. ])
  424. ], 10, je))), 128))
  425. ])
  426. ], 544)
  427. ]),
  428. s.multiple ? (w(), S("div", Ue, [
  429. p("div", Fe, [
  430. V(m(e.$l("本次已选的")) + m(Q.value), 1),
  431. p("a", {
  432. onClick: ne,
  433. class: "all-clear-selected"
  434. }, m(e.$l("清除")), 1)
  435. ]),
  436. p("div", Ke, [
  437. p("ul", Je, [
  438. (w(!0), S(K, null, J(v.value, (u) => (w(), S("li", {
  439. key: u.id
  440. }, [
  441. p("div", Ge, [
  442. p("div", Qe, m(`${u.name}(${u.nameOrCount})`), 1),
  443. p("div", We, m(u.deptName), 1)
  444. ]),
  445. p("div", {
  446. onClick: (de) => ie(u)
  447. }, [
  448. x(we(be), { class: "remove-icon" })
  449. ], 8, Xe)
  450. ]))), 128))
  451. ])
  452. ])
  453. ])) : F("", !0)
  454. ])
  455. ])
  456. ])
  457. ]),
  458. _: 1
  459. }, 8, ["value", "title", "width"]);
  460. };
  461. }
  462. }, lt = /* @__PURE__ */ Ie(Ye, [["__scopeId", "data-v-22f64a90"]]);
  463. export {
  464. lt as default
  465. };