fineui是帆软报表和BI产品线所使用的前端框架。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

112 lines
3.4 KiB

import { shortcut } from "@/core/decorator";
import { extend, isFunction, some } from "@/core/2.base";
import { HorizontalAlign, VerticalAlign } from "@/core/constant";
import { Layout } from "../../layout";
/**
* Created by GUY on 2016/12/2.
*
* @class FlexVerticalLayout
* @extends Layout
*/
@shortcut()
export class FlexVerticalLayout extends Layout {
static xtype = "bi.flex_vertical";
props() {
return extend(super.props(...arguments), {
baseCls: "bi-f-v",
horizontalAlign: HorizontalAlign.Left,
verticalAlign: VerticalAlign.Top,
rowSize: [],
scrolly: true,
hgap: 0,
vgap: 0,
lgap: 0,
rgap: 0,
tgap: 0,
bgap: 0,
});
}
render() {
super.render(...arguments);
const self = this, o = this.options;
this.element.addClass(`h-${o.horizontalAlign}`).addClass(`v-${o.verticalAlign}`);
if (o.scrollable === true || o.scrollx === true) {
this.element.addClass("f-scroll-x");
}
if (o.scrollable === true || o.scrolly === true) {
this.element.addClass("f-scroll-y");
}
const items = isFunction(o.items) ? this.__watch(o.items, (context, newValue) => {
self.populate(newValue);
}) : o.items;
this.populate(items);
}
_hasFill() {
const o = this.options;
if (o.rowSize.length > 0) {
return o.rowSize.indexOf("fill") >= 0 || o.rowSize.indexOf("auto") >= 0;
}
return some(o.items, (i, item) => {
if (item.height === "fill" || item.height === "auto") {
return true;
}
});
}
_addElement(i, item) {
const o = this.options;
const w = super._addElement.apply(this, arguments);
let rowSize = o.rowSize.length > 0 ? o.rowSize[i] : item.height;
if (o.rowSize.length > 0) {
if (item.height >= 1 && o.rowSize[i] >= 1 && o.rowSize[i] !== item.height) {
rowSize = null;
}
}
w.element.css({
position: "relative",
});
if (rowSize !== "auto") {
if (rowSize === "fill" || rowSize === "") {
if (o.verticalAlign !== VerticalAlign.Stretch) {
if (o.scrollable === true || o.scrolly === true) {
w.element.addClass("f-s-n");
}
}
// 当既有动态宽度和自适应宽度的时候只压缩自适应
if (rowSize === "" && this._hasFill()) {
w.element.addClass("f-s-n");
}
} else {
w.element.addClass("f-s-n");
}
}
if (rowSize > 0) {
w.element.height(this._optimiseGap(rowSize));
}
if (rowSize === "fill") {
w.element.addClass("f-f");
}
if (rowSize === "" || rowSize === "auto") {
w.element.addClass("f-auto");
}
w.element.addClass("c-e");
if (i === 0) {
w.element.addClass("f-c");
}
if (i === o.items.length - 1) {
w.element.addClass("l-c");
}
this._handleGap(w, item, null, i);
return w;
}
populate(items) {
super.populate.apply(this, arguments);
this._mount();
}
}