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

const label = 'reportDesigner.divider';
const name = 'divider';
const category = 0;//0-表示默认基础组件，1-表示报告组件；2-布局组件
export default {
    initData: function(flag){
        //组件一级对象
        var obj = {
            icon: 'icon-divider',
            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: 'borderStyleSelect', field: 'borderStyle', title: 'reportDesigner.LineType', require: true, value: 'solid', unit: "",
                    rules: [{required: true, message: i18n.global.tc("reportDesigner.styleRequireMessage"), trigger: "blur"}],
                    options: [
                        { key: 'Solid', value: 'reportDesigner.solid' },
                        { key: 'Dotted', value: 'reportDesigner.dotted' },
                        { key: 'Dashed', value: 'reportDesigner.dashed' }
                    ]
                }, 
                {
                    type: 'colorPicker', field: 'borderColor', title: 'reportDesigner.Color', require: true, value: '#747474', unit: "",
                    rules: [{required: true, message: i18n.global.tc("reportDesigner.ColorRequireMessage"), trigger: "blur"}]
                }, 
                {
                    type: 'borderWeightSelect', field: 'borderWeight', title: 'reportDesigner.Thickness', require: true, value: 1, unit: "",
                    rules: [{required: true, message: i18n.global.tc("reportDesigner.weightRequireMessage"), trigger: "blur"}],
                    options: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 3, 4.5, 6]
                }, 
                {
                    type: 'input', field: 'borderWidth', title: 'reportDesigner.TextLengthPerLine', require: true, value: 185, unit: "mm",
                    rules: [{required: true, message: i18n.global.tc("reportDesigner.WidthRequireMessage"), trigger: "blur"}]
                }, 
            ],
            //属性
            property: {
                formatSet:[
                    {type: 'switch', field: 'editable', title: 'reportDesigner.editable', require: false, value: '0', unit: "", rules:[], labelWidth:"270px"}
                ]
            }
        }
    },
    finals: function(){
        return {
            //父组件id
            parentId: "",
            parentName: "",
            //占位符
            space: "",
            offsetWidth: 0,
            offsetHeight: 0,
            //样式，每个组件可根据自身特点进行增减
            pattern: {
                //线条类型
                borderStyle: "Solid",
                borderColor: "#747474",
                //粗细
                borderWeight:1,
                borderWidth: 182//长度 单位mm
            },
            //属性，每个组件可根据自身特点进行增减
            property: {
                //是否可编辑
                editable: false,
                //所属组
                group: "",
            },
            //位置坐标
            margin: {
                sort: 0,
                //0-表示absolute;1-relative
                position: 0,
                //如果采用相对定位，则需要填写上一个组件的组件id
                previousId:"",
                top: 0.0,
                bottom: 0.0,
                left: 0.0,
                right: 0.0,
            }
        }
    }
}