import React from 'react' import * as mobx from 'mobx' import { inject, observer } from 'mobx-react' import { WeaTop, WeaTab, WeaFormItem, WeaRightMenu, WeaAlertPage } from 'ecCom' import { Row, Col, Spin, Modal, Button, message, Switch } from 'antd' import { WeaSwitch, WeaTableNew } from 'comsMobx' import { i18n } from '../../public/i18n'; import '../../style/common.less'; import NewAndEditDialog from '../NewAndEditDialog'; import { renderNoright } from '../../util'; // 从util文件引入公共的方法 const toJS = mobx.toJS; const confirm = Modal.confirm; const WeaTable = WeaTableNew.WeaTable; @inject('managerDetach') @observer export default class ManagerDetach extends React.Component { constructor(props) { super(props); } componentWillMount() { } componentDidMount() { this.init(); } componentWillUnmount() { } componentWillReceiveProps(nextProps) { const { managerDetach } = this.props; if (this.props.location.key !== nextProps.location.key) { this.init(); } } init() { const { managerDetach } = this.props; managerDetach.getHasRight(); managerDetach.getTableInfo(); } getTopMenuBtns() { const { managerDetach } = this.props; const { topMenu, tableStore } = managerDetach; let btns = []; topMenu.map((item, i) => { if (item.menuFun !== 'batchDelete') { btns.push(); } else { btns.push(); } }); return btns; } handleClick(item) { const { managerDetach } = this.props; const { isPanelShow } = managerDetach; isPanelShow && managerDetach.setPanelStatus(false); this[item.menuFun] && this[item.menuFun](); } new() { const { managerDetach } = this.props; managerDetach.setNeDialogTitle(i18n.label.newManagerDetach()); managerDetach.setIsNew(true); managerDetach.setVisible(true); managerDetach.getForm(); } batchDelete() { const { managerDetach } = this.props; const { tableStore } = managerDetach; let keys = toJS(tableStore.selectedRowKeys).toString(); managerDetach.setIds(keys); this.showConfirm('batchDel'); } showConfirm(v) { let _this = this; confirm({ title: i18n.confirm.defaultTitle(), content: (v == 'del') ? i18n.confirm.delete() : i18n.confirm.batchDeleteConfirm(), okText: i18n.button.ok(), cancelText: i18n.button.cancel(), onOk() { _this.onOk(); }, onCancel() { return false; }, }); } onOk() { const { managerDetach } = this.props; managerDetach.delete(); } getDropMenuDatas() { const { managerDetach } = this.props; const { rightMenu } = managerDetach; let menus = []; toJS(rightMenu).map((item, index) => { let obj = { key: item.menuFun, icon: , content: item.menuName, } if (item.menuFun == 'collection' || item.menuFun == 'help' || item.menuFun == 'pageAddress') { obj.disabled = true; } menus.push(obj); }) return menus; } handleMenuClick(key) { const { managerDetach } = this.props; const { isPanelShow } = managerDetach; isPanelShow && managerDetach.setPanelStatus(false); this[key] && this[key](); } getTabBtn() { const { managerDetach } = this.props; const { form2 } = managerDetach; const btn = [ (), (), (), ]; return btn; } custom = () => { const { managerDetach } = this.props, { tableStore, } = managerDetach; tableStore.setColSetVisible(true); tableStore.tableColSet(true); } onSearchChange(val) { const { managerDetach } = this.props; const { form2 } = managerDetach; managerDetach.setManagerName(val); !this.isEmptyObject(form2.getFormParams()) && managerDetach.updateFields(val); } reRenderColumns(columns) { let _this = this; // columns.forEach((c, index) => { // }) } updateForbiddenTag(checked, id) { const { managerDetach } = this.props; confirm({ title: i18n.confirm.defaultTitle(), content: (checked == true) ? i18n.confirm.enableTag() : i18n.confirm.forbiddenTag(), okText: i18n.button.ok(), cancelText: i18n.button.cancel(), onOk() { managerDetach.updateForbiddenTag(checked, id); }, onCancel() { return false; }, }); } onOperatesClick(record, rowIndex, operate) { const { index } = operate; (index == '0') && this.doEdit(record.randomFieldId); (index == '1') && this.doDel(record.randomFieldId); } doEdit(id) { const { managerDetach } = this.props; managerDetach.setNeDialogTitle(i18n.label.editManagerDetach()); managerDetach.setDetachId(id); managerDetach.setIsNew(false); managerDetach.setVisible(true); managerDetach.getForm(); } doDel(id) { const { managerDetach } = this.props; managerDetach.setIds(id); this.showConfirm('del'); } log = () => { window.setLogViewProp({ logMoudleType: 14, keys: new Date().getTime(), }); } handleSave() { const { managerDetach } = this.props; const { isNew } = managerDetach; isNew && managerDetach.save(); !isNew && managerDetach.edit(); } getPanelComponents() { const { managerDetach } = this.props; const { searchCondition, form2, searchConditionLoading } = managerDetach; let arr = []; let formParams = form2.getFormParams(); const { isFormInit } = form2; isFormInit && searchCondition.map(c => { c.items.map((field, index) => { arr.push(