PerformanceDataSafeCommands.js 2.23 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
import Vue from 'vue'
import uniqueId from 'lodash'
import {i18n} from "../main";
import AuthorityFilter from '../commands/AuthorityFilter'
import DeletePerformanceDialog from '@/components/DialogComponents/DataSafeDialog/DeletePerformanceDialog'
import DeleteAlarmDialog from '@/components/DialogComponents/DataSafeDialog/DeleteAlarmDialog'

Vue.component('DeletePerformanceDialog', DeletePerformanceDialog)
Vue.component('DeleteAlarmDialog', DeleteAlarmDialog)

let CommandTypes = {
  DELETE_PERFORMANCE_CMD: {
    type: 'DeletePerformance',
    executeComponent: 'DeletePerformanceDialog',
    registerComponent: DeletePerformanceDialog // import对应的对话框组件
  },
  DELETE_ALARM_CMD: {
    type: 'DeleteAlarm',
    executeComponent: 'DeleteAlarmDialog',
    registerComponent: DeleteAlarmDialog
  }
}

class PerformanceDataSafeCommands {
  static deletePerformanceDataCommand (performanceList, commandContext) {
    let command = {
      id: uniqueId(CommandTypes.DELETE_PERFORMANCE_CMD.type),
      visible: true,
      disabled: false,
      target: performanceList,
      executeComponent: CommandTypes.DELETE_PERFORMANCE_CMD.executeComponent,
      execute: undefined,
      done: undefined,
      name: i18n.tc('PerformanceDataSafeCommands.deletePerformance')
    };
    command.execute = function () {
      Vue.set(commandContext, command.id, command);
    };
    command.done = function () {
      Vue.delete(commandContext, command.id)
    };
    return AuthorityFilter.performanceAuthorityFilter(command)
  }

  static deleteAlarmDataCommand (alarmList, commandContext){
    let command = {
      id: uniqueId(CommandTypes.DELETE_ALARM_CMD.type),
      visible: true,
      disabled: false,
      target: alarmList,
      executeComponent: CommandTypes.DELETE_ALARM_CMD.executeComponent,
      execute: undefined,
      done: undefined,
      name: i18n.tc('PerformanceDataSafeCommands.deleteAlarm')
    }
    command.execute = function () {
      Vue.set(commandContext, command.id, command)
    }
    command.done = function () {
      Vue.delete(commandContext, command.id)
    }
    return AuthorityFilter.performanceAuthorityFilter(command)
  }

}

PerformanceDataSafeCommands.CommandTypes = CommandTypes;

export default PerformanceDataSafeCommands