import {Button, Spin} from 'antd' import isEmpty from 'lodash/isEmpty' import forEach from 'lodash/forEach' import {WeaSearchGroup,WeaRightMenu,WeaDialog,WeaNewScroll, WeaFormItem, WeaAlertPage} from 'ecCom' import {WeaSwitch} from 'comsMobx'; import { inject, observer} from 'mobx-react'; import * as mobx from 'mobx'; import '../../style/roleset.less'; import {WeaTableNew} from 'comsMobx'; import {i18n} from '../../public/i18n'; const WeaTable = WeaTableNew.WeaTable; const toJS = mobx.toJS; @inject('hrmRoleSet') @inject('hrmCard') @observer class HrmRoleSet extends React.Component { constructor(props) { super(props); } componentDidMount(){ const {hrmCard} = this.props; hrmCard.setTopButtons(this.getTopButtons.bind(this)); hrmCard.setTopRightMenus(this.getRightMenu.bind(this)); hrmCard.setTopShowDropIcon(true); this.init(); } init() { const {hrmRoleSet} = this.props; let hrmId = this.props.params.hrmId || ''; hrmRoleSet.init(); hrmRoleSet.getData({id:hrmId}); } getHrmRoleSetForm() { const { hrmRoleSet } = this.props; const { form,formFields } = hrmRoleSet; const {isFormInit} = form; let group = []; const formParams = form.getFormParams(); isFormInit && !isEmpty(formFields) && toJS(formFields).map((c, i) =>{ c.items.map((fields, j) => { let dom = ; group.push( {dom} ); }); }); return group; } reRenderColumns(columns){ let _this = this; columns.forEach(c=>{ if (c.dataIndex=='roleid'){ c.render = function(text, record){ return _this.edit(record.id)} dangerouslySetInnerHTML={{__html: record.roleidspan}}> } }else { c.render = function(text, record){ let valueSpan = record[c.dataIndex + "span"] !== undefined ? record[c.dataIndex + "span"] : record[c.dataIndex]; return } } }) return columns; } onOperatesClick=(record,index,operate,flag,argumentString)=>{ const func = operate.href ? operate.href.split(':')[1].split('(')[0] : ''; let id = record.id ? record.id : ''; if(func=='showLog'){ id = record.roleid ? record.roleid : ''; } this[func] && this[func](id); } doSave() { let hrmId = this.props.params.hrmId || ''; const {hrmRoleSet} = this.props; hrmRoleSet.save(hrmId); } onCancel(){ const {hrmRoleSet} = this.props; hrmRoleSet.onCancel(); } update(){ const {hrmRoleSet} = this.props; hrmRoleSet.update(); } edit(id){ const {hrmRoleSet} = this.props; let hrmId = this.props.params.hrmId || ''; hrmRoleSet.edit(id, hrmId); } add(){ const {hrmRoleSet} = this.props; let hrmId = this.props.params.hrmId || ''; hrmRoleSet.add({id: hrmId}); } delBatch(){ const {hrmRoleSet} = this.props; const keys = this.getSelectedRowKeys(); const ids = keys ? keys.join(',') : ''; hrmRoleSet.delBatch(ids); } del(id){ const {hrmRoleSet} = this.props; hrmRoleSet.delBatch(id); } showLog(id){ let params = {targetId:id}; params.logType = '4'; params.logSmallType = '1012'; window.setLogViewProps(params); } getSelectedRowKeys(){ const { hrmRoleSet } = this.props; const { table } = hrmRoleSet; const selectedRowKeys = table.selectedRowKeys; return selectedRowKeys; } definedColumn() { const { hrmRoleSet } = this.props; const { table} = hrmRoleSet; table.setColSetVisible(true); table.tableColSet(true); } getRightMenu(){ const keys = this.getSelectedRowKeys(); const {hrmRoleSet} = this.props; const {hasRight, buttons} = hrmRoleSet; const opMenus = []; if (hasRight) { opMenus.push({ icon: , content:i18n.button.add(), key: 'add', onClick: key =>{ this.add(); } }); opMenus.push({ icon: , content:i18n.button.multiDelete(), key: 'delBatch', onClick: key =>{ this.delBatch(); } }); } const arr = [...opMenus, { icon: , content:i18n.button.columnVisibleSetting(), key: 'definedColumn', onClick: key =>{ this.definedColumn(); } } ]; arr.push( { icon: , content:i18n.button.log(), key: 'showLog', onClick: key =>{ this.showLog(); } } ) return arr; } getTopButtons() { const {hrmRoleSet} = this.props; const {hasRight, buttons} = hrmRoleSet; const btnAdd = ; const btns = []; if (hasRight) { btns.push(btnAdd); } return btns; } render() { const {hrmRoleSet} = this.props; const {dialogShow, isEditor, hasRight, verified,formFields,table,} = hrmRoleSet; const keys = this.getSelectedRowKeys(); const ids = keys ? keys.join(',') : ''; let customComponent =
this.add()}/> this.delBatch()} />
; if (verified && !hasRight) { return (
{i18n.message.authFailed()}
) } if (verified && hasRight) { return (
this.reRenderColumns(c)} onOperatesClick={this.onOperatesClick} /> this.onCancel()} buttons={} style={{width: 500, height: 160}} >
{this.getHrmRoleSetForm()}
) } return (
) } } export default HrmRoleSet;