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

const label = 'reportDesigner.ultrasoundImage';
const name = 'ultrasoundImage';
const category = 0;//0-表示默认基础组件，1-表示报告组件；2-布局组件
export default {
    initData: function(flag, parentId, parentName){
        //组件一级对象
        var obj = {
            icon: 'icon-upload',
            label,
            id: common.guid(),
            name,
            category: category,
            disabledMove: false,
            //二级对象,用来封装属性和样式
            data: {},
            result: {}
        };
        if (flag)
        {
            obj.data = this.props();
            obj.result = this.finals(parentId, parentName);
        }
        return obj;
    },
    props: function() {
        return {
            // 规则：type：表示标签类型
            //     field:表示绑定值
            //     title:表示显示label
            //     require:表示是否需要验证必填项
            //     value:表示设置的默认值
            //     rules:表示验证规则，同elementplus验证规则一致
            //     dataSource:动态绑定数据源
            //     labelWidth:label宽度
            //       
            // //特殊样式
            // specialStyle: [ 
            //     {icon: "", title: "左对齐", type: "left", sort: 10, value: false, group: "horizontalAlignment"},
            //     {icon: "", title: "居中", type: "center", sort: 11, value: false, group: "horizontalAlignment"},
            //     {icon: "", title: "右对齐", type: "right", sort: 12, value: false, group: "horizontalAlignment"},
            //     {icon: "", title: "两端对齐", type: "bothends", sort: 13, value: false, group: "horizontalAlignment"}
            // ],
            //样式
            pattern: [
                {
                    type: 'input', field: 'width', title: 'reportDesigner.TextLengthPerLine', require: true, value: '84', unit: "mm",
                    rules: [{required: true, message: i18n.global.tc("reportDesigner.WidthRequireMessage"), trigger: "blur"}]
                }, 
                {
                    type: 'input', field: 'height', title: 'reportDesigner.Height', require: true, value: '53.5', unit: "mm",
                    rules: [{required: true, message: i18n.global.tc("reportDesigner.heightRequireMessage"), trigger: "blur"}]
                }, 
                {type: 'switch', field: 'border', title: 'reportDesigner.HasBorder', require: false, value: '0', unit: "", rules:[], labelWidth:"270px"}, 
                {type: 'switch', field: 'backgroundShadow', title: 'reportDesigner.TransparentBackground', require: false, value: '0', unit: "", rules:[], labelWidth:"270px"},    
            ],
            //属性
            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"}]
                    }, 
                ],
                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"}
                ]
            }
        }
    },
    finals: function(parentId, parentName){
        var pId = "";
        var pName = ""; 
        if (parentId && parentId.length > 0) {
            pId = parentId;
        }
        if (parentName && parentName.length > 0) {
            pName = parentName;
        }
        return {
            //父组件id
            parentId: pId,
            parentName: pName,
            offsetWidth: 0,
            offsetHeight: 0,
            //占位符
            space: "",
            //样式，每个组件可根据自身特点进行增减
            pattern: {
                //Left,Right,Center,Bothends
                horizontalAlignment:"",
                width: 84,//单位mm
                height: 53.5,
                //是否边框
                border: false,
                //是否背景透明
                backgroundShadow: false,
            },
            //属性，每个组件可根据自身特点进行增减
            property: {
                bindId: "9fbbaa61-a91d-4399-a3f4-df29117d2d59",
                //绑定类型
                bindType: "General",
                //绑定类型名称
                bindTypeField: "bindType",
                //绑定内容
                bindField: "ReportImages",
                isDefault: false,
                //默认值
                //value: "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
                value: "img/DefaultUltrasonicImage2.png",
                //是否必填
                required: false,
                //是否可编辑
                editable: false,
                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,
            }
        }
    }
}