index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="visitList">
  3. <van-sticky>
  4. <m-header v-if="headerStatus" :isFixed="false" />
  5. <search @onSearch="search" placeholder="学生姓名或手机号">
  6. <template #left>
  7. <van-dropdown-menu style="padding-right: .1rem" :close-on-click-outside="false" active-color="#01C1B5">
  8. <van-dropdown-item title="训练时间" ref="item" class="visitTime">
  9. <van-cell title="开始时间" is-link @click="onChangeDate('showStart')" :value="formatStartTime"></van-cell>
  10. <van-cell title="结束时间" is-link @click="onChangeDate('showEnd')" :value="formatEndTime"></van-cell>
  11. <div class="btnWrap">
  12. <div class="cancelBtn" @click="cancelBtn">重置</div>
  13. <div class="okBtn" @click="okBtn">确定</div>
  14. </div>
  15. </van-dropdown-item>
  16. </van-dropdown-menu>
  17. </template>
  18. </search>
  19. </van-sticky>
  20. <van-list
  21. v-model="loading"
  22. v-if="dataShow"
  23. :finished="finished"
  24. finished-text="- 没有更多了 -"
  25. :immediate-check="false"
  26. style="padding-top: .12rem;"
  27. @load="getList"
  28. >
  29. <van-cell-group class="data-content" v-for="(item, index) in list" :key="index" @click="onHref(item)">
  30. <van-cell style="padding: 16px 12px; 12px" :center="true">
  31. <template #title>
  32. <div class="teacher_info">
  33. <img class="logo" v-if="item.avatar" :src="item.avatar" alt="" />
  34. <img class="logo" v-else src="../../assets/images/icon_student.png" alt="" />
  35. <p style="color: #1a1a1a; font-size: .14rem;">{{ item.username }}</p>
  36. </div>
  37. </template>
  38. <p style="font-size: 14px; color: #808080;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{ item.musicGroupName }}</p>
  39. </van-cell>
  40. <van-cell is-link :clickable="false" center style="padding: 12px 12px 16px">
  41. <template #title>
  42. <van-grid :border="false" column-num="4" :clickable="true">
  43. <van-grid-item text="训练时长">
  44. <template #icon>{{ item.totalPlayTime }}分钟</template>
  45. </van-grid-item>
  46. <van-grid-item text="训练天数">
  47. <template #icon><span style="color: #01C1B5">{{ item.trainDay }}天</span></template>
  48. </van-grid-item>
  49. <van-grid-item text="训练次数">
  50. <template #icon><span style="color: #01C1B5">{{ item.trainDay }}次</span></template>
  51. </van-grid-item>
  52. <van-grid-item text="评测次数">
  53. <template #icon><span style="color: #FF802C">{{ item.recordNum }}次</span></template>
  54. </van-grid-item>
  55. </van-grid>
  56. </template>
  57. </van-cell>
  58. </van-cell-group>
  59. </van-list>
  60. <m-empty v-else msg="暂无训练统计" />
  61. <van-popup v-model="dataForm.status" position="bottom" :style="{ height: '40%' }">
  62. <van-datetime-picker
  63. v-model="dataForm.currentDate"
  64. :min-date="dataForm.minDate"
  65. :max-date="dataForm.maxDate"
  66. :formatter="formatter"
  67. @cancel="dataForm.status = false"
  68. type="date"
  69. @confirm="chioseDate"
  70. />
  71. </van-popup>
  72. </div>
  73. </template>
  74. <script>
  75. import MHeader from "@/components/MHeader";
  76. import MEmpty from '@/components/MEmpty';
  77. import Search from '@/components/Search';
  78. import dayjs from "dayjs";
  79. import { browser } from "@/common/common";
  80. import { countStudentTrain } from './api.js'
  81. export default {
  82. components: { MHeader, MEmpty, Search },
  83. data() {
  84. return {
  85. headerStatus: true,
  86. dataForm: {
  87. // 时间下拉框
  88. type: null,
  89. status: false,
  90. minDate: new Date(2000, 0, 1),
  91. maxDate: new Date(2025, 10, 1),
  92. currentDate: new Date(),
  93. },
  94. purposeStatus: true,
  95. startDate: null,
  96. endDate: null,
  97. showStart: false,
  98. showEnd: false,
  99. formatEndTime: null,
  100. formatStartTime: null,
  101. list: [],
  102. loading: false,
  103. finished: false,
  104. params: {
  105. search: null,
  106. page: 1,
  107. rows: 20,
  108. },
  109. dataShow: true,
  110. };
  111. },
  112. mounted() {
  113. let params = this.$route.query;
  114. if (params.Authorization) {
  115. localStorage.setItem("Authorization", decodeURI(params.Authorization));
  116. localStorage.setItem("userInfo", decodeURI(params.Authorization));
  117. }
  118. if (browser().android || browser().iPhone) {
  119. this.headerStatus = false;
  120. }
  121. document.title = '训练统计'
  122. this.getList()
  123. },
  124. methods: {
  125. search(val) {
  126. this.params.search = val
  127. this.onResetList()
  128. },
  129. onResetList() {
  130. this.list = [];
  131. this.params.page = 1;
  132. this.dataShow = true;
  133. this.loading = true;
  134. this.finished = false;
  135. this.getList()
  136. },
  137. onHref(item) {
  138. this.$router.push({
  139. path: '/trainDetail',
  140. query: {
  141. userId: item.userId,
  142. username: item.username
  143. }
  144. })
  145. },
  146. cancelBtn() {
  147. this.formatStartTime = null;
  148. this.formatEndTime = null;
  149. this.onResetList()
  150. this.$refs.item.toggle();
  151. },
  152. okBtn() {
  153. if(this.formatStartTime && this.formatEndTime) {
  154. this.onResetList()
  155. }
  156. this.$refs.item.toggle();
  157. },
  158. onChangeDate(type) {
  159. let dataForm = this.dataForm
  160. if(type == 'showEnd') {
  161. if(this.formatStartTime) {
  162. dataForm.minDate = new Date(dayjs(this.formatStartTime))
  163. }
  164. setTimeout(() => {
  165. dataForm.currentDate = this.formatEndTime ? new Date(dayjs(this.formatEndTime)) : new Date()
  166. }, 500)
  167. } else if(type == 'showStart') {
  168. dataForm.minDate = new Date(2000, 0, 1)
  169. setTimeout(() => {
  170. dataForm.currentDate = this.formatStartTime ? new Date(dayjs(this.formatStartTime)) : new Date()
  171. }, 500)
  172. }
  173. dataForm.status = true
  174. dataForm.type = type
  175. },
  176. chioseDate(value) {
  177. let dataForm = this.dataForm
  178. if(dataForm.type == 'showStart') {
  179. this.formatStartTime = dayjs(value).format('YYYY/MM/DD')
  180. if(this.formatEndTime && dayjs(value).unix() > dayjs(this.formatEndTime).unix()) {
  181. this.formatEndTime = null
  182. }
  183. } else if(dataForm.type == 'showEnd') {
  184. this.formatEndTime = dayjs(value).format('YYYY/MM/DD')
  185. }
  186. dataForm.status = false
  187. },
  188. // onTypeChange() {
  189. // this.onResetList()
  190. // },
  191. onPurposeChange() {
  192. this.onResetList()
  193. },
  194. async getList() {
  195. let params = this.params;
  196. if(this.formatStartTime && this.formatEndTime) {
  197. params.startTime = this.formatStartTime
  198. params.endTime = this.formatEndTime
  199. } else {
  200. params.startTime = null
  201. params.endTime = null
  202. }
  203. try {
  204. let res = await countStudentTrain(params)
  205. let result = res.data;
  206. this.loading = false;
  207. params.page = result.pageNo;
  208. this.list = this.list.concat(result.rows);
  209. if (params.page >= result.totalPage) {
  210. this.finished = true;
  211. }
  212. this.params.page++;
  213. // 判断是否有数据
  214. if (this.list.length <= 0) {
  215. this.dataShow = false;
  216. }
  217. } catch {
  218. //
  219. this.finished = true;
  220. this.dataShow = false;
  221. }
  222. },
  223. formatter(type, val) {
  224. if (type === "year") {
  225. return `${val}年`;
  226. } else if (type === "month") {
  227. return `${val}月`;
  228. } else if (type == "day") {
  229. return `${val}日`;
  230. }
  231. return val;
  232. },
  233. },
  234. };
  235. </script>
  236. <style lang="less" scoped>
  237. @import url("../../assets/commonLess/variable.less");
  238. .visitList {
  239. min-height: 100vh;
  240. .visitTime {
  241. .van-cell__right-icon{
  242. line-height: .36rem;
  243. }
  244. }
  245. /deep/.van-dropdown-menu__bar {
  246. box-shadow: none;
  247. }
  248. }
  249. .data-content {
  250. margin: .15rem .15rem 0;
  251. border-radius: .1rem;
  252. overflow: hidden;
  253. &:first-child {
  254. margin-top: 0;
  255. }
  256. .van-row-item {
  257. display: flex;
  258. align-items: center;
  259. }
  260. /deep/.van-grid-item__content {
  261. padding: .03rem
  262. }
  263. /deep/.van-grid-item__content {
  264. background-color: transparent;
  265. }
  266. /deep/.van-grid-item__icon-wrapper {
  267. font-size: .15rem;
  268. color: #000;
  269. }
  270. /deep/.van-grid-item__text {
  271. font-size: .14rem;
  272. color: #808080;
  273. }
  274. .teacher_info {
  275. display: flex;
  276. align-items: center;
  277. img {
  278. margin-right: .1rem;
  279. width: .4rem;
  280. height: .4rem;
  281. border-radius: 50%;
  282. }
  283. }
  284. }
  285. // .cellGroup {
  286. // display: flex;
  287. // align-items: center;
  288. // line-height: .61rem;
  289. // .logo {
  290. // width: 0.35rem;
  291. // height: 0.35rem;
  292. // // margin-right: 0.12rem;
  293. // border-radius: 100%;
  294. // }
  295. // .type {
  296. // line-height: 1.2;
  297. // }
  298. // }
  299. // /deep/.van-cell__title {
  300. // font-size: 0.14rem;
  301. // color: @mFontColor;
  302. // flex: 1 auto;
  303. // }
  304. .btnWrap {
  305. display: flex;
  306. flex-direction: row;
  307. .cancelBtn {
  308. height: 48px;
  309. line-height: 48px;
  310. background: #eeeff3;
  311. color: @mColor;
  312. text-align: center;
  313. width: 100%;
  314. }
  315. .okBtn {
  316. width: 100%;
  317. height: 48px;
  318. line-height: 48px;
  319. background: @mColor;
  320. color: #fff;
  321. text-align: center;
  322. }
  323. }
  324. // .van-cell{
  325. // color: #1A1A1A;
  326. // line-height: .36rem!important;
  327. // font-size: .16rem;
  328. // }
  329. // /deep/.van-col--9 {
  330. // display: flex;
  331. // }
  332. // /deep/.van-col--5 {
  333. // text-align: center;
  334. // }
  335. </style>