This commit is contained in:
黎永顺 2023-03-20 18:00:36 +08:00
parent 785ecf9ae8
commit 09ee398bfc
1 changed files with 67 additions and 65 deletions

View File

@ -82,77 +82,79 @@ class DataTables extends Component {
});
}
};
const getColumns = _.map(columns, item => {
const { dataIndex } = item;
if (dataIndex === "username") {
return {
...item,
render: (text, record) => {
return <a
className="ellipsis"
href={`javaScript:openhrm(${record.employeeId});`}
onClick={e => window.pointerXY(e)}
title={text}
>
{text}
</a>;
}
};
} else if (dataIndex === "operate") {
return {
...item,
render: (text, record) => (
<div className="linkWapper">
{
!isSpecial &&
<React.Fragment>
<a href="javaScript:void(0);" onClick={() => onViewDetails(record)}>查看明细</a>
{
showOperateBtn &&
<Popover
overlayClassName="moreIconWrapper"
placement="bottomRight"
content={<Menu onClick={(e) => onTableOperate(e, record)}>
<Menu.Item key="handleAddData">编辑</Menu.Item>
<Menu.Item key="deleteSelectAddUpDeduction">删除</Menu.Item>
</Menu>} title="">
<i className="icon-coms-more"/>
</Popover>
}
</React.Fragment>
}
{
isSpecial &&
<React.Fragment>
{
showOperateBtn &&
<React.Fragment>
<a href="javaScript:void(0);"
onClick={() => onTableOperate({ key: "handleAddData" }, record)}>编辑</a>
<a href="javaScript:void(0);"
onClick={() => onTableOperate({ key: "deleteSelectAddUpDeduction" }, record)}>删除</a>
</React.Fragment>
}
</React.Fragment>
}
</div>
)
};
} else {
return {
...item,
render: (text) => {
return <span className="ellipsis" title={text}> {text} </span>;
}
};
}
});
return <UnifiedTable
rowKey="id"
rowSelection={rowSelection}
columns={_.map(columns, item => {
const { dataIndex } = item;
if (dataIndex === "username") {
return {
...item,
render: (text, record) => {
return <a
className="ellipsis"
href={`javaScript:openhrm(${record.employeeId});`}
onClick={e => window.pointerXY(e)}
title={text}
>
{text}
</a>;
}
};
} else if (dataIndex === "operate") {
return {
...item,
render: (text, record) => (
<div className="linkWapper">
{
!isSpecial &&
<React.Fragment>
<a href="javaScript:void(0);" onClick={() => onViewDetails(record)}>查看明细</a>
{
showOperateBtn &&
<Popover
overlayClassName="moreIconWrapper"
placement="bottomRight"
content={<Menu onClick={(e) => onTableOperate(e, record)}>
<Menu.Item key="handleAddData">编辑</Menu.Item>
<Menu.Item key="deleteSelectAddUpDeduction">删除</Menu.Item>
</Menu>} title="">
<i className="icon-coms-more"/>
</Popover>
}
</React.Fragment>
}
{
isSpecial &&
<React.Fragment>
{
showOperateBtn &&
<React.Fragment>
<a href="javaScript:void(0);"
onClick={() => onTableOperate({ key: "handleAddData" }, record)}>编辑</a>
<a href="javaScript:void(0);"
onClick={() => onTableOperate({ key: "deleteSelectAddUpDeduction" }, record)}>删除</a>
</React.Fragment>
}
</React.Fragment>
}
</div>
)
};
} else {
return {
...item,
render: (text) => {
return <span className="ellipsis" title={text}> {text} </span>;
}
};
}
})}
columns={getColumns}
dataSource={dataSource}
pagination={pagination}
loading={loading.query}
xWidth={getColumns.length * 120}
/>;
}
}