优化首页界面

This commit is contained in:
季圣华 2021-06-23 23:01:13 +08:00
parent 14427ddc53
commit 4ba05f4892
5 changed files with 129 additions and 526 deletions

View File

@ -1,9 +0,0 @@
export {
default as HomeOutline
} from '@ant-design/icons/lib/outline/HomeOutline'
export {
default as SlidersOutline
} from '@ant-design/icons/lib/outline/SlidersOutline'
export {
default as TransactionOutline
} from '@ant-design/icons/lib/outline/TransactionOutline'

View File

@ -1,139 +1,126 @@
路由/菜单说明 路由/菜单说明
==== ====
配置文件路径 配置文件路径
---- ----
`@/config/router.config.js` `@/config/router.config.js`
格式和说明 格式和说明
---- ----
```javascript ```javascript
/** /**
* 路由配置说明: * 路由配置说明:
* 建议sider menu 请不要超过三级菜单,若超过三级菜单,则应该设计为顶部主菜单 配合左侧次级菜单 * 建议sider menu 请不要超过三级菜单,若超过三级菜单,则应该设计为顶部主菜单 配合左侧次级菜单
* *
**/ **/
{ {
redirect: noredirect, redirect: noredirect,
name: 'router-name', name: 'router-name',
hidden: true, hidden: true,
meta: { meta: {
title: 'title', title: 'title',
icon: 'a-icon', icon: 'a-icon',
keepAlive: true, keepAlive: true,
hiddenHeaderContent: true, hiddenHeaderContent: true,
} }
} }
``` ```
`{ Route }` 对象 `{ Route }` 对象
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
| -------- | ----------------------------------------- | ------- | ------ | | -------- | ----------------------------------------- | ------- | ------ |
| hidden | 控制路由是否显示在 sidebar | boolean | falase | | hidden | 控制路由是否显示在 sidebar | boolean | falase |
| redirect | 重定向地址, 访问这个路由时,自定进行重定向 | string | - | | redirect | 重定向地址, 访问这个路由时,自定进行重定向 | string | - |
| name | 路由名称, 建议设置,且不能重名 | string | - | | name | 路由名称, 建议设置,且不能重名 | string | - |
| meta | 路由元信息(路由附带扩展信息) | object | {} | | meta | 路由元信息(路由附带扩展信息) | object | {} |
`{ Meta }` 路由元信息对象 `{ Meta }` 路由元信息对象
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
| ------------------- | ------------------------------------------------------------ | ------- | ------ | | ------------------- | ------------------------------------------------------------ | ------- | ------ |
| title | 路由标题, 用于显示面包屑, 页面标题 *推荐设置 | string | - | | title | 路由标题, 用于显示面包屑, 页面标题 *推荐设置 | string | - |
| icon | 路由在 menu 上显示的图标 | string | - | | icon | 路由在 menu 上显示的图标 | string | - |
| keepAlive | 缓存该路由 | boolean | false | | keepAlive | 缓存该路由 | boolean | false |
| hiddenHeaderContent | *特殊 隐藏 [PageHeader](https://github.com/sendya/ant-design-pro-vue/blob/master/src/components/layout/PageHeader.vue#L14) 组件中的页面带的 面包屑和页面标题栏 | boolean | false | | hiddenHeaderContent | *特殊 隐藏 [PageHeader](https://github.com/sendya/ant-design-pro-vue/blob/master/src/components/layout/PageHeader.vue#L14) 组件中的页面带的 面包屑和页面标题栏 | boolean | false |
| permission | 与项目提供的权限拦截匹配的权限,如果不匹配,则会被禁止访问该路由页面 | array | [] | | permission | 与项目提供的权限拦截匹配的权限,如果不匹配,则会被禁止访问该路由页面 | array | [] |
路由例子 路由例子
---- ----
```ecmascript 6 ```ecmascript 6
const asyncRouterMap = [ const asyncRouterMap = [
{ {
path: '/', path: '/',
name: 'index', name: 'index',
component: BasicLayout, component: BasicLayout,
meta: { title: '首页' }, meta: { title: '首页' },
redirect: '/dashboard/analysis', redirect: '/dashboard/analysis',
children: [ children: [
{ {
path: '/dashboard', path: '/dashboard',
component: Layout, component: Layout,
name: 'dashboard', name: 'dashboard',
redirect: '/dashboard/workplace', redirect: '/dashboard/workplace',
meta: {title: '仪表盘', icon: 'dashboard', permission: ['dashboard']}, meta: {title: '仪表盘', icon: 'dashboard', permission: ['dashboard']},
children: [ children: [
{ {
path: '/dashboard/analysis', path: '/dashboard/analysis',
name: 'Analysis', name: 'Analysis',
component: () => import('@/views/dashboard/Analysis'), component: () => import('@/views/dashboard/Analysis'),
meta: {title: '分析页', permission: ['dashboard']} meta: {title: '分析页', permission: ['dashboard']}
}, }
{ ]
path: '/dashboard/monitor', },
name: 'Monitor',
hidden: true, // result
component: () => import('@/views/dashboard/Monitor'), {
meta: {title: '监控页', permission: ['dashboard']} path: '/result',
}, name: 'result',
{ component: PageView,
path: '/dashboard/workplace', redirect: '/result/success',
name: 'Workplace', meta: { title: '结果页', icon: 'check-circle-o', permission: [ 'result' ] },
component: () => import('@/views/dashboard/Workplace'), children: [
meta: {title: '工作台', permission: ['dashboard']} {
} path: '/result/success',
] name: 'ResultSuccess',
}, component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'),
// 该页面隐藏面包屑和页面标题栏
// result meta: { title: '成功', hiddenHeaderContent: true, permission: [ 'result' ] }
{ },
path: '/result', {
name: 'result', path: '/result/fail',
component: PageView, name: 'ResultFail',
redirect: '/result/success', component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'),
meta: { title: '结果页', icon: 'check-circle-o', permission: [ 'result' ] }, // 该页面隐藏面包屑和页面标题栏
children: [ meta: { title: '失败', hiddenHeaderContent: true, permission: [ 'result' ] }
{ }
path: '/result/success', ]
name: 'ResultSuccess', },
component: () => import(/* webpackChunkName: "result" */ '@/views/result/Success'), ...
// 该页面隐藏面包屑和页面标题栏 ]
meta: { title: '成功', hiddenHeaderContent: true, permission: [ 'result' ] } },
}, ]
{ ```
path: '/result/fail',
name: 'ResultFail', > 1. 请注意 `component: () => import('..') ` 方式引入路由的页面组件为 懒加载模式。具体可以看 [Vue 官方文档](https://router.vuejs.org/zh/guide/advanced/lazy-loading.html)
component: () => import(/* webpackChunkName: "result" */ '@/views/result/Error'), > 2. 增加新的路由应该增加在 '/' (index) 路由的 `children`
// 该页面隐藏面包屑和页面标题栏 > 3. `permission` 可以进行自定义修改,只需要对这个模块进行自定义修改即可 [src/store/modules/permission.js#L10](https://github.com/sendya/ant-design-pro-vue/blob/master/src/store/modules/permission.js#L10)
meta: { title: '失败', hiddenHeaderContent: true, permission: [ 'result' ] }
}
]
}, 附权限路由结构:
...
]
},
]
```
> 1. 请注意 `component: () => import('..') ` 方式引入路由的页面组件为 懒加载模式。具体可以看 [Vue 官方文档](https://router.vuejs.org/zh/guide/advanced/lazy-loading.html)
> 2. 增加新的路由应该增加在 '/' (index) 路由的 `children`
> 3. `permission` 可以进行自定义修改,只需要对这个模块进行自定义修改即可 [src/store/modules/permission.js#L10](https://github.com/sendya/ant-design-pro-vue/blob/master/src/store/modules/permission.js#L10)
附权限路由结构:
![权限结构](https://static-2.loacg.com/open/static/github/permissions.png) ![权限结构](https://static-2.loacg.com/open/static/github/permissions.png)

View File

@ -18,7 +18,7 @@
</chart-card> </chart-card>
</a-col> </a-col>
<a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }"> <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
<chart-card :loading="loading" title="今日累计进货"> <chart-card :loading="loading" title="今日累计采购">
<a-tooltip title="指标说明" slot="action"> <a-tooltip title="指标说明" slot="action">
<a-icon type="info-circle-o" /> <a-icon type="info-circle-o" />
</a-tooltip> </a-tooltip>
@ -26,7 +26,7 @@
</chart-card> </chart-card>
</a-col> </a-col>
<a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }"> <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
<chart-card :loading="loading" title="本月累计进货"> <chart-card :loading="loading" title="本月累计采购">
<a-tooltip title="指标说明" slot="action"> <a-tooltip title="指标说明" slot="action">
<a-icon type="info-circle-o" /> <a-icon type="info-circle-o" />
</a-tooltip> </a-tooltip>
@ -37,12 +37,12 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :sm="24" :md="12" :xl="12" :style="{ marginBottom: '24px' }"> <a-col :sm="24" :md="12" :xl="12" :style="{ marginBottom: '24px' }">
<a-card :loading="loading" :bordered="false" :body-style="{paddingRight: '5'}"> <a-card :loading="loading" :bordered="false" :body-style="{paddingRight: '5'}">
<bar title="采购统计" :dataSource="buyPriceData"/> <bar title="销售统计" :dataSource="salePriceData"/>
</a-card> </a-card>
</a-col> </a-col>
<a-col :sm="24" :md="12" :xl="12" :style="{ marginBottom: '24px' }"> <a-col :sm="24" :md="12" :xl="12" :style="{ marginBottom: '24px' }">
<a-card :loading="loading" :bordered="false" :body-style="{paddingRight: '5'}"> <a-card :loading="loading" :bordered="false" :body-style="{paddingRight: '5'}">
<bar title="销售统计" :dataSource="salePriceData"/> <bar title="采购统计" :dataSource="buyPriceData"/>
</a-card> </a-card>
</a-col> </a-col>
</a-row> </a-row>

View File

@ -1,15 +0,0 @@
<template>
<div>
Monitor
</div>
</template>
<script>
export default {
name: "Monitor"
}
</script>
<style scoped>
</style>

View File

@ -1,360 +0,0 @@
<template>
<page-layout :avatar="avatar">
<div slot="headerContent">
<div class="title">{{ timeFix }}{{ nickname() }}<span class="welcome-text">{{ welcome() }}</span></div>
<div>前端工程师 | 蚂蚁金服 - 某某某事业群 - VUE平台</div>
</div>
<div slot="extra">
<a-row class="more-info">
<a-col :span="8">
<head-info title="项目数" content="56" :center="false" :bordered="false"/>
</a-col>
<a-col :span="8">
<head-info title="团队排名" content="8/24" :center="false" :bordered="false"/>
</a-col>
<a-col :span="8">
<head-info title="项目访问" content="2,223" :center="false" />
</a-col>
</a-row>
</div>
<div>
<a-row :gutter="24">
<a-col :xl="16" :lg="24" :md="24" :sm="24" :xs="24">
<a-card
class="project-list"
:loading="loading"
style="margin-bottom: 24px;"
:bordered="false"
title="进行中的项目"
:body-style="{ padding: 0 }">
<a slot="extra">全部项目</a>
<div>
<a-card-grid class="project-card-grid" :key="i" v-for="(item, i) in projects">
<a-card :bordered="false" :body-style="{ padding: 0 }">
<a-card-meta>
<div slot="title" class="card-title">
<a-avatar size="small" :src="item.cover"/>
<a>{{ item.title }}</a>
</div>
<div slot="description" class="card-description">
{{ item.description }}
</div>
</a-card-meta>
<div class="project-item">
<a href="/#/">科学搬砖组</a>
<span class="datetime">9小时前</span>
</div>
</a-card>
</a-card-grid>
</div>
</a-card>
<a-card :loading="loading" title="动态" :bordered="false">
<a-list>
<a-list-item :key="index" v-for="(item, index) in activities">
<a-list-item-meta>
<a-avatar slot="avatar" :src="item.user.avatar" />
<div slot="title">
<span>{{ item.user.nickname }}</span>&nbsp;
&nbsp;<a href="#">{{ item.project.name }}</a>&nbsp;
<span>{{ item.project.action }}</span>&nbsp;
<a href="#">{{ item.project.event }}</a>
</div>
<div slot="description">{{ item.time }}</div>
</a-list-item-meta>
</a-list-item>
</a-list>
</a-card>
</a-col>
<a-col
style="padding: 0 12px"
:xl="8"
:lg="24"
:md="24"
:sm="24"
:xs="24">
<a-card title="快速开始 / 便捷导航" style="margin-bottom: 24px" :bordered="false" :body-style="{padding: 0}">
<div class="item-group">
<a>操作一</a>
<a>操作二</a>
<a>操作三</a>
<a>操作四</a>
<a>操作五</a>
<a>操作六</a>
<a-button size="small" type="primary" ghost icon="plus">添加</a-button>
</div>
</a-card>
<a-card title="XX 指数" style="margin-bottom: 24px" :loading="radarLoading" :bordered="false" :body-style="{ padding: 0 }">
<div style="min-height: 400px;">
<!-- :scale="scale" :axis1Opts="axis1Opts" :axis2Opts="axis2Opts" -->
<radar :data="radarData" />
</div>
</a-card>
<a-card :loading="loading" title="团队" :bordered="false">
<div class="members">
<a-row>
<a-col :span="12" v-for="(item, index) in teams" :key="index">
<a>
<a-avatar size="small" :src="item.avatar" />
<span class="member">{{ item.name }}</span>
</a>
</a-col>
</a-row>
</div>
</a-card>
</a-col>
</a-row>
</div>
</page-layout>
</template>
<script>
import { timeFix } from "@/utils/util"
import {mapGetters} from "vuex"
import PageLayout from '@/components/page/PageLayout'
import HeadInfo from '@/components/tools/HeadInfo'
import Radar from '@/components/chart/Radar'
import { getRoleList, getServiceList, getFileAccessHttpUrl } from "@/api/manage"
const DataSet = require('@antv/data-set')
export default {
name: "Workplace",
components: {
PageLayout,
HeadInfo,
Radar
},
data() {
return {
timeFix: timeFix(),
avatar: '',
user: {},
projects: [],
loading: true,
radarLoading: true,
activities: [],
teams: [],
// data
axis1Opts: {
dataKey: 'item',
line: null,
tickLine: null,
grid: {
lineStyle: {
lineDash: null
},
hideFirstLine: false
}
},
axis2Opts: {
dataKey: 'score',
line: null,
tickLine: null,
grid: {
type: 'polygon',
lineStyle: {
lineDash: null
}
}
},
scale: [{
dataKey: 'score',
min: 0,
max: 80
}],
axisData: [
{ item: '引用', a: 70, b: 30, c: 40 },
{ item: '口碑', a: 60, b: 70, c: 40 },
{ item: '产量', a: 50, b: 60, c: 40 },
{ item: '贡献', a: 40, b: 50, c: 40 },
{ item: '热度', a: 60, b: 70, c: 40 },
{ item: '引用', a: 70, b: 50, c: 40 }
],
radarData: []
}
},
computed: {
userInfo() {
return this.$store.getters.userInfo
}
},
created() {
this.user = this.userInfo
this.avatar = getFileAccessHttpUrl(this.userInfo.avatar)
console.log('this.avatar :'+ this.avatar)
getRoleList().then(res => {
console.log('workplace -> call getRoleList()', res)
})
getServiceList().then(res => {
console.log('workplace -> call getServiceList()', res)
})
},
mounted() {
this.getProjects()
this.getActivity()
this.getTeams()
this.initRadar()
},
methods: {
...mapGetters(["nickname", "welcome"]),
getProjects() {
this.$http.get('/api/list/search/projects')
.then(res => {
this.projects = res.result && res.result.data
this.loading = false
})
},
getActivity() {
this.$http.get('/api/workplace/activity')
.then(res => {
this.activities = res.result
})
},
getTeams() {
this.$http.get('/api/workplace/teams')
.then(res => {
this.teams = res.result
})
},
initRadar() {
this.radarLoading = true
this.$http.get('/api/workplace/radar')
.then(res => {
const dv = new DataSet.View().source(res.result)
dv.transform({
type: 'fold',
fields: ['个人', '团队', '部门'],
key: 'user',
value: 'score'
})
this.radarData = dv.rows
this.radarLoading = false
})
}
}
}
</script>
<style lang="less" scoped>
.project-list {
.card-title {
font-size: 0;
a {
color: rgba(0, 0, 0, 0.85);
margin-left: 12px;
line-height: 24px;
height: 24px;
display: inline-block;
vertical-align: top;
font-size: 14px;
&:hover {
color: #1890ff;
}
}
}
.card-description {
color: rgba(0, 0, 0, 0.45);
height: 44px;
line-height: 22px;
overflow: hidden;
}
.project-item {
display: flex;
margin-top: 8px;
overflow: hidden;
font-size: 12px;
height: 20px;
line-height: 20px;
a {
color: rgba(0, 0, 0, 0.45);
display: inline-block;
flex: 1 1 0;
&:hover {
color: #1890ff;
}
}
.datetime {
color: rgba(0, 0, 0, 0.25);
flex: 0 0 auto;
float: right;
}
}
.ant-card-meta-description {
color: rgba(0, 0, 0, 0.45);
height: 44px;
line-height: 22px;
overflow: hidden;
}
}
.item-group {
padding: 20px 0 8px 24px;
font-size: 0;
a {
color: rgba(0, 0, 0, 0.65);
display: inline-block;
font-size: 14px;
margin-bottom: 13px;
width: 25%;
}
}
.members {
a {
display: block;
margin: 12px 0;
line-height: 24px;
height: 24px;
.member {
font-size: 14px;
color: rgba(0, 0, 0, .65);
line-height: 24px;
max-width: 100px;
vertical-align: top;
margin-left: 12px;
transition: all 0.3s;
display: inline-block;
}
&:hover {
span {
color: #1890ff;
}
}
}
}
.mobile {
.project-list {
.project-card-grid {
width: 100%;
}
}
.more-info {
border: 0;
padding-top: 16px;
margin: 16px 0 16px;
}
.headerContent .title .welcome-text {
display: none;
}
}
</style>