
import common from "@/utils/common"
import api from "@/api"
import styleDesigner from '@/config/designer/style';
import i18n from '@/locales'

const label = 'reportDesigner.radio';
const name = 'radio';
const category = 0;//0-表示默认基础组件，1-表示报告组件；2-布局组件
export default {
    initData: function(flag){
        //组件一级对象
        var obj = {
            icon: 'icon-radio',
            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 {
            // 规则：type：表示标签类型
            //     field:表示绑定值
            //     title:表示显示label
            //     require:表示是否需要验证必填项
            //     value:表示设置的默认值
            //     rules:表示验证规则，同elementplus验证规则一致
            //     dataSource:动态绑定数据源
            //     labelWidth:label宽度
            //
            //基础样式
            style: styleDesigner(),
            //样式
            pattern: [
                {
                    type: 'input', field: 'width', title: 'reportDesigner.TextLengthPerLine', require: true, value: '100', 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: true, value: '', unit: "",
                        rules: [{required: true, message: i18n.global.tc("reportDesigner.ContentRequireMessage"), trigger: "blur"}]
                    },
					// {
					// 	type: 'select', field: 'featureTag', title: 'reportDesigner.featureTag', require: false, value: '', unit: "", rules:[], multiple:true
					// },
                ],
                formatSet:[
                    {type: 'switch', field: 'required', title: 'reportDesigner.required', require: false, value: '0', unit: "", rules:[], labelWidth:"270px"},
                    {type: 'switch', field: 'editable', title: 'reportDesigner.editable', require: false, value: '0', unit: "", rules:[], labelWidth:"270px"},
                    {type: 'switch', field: 'arrangement', title: 'reportDesigner.horizontalArrangement', require: false, value: '1', unit: "", rules:[], labelWidth:"270px"}
                ],
                dataSourceSet: [
                    {
                        //数据源类型：0-静态；1-动态
                        type: 'switch', field: 'dataSourceType', title: 'reportDesigner.dynamicData', require: false, value: '0', unit: "", rules:[]
                    }
                ]
            }
        }
    },
    finals: function(){
        return {
            //父组件id
            parentId: "",
            parentName: "",
            //占位符
            space: "",
            offsetWidth: 0,
            offsetHeight: 0,
            //样式，每个组件可根据自身特点进行增减
            pattern: {
                fontName:"微软雅黑",
                fontSize:"10.5",
                fontWeight:400,
                fontItalic:false,
                fontUnderLine:false,
                fontColor:"",
                //Left,Right,Center,Bothends
                horizontalAlignment:"",
                //Top,Middle,Bottom
                verticalAlignment:"",
                width:100,//单位mm
                height:10
            },
            //属性，每个组件可根据自身特点进行增减
            property: {
                bindId: "",
                //绑定类型
                bindType: "",
                //绑定类型名称
                bindTypeField: "bindType",
                //绑定内容
                bindField: "",
                isDefault: false,
                //排列方式：0-纵向排列-false；1-横向排列-true
                arrangement: true,
                //是否必填
                required: false,
                //是否可编辑
                editable: false,
                //当前数据源类型,这里的名称一定要
                dataSourceType: { field: 'dataSourceType', value: '0'},
                //动态数据源
                dynamicDataSource: {api: api, methodString: "template.findDefaultDynamicDataAsync"},
                //数据源，需要用到则赋值，无需则为空数组
                staticOptions: ["reportDesigner.Option1","reportDesigner.Option2","reportDesigner.Option3","reportDesigner.OptionOther"],//['选项1','选项2', '选项3', '其他'],
                //动态数据数据源
                dynamicOptions: ["reportDesigner.DynamicOption1","reportDesigner.DynamicOption2","reportDesigner.DynamicOption3","reportDesigner.DynamicOptionOther"],//'动态选项1','动态选项2', '动态选项3', '动态其他'],
                //所属组
                group: "",
                measureItem: {
                    AvailableMethods: [],
                    BaseType: "",
                    CalculationId: "",
                    MatchId: "",
                    Method: "",
                    Mode: "",
                    Output: "",
                    OutputV2: "",
                    Unit: "",
                    UserId: ""
                },
				featureTag:[]
            },
            //位置坐标
            margin: {
                sort: 0,
                //0-表示absolute;1-relative
                position: 0,
                //如果采用相对定位，则需要填写上一个组件的组件id
                previousId:"",
                top: 0.0,
                bottom: 0.0,
                left: 0.0,
                right: 0.0,
            }
        }
    }
};
