|
|
|
import { shortcut } from "@/core/decorator";
|
|
|
|
import { extend, isArray, each, map, stripEL } from "@/core/2.base";
|
|
|
|
import { Layout } from "../../layout";
|
|
|
|
|
|
|
|
@shortcut()
|
|
|
|
export class FlexLeftRightVerticalAdaptLayout extends Layout {
|
|
|
|
static xtype = "bi.flex_left_right_vertical_adapt";
|
|
|
|
|
|
|
|
props() {
|
|
|
|
return extend(super.props(...arguments), {
|
|
|
|
baseCls: "bi-f-lr-v-c",
|
|
|
|
columnSize: [],
|
|
|
|
items: {},
|
|
|
|
llgap: 0,
|
|
|
|
lrgap: 0,
|
|
|
|
lhgap: 0,
|
|
|
|
ltgap: 0,
|
|
|
|
lbgap: 0,
|
|
|
|
lvgap: 0,
|
|
|
|
rlgap: 0,
|
|
|
|
rrgap: 0,
|
|
|
|
rhgap: 0,
|
|
|
|
rtgap: 0,
|
|
|
|
rbgap: 0,
|
|
|
|
rvgap: 0,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const o = this.options;
|
|
|
|
super.render(...arguments);
|
|
|
|
const items = this._formatItems(o.items);
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: "bi.flex_vertical_adapt",
|
|
|
|
ref: _ref => {
|
|
|
|
this.layout = _ref;
|
|
|
|
},
|
|
|
|
columnSize: o.columnSize.slice(0, (o.items.left || []).length).concat((o.items.right || []).length > 0 ? [""] : []),
|
|
|
|
items,
|
|
|
|
scrollx: o.scrollx,
|
|
|
|
scrolly: o.scrolly,
|
|
|
|
scrollable: o.scrollable,
|
|
|
|
innerHgap: o.innerHgap,
|
|
|
|
innerVgap: o.innerVgap,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
_formatItems(items) {
|
|
|
|
const o = this.options;
|
|
|
|
let left, right;
|
|
|
|
if (isArray(items)) {
|
|
|
|
each(items, (i, item) => {
|
|
|
|
if (item.left) {
|
|
|
|
left = item.left;
|
|
|
|
}
|
|
|
|
if (item.right) {
|
|
|
|
right = item.right;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
let leftItems = left || items.left || [];
|
|
|
|
const rightItems = right || items.right || [];
|
|
|
|
leftItems = map(leftItems, (i, item) => {
|
|
|
|
const json = {
|
|
|
|
el: stripEL(item),
|
|
|
|
};
|
|
|
|
if (o.lvgap + o.ltgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item) !== 0) {
|
|
|
|
json.tgap = o.lvgap + o.ltgap + this._optimiseItemTgap(item) + this._optimiseItemVgap(item);
|
|
|
|
}
|
|
|
|
if (o.lhgap + o.llgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item) !== 0) {
|
|
|
|
json.lgap = (i === 0 ? o.lhgap : 0) + o.llgap + this._optimiseItemLgap(item) + this._optimiseItemHgap(item);
|
|
|
|
}
|
|
|
|
if (o.lhgap + o.lrgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item) !== 0) {
|
|
|
|
json.rgap = o.lhgap + o.lrgap + this._optimiseItemRgap(item) + this._optimiseItemHgap(item);
|
|
|
|
}
|
|
|
|
if (o.lvgap + o.lbgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item) !== 0) {
|
|
|
|
json.bgap = o.lvgap + o.lbgap + this._optimiseItemBgap(item) + this._optimiseItemVgap(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return json;
|
|
|
|
});
|
|
|
|
|
|
|
|
return leftItems.concat({
|
|
|
|
el: {
|
|
|
|
type: "bi.flex_vertical_adapt",
|
|
|
|
columnSize: o.columnSize.slice(leftItems.length),
|
|
|
|
css: {
|
|
|
|
"margin-left": "auto",
|
|
|
|
},
|
|
|
|
hgap: o.rhgap,
|
|
|
|
vgap: o.rvgap,
|
|
|
|
lgap: o.rlgap,
|
|
|
|
rgap: o.rrgap,
|
|
|
|
tgap: o.rtgap,
|
|
|
|
bgap: o.rbgap,
|
|
|
|
items: rightItems,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
resize() {
|
|
|
|
this.layout.stroke(this._formatItems(this.options.items));
|
|
|
|
}
|
|
|
|
|
|
|
|
addItem() {
|
|
|
|
// do nothing
|
|
|
|
throw new Error("不能添加子组件");
|
|
|
|
}
|
|
|
|
|
|
|
|
populate(items) {
|
|
|
|
this.layout.populate(this._formatItems(items));
|
|
|
|
}
|
|
|
|
}
|