index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div class="container">
  3. <save-form inline :model="search" @submit="FetchDetail" @reset="reset" saveKey="/main/main/baseInfo">
  4. <el-form-item prop="year">
  5. <el-date-picker
  6. v-model="search.year"
  7. type="year"
  8. format="yyyy年"
  9. :picker-options="{
  10. disabledDate(time) {
  11. return time.getTime() > Date.now()
  12. }
  13. }"
  14. placeholder="请选择年份">
  15. </el-date-picker>
  16. </el-form-item>
  17. <el-form-item prop="organId">
  18. <el-select
  19. clearable
  20. filterable
  21. placeholder="请选择分部"
  22. v-model="search.organId"
  23. >
  24. <el-option v-for="(item,index) in selects.branchs"
  25. :key="index"
  26. :label="item.name"
  27. :value="item.id"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-button native-type="submit" type="primary">搜索</el-button>
  31. <el-button native-type="reset" type="danger">重置</el-button>
  32. </save-form>
  33. <el-alert type="info" :closable="false" style="margin-bottom: 20px;">
  34. 每日0点更新前一日数据
  35. </el-alert>
  36. <empty desc="暂无统计数据" v-if="isEmpty"/>
  37. <el-row v-else class="rows" :gutter="20">
  38. <el-col :xs="24" :sm="24" :md="12">
  39. <operate :data="dataInfo"/>
  40. </el-col>
  41. <el-col :xs="24" :sm="24" :md="12">
  42. <business :data="dataInfo"/>
  43. </el-col>
  44. <!-- <el-col :xs="24" :sm="24" :md="24" :xl="10">
  45. <management :data="dataInfo"/>
  46. </el-col> -->
  47. <el-col :xs="24" :sm="24" :md="12">
  48. <hrdata :data="dataInfo"/>
  49. </el-col>
  50. <el-col :xs="24" :sm="24" :md="12">
  51. <student :data="dataInfo"/>
  52. </el-col>
  53. <el-col :xs="24" :sm="24" :md="24">
  54. <curriculum :data="dataInfo"/>
  55. </el-col>
  56. </el-row>
  57. </div>
  58. </template>
  59. <script>
  60. import { getIndex } from '../api'
  61. import operate from './operate'
  62. import business from './business'
  63. import management from './management'
  64. import hrdata from './hr'
  65. import student from './student'
  66. import curriculum from './curriculum'
  67. import { descs } from '../constant'
  68. export default {
  69. components: {
  70. operate,
  71. business,
  72. management,
  73. hrdata,
  74. student,
  75. curriculum,
  76. },
  77. data () {
  78. return {
  79. search: {
  80. year: '',
  81. organId: null
  82. },
  83. dataInfo: {},
  84. business: {},
  85. }
  86. },
  87. computed: {
  88. isEmpty() {
  89. return !Object.keys(this.dataInfo).length
  90. }
  91. },
  92. mounted () {
  93. this.reset()
  94. this.$store.dispatch('setBranchs')
  95. },
  96. methods: {
  97. reset() {
  98. this.$set(this.search, 'year', this.$helpers.dayjs())
  99. this.$set(this.search, 'organId', [])
  100. this.FetchDetail()
  101. },
  102. async FetchDetail() {
  103. const data = {}
  104. try {
  105. const res = await getIndex({
  106. ...this.search,
  107. year: this.$helpers.dayjs(this.search.year).year() || '',
  108. })
  109. for (const item of res.data) {
  110. data[item.dataType] = {
  111. ...item,
  112. desc: descs[item.dataType]
  113. }
  114. }
  115. } catch (error) {
  116. console.log(error)
  117. }
  118. this.dataInfo = data
  119. },
  120. }
  121. }
  122. </script>
  123. <style lang="less" scoped>
  124. .container{
  125. overflow: hidden;
  126. .rows{
  127. >div{
  128. margin-bottom: 20px;
  129. }
  130. }
  131. /deep/ .el-card__body .statistic {
  132. margin-bottom: 15px;
  133. padding: 0;
  134. }
  135. }
  136. </style>