
import common from "@/utils/common"

const label = 'reportDesigner.cell';
const name = 'cell';
const category = 2;//0-表示默认基础组件，1-表示报告组件；2-布局组件
export default {
    initData: function(pId, rowIndex, columnIndex, pName, rowSpan, colSpan){
        //组件一级对象
        var obj = {
            icon: 'icon-cell',
            label: label,
            id: common.guid(),
            name: name,
            sort: 0,
            category: category,
            //二级对象,用来封装属性和样式
            data: this.props(),
            result: this.finals(pId, rowIndex, columnIndex, pName, rowSpan, colSpan)
        };
        return obj;
    },
    props: function() {
        return {
            //样式
            pattern: [
                {
                    type: 'borderStyleSelect', field: 'cellBorderStyle', title: 'reportDesigner.LineType', require: false, value: 'solid', unit: "",
                    options: [
                        { key: 'Solid', value: 'reportDesigner.solid' },
                        { key: 'Dotted', value: 'reportDesigner.dotted' },
                        { key: 'Dashed', value: 'reportDesigner.dashed' }
                    ]
                }, 
                {
                    type: 'colorPicker', field: 'cellBorderColor', title: 'reportDesigner.borderColor', require: false, value: '#888', unit: ""
                },
                {
                    type: 'borderWeightSelect', field: 'cellBorderWeight', title: 'reportDesigner.Thickness', require: false, value: 1, unit: "",
                    options: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 3, 4.5, 6]
                }, 
                {
                    type: 'colorPicker', field: 'cellBackgroundColor', title: 'reportDesigner.Fill', require: false, value: '#FFF', unit: ""
                }, 
                {
                    type: 'switch', field: 'showCellBorder', title: 'reportDesigner.showTableBorder', require: false, value: '1', unit: "", rules:[], labelWidth:"270px"
                }, 
                // {
                //     type: 'switch', field: 'showBottomBorder', title: '显示下边框', require: true, value: true, unit: ""
                // }, 
                // {
                //     type: 'switch', field: 'showLeftBorder', title: '显示左边框', require: true, value: true, unit: ""
                // }, 
                // {
                //     type: 'switch', field: 'showRightBorder', title: '显示右边框', require: true, value: true, unit: ""
                // }, 
            ],
            //属性
            property: {
                contentSet:[
                    // {
                    //     type: 'select', field: 'bindModule', title: '默认组件', require: true, value: '', unit: "", 
                    //     dataSource: api.organization.organizationSelectList
                    // }
                ],
                formatSet:[
                    {
                        type: 'inputSelect', field: 'cellColumnWidth', title: 'reportDesigner.ColumnWidth', require: true, value: '60', unit: "mm", 
                        options:[
                            { label: 'reportDesigner.FixedValue', value: 1 }
                        ],
                        defaultOptionType: "cellColumnWidhtType"
                    }, 
                    {
                        type: 'inputSelect', field: 'cellRowHeight', title: 'reportDesigner.RowHeight', require: true, value: '6', unit: "mm", 
                        options:[
                            { label: 'reportDesigner.MinValue', value: 0 },
                            { label: 'reportDesigner.FixedValue', value: 1 }
                        ],
                        defaultOptionType: "cellRowHeightType"
                    }
                ],
                cellOperate:[
                    {
                        icon:'', field: 'mergeBottomCell', title: 'reportDesigner.MergeBelowCell', value: false, sort: 1,
                    },
                    {
                        icon:'', field: 'mergeRightCell', title: 'reportDesigner.MergeRightCell', value: false, sort: 2,
                    },
                    {
                        icon:'', field: 'insertTopCell', title: 'reportDesigner.insertTopCell', value: false, sort: 3,
                    },
                    {
                        icon:'', field: 'insertBottomCell', title: 'reportDesigner.insertBottomCell', value: false, sort: 4,
                    },
                    {
                        icon:'', field: 'insertLeftCell', title: 'reportDesigner.insertLeftCell', value: false, sort: 5,
                    },
                    {
                        icon:'', field: 'insertRightCell', title: 'reportDesigner.insertRightCell', value: false, sort: 6,
                    },
                    {
                        icon:'', field: 'deleteRow', title: 'reportDesigner.deleteRow', value: false, sort: 7,
                    },
                    {
                        icon:'', field: 'deleteColumn', title: 'reportDesigner.deleteColumn', value: false, sort: 8,
                    },
                    {
                        icon:'', field: 'spliceCell', title: 'reportDesigner.SplitCell', value: false, sort: 9,
                    }, 
                ]
            },
        }
    },
    //结果
    finals: function(pId, rowIndex, columnIndex, pName, rowSpan, colSpan){
        if (!rowSpan || rowSpan <= 1) {
            rowSpan = 1;
        }
        if (!colSpan || colSpan <= 1) {
            colSpan = 1;
        }
        return {
            //父组件id
            parentId: pId,
            parentName: pName,
            tasks: [],
            offsetWidth: 0,
            offsetHeight: 20,
            //占位符
            space: "",
            base: {
                rowStartIndex: rowIndex,
                colStartIndex: columnIndex,
                rowEndIndex: rowIndex + rowSpan,
                colEndIndex: columnIndex + colSpan,
                rowSpan: rowSpan,
                colSpan: colSpan
            },
            //样式，每个组件可根据自身特点进行增减
            pattern: {
                //Left,Right,Center,Bothends
                horizontalAlignment:"",
                //Left,Right,Center,Bothends
                verticalAlignment:"",
                cellBorderStyle: "Solid",
                cellBorderColor: "#747474",
                cellBorderWeight: 1,
                cellBackgroundColor: "",
                showCellBorder: true,
            },
            //属性，每个组件可根据自身特点进行增减
            property: {
                cellColumnWidth: 60,//单位mm
                cellColumnWidhtType: 1,
                cellRowHeight: 6,
                cellRowHeightType: 0,
                mergeBottomCell: false,
                mergeRightCell: false,
                insertTopCell: false,
                insertBottomCell: false,
                insertLeftCell: false,
                insertRightCell: false,
                deleteRow: false,
                deleteColumn: false,
                spliceCell: false,
                groupField: ""
            },
            //位置坐标
            margin: {
                sort: 0,
                //0-表示absolute;1-relative
                position: 0,
                //如果采用相对定位，则需要填写上一个组件的组件id
                previousId:"",
                top: 0.0,
                bottom: 0.0,
                left: 0.0,
                right: 0.0,
            }
        }
    }
}