| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- var oe = Object.defineProperty, ue = Object.defineProperties;
- var re = Object.getOwnPropertyDescriptors;
- var A = Object.getOwnPropertySymbols;
- var ve = Object.prototype.hasOwnProperty, pe = Object.prototype.propertyIsEnumerable;
- 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) => {
- for (var o in n || (n = {}))
- ve.call(n, o) && R(s, o, n[o]);
- if (A)
- for (var o of A(n))
- pe.call(n, o) && R(s, o, n[o]);
- return s;
- }, T = (s, n) => ue(s, re(n));
- var $ = (s, n, o) => new Promise((i, f) => {
- var N = (r) => {
- try {
- y(o.next(r));
- } catch (v) {
- f(v);
- }
- }, a = (r) => {
- try {
- y(o.throw(r));
- } catch (v) {
- f(v);
- }
- }, y = (r) => r.done ? i(r.value) : Promise.resolve(r.value).then(N, a);
- y((o = o.apply(s, n)).next());
- });
- 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";
- 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";
- function C() {
- this.map = {}, this.arrayLink = [];
- }
- C.prototype = {
- set: function(s, n) {
- var o = this.arrayLink.indexOf(s);
- o === -1 && (this.arrayLink.push(s), o = this.arrayLink.indexOf(s)), this.map[o] = n;
- },
- get: function(s) {
- var n = this.arrayLink.indexOf(s);
- return this.map.hasOwnProperty(n) ? this.map[n] : null;
- },
- delete: function(s) {
- var n = this.arrayLink.indexOf(s);
- this.arrayLink.splice(n, 1, "-1");
- var o = this.arrayLink.slice(0, n), i = this.arrayLink.slice(n + 1, this.arrayLink.length);
- return this.arrayLink = [], this.arrayLink.concat(o), this.arrayLink.concat(i), this.map.hasOwnProperty(n) ? delete this.map[n] : !1;
- },
- clear: function() {
- this.map = {}, this.arrayLink = [];
- },
- keys: function() {
- return this.arrayLink;
- },
- has: function(s) {
- return !!this.arrayLink.find((n) => n === s);
- },
- size: function() {
- var s;
- return ((s = this.arrayLink) == null ? void 0 : s.length) || 0;
- }
- };
- C.prototype.constructor = C;
- const De = { class: "modal-container" }, Oe = { class: "side-tree" }, Be = { class: "s-tree-common" }, Te = { class: "node-title" }, Ve = {
- key: 1,
- class: "node-title"
- }, 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 = {
- key: 0,
- class: "side-right"
- }, Fe = { class: "sub-title" }, Ke = { class: "roll-div" }, Je = { class: "lists" }, Ge = { class: "info" }, Qe = { class: "selected-name" }, We = { class: "desc" }, Xe = ["onClick"], Ye = {
- __name: "SBelowChoosePosition",
- props: {
- // 弹窗显隐
- value: {
- type: Boolean,
- default: !1
- },
- // 弹窗标题
- title: {
- type: String,
- default: window.$l("选择岗位")
- },
- // 是否多选
- multiple: {
- type: Boolean,
- default: !1
- },
- // 搜索框占位文案
- searchPlaceholder: {
- type: String,
- default: window.$l("按岗位名称、岗位编号搜索")
- },
- // 是否必填(校验用,未选时提示)
- required: {
- // 是否必填
- type: Boolean,
- default: !1
- },
- // 多选回显入参(selectedIds.sync)
- selectedIds: {
- // 多选时组件回显入参(selectedIds 双向绑定)
- type: Array,
- default: () => []
- },
- // 单选回显入参(selectedId.sync)
- selectedId: {
- // 单选时组件回显入参(selectedId 双向绑定)
- type: String,
- default: ""
- },
- // 只加载该根节点下的岗位(为空则从 -1 层开始)
- rootId: {
- // 根节点 id
- type: String,
- default: ""
- }
- },
- emits: [
- "update:value",
- "update:selectedIds",
- "update:selectedId",
- "callback",
- "input"
- ],
- setup(s, { expose: n, emit: o }) {
- const i = s, f = o, N = g(!1), a = he({
- pageNum: 1,
- pageSize: 10,
- searchValue: null,
- selectedData: {}
- }), y = g(!1), r = g(null), v = g([]), c = g([]), h = g([]), z = g([]), D = g([]), G = g(!1), Q = fe(() => window.$l("岗位"));
- b(
- () => i.selectedIds,
- (e) => {
- h.value = [...e || []], H();
- },
- { deep: !0 }
- ), b(
- () => i.selectedId,
- () => {
- j();
- }
- ), b(
- () => i.rootId,
- (e) => {
- console.log("val", e), B(e);
- }
- );
- const W = () => {
- var e;
- if (i.multiple) {
- if (i.required && (!v.value || v.value.length === 0)) {
- window.$message.warning(window.$l("请选择岗位"));
- return;
- }
- f("update:selectedIds", [...h.value]), f("callback", { selectedList: v.value }), f("update:value", !1);
- } else {
- if (i.required && !a.selectedData) {
- window.$message.warning(window.$l("请选择岗位"));
- return;
- }
- f("update:selectedId", ((e = a.selectedData) == null ? void 0 : e.id) || null), f("callback", { selected: a.selectedData || null }), f("update:value", !1), c.value = [];
- }
- }, M = () => {
- i.multiple || (c.value = []), f("callback", !1), f("update:value", !1);
- }, X = (e, l) => $(this, null, function* () {
- var _;
- const t = l.node.dataRef;
- if (a.pageNum = 1, t.type === "1" || t.type === "2") {
- a.campusId = null, a.unitId = null, c.value = [];
- return;
- }
- a.campusId = null, a.unitId = t.id, a.parentIds = `${t.parentIds}${t.id}`, a.unitType = t.type;
- const d = yield P({
- pageNum: a.pageNum || 1,
- pageSize: a.pageSize,
- searchValue: a.searchValue || "",
- unitid: t.id,
- containsChild: !0
- });
- a.pageTotal = d.total || 0, i.multiple && d && ((_ = d == null ? void 0 : d.list) != null && _.length) && v.value.length && (d.list || []).forEach((I) => {
- const E = v.value.find((u) => u.id === I.id);
- I.selected = !!E;
- }), O(d.list), c.value = d.list || [];
- }), Y = () => $(this, null, function* () {
- var d;
- a.pageNum = 1;
- const e = a.unitId || a.campusId, l = a.unitId ? 2 : 1, t = yield P({
- pageNum: a.pageNum || 1,
- pageSize: a.pageSize,
- searchValue: a.searchValue || "",
- unitid: e,
- containsChild: !0,
- unitType: l,
- isEnabled: !0
- });
- a.pageTotal = t.total || 0, i.multiple && t && ((d = t == null ? void 0 : t.list) != null && d.length) && v.value.length && (t.list || []).forEach((_) => {
- const I = v.value.find((E) => E.id === _.id);
- _.selected = !!I;
- }), O(t.list), c.value = (t == null ? void 0 : t.list) || [];
- }), Z = () => {
- const e = q.value;
- if (!e || G.value) return;
- Math.ceil(e.scrollTop + e.clientHeight) >= e.scrollHeight && c.value.length < a.pageTotal && (a.pageNum += 1, se());
- }, q = g(null), ee = (e) => {
- i.multiple ? e.selected = !e.selected : ((c.value || []).filter((l) => l.id !== e.id).forEach((l) => {
- l.selected = !1;
- }), e.selected = !e.selected, a.selectedData = k({}, e)), O(c.value);
- }, te = () => {
- y.value = !y.value, c.value.forEach((e) => {
- e.selected = y.value;
- });
- }, le = () => {
- if (!i.multiple) {
- r.value = new C(), h.value = [];
- const l = (c.value || []).find((t) => t.selected);
- a.selectedData = l ? k({}, l) : null;
- return;
- }
- const e = c.value || [];
- e && e.length && e.forEach((l) => {
- const t = h.value.find((d) => d === l.id);
- l.selected && !t ? h.value.push(l.id) : !l.selected && t && (h.value = h.value.filter((d) => d !== l.id));
- }), f("update:selectedIds", [...h.value]);
- }, H = () => $(this, null, function* () {
- if (i.multiple)
- if (h.value && h.value.length) {
- const e = yield Le(h.value);
- if (e && e.length) {
- const l = e.map((t) => T(k({}, t), { deptName: t.officeName }));
- r.value ? r.value.clear() : r.value = new C(), l.forEach((t) => {
- r.value.has(t.id) || r.value.set(t.id, {
- id: t.id,
- name: t.name,
- cover: t.cover,
- deptName: t.deptName,
- nameOrCount: t.nameOrCount.replace("此岗位暂无人员", "0") || "",
- rowno: t.sort || t.rowno
- });
- }), ae();
- }
- } else
- r.value = new C(), v.value = [];
- }), j = () => $(this, null, function* () {
- if (r.value = new C(), v.value = [], !i.selectedId) return;
- const e = yield Se(i.selectedId);
- e && (c.value.push({
- id: e.id,
- name: e.name,
- cover: null,
- deptName: e.officeName,
- nameOrCount: e.nameOrCount.replace("此岗位暂无人员", "0"),
- selected: !0
- }), a.selectedData = { id: e.id, name: e.name });
- }), ae = () => {
- var l;
- v.value = [];
- const e = [];
- if (r.value && ((l = r.value) == null ? void 0 : l.size()) > 0) {
- for (const t of r.value.keys()) {
- const d = r.value.get(t);
- e.push(k({}, d));
- }
- e.forEach((t) => {
- v.value.push(k({}, t));
- });
- }
- }, O = (e) => {
- if (!e || e.length === 0)
- y.value = !1;
- else {
- const l = e.filter((t) => t.selected);
- y.value = l.length === e.length;
- }
- }, se = () => $(this, null, function* () {
- var t;
- const e = a.unitId || a.campusId, l = yield P(T(k({}, a), {
- unitid: e,
- containsChild: !0,
- sortName: "a.sort",
- sortType: "asc"
- }));
- i.multiple && l && ((t = l == null ? void 0 : l.list) != null && t.length) && v.value.length && (l.list || []).forEach((d) => {
- const _ = v.value.find((I) => I.id === d.id);
- d.selected = !!_;
- }), O(l.list), l.list && l.list.forEach((d) => {
- c.value.push(k({}, d));
- });
- }), ne = () => {
- v.value && v.value.length && (c.value && c.value.length && c.value.forEach((e) => {
- e.selected = !1;
- }), r.value && r.value.clear(), h.value = [], v.value = []), y.value = !1;
- }, ie = (e) => {
- if (h.value && h.value.length && (h.value = h.value.filter((l) => l !== e.id)), c.value && c.value.length) {
- c.value.forEach((t) => {
- t.id === e.id && (t.selected = !1);
- });
- const l = c.value.filter((t) => t.selected);
- y.value = l.length === c.value.length;
- }
- f("update:selectedIds", [...h.value]);
- }, B = (e) => {
- if (!e) {
- D.value = [], z.value = [];
- return;
- }
- Ce({ parent: { id: e || "-1" } }).then((l) => {
- l && l.length && (D.value = [l[0].id], z.value = l.map((t) => T(k({}, t), { title: t.name })));
- });
- }, ce = (e) => {
- D.value = e;
- };
- return b(
- () => c.value,
- () => {
- le();
- },
- { deep: !0 }
- ), b(
- () => i.value,
- (e) => {
- N.value = e, i.multiple ? (h.value = [...i.selectedIds || []], H()) : (c.value = [], j());
- },
- { immediate: !0 }
- ), me(() => {
- i.rootId && B(i.rootId);
- }), n({ initLeftTreeData: B }), ye(() => {
- B();
- }), (e, l) => {
- const t = xe, d = Ne, _ = $e, I = Ee, E = ge("s-modal");
- return w(), U(E, {
- value: N.value,
- "onUpdate:value": l[1] || (l[1] = (u) => N.value = u),
- title: e.$l(s.title),
- width: s.multiple ? "900px" : "780px",
- showFullScreen: !1,
- onHandCancel: M
- }, {
- footer: L(() => [
- x(t, { onClick: M }, {
- default: L(() => [
- V(m(e.$l("取消")), 1)
- ]),
- _: 1
- }),
- x(t, {
- type: "primary",
- onClick: W
- }, {
- default: L(() => [
- V(m(e.$l("确认")), 1)
- ]),
- _: 1
- })
- ]),
- default: L(() => [
- p("div", De, [
- p("div", Oe, [
- p("div", Be, [
- x(_, {
- "expanded-keys": D.value,
- "tree-data": z.value,
- "field-names": { title: "title", key: "id", children: "children" },
- showIcon: !1,
- onExpand: ce,
- onSelect: X
- }, {
- title: L((u) => [
- (u.title || "").length > 15 ? (w(), U(d, {
- key: 0,
- placement: "topLeft",
- mouseEnterDelay: 1.5,
- mouseLeaveDelay: 0.5
- }, {
- title: L(() => [
- V(m(u.title), 1)
- ]),
- default: L(() => [
- p("div", Te, m((u.title || "").slice(0, 15)) + "...", 1)
- ]),
- _: 2
- }, 1024)) : (w(), S("div", Ve, m(u.title), 1))
- ]),
- _: 1
- }, 8, ["expanded-keys", "tree-data"])
- ])
- ]),
- p("div", ze, [
- p("div", Pe, [
- x(I, {
- style: { width: "274px" },
- value: a.searchValue,
- "onUpdate:value": l[0] || (l[0] = (u) => a.searchValue = u),
- placeholder: e.$l(s.searchPlaceholder || s.title),
- onPressEnter: Y
- }, null, 8, ["value", "placeholder"])
- ]),
- p("div", Me, [
- p("div", qe, [
- s.multiple ? (w(), S("div", {
- key: 0,
- class: "sub-title all-selected",
- onClick: te
- }, m(y.value ? e.$l("反选") : e.$l("全选")), 1)) : F("", !0),
- p("div", {
- class: "roll-div",
- ref_key: "listRef",
- ref: q,
- onScroll: Z
- }, [
- p("ul", He, [
- (w(!0), S(K, null, J(c.value, (u) => (w(), S("li", {
- key: u.id,
- class: _e({ selected: u.selected }),
- onClick: (de) => ee(u)
- }, [
- p("div", Ae, [
- p("div", {
- class: "name",
- style: ke({ "max-width": s.multiple ? "250px" : "400px" })
- }, m(`${u.name}(${u.nameOrCount.replace("此岗位暂无人员", "0")})`), 5),
- p("div", Re, m(u.deptName), 1)
- ])
- ], 10, je))), 128))
- ])
- ], 544)
- ]),
- s.multiple ? (w(), S("div", Ue, [
- p("div", Fe, [
- V(m(e.$l("本次已选的")) + m(Q.value), 1),
- p("a", {
- onClick: ne,
- class: "all-clear-selected"
- }, m(e.$l("清除")), 1)
- ]),
- p("div", Ke, [
- p("ul", Je, [
- (w(!0), S(K, null, J(v.value, (u) => (w(), S("li", {
- key: u.id
- }, [
- p("div", Ge, [
- p("div", Qe, m(`${u.name}(${u.nameOrCount})`), 1),
- p("div", We, m(u.deptName), 1)
- ]),
- p("div", {
- onClick: (de) => ie(u)
- }, [
- x(we(be), { class: "remove-icon" })
- ], 8, Xe)
- ]))), 128))
- ])
- ])
- ])) : F("", !0)
- ])
- ])
- ])
- ]),
- _: 1
- }, 8, ["value", "title", "width"]);
- };
- }
- }, lt = /* @__PURE__ */ Ie(Ye, [["__scopeId", "data-v-22f64a90"]]);
- export {
- lt as default
- };
|