studentChange.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. import dayjs from "dayjs";
  44. export default {
  45. props: ["groupType"],
  46. inject: ["organId", "isSearch"],
  47. components: {
  48. "count-to": countTo,
  49. searchHeader,
  50. },
  51. data() {
  52. //判断一下
  53. console.log();
  54. let startTime,endTime;
  55. let nowDate = dayjs(new Date()).get("date");
  56. if (nowDate == 1) {
  57. startTime = dayjs().add(-1, 'month').startOf('month').format('YYYY-MM-DD');
  58. endTime = dayjs(new Date()).subtract(1, "day").format("YYYY-MM-DD");
  59. } else {
  60. startTime = dayjs(new Date()).set("date", 1).format("YYYY-MM-DD");
  61. endTime = dayjs(new Date()).subtract(1, "day").format("YYYY-MM-DD");
  62. }
  63. return {
  64. active: "",
  65. loading: false,
  66. mdate: [startTime, endTime],
  67. endDate: "",
  68. data: {},
  69. flag: null,
  70. };
  71. },
  72. computed: {
  73. dataEmpty() {
  74. return !this.chartData.rows.length;
  75. },
  76. items() {
  77. let tempArr = [
  78. {
  79. text: "回访流失人数",
  80. value: 0,
  81. id: "lostNum",
  82. },
  83. {
  84. text: "新增人数",
  85. value: 0,
  86. id: "addNum",
  87. },
  88. {
  89. text: "续费人数",
  90. value: 0,
  91. id: "renewNum",
  92. },
  93. {
  94. text: "回访人数",
  95. value: 0,
  96. id: "visitNum",
  97. },
  98. ];
  99. tempArr.forEach((item) => {
  100. if (this.data[item.id]) {
  101. item.value = this.data[item.id];
  102. }
  103. });
  104. return tempArr;
  105. },
  106. organIds() {
  107. return this.organId();
  108. },
  109. isSearchs: {
  110. get() {
  111. let flag = this.isSearch();
  112. if (this.flag != flag) {
  113. this.FetchDetail();
  114. console.log("调用studentChange", flag);
  115. }
  116. this.flag = flag;
  117. return flag;
  118. },
  119. },
  120. },
  121. mounted() {
  122. this.init();
  123. },
  124. methods: {
  125. init() {
  126. this.$refs.searchHeader.initStatue("month");
  127. },
  128. getInitDate() {
  129. const end = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
  130. const start = this.$helpers
  131. .dayjs(new Date())
  132. .set("date", 1)
  133. .format("YYYY-MM-DD");
  134. return [start, end];
  135. },
  136. changeValue(date) {
  137. // 请求更改数据
  138. console.log(date, "date");
  139. this.mdate = date;
  140. this.FetchDetail();
  141. },
  142. async FetchDetail() {
  143. this.loading = true;
  144. try {
  145. console.log({
  146. groupType: this.groupType,
  147. ...getTimes(this.mdate, ["startDate", "endDate"]),
  148. organId: this.organIds,
  149. });
  150. const res = await studentSmallClassStatisticsSumForDate({
  151. groupType: this.groupType,
  152. ...getTimes(this.mdate, ["startDate", "endDate"]),
  153. organId: this.organIds,
  154. });
  155. this.data = res.data || {};
  156. } catch (error) {
  157. console.log(error);
  158. }
  159. this.loading = false;
  160. },
  161. },
  162. };
  163. </script>
  164. <style lang="scss" scoped>
  165. ::v-deep .el-card__body .statistic {
  166. margin-bottom: 15px;
  167. padding: 0;
  168. }
  169. ::v-deep .el-card__header {
  170. padding: 0 20px !important;
  171. }
  172. .box {
  173. display: flex;
  174. flex-direction: row;
  175. align-items: center;
  176. height: 55px;
  177. line-height: 55px;
  178. .shape {
  179. margin-right: 10px;
  180. height: 18px;
  181. width: 4px;
  182. background-color: var(--color-primary);
  183. }
  184. }
  185. </style>