| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- var F = Object.defineProperty;
- var k = Object.getOwnPropertySymbols;
- var z = Object.prototype.hasOwnProperty, G = Object.prototype.propertyIsEnumerable;
- var O = (r, u, t) => u in r ? F(r, u, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[u] = t, I = (r, u) => {
- for (var t in u || (u = {}))
- z.call(u, t) && O(r, t, u[t]);
- if (k)
- for (var t of k(u))
- G.call(u, t) && O(r, t, u[t]);
- return r;
- };
- var T = (r, u, t) => new Promise((g, S) => {
- var m = (n) => {
- try {
- f(t.next(n));
- } catch (i) {
- S(i);
- }
- }, d = (n) => {
- try {
- f(t.throw(n));
- } catch (i) {
- S(i);
- }
- }, f = (n) => n.done ? g(n.value) : Promise.resolve(n.value).then(m, d);
- f((t = t.apply(r, u)).next());
- });
- import { ref as p, computed as C, onMounted as L, watch as y, openBlock as j, createElementBlock as U, createVNode as H } from "vue";
- import { ae as R, af as M, ag as q, ah as J } from "./index2.js";
- import { _ as K } from "./index7.js";
- const P = { class: "s-data-range-tree-select" }, Z = {
- __name: "SDataRangeTreeSelect",
- props: {
- // 选中的组织 id 集合(v-model 双向绑定)
- value: {
- type: [String, Array],
- default: null
- },
- // 允许清空
- allowClear: {
- type: Boolean,
- default: !0
- },
- // 显示搜索框
- showSearch: {
- type: Boolean,
- default: !0
- },
- multiple: {
- type: Boolean,
- default: !1
- },
- // 是否显示复选框
- treeCheckable: {
- type: Boolean,
- default: !1
- },
- // 是否默认展开全部
- treeDefaultExpandAll: {
- type: Boolean,
- default: !0
- },
- placeholder: {
- type: String,
- default: ""
- },
- // 对应 antd treeDataSimpleMode
- treeDataSimpleMode: {
- type: [Boolean, Array],
- default: !0
- },
- // 最多显示的 tag 数
- maxTagCount: {
- type: Number,
- default: 1
- },
- // 已分组的形式禁用数据:1 禁用组织 / 2 禁用校区 / 3 禁用单位
- // 传字符串匹配单个 type,传数组匹配多个 type
- disabledGroup: {
- type: [String, Array],
- default: ""
- },
- // 只展示组织(type 固定为 '1')
- showOnlyOrganization: {
- type: Boolean,
- default: !1
- },
- // 支持自定义数据源(传数组则不再请求接口)
- treeSelectData: {
- type: [Boolean, Array],
- default: !1
- },
- // 是否启用数据权限过滤
- isDataScopeFilter: {
- type: Boolean,
- default: !1
- },
- // 启用后自动托管系统配置(dataScope),数据范围与系统保持一致
- autoSysConfig: {
- type: Boolean,
- default: !1
- },
- // 默认值(为当前登录用户组织),仅 showOnlyOrganization 时生效
- defaultValue: {
- type: Boolean,
- default: !0
- }
- },
- emits: ["update:value", "change"],
- setup(r, { emit: u }) {
- const t = r, g = u, S = R(), m = p(!1), d = p(!1), f = p(""), n = p(!1), i = C(() => !!(m.value || t.multiple)), c = p([]), o = p([]), E = C(() => t.treeDataSimpleMode ? !(o.value || []).some((e) => Array.isArray(e.children) && e.children.length) : !1), b = p([]);
- let A = !1;
- const x = C(() => {
- const a = f.value;
- return a ? Array.isArray(a) ? a : [a] : [];
- }), w = (a) => (!a || !a.length || !x.value.length || a.forEach((e) => {
- x.value.includes(e.type) && (e.disabled = !0, e.disableCheckbox = !0);
- }), a), h = (a) => {
- const e = I({}, a);
- return e.parent ? e.pId = e.parent.id || null : e.pId = null, e.value = a.id, e.label = a.name, Array.isArray(e.children) && e.children.length && (e.children = e.children.map(h)), e;
- }, D = () => {
- if (!b.value.length || !o.value || !o.value.length) return;
- const a = o.value.map((l) => l.value), e = b.value.filter((l) => !a.includes(l.value));
- e.length && (e.forEach((l) => {
- l.disabled = !0, l.disableCheckbox = !0;
- }), o.value = [...o.value, ...e]);
- }, V = (a, e) => {
- var s, v;
- const l = (v = (s = e == null ? void 0 : e.name) != null ? s : e == null ? void 0 : e.label) != null ? v : "";
- return String(l).toLowerCase().indexOf(String(a).toLowerCase()) >= 0;
- }, B = (a) => {
- let e;
- typeof a == "string" ? e = [a] : Array.isArray(a) ? e = (a || []).map((l) => l && typeof l == "object" ? l.value : l) : a && typeof a == "object" ? e = [a.value] : t.autoSysConfig ? e = null : e = "", g("update:value", e), g("change", e);
- }, _ = () => T(this, null, function* () {
- if (t.defaultValue && d.value) {
- const e = S.user || {};
- e.campusId && M([e.campusId]).then((l) => {
- const s = (l || []).map((v) => h(v));
- c.value = i.value ? s : s[0] || [], B(c.value);
- });
- }
- if (t.autoSysConfig) {
- const e = yield q("dataScope");
- if (!e) return;
- e.value === "1" ? d.value = !0 : e.value === "3" && (d.value = !1), f.value = "2", m.value = !1, n.value = !0;
- }
- if (Array.isArray(t.treeSelectData) && t.treeSelectData.length) {
- o.value = w(t.treeSelectData.map(h)), A = !0;
- return;
- }
- const a = yield J({
- type: d.value ? "1" : "",
- isDataScopeFilter: !!n.value
- });
- o.value = w((a || []).map(h)), A = !0, D();
- });
- return L(() => {
- _();
- }), y(i, (a) => {
- const e = c.value;
- !a && Array.isArray(e) ? c.value = e[0] || [] : a && e && !Array.isArray(e) && (c.value = e ? [e] : []);
- }), y(
- () => t.treeCheckable,
- (a) => {
- m.value = a;
- },
- { immediate: !0 }
- ), y(
- () => t.value,
- (a) => {
- if (a && a.length > 0) {
- const e = Array.isArray(a) ? a : [a];
- M(e).then((l) => {
- const s = (l || []).map((v) => h(v));
- b.value = s, c.value = i.value ? s : s[0] || [], setTimeout(() => {
- A && D();
- }, 300);
- });
- return;
- }
- c.value = [];
- },
- { immediate: !0 }
- ), y(
- () => t.disabledGroup,
- (a) => {
- f.value = a;
- },
- { immediate: !0 }
- ), y(
- () => t.showOnlyOrganization,
- (a) => {
- d.value = a;
- },
- { immediate: !0 }
- ), y(
- () => t.isDataScopeFilter,
- (a) => {
- n.value = a;
- },
- { immediate: !0 }
- ), y(
- () => t.treeSelectData,
- (a) => {
- !a || !a.length || (o.value = w(a.map(h)));
- },
- { immediate: !0 }
- ), (a, e) => {
- const l = K;
- return j(), U("div", P, [
- H(l, {
- value: c.value,
- "onUpdate:value": e[0] || (e[0] = (s) => c.value = s),
- style: { width: "100%" },
- "popup-class-name": "s-tree-select-popup",
- "allow-clear": r.allowClear,
- "show-search": r.showSearch,
- "tree-checkable": m.value,
- multiple: i.value,
- "dropdown-style": { maxHeight: "400px", overflow: "auto" },
- "tree-data": o.value,
- placeholder: r.placeholder,
- "tree-default-expand-all": r.treeDefaultExpandAll,
- "tree-data-simple-mode": E.value,
- "tree-check-strictly": i.value,
- "label-in-value": !0,
- "max-tag-count": r.maxTagCount,
- "filter-tree-node": V,
- onChange: B
- }, null, 8, ["value", "allow-clear", "show-search", "tree-checkable", "multiple", "tree-data", "placeholder", "tree-default-expand-all", "tree-data-simple-mode", "tree-check-strictly", "max-tag-count"])
- ]);
- };
- }
- };
- export {
- Z as default
- };
|