import Vue from 'vue'
import uniqueId from 'lodash'
import {i18n} from '../main'
import AuthorityFilter from '../commands/AuthorityFilter'
import CreateAndCopyAlarmMangExpDialog from '@/components/DialogComponents/AlarmMangExpDialog/CreateAndCopyAlarmMangExpDialog.vue'
import QueryCreateAlarmMangExpDialog from '@/components/DialogComponents/AlarmMangExpDialog/QueryCreateAlarmMangExpDialog.vue'
import UpdateAlarmMangExpDialog from '@/components/DialogComponents/AlarmMangExpDialog/UpdateAlarmMangExpDialog.vue'
import DeleteAlarmMangExpDialog from '@/components/DialogComponents/AlarmMangExpDialog/DeleteAlarmMangExpDialog.vue'
import ImportAlarmMangExpDialog from '@/components/DialogComponents/AlarmMangExpDialog/ImportAlarmMangExpDialog.vue'

Vue.component('ImportAlarmMangExpDialog', ImportAlarmMangExpDialog)
Vue.component('CreateAndCopyAlarmMangExpDialog', CreateAndCopyAlarmMangExpDialog)
Vue.component('QueryCreateAlarmMangExpDialog', QueryCreateAlarmMangExpDialog)
Vue.component('DeleteAlarmMangExpDialog', DeleteAlarmMangExpDialog)
Vue.component('UpdateAlarmMangExpDialog', UpdateAlarmMangExpDialog)

let CommandTypes = {
  IMPORT_ALARM_Exp_CMD: {
    type: 'ImportAlarmMangExpDialog',
    executeComponent: 'ImportAlarmMangExpDialog',
    registerComponent: ImportAlarmMangExpDialog // import对应的对话框组件
  },
  CREATE_COPY_ALARM_MANG_EXP_CMD: {
    type: 'CreateAndCopyAlarmMangExpDialog',
    executeComponent: 'CreateAndCopyAlarmMangExpDialog',
    registerComponent: CreateAndCopyAlarmMangExpDialog
  },
  QUERY_CREATE_ALARM_MANG_EXP_CMD: {
    type: 'QueryCreateAlarmMangExpDialog',
    executeComponent: 'QueryCreateAlarmMangExpDialog',
    registerComponent: QueryCreateAlarmMangExpDialog
  },
  DELETE_ALARM_MANG_EXP_CMD: {
    type: 'DeleteAlarmMangExpDialog',
    executeComponent: 'DeleteAlarmMangExpDialog',
    registerComponent: DeleteAlarmMangExpDialog
  },
  UPDATE_ALARM_MANG_EXP_CMD: {
    type: 'UpdateAlarmMangExpDialog',
    executeComponent: 'UpdateAlarmMangExpDialog',
    registerComponent: UpdateAlarmMangExpDialog
  }
}

class AlarmMangExpCommands {
  static importAlarmMangExpCommand (commandContext) {
    let command = {
      id: uniqueId(CommandTypes.IMPORT_ALARM_Exp_CMD.type),
      visible: true,
      disabled: false,
      target: null,
      executeComponent: CommandTypes.IMPORT_ALARM_Exp_CMD.executeComponent,
      execute: undefined,
      done: undefined
    }
    command.execute = function () {
      Vue.set(commandContext, command.id, command)
    }
    command.done = function () {
      Vue.delete(commandContext, command.id)
    }
    return AuthorityFilter.alarmMangExpAuthorityFilter(command)
  }
  static createAndCopyAlarmMangExpCommand (title, templatePa, commandContext) {
    let command = {
      id: uniqueId(CommandTypes.CREATE_COPY_ALARM_MANG_EXP_CMD.type),
      visible: true,
      disabled: false,
      target: templatePa,
      title: title,
      executeComponent: CommandTypes.CREATE_COPY_ALARM_MANG_EXP_CMD.executeComponent,
      execute: undefined,
      done: undefined,
      name: i18n.tc('AlarmMangExp.createAlarmMangExp')
    }
    command.execute = function () {
      Vue.set(commandContext, command.id, command)
    }
    command.done = function () {
      Vue.delete(commandContext, command.id)
    }
    return AuthorityFilter.alarmMangExpAuthorityFilter(command)
  }
  static queryCreateAlarmMangExpCommand (title, templatePa, commandContext) {
    let command = {
      id: uniqueId(CommandTypes.QUERY_CREATE_ALARM_MANG_EXP_CMD.type),
      visible: true,
      disabled: false,
      target: templatePa,
      title: title,
      executeComponent: CommandTypes.QUERY_CREATE_ALARM_MANG_EXP_CMD.executeComponent,
      execute: undefined,
      done: undefined,
      name: i18n.tc('AlarmMangExp.createAlarmMangExp')
    }
    command.execute = function () {
      Vue.set(commandContext, command.id, command)
    }
    command.done = function () {
      Vue.delete(commandContext, command.id)
    }
    return AuthorityFilter.alarmQueryAlarmMangExpAuthorityFilter(command)
  }
  static updateAlarmMangExpCommand (templatePa, commandContext) {
    let command = {
      id: uniqueId(CommandTypes.UPDATE_ALARM_MANG_EXP_CMD.type),
      visible: true,
      disabled: false,
      target: templatePa,
      executeComponent: CommandTypes.UPDATE_ALARM_MANG_EXP_CMD.executeComponent,
      execute: undefined,
      done: undefined,
      name: i18n.tc('AlarmMangExp.updateAlarmMangExp')
    }
    command.execute = function () {
      Vue.set(commandContext, command.id, command)
    }
    command.done = function () {
      Vue.delete(commandContext, command.id)
    }
    return AuthorityFilter.alarmMangExpAuthorityFilter(command)
  }

  static deleteAlarmMangExpCommand (template1, commandContext) {
    let command = {
      id: uniqueId(CommandTypes.DELETE_ALARM_MANG_EXP_CMD.type),
      visible: true,
      disabled: false,
      target: template1,
      executeComponent: CommandTypes.DELETE_ALARM_MANG_EXP_CMD.executeComponent,
      execute: undefined,
      done: undefined,
      name: i18n.tc('AlarmMangExp.deleteAlarmMangExp')
    }
    command.execute = function () {
      Vue.set(commandContext, command.id, command)
    }
    command.done = function () {
      Vue.delete(commandContext, command.id)
    }
    return AuthorityFilter.alarmMangExpAuthorityFilter(command)
  }
}

AlarmMangExpCommands.CommandTypes = CommandTypes

export default AlarmMangExpCommands
