index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="educationStatistics">
  3. <NavBar />
  4. <div class="statistics-container">
  5. <div class="org-line van-hairline--bottom">
  6. <org-tree v-model="query.orgId" @change="getDataList"></org-tree>
  7. </div>
  8. <div class="search-flex">
  9. <select-cell
  10. style="border-right:1px solid #f5f5f5;"
  11. title="教育计划"
  12. v-model="query.planId"
  13. :dataList="planList"
  14. :prop="prop"
  15. @change="getDataList"
  16. />
  17. <date-cell title="统计月份" v-model="query.date" date-type="year-month" @change="getDataList" />
  18. </div>
  19. <div class="card-list">
  20. <empty v-if="!dataList || dataList.length === 0" />
  21. <ve-table
  22. v-else
  23. maxHeight="calc(100vh - 252px)"
  24. fixedHeader
  25. borderX
  26. borderY
  27. borderAround
  28. :columns="columns"
  29. :table-data="dataList"
  30. />
  31. </div>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import NavBar from '@/components/NavBar'
  37. import OrgTree from '@/components/orgTree'
  38. import dateCell from '@/components/dateCell'
  39. import selectCell from '@/components/selectCell'
  40. import { dataList, planList } from './api'
  41. import { mapGetters } from 'vuex'
  42. import { formatDate } from '@/filters/filter'
  43. export default {
  44. components: {
  45. NavBar,
  46. OrgTree,
  47. dateCell,
  48. selectCell
  49. },
  50. data() {
  51. return {
  52. query: {
  53. date: `${formatDate(new Date(),'YYYY-MM')}`,
  54. orgId: null,
  55. planId: null
  56. },
  57. planList: [],
  58. prop: {
  59. label: 'name',
  60. value: 'id'
  61. },
  62. loading: false,
  63. columns: [
  64. {
  65. field: 'index',
  66. key: 'index',
  67. title: '序号',
  68. width: 50,
  69. align: 'center',
  70. renderBodyCell: ({ row, column, rowIndex }, h) => {
  71. return ++rowIndex
  72. }
  73. },
  74. { field: 'orgName', key: 'a', title: '单位名称', align: 'center' },
  75. { field: 'shouldFinish', key: 'b', title: '应完成数', align: 'center' },
  76. { field: 'finish', key: 'c', title: '已完成数', align: 'center' },
  77. { field: 'finishRate', key: 'd', title: '完成率', align: 'center' }
  78. ],
  79. dataList: []
  80. }
  81. },
  82. mounted() {
  83. this.initData()
  84. },
  85. computed: {
  86. ...mapGetters(['orgId'])
  87. },
  88. methods: {
  89. initData() {
  90. this.query.orgId = this.orgId
  91. this.getPlanList()
  92. },
  93. getPlanList() {
  94. planList(this.query.orgId).then(res => {
  95. this.planList = res.data
  96. if (res.data.length === 0) return this.$toast('暂无教育计划')
  97. this.query.planId = res.data[0].id
  98. this.query.date = formatDate(new Date(), 'YYYY-MM')
  99. this.getDataList()
  100. })
  101. },
  102. getDataList() {
  103. let data = {
  104. ...this.query
  105. }
  106. data.date = this.query.date && `${this.query.date}-01`
  107. if (!this.query.orgId) return this.$toast('请选择机构')
  108. dataList(data).then(res => {
  109. this.dataList = res.data
  110. })
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. .van-cell-group {
  117. margin-bottom: 20px;
  118. }
  119. .van-cell-group:last-child {
  120. margin-bottom: 0;
  121. }
  122. .vue-table-root {
  123. tr,
  124. td,
  125. th {
  126. font-size: 25px !important;
  127. color: #666 !important;
  128. }
  129. }
  130. </style>
  131. <style lang="scss" scoped>
  132. .educationStatistics {
  133. }
  134. .statistics-container {
  135. }
  136. .card-list {
  137. padding: 20px;
  138. height: calc(100vh - 420px);
  139. overflow: hidden;
  140. }
  141. .org-line{
  142. padding:0 10px;
  143. background-color: #fff;
  144. }
  145. .card-num {
  146. display: flex;
  147. align-items: center;
  148. font-size: 28px;
  149. color: #009dff;
  150. }
  151. .flex-box {
  152. display: flex;
  153. align-items: center;
  154. > div {
  155. margin-right: 40px;
  156. }
  157. }
  158. .search-flex {
  159. display: flex;
  160. align-items: center;
  161. justify-content: space-between;
  162. > div {
  163. width: 50%;
  164. }
  165. }
  166. </style>