cam-ui
Version:
Vue 2 UI Components Library
1,606 lines • 228 kB
JavaScript
var Yo = Object.defineProperty;
var Jo = (n, r, e) => r in n ? Yo(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
var p = (n, r, e) => (Jo(n, typeof r != "symbol" ? r + "" : r, e), e);
import "element-ui/lib/button";
import "element-ui/lib/checkbox";
import "element-ui/lib/checkbox-group";
import "element-ui/lib/input";
import "element-ui/lib/message";
import "element-ui/lib/pagination";
import "element-ui/lib/popover";
import "element-ui/lib/tooltip";
import ce from "lodash/debounce";
import z from "vue";
import jt from "resize-observer-polyfill";
import Cr from "lodash/intersection";
import Zo from "lodash/orderBy";
import Wt from "lodash/pick";
import Qo from "vuedraggable";
import ea from "vue-clipboard2";
var fe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, xr = {}, ta = {
get exports() {
return xr;
},
set exports(n) {
xr = n;
}
};
(function(n) {
n.exports = /******/
function(r) {
var e = {};
function t(o) {
if (e[o])
return e[o].exports;
var i = e[o] = {
/******/
i: o,
/******/
l: !1,
/******/
exports: {}
/******/
};
return r[o].call(i.exports, i, i.exports, t), i.l = !0, i.exports;
}
return t.m = r, t.c = e, t.d = function(o, i, a) {
t.o(o, i) || Object.defineProperty(o, i, { enumerable: !0, get: a });
}, t.r = function(o) {
typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(o, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(o, "__esModule", { value: !0 });
}, t.t = function(o, i) {
if (i & 1 && (o = t(o)), i & 8 || i & 4 && typeof o == "object" && o && o.__esModule)
return o;
var a = /* @__PURE__ */ Object.create(null);
if (t.r(a), Object.defineProperty(a, "default", { enumerable: !0, value: o }), i & 2 && typeof o != "string")
for (var s in o)
t.d(a, s, function(l) {
return o[l];
}.bind(null, s));
return a;
}, t.n = function(o) {
var i = o && o.__esModule ? (
/******/
function() {
return o.default;
}
) : (
/******/
function() {
return o;
}
);
return t.d(i, "a", i), i;
}, t.o = function(o, i) {
return Object.prototype.hasOwnProperty.call(o, i);
}, t.p = "/dist/", t(t.s = 102);
}({
/***/
0: (
/***/
function(r, e, t) {
t.d(e, "a", function() {
return o;
});
function o(i, a, s, l, d, m, g, f) {
var v = typeof i == "function" ? i.options : i;
a && (v.render = a, v.staticRenderFns = s, v._compiled = !0), l && (v.functional = !0), m && (v._scopeId = "data-v-" + m);
var b;
if (g ? (b = function(O) {
O = O || // cached call
this.$vnode && this.$vnode.ssrContext || // stateful
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !O && typeof __VUE_SSR_CONTEXT__ < "u" && (O = __VUE_SSR_CONTEXT__), d && d.call(this, O), O && O._registeredComponents && O._registeredComponents.add(g);
}, v._ssrRegister = b) : d && (b = f ? function() {
d.call(this, this.$root.$options.shadowRoot);
} : d), b)
if (v.functional) {
v._injectStyles = b;
var S = v.render;
v.render = function(M, A) {
return b.call(A), S(M, A);
};
} else {
var $ = v.beforeCreate;
v.beforeCreate = $ ? [].concat($, b) : [b];
}
return {
exports: i,
options: v
};
}
}
),
/***/
102: (
/***/
function(r, e, t) {
t.r(e);
var o = function() {
var f = this, v = f.$createElement, b = f._self._c || v;
return b("transition", { attrs: { name: "el-alert-fade" } }, [
b(
"div",
{
directives: [
{
name: "show",
rawName: "v-show",
value: f.visible,
expression: "visible"
}
],
staticClass: "el-alert",
class: [
f.typeClass,
f.center ? "is-center" : "",
"is-" + f.effect
],
attrs: { role: "alert" }
},
[
f.showIcon ? b("i", {
staticClass: "el-alert__icon",
class: [f.iconClass, f.isBigIcon]
}) : f._e(),
b("div", { staticClass: "el-alert__content" }, [
f.title || f.$slots.title ? b(
"span",
{ staticClass: "el-alert__title", class: [f.isBoldTitle] },
[f._t("title", [f._v(f._s(f.title))])],
2
) : f._e(),
f.$slots.default && !f.description ? b(
"p",
{ staticClass: "el-alert__description" },
[f._t("default")],
2
) : f._e(),
f.description && !f.$slots.default ? b("p", { staticClass: "el-alert__description" }, [
f._v(f._s(f.description))
]) : f._e(),
b(
"i",
{
directives: [
{
name: "show",
rawName: "v-show",
value: f.closable,
expression: "closable"
}
],
staticClass: "el-alert__closebtn",
class: {
"is-customed": f.closeText !== "",
"el-icon-close": f.closeText === ""
},
on: {
click: function(S) {
f.close();
}
}
},
[f._v(f._s(f.closeText))]
)
])
]
)
]);
}, i = [];
o._withStripped = !0;
var a = {
success: "el-icon-success",
warning: "el-icon-warning",
error: "el-icon-error"
}, s = {
name: "ElAlert",
props: {
title: {
type: String,
default: ""
},
description: {
type: String,
default: ""
},
type: {
type: String,
default: "info"
},
closable: {
type: Boolean,
default: !0
},
closeText: {
type: String,
default: ""
},
showIcon: Boolean,
center: Boolean,
effect: {
type: String,
default: "light",
validator: function(v) {
return ["light", "dark"].indexOf(v) !== -1;
}
}
},
data: function() {
return {
visible: !0
};
},
methods: {
close: function() {
this.visible = !1, this.$emit("close");
}
},
computed: {
typeClass: function() {
return "el-alert--" + this.type;
},
iconClass: function() {
return a[this.type] || "el-icon-info";
},
isBigIcon: function() {
return this.description || this.$slots.default ? "is-big" : "";
},
isBoldTitle: function() {
return this.description || this.$slots.default ? "is-bold" : "";
}
}
}, l = s, d = t(0), m = Object(d.a)(
l,
o,
i,
!1,
null,
null,
null
);
m.options.__file = "packages/alert/src/main.vue";
var g = m.exports;
g.install = function(f) {
f.component(g.name, g);
}, e.default = g;
}
)
/******/
});
})(ta);
/**
* vue-class-component v7.2.6
* (c) 2015-present Evan You
* @license MIT
*/
function Ye(n) {
return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? Ye = function(r) {
return typeof r;
} : Ye = function(r) {
return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
}, Ye(n);
}
function ra(n, r, e) {
return r in n ? Object.defineProperty(n, r, {
value: e,
enumerable: !0,
configurable: !0,
writable: !0
}) : n[r] = e, n;
}
function na(n) {
return ia(n) || oa(n) || aa();
}
function ia(n) {
if (Array.isArray(n)) {
for (var r = 0, e = new Array(n.length); r < n.length; r++)
e[r] = n[r];
return e;
}
}
function oa(n) {
if (Symbol.iterator in Object(n) || Object.prototype.toString.call(n) === "[object Arguments]")
return Array.from(n);
}
function aa() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function sa() {
return typeof Reflect < "u" && Reflect.defineMetadata && Reflect.getOwnMetadataKeys;
}
function la(n, r) {
dt(n, r), Object.getOwnPropertyNames(r.prototype).forEach(function(e) {
dt(n.prototype, r.prototype, e);
}), Object.getOwnPropertyNames(r).forEach(function(e) {
dt(n, r, e);
});
}
function dt(n, r, e) {
var t = e ? Reflect.getOwnMetadataKeys(r, e) : Reflect.getOwnMetadataKeys(r);
t.forEach(function(o) {
var i = e ? Reflect.getOwnMetadata(o, r, e) : Reflect.getOwnMetadata(o, r);
e ? Reflect.defineMetadata(o, i, n, e) : Reflect.defineMetadata(o, i, n);
});
}
var ca = {
__proto__: []
}, ua = ca instanceof Array;
function cr(n) {
return function(r, e, t) {
var o = typeof r == "function" ? r : r.constructor;
o.__decorators__ || (o.__decorators__ = []), typeof t != "number" && (t = void 0), o.__decorators__.push(function(i) {
return n(i, e, t);
});
};
}
function ha(n) {
var r = Ye(n);
return n == null || r !== "object" && r !== "function";
}
function xo(n) {
typeof console < "u" && console.warn("[vue-class-component] " + n);
}
function da(n, r) {
var e = r.prototype._init;
r.prototype._init = function() {
var i = this, a = Object.getOwnPropertyNames(n);
if (n.$options.props)
for (var s in n.$options.props)
n.hasOwnProperty(s) || a.push(s);
a.forEach(function(l) {
Object.defineProperty(i, l, {
get: function() {
return n[l];
},
set: function(m) {
n[l] = m;
},
configurable: !0
});
});
};
var t = new r();
r.prototype._init = e;
var o = {};
return Object.keys(t).forEach(function(i) {
t[i] !== void 0 && (o[i] = t[i]);
}), process.env.NODE_ENV !== "production" && !(r.prototype instanceof z) && Object.keys(o).length > 0 && xo("Component class must inherit Vue or its descendant class when class property is used."), o;
}
var Bt = [
"data",
"beforeCreate",
"created",
"beforeMount",
"mounted",
"beforeDestroy",
"destroyed",
"beforeUpdate",
"updated",
"activated",
"deactivated",
"render",
"errorCaptured",
"serverPrefetch"
// 2.6
];
function wr(n) {
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
r.name = r.name || n._componentTag || n.name;
var e = n.prototype;
Object.getOwnPropertyNames(e).forEach(function(s) {
if (s !== "constructor") {
if (Bt.indexOf(s) > -1) {
r[s] = e[s];
return;
}
var l = Object.getOwnPropertyDescriptor(e, s);
l.value !== void 0 ? typeof l.value == "function" ? (r.methods || (r.methods = {}))[s] = l.value : (r.mixins || (r.mixins = [])).push({
data: function() {
return ra({}, s, l.value);
}
}) : (l.get || l.set) && ((r.computed || (r.computed = {}))[s] = {
get: l.get,
set: l.set
});
}
}), (r.mixins || (r.mixins = [])).push({
data: function() {
return da(this, n);
}
});
var t = n.__decorators__;
t && (t.forEach(function(s) {
return s(r);
}), delete n.__decorators__);
var o = Object.getPrototypeOf(n.prototype), i = o instanceof z ? o.constructor : z, a = i.extend(r);
return ga(a, n, i), sa() && la(a, n), a;
}
var fa = [
// Unique id
"cid",
// Super Vue constructor
"super",
// Component options that will be used by the component
"options",
"superOptions",
"extendOptions",
"sealedOptions",
// Private assets
"component",
"directive",
"filter"
], pa = {
prototype: !0,
arguments: !0,
callee: !0,
caller: !0
};
function ga(n, r, e) {
Object.getOwnPropertyNames(r).forEach(function(t) {
if (!pa[t]) {
var o = Object.getOwnPropertyDescriptor(n, t);
if (!(o && !o.configurable)) {
var i = Object.getOwnPropertyDescriptor(r, t);
if (!ua) {
if (t === "cid")
return;
var a = Object.getOwnPropertyDescriptor(e, t);
if (!ha(i.value) && a && a.value === i.value)
return;
}
process.env.NODE_ENV !== "production" && fa.indexOf(t) >= 0 && xo("Static property name '".concat(t, "' declared on class '").concat(r.name, "' ") + "conflicts with reserved property name of Vue internal. It may cause unexpected behavior of the component. Consider renaming the property."), Object.defineProperty(n, t, i);
}
}
});
}
function X(n) {
return typeof n == "function" ? wr(n) : function(r) {
return wr(r, n);
};
}
X.registerHooks = function(r) {
Bt.push.apply(Bt, na(r));
};
globalThis && globalThis.__spreadArrays;
var ma = typeof Reflect < "u" && typeof Reflect.getMetadata < "u";
function ba(n, r, e) {
if (ma && !Array.isArray(n) && typeof n != "function" && !n.hasOwnProperty("type") && typeof n.type > "u") {
var t = Reflect.getMetadata("design:type", r, e);
t !== Object && (n.type = t);
}
}
function y(n) {
return n === void 0 && (n = {}), function(r, e) {
ba(n, r, e), cr(function(t, o) {
(t.props || (t.props = {}))[o] = n;
})(r, e);
};
}
function Q(n) {
return cr(function(r, e) {
r.computed = r.computed || {}, r.computed[e] = {
cache: !1,
get: function() {
return this.$refs[n || e];
}
};
});
}
function R(n, r) {
r === void 0 && (r = {});
var e = r.deep, t = e === void 0 ? !1 : e, o = r.immediate, i = o === void 0 ? !1 : o;
return cr(function(a, s) {
typeof a.watch != "object" && (a.watch = /* @__PURE__ */ Object.create(null));
var l = a.watch;
typeof l[n] == "object" && !Array.isArray(l[n]) ? l[n] = [l[n]] : typeof l[n] > "u" && (l[n] = []), l[n].push({ handler: s, deep: t, immediate: i });
});
}
const Nt = z.prototype.$isServer, ya = /([\:\-\_]+(.))/g, va = /^moz([A-Z])/, _a = Nt ? 0 : Number(document.documentMode), Sa = function(n) {
return (n || "").replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
}, $r = function(n) {
return n.replace(ya, function(r, e, t, o) {
return o ? t.toUpperCase() : t;
}).replace(va, "Moz$1");
};
function Ie(n, r) {
if (!n || !r)
return !1;
if (r.indexOf(" ") !== -1)
throw new Error("className should not contain space.");
return n.classList ? n.classList.contains(r) : (" " + n.className + " ").indexOf(" " + r + " ") > -1;
}
function Ca(n, r) {
if (!n)
return;
let e = n.className;
const t = (r || "").split(" ");
for (let o = 0, i = t.length; o < i; o++) {
const a = t[o];
a && (n.classList ? n.classList.add(a) : Ie(n, a) || (e += " " + a));
}
n.classList || n.setAttribute("class", e);
}
function Tr(n, r) {
if (!n || !r)
return;
const e = r.split(" ");
let t = " " + n.className + " ";
for (let o = 0, i = e.length; o < i; o++) {
const a = e[o];
a && (n.classList ? n.classList.remove(a) : Ie(n, a) && (t = t.replace(" " + a + " ", " ")));
}
n.classList || n.setAttribute("class", Sa(t));
}
const wo = _a < 9 ? function(n, r) {
if (!Nt) {
if (!n || !r)
return null;
r = $r(r), r === "float" && (r = "styleFloat");
try {
switch (r) {
case "opacity":
try {
return n.filters.item("alpha").opacity / 100;
} catch {
return 1;
}
default:
return n.style[r] || n.currentStyle ? n.currentStyle[r] : null;
}
} catch {
return n.style[r];
}
}
} : function(n, r) {
if (!Nt) {
if (!n || !r)
return null;
r = $r(r), r === "float" && (r = "cssFloat");
try {
const e = document.defaultView.getComputedStyle(n, "");
return n.style[r] || e ? e[r] : null;
} catch {
return n.style[r];
}
}
}, xa = function(n) {
for (const r of n) {
const e = r.target.__resizeListeners__ || [];
e.length && e.forEach((t) => {
t();
});
}
}, Or = function(n, r) {
n.__resizeListeners__ || (n.__resizeListeners__ = [], n.__ro__ = new jt(xa), n.__ro__.observe(n)), n.__resizeListeners__.push(r);
}, Rr = function(n, r) {
!n || !n.__resizeListeners__ || (n.__resizeListeners__.splice(n.__resizeListeners__.indexOf(r), 1), n.__resizeListeners__.length || n.__ro__.disconnect());
};
var wa = Object.defineProperty, $a = Object.getOwnPropertyDescriptor, oe = (n, r, e, t) => {
for (var o = t > 1 ? void 0 : t ? $a(r, e) : r, i = n.length - 1, a; i >= 0; i--)
(a = n[i]) && (o = (t ? a(r, e, o) : a(o)) || o);
return t && o && wa(r, e, o), o;
};
let J = class extends z {
constructor() {
super(...arguments);
p(this, "container");
p(this, "box");
p(this, "bodyHeight");
p(this, "data");
p(this, "itemHeight");
p(this, "sufBufferSize");
p(this, "preBufferSize");
p(this, "useVirtual");
//=====================Variables========================
p(this, "startIndex", 0);
p(this, "endIndex", 0);
p(this, "visibleCount", 0);
p(this, "debounceScroll", ce(this.addScroll, 100));
}
//=====================Computed=========================
get startOffset() {
return this.startIndex * this.itemHeight;
}
get containerStyle() {
const { bodyHeight: e, data: t } = this;
return t.length ? {
maxHeight: e ? e + "px" : "auto",
overflowY: "auto"
} : {};
}
get boxStyle() {
const { itemHeight: e, data: t, useVirtual: o } = this;
return {
height: o && t.length ? e * t.length + "px" : "auto"
};
}
get listStyle() {
const { startOffset: e, useVirtual: t } = this;
return {
// paddingTop: useVirtual ? startOffset + 'px' : '0px'
transform: `translate3d(0, ${t ? Math.ceil(e) + "px" : "0px"}, 0)`
};
}
get visibleList() {
const { data: e, startIndex: t, endIndex: o, useVirtual: i } = this;
return i ? e.slice(t, o) : e.slice(0);
}
onParamsChange() {
this.useVirtual && this.handleScroll();
}
onDataChange(e) {
!e.length && this.container && (this.container.scrollLeft = 0, this.container.scrollTop = 0);
}
//=====================Methods==========================
handleScroll() {
(() => {
const { scrollTop: t, scrollLeft: o } = this.container;
this.useVirtual && (this.visibleCount = this.bodyHeight / this.itemHeight + this.sufBufferSize + this.preBufferSize, this.startIndex = Math.max(
0,
Math.floor(t / this.itemHeight - this.preBufferSize)
), this.endIndex = Math.min(
Math.ceil(this.startIndex + this.visibleCount),
this.data.length
)), this.$emit("scroll", { scrollTop: t, scrollLeft: o });
})();
}
scrollToItem(e) {
const t = this.data.indexOf(e);
this.scrollToIndex(t);
}
scrollToTop() {
this.container.scrollTo({ top: 0, behavior: "auto" });
}
scrollToIndex(e) {
this.container.scrollTo({
top: Math.max(e - 1, 0) * this.itemHeight
});
}
scrollToLeft(e) {
this.container && this.container.scrollLeft !== e && (this.container.removeEventListener("scroll", this.handleScroll), this.container.scrollLeft = e, this.debounceScroll());
}
addScroll() {
this.container.addEventListener("scroll", this.handleScroll);
}
//=====================Lifecycle========================
mounted() {
this.container.addEventListener("scroll", this.handleScroll), this.handleScroll();
}
beforeDestroy() {
this.container.removeEventListener("scroll", this.handleScroll);
}
};
oe([
Q()
], J.prototype, "container", 2);
oe([
Q()
], J.prototype, "box", 2);
oe([
y({ type: Number })
], J.prototype, "bodyHeight", 2);
oe([
y({ type: Array, default: () => [] })
], J.prototype, "data", 2);
oe([
y({ type: Number, default: 42 })
], J.prototype, "itemHeight", 2);
oe([
y({ type: Number, default: 5 })
], J.prototype, "sufBufferSize", 2);
oe([
y({ type: Number, default: 5 })
], J.prototype, "preBufferSize", 2);
oe([
y({ type: Boolean, default: !0 })
], J.prototype, "useVirtual", 2);
oe([
R("preBufferSize"),
R("sufBufferSize"),
R("itemHeight"),
R("bodyHeight"),
R("data"),
R("useVirtual")
], J.prototype, "onParamsChange", 1);
oe([
R("data")
], J.prototype, "onDataChange", 1);
J = oe([
X({
name: "VirtualList"
})
], J);
var Ta = function() {
var n = this, r = n.$createElement, e = n._self._c || r;
return e("div", {
ref: "container",
staticClass: "virtual-list-container",
style: n.containerStyle
}, [e("div", {
ref: "box",
staticClass: "virtual-list-box",
style: n.boxStyle
}, [e("div", {
staticClass: "virtual-list",
style: n.listStyle
}, [n._t("default", null, {
list: n.visibleList
})], 2)])]);
}, Oa = [];
function ee(n, r, e, t, o, i, a, s) {
var l = typeof n == "function" ? n.options : n;
r && (l.render = r, l.staticRenderFns = e, l._compiled = !0), t && (l.functional = !0), i && (l._scopeId = "data-v-" + i);
var d;
if (a ? (d = function(f) {
f = f || // cached call
this.$vnode && this.$vnode.ssrContext || // stateful
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !f && typeof __VUE_SSR_CONTEXT__ < "u" && (f = __VUE_SSR_CONTEXT__), o && o.call(this, f), f && f._registeredComponents && f._registeredComponents.add(a);
}, l._ssrRegister = d) : o && (d = s ? function() {
o.call(
this,
(l.functional ? this.parent : this).$root.$options.shadowRoot
);
} : o), d)
if (l.functional) {
l._injectStyles = d;
var m = l.render;
l.render = function(v, b) {
return d.call(b), m(v, b);
};
} else {
var g = l.beforeCreate;
l.beforeCreate = g ? [].concat(g, d) : [d];
}
return {
exports: n,
options: l
};
}
const Mr = {};
var Ra = /* @__PURE__ */ ee(
J,
Ta,
Oa,
!1,
Ma,
null,
null,
null
);
function Ma(n) {
for (let r in Mr)
this[r] = Mr[r];
}
const Pa = /* @__PURE__ */ function() {
return Ra.exports;
}();
var Aa = Object.defineProperty, La = Object.getOwnPropertyDescriptor, re = (n, r, e, t) => {
for (var o = t > 1 ? void 0 : t ? La(r, e) : r, i = n.length - 1, a; i >= 0; i--)
(a = n[i]) && (o = (t ? a(r, e, o) : a(o)) || o);
return t && o && Aa(r, e, o), o;
};
let Y = class extends z {
constructor() {
super(...arguments);
p(this, "container");
p(this, "box");
p(this, "bodyHeight");
p(this, "data");
p(this, "preBufferSize");
p(this, "sufBufferSize");
p(this, "useVirtual");
p(this, "estimatedItemHeight");
p(this, "uniqueKey");
p(this, "startIndex", 0);
p(this, "endIndex", 0);
p(this, "visibleCount", 0);
p(this, "resizeObserver", null);
// 锚点,当高度动态改变的时候,用来保持视图不变
p(this, "anchorInfo", {
index: 0,
offset: 0,
// 锚点元素相对于其顶部的偏移量
element: null
});
p(this, "lastScrollTop", 0);
// 上次滚动位置
// 存储每个项目的实际高度
p(this, "itemHeights", /* @__PURE__ */ new Map());
p(this, "positions", []);
p(this, "totalHeight", 0);
p(this, "isUpdatingHeight", !1);
p(this, "debounceScroll", ce(this.addScroll, 100));
p(this, "debounceUpdateHeight", ce(() => {
this.updateItemsHeight(), this.handleScroll();
}, 100));
}
// 计算起始偏移量
get startOffset() {
return this.startIndex <= 0 ? 0 : this.positions[this.startIndex] ? this.positions[this.startIndex].top : 0;
}
get containerStyle() {
return this.data.length ? {
maxHeight: this.bodyHeight ? this.bodyHeight + "px" : "auto",
overflowY: "auto"
} : {};
}
get boxStyle() {
return !this.useVirtual || !this.data.length ? { height: "auto" } : { height: this.totalHeight + "px" };
}
get listStyle() {
return this.useVirtual ? {
transform: `translate3d(0, ${Math.ceil(this.startOffset)}px, 0)`
} : { transform: "translate3d(0, 0px, 0)" };
}
get visibleList() {
return this.useVirtual ? this.data.slice(this.startIndex, this.endIndex) : this.data.slice(0);
}
getItemKey(e, t) {
return typeof this.uniqueKey == "function" ? this.uniqueKey(e) : typeof this.uniqueKey == "string" && e[this.uniqueKey] !== void 0 ? e[this.uniqueKey] : `${t}-${JSON.stringify(e).slice(0, 30)}`;
}
initPositionCache() {
const { data: e, estimatedItemHeight: t } = this, o = { ...this.anchorInfo };
this.positions = new Array(e.length);
let i = 0;
for (let a = 0; a < e.length; a++) {
const s = this.getItemKey(e[a], a), l = this.itemHeights.get(s) || t, d = {
index: a,
height: l,
top: i,
bottom: i + l
};
this.positions[a] = d, i += l;
}
this.totalHeight = i, this.$nextTick(() => {
if (o.index > 0 && o.index < this.data.length) {
const a = this.positions[o.index].top + o.offset;
this.container && Math.abs(this.container.scrollTop - a) > 1 && (this.container.removeEventListener("scroll", this.handleScroll), this.container.scrollTop = a, this.lastScrollTop = a, setTimeout(() => {
this.container.addEventListener("scroll", this.handleScroll);
}, 10));
}
});
}
/**
* 更新可见项的实际高度
*/
updateItemsHeight() {
if (!(!this.useVirtual || !this.container || this.isUpdatingHeight)) {
this.isUpdatingHeight = !0;
try {
const e = this.container.querySelectorAll(
".virtual-list > table > tbody > .cam-ui-table-row"
);
let t = !1;
e.forEach((o, i) => {
const a = this.startIndex + i;
if (a < this.data.length) {
const s = this.getItemKey(this.data[a], a), l = o.getBoundingClientRect().height, d = this.itemHeights.get(s) || this.estimatedItemHeight;
Math.abs(d - l) > 0 && (this.itemHeights.set(s, l), t = !0);
}
}), t && this.updatePositions();
} finally {
this.isUpdatingHeight = !1;
}
}
}
updatePositions() {
const { data: e, estimatedItemHeight: t } = this;
let o = 0;
for (let i = 0; i < e.length; i++) {
const a = this.getItemKey(e[i], i), s = this.itemHeights.get(a) || t;
this.positions[i] = {
index: i,
height: s,
top: o,
bottom: o + s
}, o += s;
}
this.totalHeight = o;
}
getAverageHeight() {
if (this.itemHeights.size === 0)
return this.estimatedItemHeight;
let e = 0;
return this.itemHeights.forEach((t) => {
e += t;
}), this.itemHeights.size > 0 ? e / this.itemHeights.size : this.estimatedItemHeight;
}
onParamsChange() {
this.useVirtual && (this.initPositionCache(), this.handleScroll());
}
onDataChange(e) {
!e.length && this.container && (this.container.scrollLeft = 0, this.container.scrollTop = 0), this.useVirtual && (this.initPositionCache(), this.handleScroll());
}
/**
* todo 不太好使,慎用 滚动到指定项
*/
scrollToItem(e) {
const t = this.data.indexOf(e);
this.scrollToIndex(t);
}
/**
* 滚动到顶部
*/
scrollToTop() {
this.container.scrollTo({ top: 0, behavior: "auto" });
}
/**
* todo 滚动到指定索引 (不准确)
* 如果想要准确,需要每行都渲染一遍
*/
scrollToIndex(e) {
if (e < 0 || e >= this.data.length)
return;
const t = e > 0 ? this.positions[e].top : 0;
this.container.scrollTo({
top: t,
behavior: "auto"
});
}
scrollToLeft(e) {
this.container && this.container.scrollLeft !== e && (this.container.removeEventListener("scroll", this.handleScroll), this.container.scrollLeft = e, this.debounceScroll());
}
addScroll() {
this.container.addEventListener("scroll", this.handleScroll);
}
mounted() {
if (this.initPositionCache(), this.container.addEventListener("scroll", this.handleScroll), this.handleScroll(), typeof jt < "u") {
this.resizeObserver = new jt(this.debounceUpdateHeight), this.container && this.resizeObserver.observe(this.container);
const e = this.container.querySelector(".virtual-list");
e && this.resizeObserver.observe(e);
}
}
updated() {
this.$nextTick(() => this.updateItemsHeight());
}
beforeDestroy() {
this.container.removeEventListener("scroll", this.handleScroll), this.resizeObserver && this.resizeObserver.disconnect();
}
// 找到第一个底部位置大于或等于scrollTop的项
findStartIndex(e) {
if (e <= 0 || !this.positions.length)
return 0;
for (let t = 0; t < this.positions.length; t++)
if (this.positions[t].bottom > e)
return t;
return this.positions.length - 1;
}
handleScroll() {
if (!this.container)
return;
const { scrollTop: e, scrollLeft: t } = this.container;
this.lastScrollTop = e, this.useVirtual && requestAnimationFrame(() => {
this.updateItemsHeight();
const o = this.getAverageHeight();
this.visibleCount = Math.ceil(this.bodyHeight / o) + this.preBufferSize + this.sufBufferSize, this.startIndex = Math.max(
0,
this.findStartIndex(e) - this.preBufferSize
), this.endIndex = Math.min(
this.startIndex + this.visibleCount,
this.data.length
);
let i = this.startIndex, a = !1;
for (let l = this.startIndex; l < this.endIndex; l++) {
const d = this.positions[l];
if (d.top >= e && d.bottom <= e + this.bodyHeight) {
i = l, a = !0;
break;
}
}
a || (i = this.startIndex);
const s = this.positions[i];
s && (this.anchorInfo = {
index: i,
offset: e - s.top,
element: this.data[i]
});
}), this.$emit("scroll", { scrollTop: e, scrollLeft: t });
}
};
re([
Q()
], Y.prototype, "container", 2);
re([
Q()
], Y.prototype, "box", 2);
re([
y({ type: Number })
], Y.prototype, "bodyHeight", 2);
re([
y({ type: Array, default: () => [] })
], Y.prototype, "data", 2);
re([
y({ type: Number, default: 5 })
], Y.prototype, "preBufferSize", 2);
re([
y({ type: Number, default: 5 })
], Y.prototype, "sufBufferSize", 2);
re([
y({ type: Boolean, default: !0 })
], Y.prototype, "useVirtual", 2);
re([
y({ type: Number, default: 50 })
], Y.prototype, "estimatedItemHeight", 2);
re([
y({ type: [String, Function] })
], Y.prototype, "uniqueKey", 2);
re([
R("preBufferSize"),
R("sufBufferSize"),
R("bodyHeight"),
R("useVirtual")
], Y.prototype, "onParamsChange", 1);
re([
R("data")
], Y.prototype, "onDataChange", 1);
Y = re([
X({
name: "DynamicVirtualList"
})
], Y);
var Ea = function() {
var n = this, r = n.$createElement, e = n._self._c || r;
return e("div", {
ref: "container",
staticClass: "virtual-list-container dynamic-virtual-list",
style: n.containerStyle
}, [e("div", {
ref: "box",
staticClass: "virtual-list-box",
style: n.boxStyle
}, [e("div", {
staticClass: "virtual-list",
style: n.listStyle
}, [n._t("default", null, {
list: n.visibleList
})], 2)])]);
}, Ia = [];
const Pr = {};
var ka = /* @__PURE__ */ ee(
Y,
Ea,
Ia,
!1,
Fa,
null,
null,
null
);
function Fa(n) {
for (let r in Pr)
this[r] = Pr[r];
}
const Ha = /* @__PURE__ */ function() {
return ka.exports;
}(), Da = {
name: "VirtualList",
functional: !0,
props: {
dynamic: {
type: Boolean,
default: !1
}
},
render(n, r) {
const e = r.props.dynamic ? Ha : Pa;
return n(e, r.data, r.children);
}
};
let Ne;
function za() {
var o;
if (Ne !== void 0)
return Ne;
const n = document.createElement("div");
n.className = "el-scrollbar__wrap", n.style.visibility = "hidden", n.style.width = "100px", n.style.position = "absolute", n.style.top = "-9999px", document.body.appendChild(n);
const r = n.offsetWidth;
n.style.overflow = "scroll";
const e = document.createElement("div");
e.style.width = "100%", n.appendChild(e);
const t = e.offsetWidth;
return (o = n.parentNode) == null || o.removeChild(n), Ne = r - t, Ne;
}
function xe(n) {
if (n !== void 0) {
let r = parseInt(n.toString(), 10);
return isNaN(r) && (r = null), r;
}
return null;
}
function Ae(n) {
if (n !== void 0) {
let r = xe(n);
return isNaN(r) && (r = 80), r;
}
return n;
}
function de(n, r) {
let e = n;
const t = r.split(".");
for (let o = 0; o < t.length; o++) {
const i = t[o];
if (e = e[i], !e)
break;
}
return e;
}
function Qe(n, r) {
return getComputedStyle(n === window ? document.documentElement : n)[r];
}
var ja = Object.defineProperty, Wa = Object.getOwnPropertyDescriptor, it = (n, r, e, t) => {
for (var o = t > 1 ? void 0 : t ? Wa(r, e) : r, i = n.length - 1, a; i >= 0; i--)
(a = n[i]) && (o = (t ? a(r, e, o) : a(o)) || o);
return t && o && ja(r, e, o), o;
};
const Ba = new Array(300).fill("Z").join(), Je = (n) => {
const r = [];
return n.forEach((e) => {
e.children ? (e.children.forEach((t) => t.fixed = e.fixed), r.push.apply(r, Je(e.children))) : r.push(e);
}), r;
}, et = (n, r = (s) => !0, e = "children", t, o, i, a) => {
const s = [];
return n.forEach((l, d) => {
const m = r(l);
if (m && s.push(t ? l[t] : l), o && o(l, d, m), !i)
l[e] && s.push.apply(
s,
et(
l[e],
r,
e,
t,
o
)
);
else {
const g = a[l[t]] || {};
g.children && s.push.apply(
s,
et(
g.children,
r,
e,
t,
o,
i,
a
)
);
}
}), s;
};
let we = class extends z {
constructor() {
super(...arguments);
//=====================Variables========================
p(this, "table", null);
// 表格的配置
p(this, "config", null);
// 列数据 与 template 中一致,会有层级的嵌套
p(this, "columns", []);
// 表格原数据,方便重置排序 todo 后续看看有没有更好的方式
p(this, "dataSource", []);
// 表格数据
p(this, "data", []);
// 过滤后的数据
p(this, "filteredData", []);
// 过滤条件数组
p(this, "filterRules", []);
p(this, "matchedTotal", 0);
// 存储真正匹配筛选条件的节点集合,方便其他功能使用
p(this, "matchedNodes", /* @__PURE__ */ new Set());
// 树形表格打平后的数组(flat)不写成计算属性(计算属性是同步的,大数据量同时有数据变更的话,会有性能问题。使用watch可以控制更新节奏)
// public flatData: any[] = []
// depthsMap 标记行数据所在的层级
p(this, "depthMap", {});
// 表格实际宽度
p(this, "bodyWidth", 0);
// 表格实际高度
p(this, "bodyHeight", 0);
// 表头实际高度
p(this, "headerHeight", 44);
// 表尾实际高度
p(this, "footerHeight", 44);
// 分页器实际高度
p(this, "paginationHeight", 32);
// 是否有横向滚动条 todo 虚拟滚动支持后,需要更新现在的算法
p(this, "scrollX", !1);
// 是否有纵向滚动条
p(this, "scrollY", !1);
// 滚动条卡宽度
p(this, "scrollbarWidth", za());
// 展开列的keys
p(this, "expandRowKeys", []);
// 当前选择的行(单选)
p(this, "currentRowKey", null);
// 当前选择的行 (多选)
p(this, "selectionRowKeys", []);
// rowKey => row
p(this, "rowKeyMap", /* @__PURE__ */ new Map());
// rowKey => rowIndex
p(this, "rowKeyIndexMap", /* @__PURE__ */ new Map());
// rowKey => isRoot
p(this, "rowKeyIsRootMap", /* @__PURE__ */ new Map());
p(this, "allUnSelectableKeys", []);
// 当前排序的列信息
p(this, "currentSort", null);
p(this, "pagination", null);
p(this, "fastExpandStatus", !1);
// key 为 id
p(this, "lazyNodeStateMap", {});
}
//=====================Computed=========================
get filterShowColumns() {
return this.columns.filter((r) => r.show);
}
get selectionColumn() {
return this.filterShowColumns.find((r) => r.type === "selection");
}
// 所有的固定列只针对父层级
// 左固定列
get leftFixedColumns() {
return this.filterShowColumns.filter((r) => r.fixed === "left");
}
// 右固定列
get rightFixedColumns() {
return this.filterShowColumns.filter((r) => r.fixed === "right");
}
// 非固定列
get noFixedColumns() {
return this.filterShowColumns.filter((r) => !r.fixed);
}
// 排完顺序后的列数组 left - no - right
get originColumns() {
const { leftFixedColumns: r, noFixedColumns: e, rightFixedColumns: t } = this;
return r.concat(e).concat(t);
}
// 打平后的列 所有叶子列
get flatColumns() {
const { leftFixedColumns: r, noFixedColumns: e, rightFixedColumns: t } = this;
return Je(r).concat(Je(e)).concat(Je(t));
}
// 表格内容实际宽度
get bodyRealWidth() {
return this.flatColumns.reduce((r, e) => (r += e.realWidth || 0, r), 0);
}
// 真正绑定给表格的数据, 根据 expandRowKeys 打平后的表格数据, 获取的过程中会更新 depthsMap(副作用)
get flatData() {
const r = {}, { currentPageData: e, expandRowKeys: t, table: o, lazyNodeStateMap: i } = this, { rowKey: a, treeProps: s, lazy: l } = o, d = s.children;
if (!t || !t.length)
return e;
const m = new Set(t), g = [];
let f = e.slice();
for (; f.length > 0; ) {
const v = f.shift();
if (g.push(v), !l)
m.has(v[a]) && Array.isArray(v[d]) && v[d].length > 0 && (f = [...v[d], ...f], v[d].forEach(
(b) => r[b[a]] = (r[v[a]] || 0) + 1
));
else {
const b = i[v[a]] || {};
m.has(v[a]) && Array.isArray(b.children) && b.children.length > 0 && (f = [...b.children, ...f], b.children.forEach(
(S) => {
r[S[a]] = (r[v[a]] || 0) + 1;
}
));
}
}
return this.depthMap = r, g;
}
// 真正绑定给表格的数据中,是否存在展开按钮
get flatDataHasChildren() {
const { treeProps: r } = this.table;
return this.flatData.some((e) => e[r.children] && e[r.children].length || e[r.hasChildren]);
}
// 打平后所有行的key (可选行),同时更新 rowKeyMap (全部行)
get allFlatKeys() {
this.rowKeyMap.clear(), this.rowKeyIndexMap.clear(), this.allUnSelectableKeys = [];
const {
table: r,
currentPageData: e,
rowKeyMap: t,
selectionColumn: o,
rowKeyIndexMap: i,
lazyNodeStateMap: a
} = this, { selectable: s } = o || {};
if (!r || !e || !e.length)
return [];
const { rowKey: l, treeProps: d, lazy: m } = r;
return et(
e,
s ? (g) => s(g) : () => !0,
d.children,
l,
(g, f, v) => {
t.set(g[l], g), i.set(g[l], f), v || this.allUnSelectableKeys.push(g[l]);
},
m,
a
);
}
// 选中行的keyMap,用于快速判断某一行是否被选中(使用数组判断,大数据下耗时)
get selectionKeyMap() {
const { selectionRowKeys: r } = this;
return r.reduce((e, t) => (e[t] = 1, e), {});
}
// 是否全选
get allSelected() {
const { allFlatKeys: r, selectionKeyMap: e } = this;
return r.length && r.every((t) => e[t]);
}
// 所有选中的行
get selectRows() {
const { selectionRowKeys: r, rowKeyMap: e } = this;
return r.map((t) => e.get(t));
}
// 当前页数据
get currentPageData() {
const { pagination: r, filteredData: e, table: t } = this;
if (!r || t && t.remotePagination)
return e;
const { pageSize: o, pageNumber: i } = r, a = (i - 1) * o, s = i * o;
return e.slice(a, s);
}
onDataChange() {
this.reapplyFilters();
}
onCurrentPageDataChange() {
this.table && this.updateScrollY(this.table);
}
onScrollYChange() {
this.table && this.updateColumnsWidth(this.table);
}
//=====================Methods==========================
// 更新表格数据源
updateData(r) {
var e, t;
this.dataSource = r.slice(0), this.table ? this.table.remotePagination || this.table.$listeners["sort-change"] || this.table.$listeners.sortChange ? this.data = this.dataSource.slice(0) : this.sort((e = this.currentSort) == null ? void 0 : e.prop, (t = this.currentSort) == null ? void 0 : t.order) : this.data = this.dataSource.slice(0), this.clearSelection(!1), this.$nextTick(() => {
const { fastExpandStatus: o, expandRowKeys: i } = this;
o && !i.length && this.toggleExpandAllRow(!0);
});
}
// 插入列
insertColumn(r, e, t) {
let o = this.columns;
t && (o = t.children, o || (o = t.children = [])), typeof e < "u" ? o.splice(e, 0, r) : o.push(r), this.table && this.updateColumnsWidth(this.table);
}
// 移除列
removeColumn(r, e) {
let t = this.columns;
e && (t = e.children, t || (t = e.children = [])), t && t.splice(t.indexOf(r), 1), this.table && this.updateColumnsWidth(this.table);
}
// 更新列宽及bodyWidth
updateColumnsWidth(r) {
const { height: e, maxHeight: t, containerScrollCallback: o } = r, { headerWrapper: i, footerWrapper: a, paginationWrapper: s } = r.$refs, l = getComputedStyle(
r.$el.querySelector(".cam-ui-table-container")
), d = parseFloat(l.borderLeftWidth), m = parseFloat(l.borderRightWidth), g = r.$el.clientWidth - d - m;
let f = 0;
const { flatColumns: v } = this, b = this.flatColumns.filter(
(S) => typeof S.width != "number"
);
if (b.length > 0) {
v.forEach(($) => {
f += $.width || $.minWidth || 80;
});
const S = this.scrollY ? this.scrollbarWidth : 0;
if (f <= g - S) {
this.scrollX = !1;
const $ = g - S - f;
if (b.length === 1)
b[0].realWidth = (b[0].minWidth || 80) + $;
else {
const O = b.reduce(
(k, G) => k + (G.minWidth || 80),
0
), M = $ / O;
let A = 0;
b.forEach((k, G) => {
if (G === 0)
return;
const W = Math.floor(
(k.minWidth || 80) * M
);
A += W, k.realWidth = (k.minWidth || 80) + W;
}), b[0].realWidth = (b[0].minWidth || 80) + $ - A;
}
} else
this.scrollX = !0, b.forEach(($) => $.realWidth = $.minWidth || 80);
this.bodyWidth = Math.min(f, g);
} else
v.forEach((S) => {
!S.width && !S.minWidth ? S.realWidth = 80 : S.realWidth = S.width || S.minWidth, f += S.realWidth;
}), this.scrollX = f > g, this.bodyWidth = f;
this.headerHeight = i ? i.offsetHeight : 0, this.footerHeight = a ? a.offsetHeight : 0, this.paginationHeight = s ? s.offsetHeight + // 有个margin-top 4px
parseFloat(wo(s, "marginTop") || 0) : 0, this.bodyHeight = e ? parseFloat(e.toString()) - this.headerHeight - this.footerHeight - this.paginationHeight : t ? parseFloat(t.toString()) - this.headerHeight - this.footerHeight - this.paginationHeight : null, o();
}
// 更新scrollY值
updateScrollY(r) {
(r.$refs.bodyInstance || r).$nextTick(() => {
setTimeout(() => {
if (!r.height)
return;
const o = r.$refs.bodyWrapper;
if (r.$el && o) {
const i = o.querySelector(".cam-ui-table-body");
this.scrollY = i.offsetHeight > Number(this.bodyHeight), r.containerScrollCallback();
}
}, 10);
});
}
// 更新表格实例
updateTableInstance(r) {
this.table = r;
}
// 单行展开状态切换
toggleExpandRow(r, e) {
const t = r[this.table.rowKey], o = this.expandRowKeys.findIndex((i) => i === t);
if (e ? o === -1 && this.expandRowKeys.push(t) : o !== -1 && this.expandRowKeys.splice(o, 1), this.table.$emit("expand-change", r, e), this.table.lazy) {
const i = this.lazyNodeStateMap[t];
if (i) {
const { loaded: a } = i;
a && (this.lazyNodeStateMap[t] = {
...i,
expanded: e
});
} else {
const a = {
expanded: !0,
loading: !0,
loaded: !1,
children: []
};
this.$set(this.lazyNodeStateMap, t, a);
const s = (l) => {
this.$set(this.lazyNodeStateMap, t, {
...this.lazyNodeStateMap[t],
loaded: !0,
loading: !1,
children: l
});
};
this.table.load(r, s);
}
}
}
// 所有数据展开状态切换 (不支持)
toggleExpandAllRow(r) {
if (!this.table || !this.table.data.length)
return;
const { lazyNodeStateMap: e } = this, { rowKey: t, treeProps: o, lazy: i } = this.table;
if (this.fastExpandStatus = r, !r)
return this.expandRowKeys = [];
const a = et(
this.filteredData,
() => !0,
o.children,
t,
void 0,
i,
e
);
this.expandRowKeys = a;
}
// 全选状态切换
toggleAllSelection(r) {
const { allSelected: e } = this;
if (r === void 0) {
e ? this.clearSelection(!1) : this.selectionAllRow();
return;
}
r ? this.selectionAllRow() : this.clearSelection(!1);
}
// 选中所有行
selectionAllRow() {
const r = this.selectionRowKeys.slice(), e = this.allUnSelectableKeys, t = Cr(r, e);
this.selectionRowKeys = this.allFlatKeys.slice().concat(t), this.table.$emit("select-all", this.selectRows), this.table.$emit("selection-change", this.selectRows);
}
// 清空选中
clearSelection(r = !1) {
const e = this.selectionRowKeys.slice(), t = this.allUnSelectableKeys, o = Cr(e, t);
e.sort().toString() !== o.sort().toString() && (this.selectionRowKeys = o, this.table && !r && (this.table.$emit("select-all", this.selectRows), this.table.$emit("selection-change", this.selectRows)));
}
// 切换当前行状态
toggleSelectCurrentRow(r, e) {
const t = r[this.table.rowKey], o = this.selectionKeyMap[t];
if (e && !o) {
this.selectionRowKeys.push(t), this.table.$emit("select", this.selectRows, r), this.table.$emit("selection-change", this.selectRows);
return;
}
if (!e && o) {
const i = this.selectionRowKeys.findIndex(
(a) => a === t
);
this.selectionRowKeys.splice(i, 1), this.table.$emit("select", this.selectRows, r), this.table.$emit("selection-change", this.selectRows);
}
}
resetExpandState() {
this.fastExpandStatus = !1, this.expandRowKeys = [];
}
setCurrentRow(r) {
r && (this.currentRowKey = r[this.table.rowKey]);
}
// 排序
sort(r, e) {
if (this.table && this.table.remotePagination)
return;
const { defaultSortMethods: t, dataSource: o, flatColumns: i, table: a } = this, s = [...o], l = a ? a.treeProps : { children: "children" };
if (!e || !r || !i.length) {
this.data = s;
return;
}
const d = i.find((S) => S.prop === r);
if (!d) {
this.data = s;
return;
}
const { sortMethod: m, sortBy: g, sortPropType: f } = d;
if (m) {
e === "ascending" ? this.data = s.sort(m) : e === "descending" ? this.data = s.sort(m).reverse() : this.data = s;
return;
}
const v = e === "ascending" ? "asc" : "desc", b = (S) => g ? typeof g == "string" ? de(S, g) : typeof g == "function" ? g(S) : t(S, r, f, v) : t(S, r, f, v);
this.data = this.deepOrderby(s, b, v, l);
}
// 重新应用过滤(搜索和表头过滤)
reapplyFilters() {
this.table && this.table.handleSearchFilter && this.table.search ? this.table.handleSearchFilter(this.table.search) : this.filteredData = this.filterData(this.data, this.filterRules);
}
deepOrderby(r, e, t, o) {
const { deepSort: i } = this.table, { children: a } = o, s = r.length;
if (i)
for (let l = 0; l < s; l++) {
const d = r[l], m = d[a];
m && m.length && this.deepOrderby(m, e, t, o).forEach(
(g, f) => {
d[a][f] = g;
}
);
}
return Zo(r, [e], [t]);
}
// cam 用
defaultSortMethods(r, e, t, o) {
let i = de(r, e);
if (e.endsWith("_str") && t === "number") {
const a = e.split("_str")[0];
i = de(r, a);
}
return t === "string" || t === "date" ? r[e] === "-" ? o === "asc" ? Ba : "" : i : (t === "number" && (i = i == null ? i : Number(typeof i == "string" || typeof i == "number" ? i : de(r, e).replace(/,/g, ""))), isNaN(i) || i === null || i === void 0 || r[e] === "-" ? o === "asc" ? 1 / 0 : -1 / 0 : i);
}
// 更新当前排序信息
updateSort(r, e) {
const { currentSort: t } = this, o = this.flatColumns.find((s) => s.prop === r);
let i = e || null;
if (i && !o) {
this.currentSort = {
prop: r,
order: i
};
return;
}
const { sortOrders: a } = o;
if (!i)
if (!t || t.prop !== r)
i = a[0] || "ascending";
else {
const s = a.indexOf(t.order);
s === -1 ? i = a[0] || "ascending" : s === a.length - 1 ? i = a[0] : i = a[s + 1];
}
this.currentSort = {
prop: r,
order: i
}, this.table.remotePagination ? this.table.remoteSort(this.currentSort) : !this.table.$listeners["sort-change"] && !this.table.$listeners.sortChange && this.sort(r, i), this.table.$emit("sort-change", { column: o, prop: r, order: i }), this.selectionRowKeys.length && this.clearSelection(!1);
}
clearSort() {
this.currentSort = null, this.sort();
}
updatePagination(r) {
this.pagination = r;
}
updateRule(r, e) {
const t = this.filterRules.findIndex((i) => i.prop === r), o = { prop: r, ...e };
t < 0 && this.filterRules.push(o), this.filterRules.splice(t, 1, o), this.clearSelection(!1);
}
updateAndMergerRule(r, e) {
const t = this.filterRules.findIndex((s) => s.prop === r), o = t < 0 ? {} : this.filterRules[t], i = this.columns.find((s) => r === s.prop), a = {
prop: r,
getFilterItem: