AlarmMangExpCommands.js 5.36 KB
Newer Older
YazhouChen's avatar
YazhouChen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
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