优化node-ops方法

This commit is contained in:
Julyp
2020-01-31 13:23:47 +08:00
parent deabc09955
commit 047343c6f6
6 changed files with 52 additions and 54 deletions

View File

@@ -15,7 +15,6 @@ import {
getIntByAttr,
throttle,
debounce,
isWindows,
refactorCell,
replaceColGroup
} from './utils';
@@ -27,8 +26,7 @@ export default function initMixin(Table) {
}
const vm = this;
vm.$options = options;
vm.isWindows = isWindows();
vm.scrollbarFit = options.scrollbarWidth ? options.scrollbarWidth : 8;
vm.scrollbarFit = 8;
const root = options.selector && querySelector(document, String(options.selector).trim());
if (!root) return;
@@ -38,7 +36,7 @@ export default function initMixin(Table) {
root.classList.add("smart-table");
options.size && root.classList.add("smart-table-custom-" + options.size)
options.textAlign && root.classList.add("smart-table-custom-" + options.textAlign)
options.align && root.classList.add("smart-table-custom-" + options.align)
const thead = querySelector(table, "thead")
const tbody = querySelector(table, "tbody")
@@ -54,7 +52,7 @@ export default function initMixin(Table) {
const theadHeight = thead.offsetHeight;
const tableHeight = table.offsetHeight;
let customHeight = options.tableHeight;
let customHeight = options.height;
customHeight = (typeof customHeight === 'function' ? customHeight() : customHeight) || tableHeight;
customHeight = customHeight > theadHeight ? customHeight : (theadHeight + 100);
//获取table宽高
@@ -109,6 +107,10 @@ export default function initMixin(Table) {
}
}
function refactorTable() {
}
function rollupFixed(vm, theadModel, tbodyModel) {
const {
fixedLeft,
@@ -142,8 +144,7 @@ function rollupFixed(vm, theadModel, tbodyModel) {
let bodyWrapper = createTabelWrapper("smart-table_fixed-body-wrapper", vm, "body", tbody);
bodyWrapper.style.top = vm.size.theadHeight + "px";
bodyWrapper.style.height = (vm.size.tbodyHeight - (vm.hasHorizontalScroll ? vm.scrollbarFit : 0)) + "px";
let fixedContainer = createElement("div");
fixedContainer.className = "smart-table_fixed";
let fixedContainer = createElement("div", "smart-table_fixed");
appendChild(fixedContainer, headerWrapper);
appendChild(fixedContainer, bodyWrapper);
fixedContainer.style.width = fixedLeft.width + "px";
@@ -175,8 +176,7 @@ function rollupFixed(vm, theadModel, tbodyModel) {
let bodyWrapper = createTabelWrapper("smart-table_fixed-body-wrapper", vm, "body", tbody);
bodyWrapper.style.top = vm.size.theadHeight + "px";
bodyWrapper.style.height = (vm.size.tbodyHeight - (vm.hasHorizontalScroll ? vm.scrollbarFit : 0)) + "px";
let fixedContainer = createElement("div");
fixedContainer.className = "smart-table_fixed-right";
let fixedContainer = createElement("div", "smart-table_fixed-right");
fixedContainer.style.right = (vm.hasVerticalScroll ? vm.scrollbarFit : 0) + "px";
appendChild(fixedContainer, headerWrapper);
appendChild(fixedContainer, bodyWrapper);
@@ -185,8 +185,7 @@ function rollupFixed(vm, theadModel, tbodyModel) {
appendChild(vm.$root, fixedContainer);
vm.$fixedRight = bodyWrapper;
if (vm.hasVerticalScroll) {
let rightPatch = createElement("div");
rightPatch.className = "smart-table_fixed-right-patch";
let rightPatch = createElement("div", "smart-table_fixed-right-patch");
rightPatch.style.width = vm.scrollbarFit + "px";
rightPatch.style.height = vm.size.theadHeight + "px";
appendChild(vm.$root, rightPatch)