帆软决策平台数据连接界面库
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.

74 lines
2.0 KiB

import { shortcut, store } from '@core/core';
import { CollapseModel } from './collapse.model';
import { IconLabel } from '@fui/core';
export const EVENT_CHANGE = 'EVENT_CHANGE';
@shortcut()
@store(CollapseModel)
export class Collapse extends BI.BasicButton {
static xtype = 'dec.dcm.components.collapse';
props = {
name: '',
isCollapse: true,
$testId: 'dec-dcm-components-collapse',
el: {},
}
rightFont: IconLabel;
downFont: IconLabel;
model: CollapseModel['model'];
store: CollapseModel['store'];
watch = {
isCollapse: (isCollapse: boolean) => {
this.rightFont.setVisible(isCollapse);
this.downFont.setVisible(!isCollapse);
this.fireEvent(EVENT_CHANGE, isCollapse);
},
}
render() {
this.store.setCollapse(this.options.isCollapse);
return {
type: BI.FloatLeftLayout.xtype,
items: [
{
type: BI.IconLabel.xtype,
height: 17,
cls: 'dcm-triangle-collapse-font icon-size-16',
ref: (_ref: IconLabel) => {
this.rightFont = _ref;
},
invisible: !this.model.isCollapse,
},
{
type: BI.IconLabel.xtype,
height: 17,
cls: 'dcm-triangle-expand-font icon-size-16',
ref: (_ref: IconLabel) => {
this.downFont = _ref;
},
invisible: this.model.isCollapse,
},
{
type: BI.Label.xtype,
lgap: 2,
text: this.options.name,
},
this.options.el,
],
};
}
doClick() {
this.store.setCollapse(!this.model.isCollapse);
}
setCollapse(v: boolean) {
this.store.setCollapse(v);
}
}