bixi
Version:
企业级中后台前端解决方案
40 lines (34 loc) • 1.08 kB
text/typescript
import { HostListener, Input } from '@angular/core';
import { get, isFunction } from '@bixi/core/utils';
import { ICol, IRow } from '../table.type';
import { hasKey, propGetter, valueGetter } from '../utils';
export class ColBase {
row: IRow;
col: ICol;
index: number;
configVersion = new Date().toTimeString();
onClick() {
if (this.col.onClick && isFunction(this.col.onClick)) {
this.col.onClick(this.row, this.index);
}
}
get value() {
return valueGetter(this.row, this.col, this.index);
}
get tooltip() {
const tooltip = get(this.col, 'tooltip');
if (!hasKey(this.col, 'tooltip') || tooltip === true) {
return this.value;
}
return propGetter(this.row, this.col, this.index, tooltip);
}
get style() {
return {
display: 'inline-block',
width: this.col.fixed ? '100%' : this.col.width || 'auto',
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: get(this.col, 'ellipsis', true) ? 'ellipsis' : null
};
}
}