Workplace.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <page-view :avatar="avatar" :title="false">
  3. <div slot="headerContent">
  4. <div class="title">{{ timeFix }},{{ user.name }}<span class="welcome-text">,{{ welcome }}</span></div>
  5. <div>前端工程师 | 蚂蚁金服 - 某某某事业群 - VUE平台</div>
  6. </div>
  7. <div slot="extra">
  8. <a-row class="more-info">
  9. <a-col :span="8">
  10. <head-info title="项目数" content="56" :center="false" :bordered="false"/>
  11. </a-col>
  12. <a-col :span="8">
  13. <head-info title="团队排名" content="8/24" :center="false" :bordered="false"/>
  14. </a-col>
  15. <a-col :span="8">
  16. <head-info title="项目访问" content="2,223" :center="false" />
  17. </a-col>
  18. </a-row>
  19. </div>
  20. <div>
  21. <a-row :gutter="24">
  22. <a-col :xl="16" :lg="24" :md="24" :sm="24" :xs="24">
  23. <a-card
  24. class="project-list"
  25. :loading="loading"
  26. style="margin-bottom: 24px;"
  27. :bordered="false"
  28. title="进行中的项目"
  29. :body-style="{ padding: 0 }">
  30. <a slot="extra">全部项目</a>
  31. <div>
  32. <a-card-grid class="project-card-grid" :key="i" v-for="(item, i) in projects">
  33. <a-card :bordered="false" :body-style="{ padding: 0 }">
  34. <a-card-meta>
  35. <div slot="title" class="card-title">
  36. <a-avatar size="small" :src="item.cover"/>
  37. <a>{{ item.title }}</a>
  38. </div>
  39. <div slot="description" class="card-description">
  40. {{ item.description }}
  41. </div>
  42. </a-card-meta>
  43. <div class="project-item">
  44. <a href="/#/">科学搬砖组</a>
  45. <span class="datetime">9小时前</span>
  46. </div>
  47. </a-card>
  48. </a-card-grid>
  49. </div>
  50. </a-card>
  51. <a-card :loading="loading" title="动态" :bordered="false">
  52. <a-list>
  53. <a-list-item :key="index" v-for="(item, index) in activities">
  54. <a-list-item-meta>
  55. <a-avatar slot="avatar" :src="item.user.avatar" />
  56. <div slot="title">
  57. <span>{{ item.user.nickname }}</span>&nbsp;
  58. 在&nbsp;<a href="#">{{ item.project.name }}</a>&nbsp;
  59. <span>{{ item.project.action }}</span>&nbsp;
  60. <a href="#">{{ item.project.event }}</a>
  61. </div>
  62. <div slot="description">{{ item.time }}</div>
  63. </a-list-item-meta>
  64. </a-list-item>
  65. </a-list>
  66. </a-card>
  67. </a-col>
  68. <a-col
  69. style="padding: 0 12px"
  70. :xl="8"
  71. :lg="24"
  72. :md="24"
  73. :sm="24"
  74. :xs="24">
  75. <a-card title="快速开始 / 便捷导航" style="margin-bottom: 24px" :bordered="false" :body-style="{padding: 0}">
  76. <div class="item-group">
  77. <a>操作一</a>
  78. <a>操作二</a>
  79. <a>操作三</a>
  80. <a>操作四</a>
  81. <a>操作五</a>
  82. <a>操作六</a>
  83. <a-button size="small" type="primary" ghost icon="plus">添加</a-button>
  84. </div>
  85. </a-card>
  86. <a-card title="XX 指数" style="margin-bottom: 24px" :loading="radarLoading" :bordered="false" :body-style="{ padding: 0 }">
  87. <div style="min-height: 400px;">
  88. <!-- :scale="scale" :axis1Opts="axis1Opts" :axis2Opts="axis2Opts" -->
  89. <radar :data="radarData" />
  90. </div>
  91. </a-card>
  92. <a-card :loading="loading" title="团队" :bordered="false">
  93. <div class="members">
  94. <a-row>
  95. <a-col :span="12" v-for="(item, index) in teams" :key="index">
  96. <a>
  97. <a-avatar size="small" :src="item.avatar" />
  98. <span class="member">{{ item.name }}</span>
  99. </a>
  100. </a-col>
  101. </a-row>
  102. </div>
  103. </a-card>
  104. </a-col>
  105. </a-row>
  106. </div>
  107. </page-view>
  108. </template>
  109. <script>
  110. import { timeFix } from '@/utils/util'
  111. import { mapState } from 'vuex'
  112. import { PageView } from '@/layouts'
  113. import HeadInfo from '@/components/tools/HeadInfo'
  114. import { Radar } from '@/components'
  115. import { getRoleList, getServiceList } from '@/api/manage'
  116. const DataSet = require('@antv/data-set')
  117. export default {
  118. name: 'Workplace',
  119. components: {
  120. PageView,
  121. HeadInfo,
  122. Radar
  123. },
  124. data () {
  125. return {
  126. timeFix: timeFix(),
  127. avatar: '',
  128. user: {},
  129. projects: [],
  130. loading: true,
  131. radarLoading: true,
  132. activities: [],
  133. teams: [],
  134. // data
  135. axis1Opts: {
  136. dataKey: 'item',
  137. line: null,
  138. tickLine: null,
  139. grid: {
  140. lineStyle: {
  141. lineDash: null
  142. },
  143. hideFirstLine: false
  144. }
  145. },
  146. axis2Opts: {
  147. dataKey: 'score',
  148. line: null,
  149. tickLine: null,
  150. grid: {
  151. type: 'polygon',
  152. lineStyle: {
  153. lineDash: null
  154. }
  155. }
  156. },
  157. scale: [{
  158. dataKey: 'score',
  159. min: 0,
  160. max: 80
  161. }],
  162. axisData: [
  163. { item: '引用', a: 70, b: 30, c: 40 },
  164. { item: '口碑', a: 60, b: 70, c: 40 },
  165. { item: '产量', a: 50, b: 60, c: 40 },
  166. { item: '贡献', a: 40, b: 50, c: 40 },
  167. { item: '热度', a: 60, b: 70, c: 40 },
  168. { item: '引用', a: 70, b: 50, c: 40 }
  169. ],
  170. radarData: []
  171. }
  172. },
  173. computed: {
  174. ...mapState({
  175. nickname: (state) => state.user.nickname,
  176. welcome: (state) => state.user.welcome
  177. }),
  178. userInfo () {
  179. return this.$store.getters.userInfo
  180. }
  181. },
  182. created () {
  183. this.user = this.userInfo
  184. this.avatar = this.userInfo.avatar
  185. getRoleList().then(res => {
  186. // console.log('workplace -> call getRoleList()', res)
  187. })
  188. getServiceList().then(res => {
  189. // console.log('workplace -> call getServiceList()', res)
  190. })
  191. },
  192. mounted () {
  193. this.getProjects()
  194. this.getActivity()
  195. this.getTeams()
  196. this.initRadar()
  197. },
  198. methods: {
  199. getProjects () {
  200. this.$http.get('/list/search/projects')
  201. .then(res => {
  202. this.projects = res.result && res.result.data
  203. this.loading = false
  204. })
  205. },
  206. getActivity () {
  207. this.$http.get('/workplace/activity')
  208. .then(res => {
  209. this.activities = res.result
  210. })
  211. },
  212. getTeams () {
  213. this.$http.get('/workplace/teams')
  214. .then(res => {
  215. this.teams = res.result
  216. })
  217. },
  218. initRadar () {
  219. this.radarLoading = true
  220. this.$http.get('/workplace/radar')
  221. .then(res => {
  222. const dv = new DataSet.View().source(res.result)
  223. dv.transform({
  224. type: 'fold',
  225. fields: ['个人', '团队', '部门'],
  226. key: 'user',
  227. value: 'score'
  228. })
  229. this.radarData = dv.rows
  230. this.radarLoading = false
  231. })
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="less" scoped>
  237. .project-list {
  238. .card-title {
  239. font-size: 0;
  240. a {
  241. color: rgba(0, 0, 0, 0.85);
  242. margin-left: 12px;
  243. line-height: 24px;
  244. height: 24px;
  245. display: inline-block;
  246. vertical-align: top;
  247. font-size: 14px;
  248. &:hover {
  249. color: #1890ff;
  250. }
  251. }
  252. }
  253. .card-description {
  254. color: rgba(0, 0, 0, 0.45);
  255. height: 44px;
  256. line-height: 22px;
  257. overflow: hidden;
  258. }
  259. .project-item {
  260. display: flex;
  261. margin-top: 8px;
  262. overflow: hidden;
  263. font-size: 12px;
  264. height: 20px;
  265. line-height: 20px;
  266. a {
  267. color: rgba(0, 0, 0, 0.45);
  268. display: inline-block;
  269. flex: 1 1 0;
  270. &:hover {
  271. color: #1890ff;
  272. }
  273. }
  274. .datetime {
  275. color: rgba(0, 0, 0, 0.25);
  276. flex: 0 0 auto;
  277. float: right;
  278. }
  279. }
  280. .ant-card-meta-description {
  281. color: rgba(0, 0, 0, 0.45);
  282. height: 44px;
  283. line-height: 22px;
  284. overflow: hidden;
  285. }
  286. }
  287. .item-group {
  288. padding: 20px 0 8px 24px;
  289. font-size: 0;
  290. a {
  291. color: rgba(0, 0, 0, 0.65);
  292. display: inline-block;
  293. font-size: 14px;
  294. margin-bottom: 13px;
  295. width: 25%;
  296. }
  297. }
  298. .members {
  299. a {
  300. display: block;
  301. margin: 12px 0;
  302. line-height: 24px;
  303. height: 24px;
  304. .member {
  305. font-size: 14px;
  306. color: rgba(0, 0, 0, .65);
  307. line-height: 24px;
  308. max-width: 100px;
  309. vertical-align: top;
  310. margin-left: 12px;
  311. transition: all 0.3s;
  312. display: inline-block;
  313. }
  314. &:hover {
  315. span {
  316. color: #1890ff;
  317. }
  318. }
  319. }
  320. }
  321. .mobile {
  322. .project-list {
  323. .project-card-grid {
  324. width: 100%;
  325. }
  326. }
  327. .more-info {
  328. border: 0;
  329. padding-top: 16px;
  330. margin: 16px 0 16px;
  331. }
  332. .headerContent .title .welcome-text {
  333. display: none;
  334. }
  335. }
  336. </style>