import React from 'react'; import {inject, observer} from 'mobx-react'; import {toJS} from 'mobx'; import { WeaTop, WeaLeftRightLayout, WeaLeftTree, WeaTools, WeaOrgTree, WeaTab, WeaFormItem, WeaSearchGroup, WeaRightMenu, WeaAlertPage, WeaLocaleProvider } from 'ecCom'; import {Button} from 'antd'; import {WeaTableNew, WeaSwitch} from 'comsMobx'; const {WeaTable} = WeaTableNew; const getLabel = WeaLocaleProvider.getLabel; import * as EsearchUtil from '../../util/EsearchUtil'; import WeesoRobotDialog from './RobotDialog'; @inject('weesoRobotStore') @observer export default class Index extends React.Component { constructor (props) { super(props); this.state = { } } componentDidMount() { const {weesoRobotStore} = this.props; weesoRobotStore.doInit(); } componentWillReceiveProps(nextProps) { const {weesoRobotStore} = this.props; if (this.props.location.key !== nextProps.location.key) { weesoRobotStore.doInit() } } getTabButtonsAd() { const {weesoRobotStore} = this.props; let btns = btns=[ , , , ] return btns; } getRightMenu() { const selectedRowKeys = toJS(this.props.weesoRobotStore.tableStore.selectedRowKeys); let btnArr = [ { key: 'BTN_NEW', icon: , content : getLabel(611,'添加'), onClick : () => this.onRightMenuClick('BTN_NEW') }, { key: 'BTN_DEL', icon: , disabled:selectedRowKeys.length === 0, content : getLabel(32136,'批量删除'), onClick : () => this.onRightMenuClick('BTN_DEL') }, { key: 'BTN_INDEX', icon: , content : getLabel(20472,'创建索引'), onClick : () => this.onRightMenuClick('BTN_INDEX') }, { key: 'BTN_COLUMN', icon: , content : getLabel(32535,'显示列定制'), onClick : () => this.onRightMenuClick('BTN_COLUMN') } ]; return btnArr; } getBtns = () => { const selectedRowKeys = toJS(this.props.weesoRobotStore.tableStore.selectedRowKeys); let btns = [ , , ]; return btns; } onRightMenuClick = (type) => { const {weesoRobotStore} = this.props; const selectedRowKeys = toJS(weesoRobotStore.tableStore.selectedRowKeys); if(type == 'BTN_NEW'){//新建 weesoRobotStore.setDialogState({createOrEdit: 0}); weesoRobotStore.dialogStatus.canClick && weesoRobotStore.getFields(); } if(type == 'BTN_DEL'){//批量删除 if(selectedRowKeys && selectedRowKeys.length > 0){ EsearchUtil.doConfirm(`${getLabel(127574, '确定删除吗?')}`, () => weesoRobotStore.deleteRobot({ids: selectedRowKeys.join(',')})); }else { EsearchUtil.setModal(`${getLabel(22000,'请先选择操作对象')}`); } } if(type == 'BTN_INDEX'){//创建索引 weesoRobotStore.createRobotIndex(); } if(type == 'BTN_COLUMN'){//显示列定制 weesoRobotStore.tableStore.setColSetVisible(true); weesoRobotStore.tableStore.tableColSet(true); } } onOperatesClick = (record, index, operate) => { const {weesoRobotStore} = this.props; if(operate.index == 0){//启用 EsearchUtil.doConfirm(getLabel(83450, '确定启用吗?'), () => weesoRobotStore.openRobot({state: 0, id: record.randomFieldId})) } if(operate.index == 1){//禁用 EsearchUtil.doConfirm(getLabel(83451, '确定禁用吗?'), () => weesoRobotStore.openRobot({state: 1, id: record.randomFieldId})) } if(operate.index == 2){//编辑 weesoRobotStore.setDialogState({createOrEdit: 1, editId: record.randomFieldId}); weesoRobotStore.dialogStatus.canClick && weesoRobotStore.getFields({id: record.randomFieldId}); } if(operate.index == 3){//删除 EsearchUtil.doConfirm(getLabel(127574, '确定删除吗?'), () => weesoRobotStore.deleteRobot({ids: record.randomFieldId})); } } render() { const {weesoRobotStore} = this.props; const {tableStore, status, form } = weesoRobotStore; const {showSearchAd, conditioninfo, alertPage} = toJS(status); let collectParams={ favname: getLabel(82832, '智能指令'), favouritetype: 5, objid:0, importantlevel: 1, }; let title=getLabel(82832, '智能指令'); return (
{alertPage ?
{getLabel(382663,'暂无权限')}
: } iconBgcolor='#A0B0BA' buttonSpace={10} buttons={this.getBtns()} showDropIcon={true} dropMenuDatas={this.getRightMenu()} dropMenuProps={{ collectParams:collectParams }} /> { weesoRobotStore.setState({showSearchAd: false}); weesoRobotStore.getList({...weesoRobotStore.form.getFormParams()},true); })} showSearchAd={showSearchAd} advanceHeight={220} buttonsAd={this.getTabButtonsAd()} setShowSearchAd={() => weesoRobotStore.setState({showSearchAd: !showSearchAd})} hideSearchAd={() => weesoRobotStore.setState({showSearchAd: false})} searchsBaseValue= {form.isFormInit && form.getFormParams() && form.getFormParams().title || ''} onSearch={() => weesoRobotStore.getList({...form.getFormParams()}, true)} onSearchChange={value => form.updateFields({title : value})} /> }
) } }