新增AvatarList组件

This commit is contained in:
chenghx 2018-08-06 16:30:38 +08:00
parent 7befb78ba5
commit 9f244f3719
5 changed files with 130 additions and 8 deletions

View File

@ -0,0 +1,23 @@
<template>
<div>
<a-card :bordered="false">
<a-tooltip slot="title" title="test" >
<a-avatar src="https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png" />
</a-tooltip>
</a-card>
</div>
</template>
<script>
import ACard from 'vue-antd-ui/es/card/Card'
import ATooltip from 'vue-antd-ui/es/tooltip/Tooltip'
import AAvatar from 'vue-antd-ui/es/avatar/Avatar'
export default {
name: 'BasicDetail',
components: {AAvatar, ATooltip, ACard}
}
</script>
<style scoped>
</style>

View File

@ -21,6 +21,11 @@
</a-tooltip> </a-tooltip>
<a-dropdown class="tool"> <a-dropdown class="tool">
<a-icon type="ellipsis" /> <a-icon type="ellipsis" />
<a-menu slot="overlay">
<a-menu-item>1 item</a-menu-item>
<a-menu-item>2 item</a-menu-item>
<a-menu-item>3 item</a-menu-item>
</a-menu>
</a-dropdown> </a-dropdown>
</ul> </ul>
<div class="content"> <div class="content">
@ -49,9 +54,13 @@ import AAvatar from 'vue-antd-ui/es/avatar/Avatar'
import ATooltip from 'vue-antd-ui/es/tooltip/Tooltip' import ATooltip from 'vue-antd-ui/es/tooltip/Tooltip'
import AIcon from 'vue-antd-ui/es/icon/icon' import AIcon from 'vue-antd-ui/es/icon/icon'
import ADropdown from 'vue-antd-ui/es/dropdown' import ADropdown from 'vue-antd-ui/es/dropdown'
import AMenu from 'vue-antd-ui/es/menu/index'
const AMenuItem = AMenu.Item
export default { export default {
name: 'ApplicationList', name: 'ApplicationList',
components: {ADropdown, AIcon, ATooltip, AAvatar, ACardMeta, AListItem, AList, SearchForm, ACard} components: {AMenuItem, AMenu, ADropdown, AIcon, ATooltip, AAvatar, ACardMeta, AListItem, AList, SearchForm, ACard}
} }
</script> </script>
@ -99,16 +108,22 @@ export default {
list-style: none; list-style: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
height: 38px; height: 47px;
.tool{ .tool{
width: 25%; width: 25%;
float: left; float: left;
text-align: center; text-align: center;
margin: 12px 0; margin: 12px 0;
color: rgba(0,0,0,.45); color: rgba(0,0,0,.45);
cursor: pointer;
font-size: 16px;
line-height: 22px;
&:hover{
color: #1890ff;
} }
.tool:not(:last-child) { &:not(:last-child) {
border-right: 1px solid #e8e8e8; border-right: 1px solid #e8e8e8;
} }
} }
}
</style> </style>

View File

@ -14,7 +14,11 @@
</a-card-meta> </a-card-meta>
<div class="content"> <div class="content">
<span>4小时前</span> <span>4小时前</span>
<a-avatar size="small" src="https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png" /> <avatar-list>
<avatar-list-item size="small" tips="曲丽丽" src="https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png" />
<avatar-list-item size="small" tips="周星星" src="https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png" />
<avatar-list-item size="small" tips="董娜娜" src="https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png" />
</avatar-list>
</div> </div>
</a-card> </a-card>
</a-list-item> </a-list-item>
@ -29,9 +33,14 @@ import AList from 'vue-antd-ui/es/list'
import AListItem from 'vue-antd-ui/es/list/Item' import AListItem from 'vue-antd-ui/es/list/Item'
import ACardMeta from 'vue-antd-ui/es/card/Meta' import ACardMeta from 'vue-antd-ui/es/card/Meta'
import AAvatar from 'vue-antd-ui/es/avatar/Avatar' import AAvatar from 'vue-antd-ui/es/avatar/Avatar'
import AvatarList from '../../tool/AvatarList'
import ATooltip from 'vue-antd-ui/es/tooltip/Tooltip'
const AvatarListItem = AvatarList.Item
export default { export default {
name: 'ProjectList', name: 'ProjectList',
components: {AAvatar, ACardMeta, AListItem, AList, SearchForm, ACard} components: {ATooltip, AvatarListItem, AvatarList, AAvatar, ACardMeta, AListItem, AList, SearchForm, ACard}
} }
</script> </script>

View File

@ -0,0 +1,74 @@
<template>
<div class="avatar-list">
<ul>
<slot>
</slot>
</ul>
</div>
</template>
<script>
import AAvatar from 'vue-antd-ui/es/avatar/Avatar'
import ATooltip from 'vue-antd-ui/es/tooltip/Tooltip'
const Item = {
name: 'AvatarListItem',
props: {
size: {
type: String,
required: false,
default: 'small'
},
src: {
type: String,
required: true
},
tips: {
type: String,
required: false
}
},
methods: {
renderAvatar (h, size, src) {
return h(AAvatar, {props: {size: size, src: src}}, [])
}
},
render (h) {
const avatar = this.renderAvatar(h, this.$props.size, this.$props.src)
return h(
'li',
{class: 'avatar-item'},
[!this.$props.tips ? h(ATooltip, {props: {title: this.$props.tips}}, [avatar]) : avatar]
)
}
}
export default {
name: 'AvatarList',
components: {ATooltip},
Item: Item
}
</script>
<style lang="less">
.avatar-list {
display: inline-block;
ul {
display: inline-block;
margin-left: 8px;
font-size: 0;
.avatar-item {
display: inline-block;
font-size: 14px;
margin-left: -8px;
width: 20px;
height: 20px;
:global {
.ant-avatar {
border: 1px solid #fff;
width: 20px;
height: 20px;
}
}
}
}
}
</style>

View File

@ -22,6 +22,7 @@ import ApplicationList from '@/components/list/search/ApplicationList'
import ProjectList from '@/components/list/search/ProjectList' import ProjectList from '@/components/list/search/ProjectList'
import WorkPlace from '@/components/dashboard/WorkPlace' import WorkPlace from '@/components/dashboard/WorkPlace'
import Login from '@/components/login/Login' import Login from '@/components/login/Login'
import BasicDetail from '@/components/detail/BasicDetail'
Vue.use(Router) Vue.use(Router)
@ -149,7 +150,7 @@ export default new Router({
path: '/detail/basic', path: '/detail/basic',
name: '基础详情页', name: '基础详情页',
icon: 'none', icon: 'none',
component: NotFound component: BasicDetail
}, },
{ {
path: '/detail/advanced', path: '/detail/advanced',