
import common from "@/utils/common"
import api from "@/api"
import i18n from '@/locales'

const label = 'reportDesigner.space';
const name = 'space';
const category = 0;//0-表示默认基础组件，1-表示报告组件；2-布局组件
export default {
    initData: function(flag){
        //组件一级对象
        var obj = {
            icon: 'icon-space',
            label,
            id: common.guid(),
            name,
            category: category,
            disabledMove: false,
            //二级对象,用来封装属性和样式
            data: {},
            result: {}
        };
        if (flag)
        {
            obj.data = this.props();
            obj.result = this.finals();
        }
        return obj;
    },
    props: function() {
        return {
            //样式
            pattern: [
                {
                    type: 'input', field: 'width', title: 'reportDesigner.TextLengthPerLine', require: true, value: 8, unit: "mm",
                    rules: [{required: true, message: i18n.global.tc("reportDesigner.WidthRequireMessage"), trigger: "blur"}]
                }, 
            ],//属性
            property: {
                contentSet:[
                    {
                        type: 'select', field: 'bindType', title: 'reportDesigner.bindType', require: false, value: '', unit: "", rules:[], 
                        dataSource: api.template.findContentConfigAsync, 
                        tiedDataSource: api.template.findContentConfigAsync,
                        tiedBack: "bindField", changeStatus: true
                    }, 
                    {
                        type: 'elSelect', field: 'bindField', title: 'reportDesigner.bindField', require: false, value: '', unit: ""
                    }
                ]
            }
        }
    },
    finals: function(){
        return {
            //父组件id
            parentId: "",
            parentName: "",
            //占位符
            space: "",
            offsetWidth: 0,
            offsetHeight: 0,
            //样式，每个组件可根据自身特点进行增减
            pattern: {
                width: 8,//长度 单位mm
            },
            //属性，每个组件可根据自身特点进行增减
            property: {
                bindId: "",
                //绑定类型
                bindType: "",
                //绑定类型名称
                bindTypeField: "bindType",
                //绑定内容
                bindField: "",
                isDefault: false,
                //所属组
                group: "",
                measureItem: {
                    AvailableMethods: [],
                    BaseType: "",
                    CalculationId: "",
                    MatchId: "",
                    Method: "",
                    Mode: "",
                    Output: "",
                    OutputV2: "",
                    Unit: "",
                    UserId: ""
                }
            },
            //位置坐标
            margin: {
                sort: 0,
                //0-表示absolute;1-relative
                position: 0,
                //如果采用相对定位，则需要填写上一个组件的组件id
                previousId:"",
                top: 0.0,
                bottom: 0.0,
                left: 0.0,
                right: 0.0,
            }
        }
    }
}