studentChange.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div>
  3. <el-card>
  4. <div slot="header" class="clearfix">
  5. <searchHeader
  6. :dates="mdate"
  7. :title="'经营数据'"
  8. @changeValue="changeValue"
  9. :isShowQuert="true"
  10. :endDate="endDate"
  11. ref="searchHeader"
  12. />
  13. </div>
  14. <!-- <div
  15. class="wall"
  16. style="height: 68px"
  17. v-if="JSON.stringify(items) == '{}'&&!data['CHARGE_STUDENT_CHANGE_RATE']&&!data['ACTIVATION_RATE']"
  18. >
  19. 暂无数据
  20. </div> -->
  21. <statistic :col="5" class="statistic" :cols="0">
  22. <statistic-item
  23. v-for="(item, key) in items"
  24. :key="key"
  25. :class="{ active: active === key }"
  26. @click="active = key"
  27. >
  28. <span>
  29. {{ item.text }}
  30. </span>
  31. <span> <count-to :endVal="item.value" /> </span>
  32. </statistic-item>
  33. </statistic>
  34. </el-card>
  35. <div v-show='isSearchs'></div>
  36. </div>
  37. </template>
  38. <script>
  39. import countTo from "vue-count-to";
  40. import searchHeader from "./searchHeader";
  41. import { studentSmallClassStatisticsSumForDate } from '../api';
  42. import { getTimes } from "@/utils";
  43. export default {
  44. props: ["groupType"],
  45. inject: ["organId", "isSearch"],
  46. components: {
  47. "count-to": countTo,
  48. searchHeader
  49. },
  50. data() {
  51. return {
  52. active: "",
  53. loading: false,
  54. mdate: [],
  55. endDate: '',
  56. data: {},
  57. flag:null
  58. };
  59. },
  60. computed: {
  61. dataEmpty() {
  62. return !this.chartData.rows.length;
  63. },
  64. items() {
  65. let tempArr = [{
  66. text: '回访流失人数',
  67. value: 0,
  68. id: 'lostNum'
  69. }, {
  70. text: '新增人数',
  71. value: 0,
  72. id: 'addNum'
  73. }, {
  74. text: '续费人数',
  75. value: 0,
  76. id: 'renewNum'
  77. }, {
  78. text: '回访人数',
  79. value: 0,
  80. id: 'visitNum'
  81. }]
  82. tempArr.forEach(item => {
  83. if(this.data[item.id]) {
  84. item.value = this.data[item.id]
  85. }
  86. })
  87. return tempArr
  88. },
  89. organIds() {
  90. return this.organId();
  91. },
  92. isSearchs: {
  93. get() {
  94. let flag = this.isSearch();
  95. if(this.flag != flag){
  96. this.FetchDetail()
  97. console.log('调用studentChange',flag)
  98. }
  99. this.flag = flag
  100. return flag;
  101. },
  102. },
  103. },
  104. mounted() {
  105. this.init()
  106. },
  107. methods: {
  108. init() {
  109. let startTime = this.$helpers
  110. .dayjs(new Date())
  111. .set("date", 1)
  112. .format("YYYY-MM-DD");
  113. let endTime = this.$helpers
  114. .dayjs(new Date())
  115. .subtract(1, "day")
  116. .format("YYYY-MM-DD");
  117. this.mdate = [startTime, endTime];
  118. this.$refs.searchHeader.initStatue('month')
  119. // this.FetchDetail();
  120. },
  121. getInitDate() {
  122. const end = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
  123. const start = this.$helpers
  124. .dayjs(new Date())
  125. .set("date", 1)
  126. .format("YYYY-MM-DD");
  127. return [start, end];
  128. },
  129. changeValue(date) {
  130. // 请求更改数据
  131. this.mdate = date;
  132. this.FetchDetail();
  133. },
  134. async FetchDetail() {
  135. this.loading = true;
  136. try {
  137. const res = await studentSmallClassStatisticsSumForDate({
  138. groupType: this.groupType,
  139. ...getTimes(this.mdate, ["startDate", "endDate"]),
  140. organId:this.organIds
  141. });
  142. this.data = res.data || {};
  143. } catch (error) {
  144. console.log(error);
  145. }
  146. this.loading = false;
  147. },
  148. },
  149. };
  150. </script>
  151. <style lang="scss" scoped>
  152. /deep/ .el-card__body .statistic {
  153. margin-bottom: 15px;
  154. padding: 0;
  155. }
  156. /deep/.el-card__header {
  157. padding: 0 20px!important;
  158. }
  159. .box {
  160. display: flex;
  161. flex-direction: row;
  162. align-items: center;
  163. height: 55px;
  164. line-height: 55px;
  165. .shape {
  166. margin-right: 10px;
  167. height: 18px;
  168. width: 4px;
  169. background-color: var(--color-primary);
  170. }
  171. }
  172. </style>