/** * Created by TonyJiang on 16/8/16. */ import {LayoutSection, LayoutProperty, LayoutSectionKeyEnum} from "./LayoutSection"; import {Layout} from "./Layout"; import {ReportProperty} from "../properties/define"; import {ReportItemBase} from "../ReportItemBase"; import {PaperKind} from "../../drawing/PaperKind"; export class ReportLayout extends Layout{ constructor() { super(); this.sections.push(ReportLayout.report()); } private static report():LayoutSection { const section = new LayoutSection(LayoutSection.LAYOUT_SECTION[LayoutSectionKeyEnum.REPORT]); section.properties.push(new LayoutProperty(ReportProperty.name)); section.properties.push(new LayoutProperty(ReportProperty.paper)); // section.properties.push(new LayoutProperty(ReportProperty.paperKind)); // section.properties.push(new LayoutProperty(ReportProperty.paperWidth)); // section.properties.push(new LayoutProperty(ReportProperty.paperHeight)); section.properties.push(new LayoutProperty(ReportProperty.margin)); // section.properties.push(new LayoutProperty(ReportProperty.topMargin)); // section.properties.push(new LayoutProperty(ReportProperty.bottomMargin)); // section.properties.push(new LayoutProperty(ReportProperty.leftMargin)); // section.properties.push(new LayoutProperty(ReportProperty.rightMargin)); return section; } getSections(item: ReportItemBase): Array { const section = this.sections[0]; const paperKind = item.getPropertyValue(ReportProperty.paperKind); const isCustomPaper = paperKind === PaperKind.Custom; section.properties.forEach(property => { // 非自定义纸张,宽度和高度设置为只读状态 if (property.property === ReportProperty.paperWidth || property.property === ReportProperty.paperHeight) { // property.setHidden(! isCustomPaper); property.setReadonly(! isCustomPaper); } }); return this.sections; } }