salary-management-front/pc4mobx/hrmSalary/pages/ledger/slideRefereUser.js

236 lines
6.6 KiB
JavaScript
Raw Normal View History

2022-06-17 16:53:27 +08:00
import React from "react";
import { inject, observer } from "mobx-react";
import { message, Modal, Table, Button } from "antd";
2022-06-17 16:53:27 +08:00
import { WeaInputSearch } from "ecCom";
import AddUserModal from "./addUserModal";
2022-08-25 17:54:18 +08:00
import "./index.less";
2022-03-16 10:41:38 +08:00
2022-06-17 16:53:27 +08:00
@inject("ledgerStore")
2022-03-25 16:41:59 +08:00
@observer
2022-03-16 10:41:38 +08:00
export default class SlideRefereUser extends React.Component {
2022-06-17 16:53:27 +08:00
constructor(props) {
super(props);
this.state = {
addUserModalVisible: false,
selectedRowKeys: [],
searchValue: ""
};
}
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
handleTabClick(tab) {
const {
ledgerStore: {
setIncludeType,
getLedgerPersonRangeInclude,
salarySobId,
getLedgerPersonRangeExclude
}
} = this.props;
setIncludeType(tab);
if (tab == 1) {
getLedgerPersonRangeInclude({ salarySobId: salarySobId });
} else {
getLedgerPersonRangeExclude({ salarySobId: salarySobId });
2022-03-25 16:41:59 +08:00
}
2022-06-17 16:53:27 +08:00
}
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
componentWillMount() {
const { edit } = this.props;
const {
ledgerStore: {
getLedgerPersonRangeInclude,
salarySobId,
getLedgerBasicForm
}
} = this.props;
getLedgerPersonRangeInclude({ salarySobId: salarySobId });
if (edit) getLedgerBasicForm();
2022-10-28 17:12:03 +08:00
// window.setLayoutWindow=window;
2022-06-17 16:53:27 +08:00
}
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
onSelectChange = selectedRowKeys => {
this.setState({ selectedRowKeys });
};
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
handleTabDelete = () => {
const { ledgerStore: { deleteLedgerPersonRange } } = this.props;
if (this.state.selectedRowKeys.length == 0) {
message.warning("未选择条目");
return;
2022-03-25 16:41:59 +08:00
}
2022-06-17 16:53:27 +08:00
Modal.confirm({
title: "信息确认",
content: "确认删除",
onOk: () => {
deleteLedgerPersonRange(this.state.selectedRowKeys);
},
2022-08-25 17:54:18 +08:00
onCancel: () => {
}
2022-06-17 16:53:27 +08:00
});
};
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
handleSearch = value => {
const {
ledgerStore: {
includeType,
salarySobId,
getLedgerPersonRangeInclude,
getLedgerPersonRangeExclude,
userTableStore
2022-06-17 16:53:27 +08:00
}
} = this.props;
if (includeType == 1) {
getLedgerPersonRangeInclude({
salarySobId: salarySobId,
2022-08-25 17:54:18 +08:00
targetName: value,
current: userTableStore.pageNum,
pageSize: userTableStore.pageSize,
2022-06-17 16:53:27 +08:00
});
} else {
getLedgerPersonRangeExclude({
salarySobId: salarySobId,
2022-08-25 17:54:18 +08:00
targetName: value,
current: userTableStore.pageNum,
pageSize: userTableStore.pageSize,
2022-06-17 16:53:27 +08:00
});
2022-03-25 16:41:59 +08:00
}
2022-06-17 16:53:27 +08:00
};
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
render() {
const {
ledgerStore: {
2022-08-25 17:54:18 +08:00
loading,
2022-06-17 16:53:27 +08:00
includeType,
2022-08-25 17:54:18 +08:00
salarySobId,
userTableStore,setUserTableStore,
2022-06-17 16:53:27 +08:00
addUserModalVisible,
setAddUserModalVisible,
2022-08-25 17:54:18 +08:00
baseInfoRequest,
getLedgerPersonRangeInclude,
getLedgerPersonRangeExclude
2022-06-17 16:53:27 +08:00
}
} = this.props;
const { canEdit = "true" } = baseInfoRequest;
let { columns, list } = userTableStore;
const { selectedRowKeys } = this.state;
columns = columns || [];
list = list || [];
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
list.map(item => (item.key = item.id));
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
const rowSelection = {
selectedRowKeys,
onChange: this.onSelectChange
};
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
return (
<div className="slideRefereUser">
<div className="refereUserHeader">
<div className="headerLeft">
<span
className={includeType == 1 ? "selectedCrumbs" : "tabItem"}
onClick={() => {
this.handleTabClick(1);
}}>
关联人员范围
2022-08-25 17:54:18 +08:00
</span>
<span style={{ margin: "0 4px" }}>|</span>
2022-06-17 16:53:27 +08:00
<span
className={includeType == 0 ? "selectedCrumbs" : "tabItem"}
onClick={() => {
this.handleTabClick(0);
}}>
从范围中排除
</span>
</div>
<WeaInputSearch
className="searchInput"
value={this.state.searchValue}
onChange={value => {
this.setState({ searchValue: value });
}}
onSearch={value => {
this.handleSearch(value);
}}
/>
{
canEdit === "true" &&
<div className='headerIcon'>
<Button type="primary"
size="small"
onClick={() => {
this.handleTabDelete();
}}
><span className="icon-coms-form-delete-hot" title="删除"></span></Button>
<Button type="primary"
size="small"
style={{ marginRight: 10 }}
onClick={() => {
setAddUserModalVisible(true);
}}
><span className="icon-coms-Add-to-hot" title="添加"></span></Button>
</div>
}
2022-06-17 16:53:27 +08:00
</div>
2022-08-25 17:54:18 +08:00
<div className="slideRefereUserTableWrapper">
2022-06-17 16:53:27 +08:00
<Table
2022-08-25 17:54:18 +08:00
loading={loading}
2022-06-17 16:53:27 +08:00
rowSelection={rowSelection}
dataSource={list}
columns={columns}
pagination={{
total: userTableStore.total,
2022-08-25 17:54:18 +08:00
current: userTableStore.pageNum,
pageSize: userTableStore.pageSize,
2022-06-17 16:53:27 +08:00
showTotal: total => `${total}`,
showQuickJumper: true,
2022-08-25 17:54:18 +08:00
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],
onShowSizeChange: (current, pageSize) => {
setUserTableStore({...userTableStore, pageNum: current, pageSize})
2022-08-25 17:54:18 +08:00
if (includeType == 1) {
getLedgerPersonRangeInclude({
salarySobId: salarySobId,
current,
pageSize
2022-08-25 17:54:18 +08:00
});
} else {
getLedgerPersonRangeExclude({
salarySobId: salarySobId,
current,
pageSize
2022-08-25 17:54:18 +08:00
});
}
},
onChange: current => {
setUserTableStore({ ...userTableStore, pageNum: current })
2022-08-25 17:54:18 +08:00
if (includeType == 1) {
getLedgerPersonRangeInclude({
salarySobId: salarySobId,
current,
pageSize: userTableStore.pageSize
2022-08-25 17:54:18 +08:00
});
} else {
getLedgerPersonRangeExclude({
salarySobId: salarySobId,
current,
pageSize: userTableStore.pageSize
2022-08-25 17:54:18 +08:00
});
}
}
2022-06-17 16:53:27 +08:00
}}
/>
</div>
2022-03-25 16:41:59 +08:00
2022-06-17 16:53:27 +08:00
{addUserModalVisible &&
<AddUserModal
visible={addUserModalVisible}
onCancel={() => {
setAddUserModalVisible(false);
}}
/>}
</div>
);
}
}