Dashboard.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. <img src="../assets/img/img.jpg" class="user-avator" alt />
  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>2019-11-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. <i class="el-icon-user-solid grid-con-icon"></i>
  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. <i class="el-icon-message-solid grid-con-icon"></i>
  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. <i class="el-icon-s-goods grid-con-icon"></i>
  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" type="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 class="todo-item" :class="{
  87. 'todo-item-del': scope.row.status,
  88. }">{{ scope.row.title }}</div>
  89. </template>
  90. </el-table-column>
  91. <el-table-column width="60">
  92. <template>
  93. <i class="el-icon-edit"></i>
  94. <i class="el-icon-delete"></i>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. </el-card>
  99. </el-col>
  100. </el-row>
  101. <el-row :gutter="20">
  102. <el-col :span="12">
  103. <el-card shadow="hover">
  104. <schart ref="bar" class="schart" canvasId="bar" :options="options"></schart>
  105. </el-card>
  106. </el-col>
  107. <el-col :span="12">
  108. <el-card shadow="hover">
  109. <schart ref="line" class="schart" canvasId="line" :options="options2"></schart>
  110. </el-card>
  111. </el-col>
  112. </el-row>
  113. </div>
  114. </template>
  115. <script>
  116. import Schart from "vue-schart";
  117. import { reactive } from "vue";
  118. export default {
  119. name: "dashboard",
  120. components: { Schart },
  121. setup() {
  122. const name = localStorage.getItem("ms_username");
  123. const role = name === "admin" ? "超级管理员" : "普通用户";
  124. const data = reactive([
  125. {
  126. name: "2018/09/04",
  127. value: 1083,
  128. },
  129. {
  130. name: "2018/09/05",
  131. value: 941,
  132. },
  133. {
  134. name: "2018/09/06",
  135. value: 1139,
  136. },
  137. {
  138. name: "2018/09/07",
  139. value: 816,
  140. },
  141. {
  142. name: "2018/09/08",
  143. value: 327,
  144. },
  145. {
  146. name: "2018/09/09",
  147. value: 228,
  148. },
  149. {
  150. name: "2018/09/10",
  151. value: 1065,
  152. },
  153. ]);
  154. const options = {
  155. type: "bar",
  156. title: {
  157. text: "最近一周各品类销售图",
  158. },
  159. xRorate: 25,
  160. labels: ["周一", "周二", "周三", "周四", "周五"],
  161. datasets: [
  162. {
  163. label: "家电",
  164. data: [234, 278, 270, 190, 230],
  165. },
  166. {
  167. label: "百货",
  168. data: [164, 178, 190, 135, 160],
  169. },
  170. {
  171. label: "食品",
  172. data: [144, 198, 150, 235, 120],
  173. },
  174. ],
  175. };
  176. const options2 = {
  177. type: "line",
  178. title: {
  179. text: "最近几个月各品类销售趋势图",
  180. },
  181. labels: ["6月", "7月", "8月", "9月", "10月"],
  182. datasets: [
  183. {
  184. label: "家电",
  185. data: [234, 278, 270, 190, 230],
  186. },
  187. {
  188. label: "百货",
  189. data: [164, 178, 150, 135, 160],
  190. },
  191. {
  192. label: "食品",
  193. data: [74, 118, 200, 235, 90],
  194. },
  195. ],
  196. };
  197. const todoList = reactive([
  198. {
  199. title: "今天要修复100个bug",
  200. status: false,
  201. },
  202. {
  203. title: "今天要修复100个bug",
  204. status: false,
  205. },
  206. {
  207. title: "今天要写100行代码加几个bug吧",
  208. status: false,
  209. },
  210. {
  211. title: "今天要修复100个bug",
  212. status: false,
  213. },
  214. {
  215. title: "今天要修复100个bug",
  216. status: true,
  217. },
  218. {
  219. title: "今天要写100行代码加几个bug吧",
  220. status: true,
  221. },
  222. ]);
  223. return {
  224. name,
  225. data,
  226. options,
  227. options2,
  228. todoList,
  229. role,
  230. };
  231. },
  232. };
  233. </script>
  234. <style scoped>
  235. .el-row {
  236. margin-bottom: 20px;
  237. }
  238. .grid-content {
  239. display: flex;
  240. align-items: center;
  241. height: 100px;
  242. }
  243. .grid-cont-right {
  244. flex: 1;
  245. text-align: center;
  246. font-size: 14px;
  247. color: #999;
  248. }
  249. .grid-num {
  250. font-size: 30px;
  251. font-weight: bold;
  252. }
  253. .grid-con-icon {
  254. font-size: 50px;
  255. width: 100px;
  256. height: 100px;
  257. text-align: center;
  258. line-height: 100px;
  259. color: #fff;
  260. }
  261. .grid-con-1 .grid-con-icon {
  262. background: rgb(45, 140, 240);
  263. }
  264. .grid-con-1 .grid-num {
  265. color: rgb(45, 140, 240);
  266. }
  267. .grid-con-2 .grid-con-icon {
  268. background: rgb(100, 213, 114);
  269. }
  270. .grid-con-2 .grid-num {
  271. color: rgb(45, 140, 240);
  272. }
  273. .grid-con-3 .grid-con-icon {
  274. background: rgb(242, 94, 67);
  275. }
  276. .grid-con-3 .grid-num {
  277. color: rgb(242, 94, 67);
  278. }
  279. .user-info {
  280. display: flex;
  281. align-items: center;
  282. padding-bottom: 20px;
  283. border-bottom: 2px solid #ccc;
  284. margin-bottom: 20px;
  285. }
  286. .user-avator {
  287. width: 120px;
  288. height: 120px;
  289. border-radius: 50%;
  290. }
  291. .user-info-cont {
  292. padding-left: 50px;
  293. flex: 1;
  294. font-size: 14px;
  295. color: #999;
  296. }
  297. .user-info-cont div:first-child {
  298. font-size: 30px;
  299. color: #222;
  300. }
  301. .user-info-list {
  302. font-size: 14px;
  303. color: #999;
  304. line-height: 25px;
  305. }
  306. .user-info-list span {
  307. margin-left: 70px;
  308. }
  309. .mgb20 {
  310. margin-bottom: 20px;
  311. }
  312. .todo-item {
  313. font-size: 14px;
  314. }
  315. .todo-item-del {
  316. text-decoration: line-through;
  317. color: #999;
  318. }
  319. .schart {
  320. width: 100%;
  321. height: 300px;
  322. }
  323. </style>