import checkbox from './designer/checkbox';
import datetime from './designer/datetime';
import divider from './designer/divider';
import image from './designer/image';
import imageList from './designer/imageList';
import input from './designer/input';
import label from './designer/label';
import radio from './designer/radio';
import select from './designer/select';
import space from './designer/space';
import table from './designer/table';
//import custom from './designer/custom';
import textarea from './designer/textarea';
import diagnosis from './designer/group/diagnosis';
import doctorInfo from './designer/group/doctorInfo';
import grid from './designer/group/grid';
import patientInfo from './designer/group/patientInfo';
import replenish from './designer/group/replenish';
import reportHeader from './designer/group/reportHeader';
import scanTable from './designer/group/scanTable';
import footer from './designer/group/footer';
import header from './designer/group/header';
import ultrasoundImage from './designer/ultrasoundImage';
import ultrasoundImageList from './designer/group/ultrasoundImageList';

export default {
    //注册组件
    createMoudle: function() {
        var moduleList = [
            {
                name: 'main',
                title: 'reportDesigner.basicModule',
                list: this.loadData([
                    label, input, radio, checkbox, textarea, image, ultrasoundImage, imageList, select, datetime, divider, space, grid, table
                ])
            },
            {
                name: 'layout',
                title: 'reportDesigner.reportModule',
                list: this.loadData([
                    reportHeader, scanTable, replenish, patientInfo, diagnosis, doctorInfo, ultrasoundImageList, header, footer,
                ])
            },
            // {
            //     name: 'customize',
            //     title: 'reportDesigner.custom',
            //     list: this.loadData([
            //         //custom,
            //     ])
            // },
        ];
        return moduleList;
    },
    //设计器clone一个新的组件
    initAppointModule: function(type, content) {
        var result = {};
        switch (type) {
            case "input":
                result = input.initData(true);
                break;
            case "table":
                result = table.initData(true);
                break;
            case "imageList":
                result = imageList.initData(true, content);
                break; 
            case "image":
                result = image.initData(true, content);
                break; 
            case "ultrasoundImage":
                result = ultrasoundImage.initData(true);
                break;
            case "grid":
                result = grid.initData(true);
                break;
            case "diagnosis":
                result = diagnosis.initData(true);
                break;
            case "doctorInfo":
                result = doctorInfo.initData(true);
                break;
            case "patientInfo":
                result = patientInfo.initData(true, content);
                break;
            case "reportHeader":
                result = reportHeader.initData(true);
                break;    
            case "footer":
                result = footer.initData(true);
                break;    
            case "header":
                result = header.initData(true);
                break;
            case "replenish":
                result = replenish.initData(true);
                break; 
            case "label":
                result = label.initData(true);
                break;
            case "select":
                result = select.initData(true);
                break;          
            case "textarea":
                result = textarea.initData(true);
                break;    
            case "datetime":
                result = datetime.initData(true);
                break;       
            case "divider":
                result = divider.initData(true);
                break;         
            case "space":
                result = space.initData(true);
                break;   
            case "checkbox":
                result = checkbox.initData(true);
                break;       
            case "radio":
                result = radio.initData(true);
                break; 
            case "ultrasoundImageList":
                result = ultrasoundImageList.initData(true);
                break;  
            case "scanTable":
                result = scanTable.initData(true);
                break;          
            default:
                break;
        }
        return result;
    },
    //初始化数据
    loadData: function(moduleList) {
        var dataList = [];
        if (moduleList && moduleList.length > 0) {
            moduleList.map(module => {
                if (Object.keys(module).length === 0)
                {
                    console.log("module","kong")
                    return false;
                }
                else
                {
                    dataList.push(module.initData());
                }
            });
        }
        return dataList;
    }
}