/** * cell-group 组件 API 文档 * props default 说明 * title - 分组标题 * border true 是否显示外边框 * labelWidth - label的宽度 优先级低于组件自身设置 * size normal 统一设置 size 优先级低于组件自身设置 * align right 统一设置 align 优先级低于组件自身设置 * center true 统一设置 center 优先级低于组件自身设置 * titleFontSize 38 title 文字的大小 * titleColor - title 文字的颜色 * cellBorder true 是否显示 cell 内边框 优先级低于组件自身设置 * cellTitleColor - cell 的 title 的颜色 优先级低于组件自身设置 * cellTitleWeight - cell 的 title 字重 优先级低于组件自身设置 * cellLabelColor - cell 的 label 颜色 优先级低于组件自身设置 * cellValueColor - cell 的 value 颜色 优先级低于组件自身设置 */ import { Component, ComponentProps } from 'waft'; import { JSONObject, JSON } from 'waft-json'; import { lodash } from 'waft-ui-common'; export class CellGroup extends Component { constructor(props: ComponentProps) { super(props); } willMount(props: JSONObject): void { // todo 目前只做一个层级的判断, 最终期望是不限定层级 // todo 判断层级关系, 向子组件传递数据 // 注册当前组件的 nodeId lodash.bus.register('cellGroupNodeId', this.nodeId.toString()); const data = new JSONObject(); data.set('size', lodash.get(props, 'size', 'normal')); data.set('align', lodash.get(props, 'align', 'right')); data.set('center', lodash.get(props, 'center', true)); data.set('cellBorder', lodash.get(props, 'cellBorder', true)); if (props.has('labelWidth')) { data.set('labelWidth', lodash.get(props, 'labelWidth', 0 as i64)); } if (props.has('cellTitleColor')) { data.set('cellTitleColor', lodash.get(props, 'cellTitleColor', '')); } if (props.has('cellTitleWeight')) { data.set('cellTitleWeight', lodash.get(props, 'cellTitleWeight', '')); } if (props.has('cellLabelColor')) { data.set('cellLabelColor', lodash.get(props, 'cellLabelColor', '')); } if (props.has('cellValueColor')) { data.set('cellValueColor', lodash.get(props, 'cellValueColor', '')); } lodash.bus.emitAnyway('cellChannel' + this.nodeId.toString(), data); } didUnmount(): void { // 卸载掉设置的监听事件 lodash.bus.remove('cellChannel'); } }