var j = Object.defineProperty; var T = Object.getOwnPropertySymbols; var O = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable; var E = (n, u, o) => u in n ? j(n, u, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[u] = o, w = (n, u) => { for (var o in u || (u = {})) O.call(u, o) && E(n, o, u[o]); if (T) for (var o of T(u)) U.call(u, o) && E(n, o, u[o]); return n; }; import { ref as d, computed as z, watch as M, getCurrentInstance as P, onMounted as W, openBlock as f, createElementBlock as h, createVNode as q, unref as B, isRef as G, withCtx as J, Fragment as L, renderList as K, toDisplayString as A } from "vue"; import { TreeSelect as Q } from "ant-design-vue"; import { n as X } from "./index2.js"; import { _ as Y } from "./index7.js"; const Z = { class: "s-tree-select-common" }, ee = ["title"], te = ["title"], le = ["title"], ae = { __name: "STreeSelect", props: { // 过滤字段 - search为tree 时生效 filterField: { type: String, default: "name" }, // 树节点属性 props: { type: Object, default: () => ({ children: "children", label: "name", value: "value" }) }, // 是否支持查询 search: { type: Boolean, default: !0 }, // 是否支持清空 clear: { type: Boolean, default: !0 }, // 是否展开所有节点 expandAll: { type: Boolean, default: !1 }, // 禁用 disabled: { type: Boolean, default: !1 }, // 占位符 - 文案提示 placeholder: { type: String, default() { return window.$l("请选择"); } }, // 默认值 - 默认选中项 // 默认为空字符串,表示不选中任何项,也可以是字符串数组,表示选中项的 value 值 // 默认选中项,支持 v-model 双向绑定 value: { type: [String, Array], default() { return ""; } }, // 获取数据 recursionChildren: { type: Function, default: () => [] }, // 是否添加全选节点 appendRootNodeAll: { type: Boolean, default: !1 }, // 多选 multiple: { type: Boolean, default: !1 }, // 显示数量 maxTagCount: { type: Number, default: 1 }, // 下拉列表高度,单位 px listHeight: { type: Number, default: 232 } }, emits: ["update:value", "change"], setup(n, { emit: u }) { const o = u, r = n, N = d(""), c = d([]), v = d([]), i = r.multiple ? d([]) : d(null), F = z(() => ({ label: r.props.label, value: r.props.value, children: r.props.children })), y = d([]), p = d(""); M( () => r.value, (e) => { r.multiple ? i.value = Array.isArray(e) ? e : e ? [e] : [] : i.value = e === void 0 || e === "" ? null : e; }, { immediate: !0 } ); const g = (e) => e && typeof e == "object" ? e.value : e, $ = (e) => { const l = Array.isArray(e) ? e.map(g) : g(e); i.value = l; const a = (Array.isArray(e) ? e : e == null ? [] : [e]).map((s) => { const m = g(s), x = b(c.value, m); return { value: m, label: s && typeof s == "object" && s.label || x && x.name || void 0, node: x }; }); o("update:value", l), o("change", i.value, a), C(); }, V = P(), C = () => { setTimeout(() => { let e = V; for (; e; ) { const l = e.exposed; if (l && typeof l.onFieldChange == "function" && typeof l.clearValidate == "function") { l.onFieldChange(); return; } e = e.parent; } }, 0); }, D = (e) => { if (!(e == null || Array.isArray(e) && !e.length)) return; const t = r.multiple ? [] : null; o("update:value", t), o("change", t, []), C(); }, b = (e, l) => { for (const t of e || []) if (t) { if (t.value === l || t[r.props.value] === l) return t; if (Array.isArray(t.children)) { const a = b(t.children, l); if (a) return a; } } return null; }, H = (e) => { e.value = e; }, _ = () => { v.value = [], r.recursionChildren("", N.value).then((e) => { c.value = I(e), c.value && c.value.length > 0 && (r.value ? v.value = [r.value] : v.value = [c.value[0][r.props.value]]); }); }, S = (e) => (e || []).map((l) => { const t = w({}, l); return (t[r.props.value] === void 0 || t[r.props.value] === null) && (t[r.props.value] = t.id), Array.isArray(t.children) && t.children.length && (t.children = S(t.children)), t; }), I = (e) => { if (r.appendRootNodeAll) { const l = { id: "all", key: "all", value: "all", label: window.$l("全选"), name: window.$l("全选"), title: window.$l("全选"), type: "1", typeLabel: window.$l("组织"), parent: { id: "0" }, children: null, isLeaf: !0 }; k(e, y.value, "children"), y.value && y.value.length && (y.value = y.value.map((t) => t[r.props.value])), e.unshift(l); } return S(e); }, R = (e, l) => (l && l.name || "").toLowerCase().indexOf((e || "").toLowerCase()) >= 0, k = (e, l = [], t = "children") => { e && e.length > 0 && e.forEach((a) => { const s = w({}, a); l.push(s), a[t] instanceof Array && a[t].length > 0 && k(a[t], l, t); }); }; return W(() => { _(); }), (e, l) => { const t = Y; return f(), h("div", Z, [ q(t, { style: { width: "100%" }, "popup-class-name": "s-tree-select-popup", multiple: n.multiple, "allow-clear": n.clear, "field-names": F.value, "show-search": n.search, "tree-data": c.value, listHeight: n.listHeight, maxTagCount: n.maxTagCount, placeholder: n.placeholder, disabled: n.disabled, value: B(i), "onUpdate:value": l[0] || (l[0] = (a) => G(i) ? i.value = a : null), showCheckedStrategy: B(Q).SHOW_ALL, searchValue: p.value, "onUpdate:searchValue": l[1] || (l[1] = (a) => p.value = a), "tree-node-filter-prop": n.filterField, "tree-default-expand-all": n.expandAll, treeExpandedKeys: v.value, "onUpdate:treeExpandedKeys": l[2] || (l[2] = (a) => v.value = a), filterTreeNode: R, onTreeExpand: H, onSelect: $, onChange: D }, { title: J(({ name: a }) => [ p.value.length && a ? (f(!0), h(L, { key: 0 }, K(a.toString().split(new RegExp(`(?<=${p.value})|(?=${p.value})`, "i")), (s, m) => (f(), h(L, { key: m }, [ s.toLowerCase() === p.value.toLowerCase() ? (f(), h("span", { key: 0, title: a, class: "s-theme-color" }, A(s), 9, ee)) : (f(), h("span", { key: 1, title: a }, A(s), 9, te)) ], 64))), 128)) : (f(), h("div", { key: 1, title: a }, A(a && a.length > 15 ? a.slice(0, 15) + "..." : a), 9, le)) ]), _: 1 }, 8, ["multiple", "allow-clear", "field-names", "show-search", "tree-data", "listHeight", "maxTagCount", "placeholder", "disabled", "value", "showCheckedStrategy", "searchValue", "tree-node-filter-prop", "tree-default-expand-all", "treeExpandedKeys"]) ]); }; } }, ie = /* @__PURE__ */ X(ae, [["__scopeId", "data-v-a5867adc"]]); export { ie as default };