import React from 'react' import * as mobx from 'mobx' import { inject, observer } from 'mobx-react' import { WeaTop, WeaTab, WeaFormItem, WeaRightMenu, WeaLeftRightLayout, WeaOrgTree, WeaLocaleProvider } 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 ImportDialog from '../ImportDialog'; import { renderNoright } from '../../util'; import SelectTag from '../SelectTag' const toJS = mobx.toJS; const confirm = Modal.confirm; const WeaTable = WeaTableNew.WeaTable; const getLabel = WeaLocaleProvider.getLabel; @inject('staff') @inject('importDialog') @observer export default class Staff extends React.Component { constructor(props) { super(props); } componentWillMount() { } componentDidMount() { this.init(); } componentWillReceiveProps(nextProps) { const { staff } = this.props; if (this.props.location.key !== nextProps.location.key) { this.init(); } } init() { const { staff } = this.props; staff.getTableInfo(); staff.getHasRight(); } getTopMenuBtns() { const { staff } = this.props; const { topMenu, tableStore } = staff; let btns = []; topMenu.map((item, i) => { if (item.menuFun !== 'batchDelete') { btns.push(); } else { btns.push(); } }); return btns; } handleClick(item) { const { staff } = this.props; const { isPanelShow } = staff; isPanelShow && staff.setPanelStatus(false); this[item.menuFun] && this[item.menuFun](); } new() { const { staff } = this.props; staff.setNeDialogTitle(i18n.label.newStaff()); staff.setIsNew(true); staff.setVisible(true); staff.getForm(); } import() { const { importDialog } = this.props; importDialog.importVisible=true; importDialog.importModule='staff'; importDialog.current = 0; importDialog.getImportForm(); } exportStaff() { const { staff } = this.props; staff.exportData(); } log = () => { window.setLogViewProp({ logMoudleType: 13, keys: new Date().getTime(), }); } batchDelete() { const { staff } = this.props; const { tableStore } = staff; let keys = toJS(tableStore.selectedRowKeysAllPages).toString(); staff.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 { staff } = this.props; staff.delete(); } getDropMenuDatas() { const { staff } = this.props; const { rightMenu } = staff; 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 { staff } = this.props; const { isPanelShow } = staff; isPanelShow && staff.setPanelStatus(false); this[key] && this[key](); } getTabBtn() { const { staff } = this.props; const { form2 } = staff; const btn = [ (), (), (), ]; return btn; } onSearchChange(val) { const { staff } = this.props; const { form2 } = staff; staff.setStaffName(val); } reRenderColumns(columns) { let _this = this; columns.forEach((c, index) => { if (c.dataIndex == 'lack_status') { c.render = function (text, record) { let value = text == "1" ? "#ff9000" : (text == 2 ? "#66cc66" : "#ff0033") return } }; if (c.dataIndex == 'staff_desc') { c.render = function (text, record) { return {`${getLabel(547345,'编制数')}: ${record.staff_num} / ${getLabel(547346,'在编数')}: ${record.permanent_num} / ${getLabel(547347,'冻结数')}: ${record.freeze_num}/ ${getLabel(547240,'状态')} :${record.lack_statusspan}`} } }; }) } getTree = () => { const { staff } = this.props; const { companysId, } = staff let tree = ( ${i18n.label.organization()}`} treeNodeClick={this.treeNodeClick} expandAllChildrenOnSearch={true} renderNode={item => this.renderNode(item)} /> ) return tree; } renderNode(item) { return
{item.name} {item.canceled && ({i18n.label.forbidden()})}
} treeNodeClick = (event, ids, nodeids, nodes) => { const { staff } = this.props; const { form2, companysId } = staff; const type = event.node.props.type || '0'; const id = event.node.props.id || ''; let params = {}; form2.resetConditionValue(); if (type == '0') { params['virtualtype'] = companysId; } if (type == '1') { params['compId'] = id; } if (type == '2') { params['deptId'] = id; } staff.doSearch(params); } replaceLeft() { const { staff } = this.props; const { leftCondition, form1, } = staff; let formParams = form1.getFormParams(); const { isFormInit } = form1; let arr = []; isFormInit && leftCondition.map(c => { c.items.map((field, index) => { arr.push(
{}
) }) }) return arr; } onChange = data => { const { staff } = this.props; staff.setPlanId(data.planId.value) }; onOperatesClick(record, rowIndex, operate) { const { index } = operate; (index == '0') && this.doEdit(record.randomFieldId); (index == '1') && this.doDel(record.randomFieldId); (index == '2') && this.doChange(record.randomFieldId); } doEdit(id) { const { staff } = this.props; staff.setNeDialogTitle(i18n.label.editStaff()); staff.setStaffId(id); staff.setOperateType("1"); staff.setIsNew(false); staff.setVisible(true); staff.getForm(); } doChange(id) { const { staff } = this.props; staff.setNeDialogTitle(i18n.label.changeStaff()); staff.setStaffId(id); staff.setOperateType("2"); staff.setIsNew(false); staff.setVisible(true); staff.getForm(); } custom = () => { const { staff } = this.props, { tableStore, } = staff; tableStore.setColSetVisible(true); tableStore.tableColSet(true); } doDel(id) { const { staff } = this.props; staff.setIds(id); this.showConfirm('del'); } handleSave() { const { staff } = this.props; const { isNew } = staff; isNew && staff.save(); !isNew && staff.edit(); } getPanelComponents() { const { staff } = this.props; const { searchCondition, form2, searchConditionLoading } = staff; let arr = []; let formParams = form2.getFormParams(); const { isFormInit } = form2; isFormInit && searchCondition.map(c => { c.items.map((field, index) => { arr.push(
{}
) }) }) if (searchConditionLoading) { return (
) } else { return { if (e.keyCode == 13 && e.target.tagName === "INPUT") { staff.getTableInfo(); staff.setPanelStatus(false) } }}>{arr} } } //非空判断 isEmptyObject(obj) { for (let key in obj) { return false; } return true; } render() { const { staff,importDialog } = this.props; const { isPanelShow, form2, staffName, conditionNum, tableStore, nEdialogTitle, visible, condition, form, dialogLoading, isEdit, date, hasRight,exSpinning } = staff; const {importVisible} = importDialog; if (hasRight === false) { return renderNoright(); } return ( hasRight &&
this.handleMenuClick(key)} > } iconBgcolor='#217346' loading={true} buttons={this.getTopMenuBtns()} showDropIcon={true} dropMenuDatas={this.getDropMenuDatas()} onDropMenuClick={(e) => this.handleMenuClick(e)} > staff.setPanelStatus(bool)} hideSearchAd={() => staff.setPanelStatus(false)} searchsAd={isPanelShow ? this.getPanelComponents() :
} advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20} hasMask={false} buttonsAd={this.getTabBtn()} onSearch={() => staff.getTableInfo()} onSearchChange={val => this.onSearchChange(val)} replaceLeft={this.replaceLeft()} /> this.reRenderColumns(c)} onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)} />
this.handleSave()} onCancel={() => staff.setVisible(false)} moduleName={"staff"} bindChangeEnvent={val => staff.updateConditions(val)} /> {importVisible && }
) } }