import { Component, Input, ViewChild, ViewContainerRef } from '@angular/core';
import { FormGroup } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "../service/common.service";
import * as i2 from "ng-devui";
import * as i3 from "@angular/forms";
import * as i4 from "@angular/common";
export class FormPreviewComponent {
    constructor(commonService) {
        this.commonService = commonService;
        this.showBtn = false;
        this.userFormGroup = new FormGroup({});
    }
    ngOnInit() {
        this.commonService.formGroup = this.userFormGroup;
        this.commonService.colloctData = Object.create(null);
        this.commonService.createComponent(this.commonService.getPreviewData(), this.main, "detail");
        console.log(this.commonService.getPreviewData());
    }
    submitPlanForm(e) {
        if (e.valid) {
            var postdata = Object.create(null);
            for (const key in this.commonService.colloctData) {
                postdata[key] = this.commonService.colloctData[key].defaultvalue;
            }
            console.log(postdata);
        }
        else {
            // error tip
        }
    }
}
FormPreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: FormPreviewComponent, deps: [{ token: i1.CommonService }], target: i0.ɵɵFactoryTarget.Component });
FormPreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: FormPreviewComponent, selector: "form-preview", inputs: { data: "data", showBtn: "showBtn" }, viewQueries: [{ propertyName: "main", first: true, predicate: ["main"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: "<form \r\n    dForm \r\n    [formGroup]=\"userFormGroup\"\r\n    [layout]=\"data.layout\" \r\n    [labelSize]=\"data.labelSize\" \r\n    [labelAlign]=\"data.labelAlign\"\r\n    #thisform = \"dValidateRules\" \r\n    [dValidateRules]=\"{message:'check this'}\" \r\n    (dSubmit)=\"submitPlanForm($event)\" >\r\n    <ng-container #main>\r\n    </ng-container>\r\n    <d-form-operation *ngIf=\"showBtn\">\r\n        <d-button dFormSubmit bsStyle=\"primary\" class=\"mr-element-spacing\" circled=\"true\" style=\"margin-right: 4px\">\u63D0\u4EA4</d-button>\r\n        <d-button bsStyle=\"common\" circled=\"true\">\u53D6\u6D88</d-button>\r\n    </d-form-operation>\r\n</form>", styles: [""], components: [{ type: i2.FormOperationComponent, selector: "d-form-operation" }, { type: i2.ButtonComponent, selector: "d-button", inputs: ["id", "type", "bsStyle", "bsSize", "bsPosition", "bordered", "icon", "disabled", "showLoading", "width", "autofocus", "loadingTemplateRef"], outputs: ["btnClick"] }], directives: [{ type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2.DFormGroupRuleDirective, selector: "[dValidateRules][formGroupName],[dValidateRules][formArrayName],[dValidateRules][ngModelGroup],          [dValidateRules][formGroup],[dValidateRules]form:not([ngNoForm]),[dValidateRules][ngForm]", inputs: ["dValidateRules"], outputs: ["dRulesStatusChange"], exportAs: ["dValidateRules"] }, { type: i2.FormDirective, selector: "[dForm]", inputs: ["layout", "labelSize", "labelAlign", "dFeedbackType", "dHasFeedback"], outputs: ["dSubmit"], exportAs: ["dForm"] }, { type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.DFormSubmitDirective, selector: "[dFormSubmit]", inputs: ["dFormSubmit", "dFormSubmitData"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: FormPreviewComponent, decorators: [{
            type: Component,
            args: [{ selector: 'form-preview', template: "<form \r\n    dForm \r\n    [formGroup]=\"userFormGroup\"\r\n    [layout]=\"data.layout\" \r\n    [labelSize]=\"data.labelSize\" \r\n    [labelAlign]=\"data.labelAlign\"\r\n    #thisform = \"dValidateRules\" \r\n    [dValidateRules]=\"{message:'check this'}\" \r\n    (dSubmit)=\"submitPlanForm($event)\" >\r\n    <ng-container #main>\r\n    </ng-container>\r\n    <d-form-operation *ngIf=\"showBtn\">\r\n        <d-button dFormSubmit bsStyle=\"primary\" class=\"mr-element-spacing\" circled=\"true\" style=\"margin-right: 4px\">\u63D0\u4EA4</d-button>\r\n        <d-button bsStyle=\"common\" circled=\"true\">\u53D6\u6D88</d-button>\r\n    </d-form-operation>\r\n</form>", styles: [""] }]
        }], ctorParameters: function () { return [{ type: i1.CommonService }]; }, propDecorators: { data: [{
                type: Input
            }], showBtn: [{
                type: Input
            }], main: [{
                type: ViewChild,
                args: ["main", { read: ViewContainerRef, static: true }]
            }] } });
//# sourceMappingURL=data:application/json;base64, 