/** * 装饰器(注解类) */ import { AMModelManager } from "./modelmanager"; import { AMModel, AMProp } from "./types"; /** * 模型装饰器 * @exclude * @param cfg:model配置项 */ export function AMModel(cfg:AMModel){ return (target) =>{ target.isData = cfg.isData||false; target.isCond = cfg.isCond; target.ref = cfg.ref; target.showName = cfg.showName; target.editable = cfg.editable; target.manageable = cfg.manageable; target.colsInRow = cfg.colsInRow || 2; target.labelWidth = cfg.labelWidth || 100; target.editWidth = cfg.editWidth; AMModelManager.addModel(target); } } /** * @exclude * 模型属性装饰器 * @param cfg: prop配置项 */ export function AMProp(cfg:AMProp){ return (target:any,propertyName:string)=>{ if(!target.constructor.props){ target.constructor.props = []; } cfg.name = propertyName; //showInGrid,默认showInDetail if(cfg.showInGrid && !cfg.showInDetail){ cfg.showInDetail = true; } target.constructor.props.push(cfg); } }