update 细节处理

This commit is contained in:
2021-06-28 21:35:07 +08:00
parent e8dd6f4eca
commit 19cb1984b0
3 changed files with 57 additions and 29 deletions

View File

@@ -5,24 +5,41 @@ function renderActions() {
const { children } = this.props
const actions = []
Array.isArray(children) ? children
Array.isArray(children)
? children
.filter(action => action)
.forEach((action, i) => {
actions.push(action)
if (i < this.props.children.length - 1) {
actions.push(<Divider type="vertical" key={i} />)
}
}) : (actions.push(children))
actions.push(action, <Divider type="vertical" key={i} />)
})
: actions.push(children)
return actions
}
export default class QueryTableActions extends Component {
componentDidMount() {
// 删除多余的间隔线
const className = 'ant-divider ant-divider-vertical'
let series = false
for (const node of this.refs.inner.childNodes) {
if (
(series && node.className == className) ||
(!node.nextElementSibling && node.className == className)
) {
node.remove()
series = false
} else if (node.className == className) {
series = true
} else {
series = false
}
}
}
render() {
return (
<div className="yo-table-actions">
<div className="yo-table-actions--inner">
<div className="yo-table-actions--inner" ref="inner">
{renderActions.call(this)}
</div>
</div>

View File

@@ -13,7 +13,16 @@ import {
Switch,
Tag,
} from 'antd'
import { AntIcon, Auth, Container, Image, ModalForm, QueryList, QueryTreeLayout } from 'components'
import {
AntIcon,
Auth,
Container,
Image,
ModalForm,
QueryList,
QueryTableActions,
QueryTreeLayout,
} from 'components'
import { api } from 'common/api'
import { toCamelCase } from 'util/format'
import { isEqual } from 'lodash'
@@ -203,9 +212,10 @@ export default class index extends Component {
<List.Item
key={id}
actions={[
<QueryTableActions>
<Auth auth="houseMember:edit">
<a onClick={() => this.onOpen(this.editForm, id)}>编辑</a>
</Auth>,
</Auth>
<Auth auth="houseMember:delete">
<Popconfirm
placement="topRight"
@@ -214,13 +224,14 @@ export default class index extends Component {
>
<a>删除</a>
</Popconfirm>
</Auth>,
<Auth aut="houseMember:resetPwd">
</Auth>
<Auth auth="houseMember:resetPwd">
<a onClick={() => this.onResetPassword(id)}>重置密码</a>
</Auth>,
</Auth>
<Auth auth="houseMember:grantData">
<a onClick={() => this.onOpen(this.dataForm, id)}>授权额外数据</a>
</Auth>,
</Auth>
</QueryTableActions>,
]}
>
<List.Item.Meta

View File

@@ -76,7 +76,7 @@ class User extends Component {
)}
{user.roles &&
user.roles.map(role => (
<Tag color="purple" className="mb-xs">
<Tag key={role.id} color="purple" className="mb-xs">
{role.name}
</Tag>
))}