import Vue from 'vue' import uniqueId from 'lodash' import AuthorityFilter from '../commands/AuthorityFilter' import CreateSnapshotDialog from "@/components/DialogComponents/SnapshotDialog/CreateSnapshotDialog.vue" import DeleteSnapshotDialog from "@/components/DialogComponents/SnapshotDialog/DeleteSnapshotDialog.vue"; Vue.component('CreateSnapshotDialog', CreateSnapshotDialog); Vue.component('DeleteSnapshotDialog', DeleteSnapshotDialog); let CommandTypes = { CREATE_SNAPSHOT_CMD: { type: 'CreateSnapshot', executeComponent: 'CreateSnapshotDialog', registerComponent: CreateSnapshotDialog }, DELETE_SNAPSHOT_CMD: { type: 'DeleteSnapshot', executeComponent: 'DeleteSnapshotDialog', registerComponent: DeleteSnapshotDialog // import对应的对话框组件 } } class SnapshotCommands { static createSnapshotCommand (title, snapshot, commandContext) { let command = { id: uniqueId(CommandTypes.CREATE_SNAPSHOT_CMD.type), visible: true, disabled: false, target: snapshot, title: title, executeComponent: CommandTypes.CREATE_SNAPSHOT_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.snapshotAuthorityFilter(command) } static deleteSnapshotCommand (snapshot, commandContext) { let command = { id: uniqueId(CommandTypes.DELETE_SNAPSHOT_CMD.type), visible: true, disabled: false, target: snapshot, executeComponent: CommandTypes.DELETE_SNAPSHOT_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.snapshotAuthorityFilter(command) } } SnapshotCommands.CommandTypes = CommandTypes; export default SnapshotCommands