import common from "@/utils/common"
import designerInfo from '@/config/designer';

const label = 'reportDesigner.diagnosis';
const name = 'diagnosis';
const category = 2;//0-表示默认基础组件，1-表示报告组件；2-布局组件
export default {
    initData: function(flag){
        var commonId = common.guid();
        //组件一级对象
        var obj = {
            icon: 'icon-space',
            label,
            id: commonId,
            name,
            category: category,
            disabledMove: false,
            displayContentList: [
                {
                    rowIndex: 1,
                    offsetWidth: 0,
                    offsetHeight: 12,//4行
                    moduleIdList: []
                },
                {
                    rowIndex: 2,
                    offsetWidth: 0,
                    offsetHeight: 20,//4行
                    moduleIdList: []
                },
                {
                    rowIndex: 3,
                    offsetWidth: 0,
                    offsetHeight: 95,//4行
                    moduleIdList: []
                },
                {
                    rowIndex: 4,
                    offsetWidth: 0,
                    offsetHeight: 20,//4行
                    moduleIdList: []
                },
                {
                    rowIndex: 5,
                    offsetWidth: 0,
                    offsetHeight: 95,//4行
                    moduleIdList: []
                }
            ],
            //二级对象,用来封装属性和样式
            data: {},
            result: {}
        };
        if (flag)
        {
            obj.data = this.props();
            obj.result = this.finals();
            var divider = designerInfo.initAppointModule('divider');
            divider.result.parentId = commonId;
            divider.result.parentName = name;
            divider.result.pattern.borderWeight = 1;
            obj.result.tasks.push(divider);
            obj.displayContentList[0].moduleIdList.push(divider.id);
    
            var labelDesc = designerInfo.initAppointModule('label');
            labelDesc.result.parentId = commonId;
            labelDesc.result.parentName = name;
            labelDesc.result.pattern.horizontalAlignment = "Left";
            labelDesc.result.pattern.width = 0;
            labelDesc.result.pattern.fontSize = "18",
            labelDesc.result.property.placeholder = 'reportDesigner.reportDescription';
            obj.result.tasks.push(labelDesc);
            obj.displayContentList[1].moduleIdList.push(labelDesc.id);
            
            var inputReportDescription = designerInfo.initAppointModule('textarea');
            inputReportDescription.result.parentId = commonId;
            inputReportDescription.result.parentName = name;
            inputReportDescription.result.pattern.horizontalAlignment = "Left";
            inputReportDescription.result.pattern.width = 169;
            inputReportDescription.result.pattern.rows = 6;
            inputReportDescription.result.property.bindType = "DiagnosticEntry";
            inputReportDescription.result.property.bindField = "ReportDescription";
            obj.result.tasks.push(inputReportDescription);
            obj.displayContentList[2].moduleIdList.push(inputReportDescription.id);
    
            var labelTip = designerInfo.initAppointModule('label');
            labelTip.result.parentId = commonId;
            labelTip.result.parentName = name;
            labelTip.result.pattern.horizontalAlignment = "Left";
            labelTip.result.pattern.width = 0;
            labelTip.result.pattern.fontSize = "18",
            labelTip.result.property.placeholder = 'reportDesigner.reportSummary';
            obj.result.tasks.push(labelTip);
            obj.displayContentList[3].moduleIdList.push(labelTip.id);
    
            var inputReportSummary = designerInfo.initAppointModule('textarea');
            inputReportSummary.result.parentId = commonId;
            inputReportSummary.result.parentName = name;
            inputReportSummary.result.pattern.horizontalAlignment = "Left";
            inputReportSummary.result.pattern.width = 169;
            inputReportSummary.result.pattern.rows = 5;
            inputReportSummary.result.property.bindType = "DiagnosticEntry";
            inputReportSummary.result.property.bindField = "ReportSummary";
            obj.result.tasks.push(inputReportSummary);
            obj.displayContentList[4].moduleIdList.push(inputReportSummary.id);
        }
        return obj;
    },
    props: function() {
        return {
            //特殊样式
            specialStyle: [ 
                {icon: "", title: 'reportDesigner.AlignLeft', type: "left", sort: 10, value: false, show: true, group: "horizontalAlignment"},
                {icon: "", title: 'reportDesigner.AlignCenter', type: "center", sort: 11, value: false, show: true, group: "horizontalAlignment"},
                {icon: "", title: 'reportDesigner.AlignRight', type: "right", sort: 12, value: false, show: true, group: "horizontalAlignment"},
                {icon: "", title: 'reportDesigner.Justify', type: "bothends", sort: 13, value: false, show: true, group: "horizontalAlignment"}
            ],
            //样式
            pattern: [
                {
                    type: 'input', field: 'interval', title: 'reportDesigner.interval', require: false, value: '1', unit: "mm"
                }, 
            ],
            //属性
            property: {
                contentSet:[],
                formatSet:[
                    {type: 'switch', field: 'isHidden', title: 'reportDesigner.hidden', require: false, value: '0', unit: "", rules:[], labelWidth:"270px"}, 
                ]
            }
        }
    },
    finals: function(){
        return {
            //父组件id
            parentId: "",
            parentName: "",
            offsetWidth: 0,
            offsetHeight: 245,//330,
            tasks: [],
            //占位符
            space: "",
            //样式，每个组件可根据自身特点进行增减
            pattern: {
                //Left,Right,Center,Bothends
                horizontalAlignment:"",
                //间隔
                interval:1//单位mm
            },
            //属性，每个组件可根据自身特点进行增减
            property: {
                //是否隐藏
                isHidden: false,
            },
            //位置坐标
            margin: {
                sort: 0,
                //0-表示absolute;1-relative
                position: 0,
                //如果采用相对定位，则需要填写上一个组件的组件id
                previousId:"",
                top: 0.0,
                bottom: 0.0,
                left: 0.0,
                right: 0.0,
            }
        }
    }
}