import ApaasCustomMydemo from './custom-page/demo.vue'
import ApaasCustomMydemo2 from './custom-page/page.vue'
import ApaasCustomModalContorl from './custom-page/modelContorl.vue'
import ApaasCustomModelDetail from './custom-page/modelDetail.vue'
import ApaasCustomSelfEnginedata from './custom-page/selfEnginedata.vue'
import ApaasCustomEngineDetail from './custom-page/engineDetail.vue'
import ApaasCustomOtherEnginedata from './custom-page/otherEnginedata.vue'
import ApaasCustomCheckData from './custom-page/checkData.vue'
import ApaasCustomReportCheck from './custom-page/reportCheck.vue'
import ApaasCustomReport from './custom-page/report.vue'
import ApaasCustomReportList from './custom-page/reportList.vue'
import ApaasSelfEngineCheck from './custom-page/selfEngineCheck.vue'
import ApaasOtherEngineCheck from './custom-page/otherEngineCheck.vue'
import ApaasCustomManagerData from './custom-page/managerData.vue'
import ApaasCustomFillerData from './custom-page/fillerData.vue'
import ApaasCustomReportDetail from './custom-page/reportDetail.vue'
import ApaasCustomApprovalManagement from './custom-page/approvalManagement.vue'
import ApaasCustomTodoList from './custom-page/todo.vue'
import ApaasCustomMyDone from './custom-page/myDone.vue'
import ApaasCustomMySend from './custom-page/mySend.vue'
import ApaasCustomPermissionManagement from './custom-page/permissionManagement.vue'

import { customFormComponentList } from './custom-component/form-component'
import { widgetConfigList } from './custom-component/form-config'

const install = function(Vue, opts) {
  // 安装Mydemo模块, 此处的和apaas.json定义的路由，必须一致
  Vue.component('apaas-custom-mydemo', ApaasCustomMydemo2)
  Vue.component('apaas-custom-mydemo-demo', ApaasCustomMydemo)
  Vue.component('apaas-custom-modalContorl', ApaasCustomModalContorl)
  Vue.component('apaas-custom-modelDetail', ApaasCustomModelDetail)
  Vue.component('apaas-custom-selfEnginedata', ApaasCustomSelfEnginedata)
  Vue.component('apaas-custom-otherEnginedata', ApaasCustomOtherEnginedata)
  Vue.component('apaas-custom-checkData', ApaasCustomCheckData)
  Vue.component('apaas-custom-reportCheck', ApaasCustomReportCheck)
  Vue.component('apaas-custom-engineDetail', ApaasCustomEngineDetail)
  Vue.component('apaas-custom-report', ApaasCustomReport)
  Vue.component('apaas-custom-reportList', ApaasCustomReportList)
  Vue.component('apaas-custom-reportDetail', ApaasCustomReportDetail)
  Vue.component('apaas-custom-approvalManagement', ApaasCustomApprovalManagement)
  Vue.component('apaas-custom-toDoList', ApaasCustomTodoList)
  Vue.component('apaas-custom-managerData', ApaasCustomManagerData)
  Vue.component('apaas-custom-fillerData', ApaasCustomFillerData)
  Vue.component('apaas-custom-selfEngineCheck', ApaasSelfEngineCheck)
  Vue.component('apaas-custom-otherEngineCheck', ApaasOtherEngineCheck)
  Vue.component('apaas-custom-myDone', ApaasCustomMyDone)
  Vue.component('apaas-custom-mySend', ApaasCustomMySend)
  Vue.component('apaas-custom-permissionManagement', ApaasCustomPermissionManagement)
  // 安装表单部件
  // 注册自开发表单组件
  if (
    customFormComponentList && Array.isArray(customFormComponentList)
  ) {
    customFormComponentList.forEach((comp) => {
      Vue.component(comp.name, comp)
    })
  }
  // 表单引擎注册自开发组件配置
  if (
    widgetConfigList && Array.isArray(widgetConfigList)
  ) {
    widgetConfigList.forEach((widgetConfig) => {
      const compConfig = {
        widgetConfig
      }
      Vue.FormEngine && Vue.FormEngine.registerCustomComponentConfig(compConfig)
    })
  }
}

const MydemoCustomPlugin = {
  install: install
}

export default MydemoCustomPlugin
