/** * Created by W.X. on 16/7/28. */ import {observable} from "mobx/lib/mobx"; import CommandReport from './CommandReport'; import CommandDataTable from './CommandDataTable'; const commandMap = { 'report': CommandReport, 'dataTable': CommandDataTable }; export class CommandModel { /** * 所有的命令工具组 */ private _commands: Object; /** * 当前使用的命令菜单组 */ @observable private _currentCommand; /** * 命令工具栏是否可用, 默认是可用的 */ @observable private _useable: boolean = true; @observable private _mode: string = 'icon+text'; constructor() { this._commands = { report: new commandMap['report']() }; this._currentCommand = this._commands["report"]; } get currentCommand() { return this._currentCommand; } get mode(): string { return this._mode; } get useable(): boolean { return this._useable; } set useable(bool: boolean) { this._useable = bool; } get items(): Array { return this._currentCommand.items; } getItemStatus(itemName: string) { return this._currentCommand.getItemStatus(itemName); } changeCommand(name: string) { if(commandMap[name]){ if (name !== 'report'){ this._commands[name] = new commandMap[name](); } this._currentCommand = this._commands[name]; } } } export default CommandModel;