Home.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <template>
  2. <div class="home-container" v-loading="loading">
  3. <div class="home-banner-wrap">
  4. <el-carousel height="400px" :interval="10000" arrow="always">
  5. <el-carousel-item v-for="(img,index) in imgList" :key="index">
  6. <img class="banner_back banner_back_1" v-bind:src="img">
  7. <router-link
  8. v-if="user != null && rolesPermissions != null &&( rolesPermissions.isAgency || rolesPermissions.isIndividualUser || rolesPermissions.isSystemAdministrator || rolesPermissions.isEnterpriseUser)"
  9. :to="{ name: 'ProjectCreate'}">
  10. <el-button class="btn-home-apply" type="primary">创建项目</el-button>
  11. </router-link>
  12. </el-carousel-item>
  13. </el-carousel>
  14. </div>
  15. <div class="home-body-wrap">
  16. <div class="title h2">系统统计信息</div>
  17. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  18. <el-col :span="6" type="flex" align="middle" justify="center" >
  19. <el-card class="box-card" shadow="hover" style="margin-right: 40px; background-color: #20A0FF;">
  20. <div slot="header" class="clearfix">
  21. <span style="font-size: 30px;color: white"><i class="el-icon-user"></i></span>
  22. </div>
  23. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  24. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px; color: white;">{{systemStatistics[0].value}}</span>
  25. </el-col>
  26. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px; color: white;"
  27. type="success"
  28. :underline="false">{{systemStatistics[0].name}}</el-link></span>
  29. </el-col>
  30. </el-row>
  31. </el-card>
  32. </el-col>
  33. <el-col :span="6" type="flex" align="middle" justify="center">
  34. <el-card class="box-card" shadow="hover" style="margin-right: 40px;background-color: #13CE66;">
  35. <div slot="header" class="clearfix">
  36. <span style="font-size: 30px;color: white;"><i class="el-icon-setting"></i></span>
  37. </div>
  38. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  39. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px;color: white;">{{systemStatistics[1].value}}</span>
  40. </el-col>
  41. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px;color: white;"
  42. type="success"
  43. :underline="false">{{systemStatistics[1].name}}</el-link></span>
  44. </el-col>
  45. </el-row>
  46. </el-card>
  47. </el-col>
  48. <!--<el-col :span="4">{{project.id}}</el-col>-->
  49. <el-col :span="6" type="flex" align="middle" justify="center">
  50. <el-card class="box-card" shadow="hover" style="margin-right: 40px;background-color: #F7BA2A;">
  51. <div slot="header" class="clearfix">
  52. <span style="font-size: 30px;color: white;"><i class="el-icon-user-solid"></i></span>
  53. </div>
  54. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  55. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px;color: white;">{{systemStatistics[2].value}}</span>
  56. </el-col>
  57. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px;color: white;"
  58. type="success"
  59. :underline="false">{{systemStatistics[2].name}}</el-link></span>
  60. </el-col>
  61. </el-row>
  62. </el-card>
  63. </el-col>
  64. <el-col :span="6" type="flex" align="middle" justify="center">
  65. <el-card class="box-card" shadow="hover" style="margin-right: 40px;background-color: #FF4949;">
  66. <div slot="header" class="clearfix">
  67. <span style="font-size: 30px;color: white;"><i class="el-icon-cpu"></i></span>
  68. </div>
  69. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  70. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px;color: white;">{{systemStatistics[3].value}}</span>
  71. </el-col>
  72. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px;color: white;"
  73. type="success"
  74. :underline="false">{{systemStatistics[3].name}}</el-link></span>
  75. </el-col>
  76. </el-row>
  77. </el-card>
  78. </el-col>
  79. </el-row>
  80. <el-row type="flex" align="middle" justify="center" style="font-size: 14px; margin-top: 15px;">
  81. <el-col :span="6" type="flex" align="middle" justify="center">
  82. <el-card class="box-card" shadow="hover" style="margin-right: 40px;background-color: #20A0FF;">
  83. <div slot="header" class="clearfix">
  84. <span style="font-size: 30px;color: white;"><i class="el-icon-coin"></i></span>
  85. </div>
  86. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  87. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px;color: white;">{{systemStatistics[4].value}}</span>
  88. </el-col>
  89. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px;color: white;"
  90. type="success"
  91. :underline="false">{{systemStatistics[4].name}}</el-link></span>
  92. </el-col>
  93. </el-row>
  94. </el-card>
  95. </el-col>
  96. <el-col :span="6" type="flex" align="middle" justify="center">
  97. <el-card class="box-card" shadow="hover" style="margin-right: 40px;background-color: #13CE66;color: white;">
  98. <div slot="header" class="clearfix">
  99. <span style="font-size: 30px;color: white;"><i class="el-icon-bank-card"></i></span>
  100. </div>
  101. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  102. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px;color: white;">{{systemStatistics[5].value}}</span>
  103. </el-col>
  104. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px;color: white;"
  105. type="success"
  106. :underline="false">{{systemStatistics[5].name}}</el-link></span>
  107. </el-col>
  108. </el-row>
  109. </el-card>
  110. </el-col>
  111. <!--<el-col :span="4">{{project.id}}</el-col>-->
  112. <el-col :span="6" type="flex" align="middle" justify="center">
  113. <el-card class="box-card" shadow="hover" style="margin-right: 40px;background-color: #F7BA2A;">
  114. <div slot="header" class="clearfix">
  115. <span style="font-size: 30px;color: white;"><i class="el-icon-notebook-1"></i></span>
  116. </div>
  117. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  118. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px;color: white;">{{systemStatistics[6].value}}</span>
  119. </el-col>
  120. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px;color: white;"
  121. type="success"
  122. :underline="false">{{systemStatistics[6].name}}</el-link></span>
  123. </el-col>
  124. </el-row>
  125. </el-card>
  126. </el-col>
  127. <el-col :span="6" type="flex" align="middle" justify="center">
  128. <el-card class="box-card" shadow="hover" style="margin-right: 40px;background-color: #FF4949;">
  129. <div slot="header" class="clearfix">
  130. <span style="font-size: 30px;color: white;"><i class="el-icon-notebook-2"></i></span>
  131. </div>
  132. <el-row type="flex" align="middle" justify="center" style="font-size: 14px;">
  133. <el-col :span="18" type="flex" align="middle" justify="start"><span style="font-size: 50px;color: white;">{{systemStatistics[7].value}}</span>
  134. </el-col>
  135. <el-col :span="20" type="flex" align="bottom" justify="end"><span> <el-link style="font-size: 16px;color: white;"
  136. type="success"
  137. :underline="false">{{systemStatistics[7].name}}</el-link></span>
  138. </el-col>
  139. </el-row>
  140. </el-card>
  141. </el-col>
  142. </el-row>
  143. </div>
  144. <div class="home-body-wrap">
  145. <div class="home-block">
  146. <div class="title">
  147. 热门任务
  148. <span class="more-info">
  149. <router-link to="/square">更多任务></router-link>
  150. </span>
  151. </div>
  152. <el-row :gutter="20">
  153. <el-col :span="6" v-for="item,index in hotTaskList" :key="index">
  154. <task-card :item="item"/>
  155. </el-col>
  156. </el-row>
  157. </div>
  158. <div class="home-block">
  159. <el-row :gutter="20">
  160. <el-col :xs="20" :sm="20" :md="20" :lg="12" :xl="12">
  161. <div class="title">机构排名</div>
  162. <institution-rank :item="institutionRank"/>
  163. </el-col>
  164. <el-col :xs="20" :sm="20" :md="20" :lg="12" :xl="12">
  165. <div class="title">用户排名</div>
  166. <person-rank :item="personRank"/>
  167. </el-col>
  168. </el-row>
  169. </div>
  170. </div>
  171. </div>
  172. </template>
  173. <script>
  174. import TaskCard from '@/components/commons/TaskCard'
  175. import InstitutionRank from '@/components/InstitutionRank'
  176. import PersonRank from '@/components/PersonRank'
  177. import Http from '@/js/http.js'
  178. import Apis from '@/js/api.js'
  179. import {notify} from '@/constants/index'
  180. import {defaultValue, getIndexStatisticsInfo, getRolesPermissions, storageGet} from '@/js/index'
  181. export default {
  182. name: 'Home',
  183. components: {TaskCard, InstitutionRank, PersonRank},
  184. data () {
  185. return {
  186. user: null,
  187. loading: false,
  188. defaultValue: defaultValue,
  189. hotTaskList: [],
  190. institutionRank: [],
  191. personRank: [],
  192. imgList: [],
  193. rolesPermissions: {},
  194. statisticsData: {
  195. userNum: 100,
  196. agencyNum: 200,
  197. deviceNum: 345,
  198. projectNum: 23,
  199. taskNum: 123
  200. },
  201. systemStatistics: [{},{},{},{},{},{},{},{}]
  202. }
  203. },
  204. mounted () {
  205. console.log('mine mount')
  206. this.$nextTick(() => {
  207. this.init()
  208. })
  209. },
  210. methods: {
  211. init () {
  212. // storageGet('user').then((res)=>{
  213. // if (res == null){
  214. // //notify('warning','请登录后访问')
  215. // }else{
  216. // this.user = res
  217. // this.setRolesPermissions()
  218. // this.loadData()
  219. // }
  220. // }).catch((error)=>{
  221. // notify('error','用户信息获取失败')
  222. // })
  223. this.setUserInfo()
  224. // if (this.rolesPermissions == null) {
  225. // let NewPage = '_empty' + '?time=' + new Date().getTime() / 500
  226. // this.$router.push(NewPage)
  227. // this.$router.go(-1)
  228. // }
  229. this.loadData()
  230. },
  231. //加载数据
  232. loadData: function () {
  233. this.showLoading()
  234. console.log('loadData')
  235. Http.get(Apis.PAGE.HOME_PAGE).then((res) => {
  236. console.log(res)
  237. this.hotTaskList = res.hotTaskList
  238. this.institutionRank = res.agencyRank
  239. this.personRank = res.userRank
  240. this.imgList = res.imgList
  241. this.systemStatistics = res.systemStatistics
  242. this.hideLoading()
  243. }).catch((error) => {
  244. this.hideLoading()
  245. notify('error', '主页加载失败:' + error.data)
  246. })
  247. },
  248. setUserInfo () {
  249. this.user = storageGet('user')
  250. this.rolesPermissions = storageGet('rolesPermissions')
  251. },
  252. showLoading () {
  253. this.loading = true
  254. },
  255. hideLoading () {
  256. this.loading = false
  257. },
  258. getStatisticsData () {
  259. getIndexStatisticsInfo().then((res) => {
  260. this.statisticsData = res
  261. }).catch((error) => {
  262. notify('error', '统计数据加载失败')
  263. })
  264. },
  265. getStatisticsDataSuccess () {
  266. },
  267. getStatisticsDataFail () {
  268. }
  269. },
  270. created: function () {
  271. //notify('info', 'info')
  272. //notify('success', 'success')
  273. //notify('error', 'error')
  274. //notify('warning', 'warning')
  275. //this.loadData()
  276. },
  277. watch: {
  278. rolesPermissions (val) {
  279. console.log(this.rolesPermissions)
  280. console.log(val)
  281. this.rolesPermissions = val
  282. }
  283. }
  284. }
  285. </script>
  286. <style lang="less" scoped>
  287. .home-banner-wrap {
  288. background: linear-gradient(#4a90e2, rgb(74, 109, 226));
  289. background: -webkit-linear-gradient(#4a90e2, rgb(74, 109, 226));
  290. background: -o-linear-gradient(#4a90e2, rgb(74, 109, 226));
  291. .banner_back {
  292. height: 100%;
  293. }
  294. .banner_back_1 {
  295. width: 100%;
  296. //float: right;
  297. }
  298. }
  299. .el-carousel__item h3 {
  300. color: #475669;
  301. font-size: 14px;
  302. opacity: 0.75;
  303. line-height: 150px;
  304. margin: 0;
  305. }
  306. .el-carousel__item:nth-child(2n) {
  307. background-color: #bed2c0;
  308. }
  309. .el-carousel__item:nth-child(2n + 1) {
  310. background-color: #eeeef2;
  311. }
  312. .home-body-wrap {
  313. padding: 20px 80px;
  314. }
  315. .more-info {
  316. float: right;
  317. cursor: pointer;
  318. font-size: 1.4rem;
  319. }
  320. .btn-home-apply {
  321. position: absolute;
  322. bottom: 15%;
  323. left: 80%;
  324. }
  325. .home-block {
  326. margin: 10px 0;
  327. }
  328. </style>