/**
* @Author: 程亮
* @Date: 2022-05-26 14:05:59
* @LastEditTime: 2022-06-01 17:16:00
* @Description:
* @FilePath: /trunk/src4js/pc4mobx/organization/components/job/job.js
*/
import React from 'react'
import * as mobx from 'mobx'
import {
inject,
observer,
} from 'mobx-react'
import {
WeaTop,
WeaTab,
WeaFormItem,
WeaRightMenu,
WeaTable,
WeaLeftRightLayout,
WeaOrgTree
} from 'ecCom'
import {
Row,
Col,
Spin,
Modal,
Button,
message,
Switch,
Menu, Dropdown, Icon
} from 'antd'
import {
WeaSwitch,
WeaTableNew
} from 'comsMobx'
import {
i18n
} from '../../public/i18n';
import '../../style/common.less';
import NewAndEditDialog from '../NewAndEditDialog';
import NewWeaTableDialog from '../NewWeaTableDialog';
import { renderLoading } from '../../util'; // 从util文件引入公共的方法
const toJS = mobx.toJS;
const confirm = Modal.confirm;
//const WeaTable = WeaTableNew.WeaTable
@inject('job')
@observer
export default class Job extends React.Component {
constructor(props) {
super(props);
}
componentWillMount() {
}
componentDidMount() {
this.init();
}
componentWillReceiveProps(nextProps) {
const {
job
} = this.props;
if (this.props.location.key !== nextProps.location.key) {
this.init();
}
}
init() {
const {
job
} = this.props;
job.getTableInfo();
job.getHasRight();
job.getCopyForm();
}
getTopMenuBtns() {
const {
job
} = this.props;
const {
topMenu,
selectedRowKeys
} = job;
let btns = [];
topMenu.map((item, i) => {
if (item.menuFun === 'batchDelete') {
btns.push();
} else if (item.menuFun === 'copy') {
btns.push();
} else {
btns.push();
}
});
return btns;
}
handleClick(item) {
const {
job
} = this.props;
const {
isPanelShow
} = job;
isPanelShow && job.setPanelStatus(false);
this[item.menuFun] && this[item.menuFun]();
}
new() {
const {
job
} = this.props;
job.setNeDialogTitle(i18n.label.jobName());
job.setNewVisible(true);
job.getJobForm();
}
//联查人员
select(id) {
const {
job
} = this.props;
job.setNeDialogTitle("联查人员");
job.setVisible(true);
job.getHrmTable(id);
}
copy() {
const {
job
} = this.props;
const {
selectedRowKeys
} = job;
let keys = toJS(selectedRowKeys).toString();
job.setIds(keys);
confirm({
title: i18n.confirm.defaultTitle(),
content: this.getCopyForm(),
okText: i18n.button.ok(),
cancelText: i18n.button.cancel(),
onOk() {
job.copy()
},
onCancel() {
return false;
},
});
}
getCopyForm() {
const {
job
} = this.props;
const {
copyCondition,
form2,
} = job;
let formParams = form2.getFormParams();
const {
isFormInit
} = form2;
let arr = [];
isFormInit && copyCondition.map(c => {
c.items.map((field, index) => {
arr.push(
{}
)
})
})
return arr;
}
batchDelete() {
const {
job
} = this.props;
const {
selectedRowKeys
} = job;
let keys = toJS(selectedRowKeys).toString();
job.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 {
job
} = this.props;
job.delete();
}
getDropMenuDatas() {
const {
job
} = this.props;
const {
rightMenu
} = job;
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 {
job
} = this.props;
const {
isPanelShow
} = job;
isPanelShow && job.setPanelStatus(false);
this[key] && this[key]();
}
updateForbiddenTag(checked, id) {
const {
job
} = this.props;
job.updateForbiddenTag(checked, id);
}
onSearchChange(val) {
const {
job
} = this.props;
const {
form
} = job;
job.setJobName(val);
!this.isEmptyObject(form.getFormParams()) && job.updateFields(val);
}
reRenderColumns(columns) {
const {
job
} = this.props;
let _this = this;
columns.forEach((c, index) => {
if (c.dataIndex == 'forbiddenTag') {
c.render = function (text, record) {
return _this.updateForbiddenTag(checked, record.id)} />
}
};
if (c.dataIndex == 'jobName') {
c.render = function (text, record) {
return {
window.open(`/spa/organization/static/index.html#/main/organization/jobExtend/${record.id}`, "_blank")
}}>{text}
}
}
if (c.dataIndex == 'operate') {
c.className = "wea-table-operates"
c.width = 80
c.render = function (text, record) {
const menu = (
)
return
}
}
})
return columns;
}
doDel(id) {
const {
job
} = this.props;
job.setIds(id);
this.showConfirm('del');
}
handleSave() {
const {
job
} = this.props;
job.save();
}
getTabBtn() {
const {
job
} = this.props;
const {
form
} = job;
const btn = [
(),
(),
(),
];
return btn;
}
getPanelComponents() {
const {
job
} = this.props;
const {
searchCondition,
form,
searchConditionLoading
} = job;
let arr = [];
let formParams = form.getFormParams();
const {
isFormInit
} = form;
isFormInit && searchCondition.map(c => {
c.items.map((field, index) => {
arr.push(
{}
)
})
})
if (searchConditionLoading) {
return (
)
} else {
return {
if (e.keyCode == 13 && e.target.tagName === "INPUT") {
job.getTableInfo();
job.setPanelStatus(false)
}
}}>{arr}
}
}
//非空判断
isEmptyObject(obj) {
for (let key in obj) {
return false;
}
return true;
}
//左侧树
getTree = () => {
const {
job
} = this.props;
const {
companysId,
} = job
let tree = (
${i18n.label.organization()}`}
treeNodeClick={this.treeNodeClick}
expandAllChildrenOnSearch={true}
/>
)
return tree;
}
treeNodeClick = (event, ids, nodeids, nodes) => {
const {
job
} = this.props;
const {
form,
companysId
} = job;
const type = event.node.props.type || '0';
const id = event.node.props.id || '';
let params = {};
form.resetConditionValue();
job.setPanelStatus(false)
// job.tabkey = 'default_3';
job.nodeType = type;
if (type == '0') {
params['virtualtype'] = companysId;
}
if (type == '1') {
params['subcompanyid1'] = id;
}
if (type == '2') {
params['departmentid'] = id;
}
job.doSearch(params);
}
render() {
const {
job
} = this.props;
const {
isPanelShow, jobName, conditionNum, visible, condition, form,
tableStore, dataSource, columns, loading, date, nEdialogTitle, dialogLoading,
form1, isEdit, newVisible, deptDataSource, deptColumns, selectedRowKeys, total, current, pageSize, init,
defaultShowLeft
} = job;
const rowSelection = {
onChange(selectedRowKeys, selectedRows) {
job.setSelectedRowKeys(selectedRowKeys);
},
getCheckboxProps: record => ({
disabled: record.isUsed === 1, // 配置无法勾选的列
}),
};
const pagination = {
current: current,
pageSize: pageSize,
total: total,
showSizeChanger: true,
showQuickJumper: true,
onShowSizeChange(current, pageSize) {
},
onChange(current) {
},
showTotal(total) {
return `共 ${total} 条`
}
};
return (
this.handleMenuClick(key)}
>
}
iconBgcolor='#217346'
loading={true}
buttons={this.getTopMenuBtns()}
showDropIcon={true}
dropMenuDatas={this.getDropMenuDatas()}
onDropMenuClick={(e) => this.handleMenuClick(e)}
>
job.setPanelStatus(bool)}
hideSearchAd={() => job.setPanelStatus(false)}
searchsAd={isPanelShow ? this.getPanelComponents() : }
advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20}
hasMask={false}
buttonsAd={this.getTabBtn()}
onSearch={() => {
job.setCurrent(1);
job.setPageSize(10);
job.getTableInfo()
}}
onSearchChange={val => this.onSearchChange(val)}
/>
{
init ?
:
record.id} ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@pgmg3x`}
loading={loading}
dataSource={dataSource} childrenColumnName="children"
columns={this.reRenderColumns(columns)}
rowSelection={rowSelection}
pagination={pagination}
onChange={(pagination, filters, sorter) => {
job.setCurrent(pagination.current);
job.setPageSize(pagination.pageSize);
job.getTableInfo();
}}
indentSize={15}
/>
}
job.setVisible(false)}
/>
this.handleSave()}
onCancel={() => job.setNewVisible(false)}
enable={false} //是否开启字段联动
/>
)
}
}