Dashboard.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <div>
  3. <el-row :gutter="20">
  4. <el-col :span="8">
  5. <el-card shadow="hover" class="mgb20" style="height: 252px">
  6. <div class="user-info">
  7. <el-avatar :size="120" :src="imgurl" />
  8. <div class="user-info-cont">
  9. <div class="user-info-name">{{ name }}</div>
  10. <div>{{ role }}</div>
  11. </div>
  12. </div>
  13. <div class="user-info-list">
  14. 上次登录时间:
  15. <span>2022-10-01</span>
  16. </div>
  17. <div class="user-info-list">
  18. 上次登录地点:
  19. <span>东莞</span>
  20. </div>
  21. </el-card>
  22. <el-card shadow="hover" style="height: 252px">
  23. <template #header>
  24. <div class="clearfix">
  25. <span>语言详情</span>
  26. </div>
  27. </template>
  28. Vue
  29. <el-progress :percentage="71.3" color="#42b983"></el-progress>JavaScript
  30. <el-progress :percentage="24.1" color="#f1e05a"></el-progress>CSS
  31. <el-progress :percentage="13.7"></el-progress>HTML
  32. <el-progress :percentage="5.9" color="#f56c6c"></el-progress>
  33. </el-card>
  34. </el-col>
  35. <el-col :span="16">
  36. <el-row :gutter="20" class="mgb20">
  37. <el-col :span="8">
  38. <el-card shadow="hover" :body-style="{ padding: '0px' }">
  39. <div class="grid-content grid-con-1">
  40. <el-icon class="grid-con-icon"><User /></el-icon>
  41. <div class="grid-cont-right">
  42. <div class="grid-num">1234</div>
  43. <div>用户访问量</div>
  44. </div>
  45. </div>
  46. </el-card>
  47. </el-col>
  48. <el-col :span="8">
  49. <el-card shadow="hover" :body-style="{ padding: '0px' }">
  50. <div class="grid-content grid-con-2">
  51. <el-icon class="grid-con-icon"><ChatDotRound /></el-icon>
  52. <div class="grid-cont-right">
  53. <div class="grid-num">321</div>
  54. <div>系统消息</div>
  55. </div>
  56. </div>
  57. </el-card>
  58. </el-col>
  59. <el-col :span="8">
  60. <el-card shadow="hover" :body-style="{ padding: '0px' }">
  61. <div class="grid-content grid-con-3">
  62. <el-icon class="grid-con-icon"><Goods /></el-icon>
  63. <div class="grid-cont-right">
  64. <div class="grid-num">5000</div>
  65. <div>商品数量</div>
  66. </div>
  67. </div>
  68. </el-card>
  69. </el-col>
  70. </el-row>
  71. <el-card shadow="hover" style="height: 403px">
  72. <template #header>
  73. <div class="clearfix">
  74. <span>待办事项</span>
  75. <el-button style="float: right; padding: 3px 0" text>添加</el-button>
  76. </div>
  77. </template>
  78. <el-table :show-header="false" :data="todoList" style="width: 100%">
  79. <el-table-column width="40">
  80. <template #default="scope">
  81. <el-checkbox v-model="scope.row.status"></el-checkbox>
  82. </template>
  83. </el-table-column>
  84. <el-table-column>
  85. <template #default="scope">
  86. <div
  87. class="todo-item"
  88. :class="{
  89. 'todo-item-del': scope.row.status
  90. }"
  91. >
  92. {{ scope.row.title }}
  93. </div>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. </el-card>
  98. </el-col>
  99. </el-row>
  100. <el-row :gutter="20">
  101. <el-col :span="12">
  102. <el-card shadow="hover">
  103. <schart ref="bar" class="schart" canvasId="bar" :options="options"></schart>
  104. </el-card>
  105. </el-col>
  106. <el-col :span="12">
  107. <el-card shadow="hover">
  108. <schart ref="line" class="schart" canvasId="line" :options="options2"></schart>
  109. </el-card>
  110. </el-col>
  111. </el-row>
  112. </div>
  113. </template>
  114. <script setup lang="ts" name="dashboard">
  115. import Schart from 'vue-schart';
  116. import { reactive } from 'vue';
  117. import imgurl from '../assets/img/img.jpg';
  118. const name = localStorage.getItem('ms_username');
  119. const role: string = name === 'admin' ? '超级管理员' : '普通用户';
  120. const options = {
  121. type: 'bar',
  122. title: {
  123. text: '最近一周各品类销售图'
  124. },
  125. xRorate: 25,
  126. labels: ['周一', '周二', '周三', '周四', '周五'],
  127. datasets: [
  128. {
  129. label: '家电',
  130. data: [234, 278, 270, 190, 230]
  131. },
  132. {
  133. label: '百货',
  134. data: [164, 178, 190, 135, 160]
  135. },
  136. {
  137. label: '食品',
  138. data: [144, 198, 150, 235, 120]
  139. }
  140. ]
  141. };
  142. const options2 = {
  143. type: 'line',
  144. title: {
  145. text: '最近几个月各品类销售趋势图'
  146. },
  147. labels: ['6月', '7月', '8月', '9月', '10月'],
  148. datasets: [
  149. {
  150. label: '家电',
  151. data: [234, 278, 270, 190, 230]
  152. },
  153. {
  154. label: '百货',
  155. data: [164, 178, 150, 135, 160]
  156. },
  157. {
  158. label: '食品',
  159. data: [74, 118, 200, 235, 90]
  160. }
  161. ]
  162. };
  163. const todoList = reactive([
  164. {
  165. title: '今天要修复100个bug',
  166. status: false
  167. },
  168. {
  169. title: '今天要修复100个bug',
  170. status: false
  171. },
  172. {
  173. title: '今天要写100行代码加几个bug吧',
  174. status: false
  175. },
  176. {
  177. title: '今天要修复100个bug',
  178. status: false
  179. },
  180. {
  181. title: '今天要修复100个bug',
  182. status: true
  183. },
  184. {
  185. title: '今天要写100行代码加几个bug吧',
  186. status: true
  187. }
  188. ]);
  189. </script>
  190. <style scoped>
  191. .el-row {
  192. margin-bottom: 20px;
  193. }
  194. .grid-content {
  195. display: flex;
  196. align-items: center;
  197. height: 100px;
  198. }
  199. .grid-cont-right {
  200. flex: 1;
  201. text-align: center;
  202. font-size: 14px;
  203. color: #999;
  204. }
  205. .grid-num {
  206. font-size: 30px;
  207. font-weight: bold;
  208. }
  209. .grid-con-icon {
  210. font-size: 50px;
  211. width: 100px;
  212. height: 100px;
  213. text-align: center;
  214. line-height: 100px;
  215. color: #fff;
  216. }
  217. .grid-con-1 .grid-con-icon {
  218. background: rgb(45, 140, 240);
  219. }
  220. .grid-con-1 .grid-num {
  221. color: rgb(45, 140, 240);
  222. }
  223. .grid-con-2 .grid-con-icon {
  224. background: rgb(100, 213, 114);
  225. }
  226. .grid-con-2 .grid-num {
  227. color: rgb(100, 213, 114);
  228. }
  229. .grid-con-3 .grid-con-icon {
  230. background: rgb(242, 94, 67);
  231. }
  232. .grid-con-3 .grid-num {
  233. color: rgb(242, 94, 67);
  234. }
  235. .user-info {
  236. display: flex;
  237. align-items: center;
  238. padding-bottom: 20px;
  239. border-bottom: 2px solid #ccc;
  240. margin-bottom: 20px;
  241. }
  242. .user-info-cont {
  243. padding-left: 50px;
  244. flex: 1;
  245. font-size: 14px;
  246. color: #999;
  247. }
  248. .user-info-cont div:first-child {
  249. font-size: 30px;
  250. color: #222;
  251. }
  252. .user-info-list {
  253. font-size: 14px;
  254. color: #999;
  255. line-height: 25px;
  256. }
  257. .user-info-list span {
  258. margin-left: 70px;
  259. }
  260. .mgb20 {
  261. margin-bottom: 20px;
  262. }
  263. .todo-item {
  264. font-size: 14px;
  265. }
  266. .todo-item-del {
  267. text-decoration: line-through;
  268. color: #999;
  269. }
  270. .schart {
  271. width: 100%;
  272. height: 300px;
  273. }
  274. </style>