{
let el = null;
// Dropdown op
if (item.name == "dropdown-menu") {
const slot = this.$scopedSlots["table-op-dropdown-menu"];
const { width } = item["dropdown-menu"] || {};
const items = render(scope).map((e) => {
return {e};
});
el = (
{slot ? (
slot({ scope })
) : (
更多操作
)}
);
} else {
el = render(scope);
}
return {el}
;
}
}
}}
/>
);
},
emptyRender() {
const empty = this.$scopedSlots["table-empty"];
const scope = {
h: this.$createElement,
scope: this
};
if (empty) {
this.$scopedSlots.empty = () => {
return empty(scope)[0];
};
}
},
appendRender() {
return this.$slots["append"];
},
changeSort(prop, order) {
if (order === "desc") {
order = "descending";
}
if (order === "asc") {
order = "ascending";
}
this.$refs["table"].sort(prop, order);
},
sortChange({ prop, order }) {
if (order === "descending") {
order = "desc";
}
if (order === "ascending") {
order = "asc";
}
if (!order) {
prop = null;
}
if (this.crud.test.sortLock) {
this.crud.refresh({
prop,
order,
page: 1
});
}
},
selectionChange(selection) {
this.dispatch("cl-crud", "table.selection-change", { selection });
this.$emit("selection-change", selection);
},
bindEmit() {
const funcs = [
"select",
"select-all",
"cell-mouse-enter",
"cell-mouse-leave",
"cell-click",
"cell-dblclick",
"row-click",
"row-contextmenu",
"row-dblclick",
"header-click",
"header-contextmenu",
"filter-change",
"current-change",
"header-dragend",
"expand-change"
];
funcs.forEach((name) => {
this.emit[name] = (...args) => {
this.$emit.apply(this, [name, ...args]);
};
});
},
bindMethods() {
[
"clearSelection",
"toggleRowSelection",
"toggleAllSelection",
"toggleRowExpansion",
"setCurrentRow",
"clearSort",
"clearFilter",
"doLayout",
"sort"
].forEach(e => {
this[e] = this.$refs["table"][e];
});
},
calcMaxHeight() {
return this.$nextTick(() => {
const el = this.crud.$el.parentNode;
let { height = "" } = this.props || {};
if (el) {
let rows = el.querySelectorAll(".cl-crud .el-row");
if (!rows[0] || !rows[0].isConnected) {
return false;
}
let h = 20;
for (let i = 0; i < rows.length; i++) {
let f = true;
for (let j = 0; j < rows[i].childNodes.length; j++) {
if (rows[i].childNodes[j].className == "cl-table") {
f = false;
}
}
if (f) {
h += rows[i].clientHeight + 10;
}
}
let h1 = Number(String(height).replace("px", ""));
let h2 = el.clientHeight - h;
this.maxHeight = h1 > h2 ? h1 : h2;
}
});
}
},
render() {
return (
{
{this.columnRender()}
}
);
}
};