ソースを参照

Merge branch 'iterationApp'

lex-xin 3 年 前
コミット
184d8cd06d

+ 4 - 4
src/assets/commonLess/common.less

@@ -58,25 +58,25 @@
 input::-webkit-input-placeholder,
 textarea::-webkit-input-placeholder {
   color: #C0C0C0 !important;
-  font-size: .16rem;
+  font-size: .14rem;
 }
 
 input:-moz-placeholder,
 textarea:-moz-placeholder {
   color: #C0C0C0 !important;
-  font-size: .16rem;
+  font-size: .14rem;
 }
 
 input::-moz-placeholder,
 textarea::-moz-placeholder {
   color: #C0C0C0 !important;
-  font-size: .16rem;
+  font-size: .14rem;
 }
 
 input:-ms-input-placeholder,
 textarea:-ms-input-placeholder {
   color: #C0C0C0 !important;
-  font-size: .16rem;
+  font-size: .14rem;
 }
 
 .van-cell__right-icon {

+ 50 - 0
src/common/common.js

@@ -3,6 +3,56 @@ export const getRandomKey = () => {
 	return key
 }
 
+export function getNowDateAndMonday(time) {
+  let timestamp = new Date(time.replace(/-/g, "/")).getTime();
+  let serverDate = new Date(time);
+  if (serverDate.getDay() == 0) {
+      timestamp -= 7 * 24 * 60 * 60 * 1000;
+  }
+  let mondayTime = timestamp - (serverDate.getDay() - 1) * 24 * 60 * 60 * 1000;
+
+  let mondayData = new Date(mondayTime);
+  //年
+  let mondayY = mondayData.getFullYear();
+  //月
+  let mondayM =
+      mondayData.getMonth() + 1 < 10
+      ? "0" + (mondayData.getMonth() + 1)
+      : mondayData.getMonth() + 1;
+  //日
+  let mondayD =
+      mondayData.getDate() < 10
+      ? "0" + mondayData.getDate()
+      : mondayData.getDate();
+
+  let str = mondayY + "-" + mondayM + "-" + mondayD;
+  return str;
+}
+export function getNowDateAndSunday(time) {
+  let timestamp = new Date(time.replace(/-/g, "/")).getTime();
+  let serverDate = new Date(time);
+
+  let num = 7 - serverDate.getDay();
+  if (num == 7) {
+      num = 0;
+  }
+  let sundayTiem = timestamp + num * 24 * 60 * 60 * 1000;
+  let SundayData = new Date(sundayTiem);
+  //年
+  let tomorrowY = SundayData.getFullYear(); //月
+  let tomorrowM =
+      SundayData.getMonth() + 1 < 10
+      ? "0" + (SundayData.getMonth() + 1)
+      : SundayData.getMonth() + 1;
+  //日
+  let tomorrowD =
+      SundayData.getDate() < 10
+      ? "0" + SundayData.getDate()
+      : SundayData.getDate();
+  let str = tomorrowY + "-" + tomorrowM + "-" + tomorrowD;
+  return str;
+}
+
 const browser = () => {
   var u = navigator.userAgent
   //   app = navigator.appVersion;

+ 20 - 1
src/components/Search.vue

@@ -37,6 +37,7 @@ export default {
     display: flex;
     align-items: center;
     padding: 0 12px;
+
     /deep/.van-search {
         flex: 1;
         background-color: #fff !important;
@@ -60,7 +61,7 @@ export default {
     /deep/.van-search__action {
         color: @tFontColor;
         background-color: #f5f5f5;
-
+        padding: 0 5px;
     }
     /deep/.van-search__content {
         background-color: #f5f5f5;
@@ -77,5 +78,23 @@ export default {
         border-radius: 15px;
     }
 }
+input::-webkit-input-placeholder {
+  color: #777 !important;
+  font-size: .14rem;
+}
+
+input:-moz-placeholder {
+  color: #777 !important;
+  font-size: .14rem;
+}
+
+input::-moz-placeholder {
+  color: #777 !important;
+  font-size: .14rem;
+}
 
+input:-ms-input-placeholder {
+  color: #777 !important;
+  font-size: .14rem;
+}
 </style>

+ 2 - 2
src/main.js

@@ -10,7 +10,7 @@ import { Button, Icon, Tag, Swipe, SwipeItem, Popup, Picker,
     Circle, Field, DatetimePicker, Image, Loading,
     ActionSheet, RadioGroup, Radio, Checkbox, CheckboxGroup,
     CountDown, Panel, Dialog, Sticky, Rate, Switch, ImagePreview, NoticeBar, NavBar, Divider,
-    Grid, GridItem,} from 'vant'
+    Grid, GridItem, Calendar} from 'vant'
 Vue.use(Button).use(Icon).use(Tag).use(Swipe).use(SwipeItem)
    .use(Popup).use(Picker).use(DropdownMenu).use(DropdownItem).use(Search)
    .use(PullRefresh).use(Toast).use(List).use(Collapse).use(CollapseItem)
@@ -18,7 +18,7 @@ Vue.use(Button).use(Icon).use(Tag).use(Swipe).use(SwipeItem)
    .use(Circle).use(Field).use(DatetimePicker).use(Image).use(Loading)
    .use(ActionSheet).use(RadioGroup).use(Radio).use(Checkbox).use(CheckboxGroup)
    .use(CountDown).use(Panel).use(Dialog).use(Sticky).use(Rate).use(Switch).use(ImagePreview).use(NoticeBar)
-   .use(NavBar).use(Divider).use(Grid).use(GridItem)
+   .use(NavBar).use(Divider).use(Grid).use(GridItem).use(Calendar)
 
 Vue.config.productionTip = false
 

+ 63 - 149
src/views/trainStatistics/index.vue

@@ -2,20 +2,14 @@
     <div class="visitList">
         <van-sticky>
             <m-header v-if="headerStatus" :isFixed="false" />
-            <search @onSearch="search" placeholder="学生姓名或手机号">
-                <template #left>
-                    <van-dropdown-menu style="padding-right: .1rem" :close-on-click-outside="false" active-color="#01C1B5">
-                        <van-dropdown-item title="训练时间" ref="item" class="visitTime">
-                            <van-cell title="开始时间" is-link @click="onChangeDate('showStart')" :value="formatStartTime"></van-cell>
-                            <van-cell title="结束时间" is-link @click="onChangeDate('showEnd')" :value="formatEndTime"></van-cell>
-                            <div class="btnWrap">
-                                <div class="cancelBtn" @click="cancelBtn">重置</div>
-                                <div class="okBtn" @click="okBtn">确定</div>
-                            </div>
-                        </van-dropdown-item>
-                    </van-dropdown-menu>
-                </template>
-            </search>
+            <van-tabs v-model="active" @change="tabChange" title-active-color="#000000" title-inactive-color="#808080" color="#01C1B5" class="van-hairline--bottom">
+                <van-tab title="全部学员" name="all">
+                    <train-model ref="trainModel1" @onLoad="onLoad" :active="active" :defaultTime="0" />
+                </van-tab>
+                <van-tab title="待回访学员" name="visited">
+                    <train-model ref="trainModel2" @onLoad="onLoad" :active="active" :defaultTime="-1" />
+                </van-tab>
+            </van-tabs>
         </van-sticky>
 
         <van-list
@@ -24,10 +18,9 @@
             :finished="finished"
             finished-text="- 没有更多了 -"
             :immediate-check="false"
-            style="padding-top: .12rem;"
             @load="getList"
         >
-            <van-cell-group class="data-content" v-for="(item, index) in list" :key="index" @click="onHref(item)">
+            <van-cell-group class="data-content" :border="false" v-for="(item, index) in list" :key="index" @click="onHref(item)">
                 <van-cell style="padding: 16px 12px;" :center="true">
                     <template #title>
                         <div class="teacher_info">
@@ -36,7 +29,7 @@
                             <p style="color: #1a1a1a; font-size: .14rem;">{{ item.username }}</p>
                         </div>
                     </template>
-                    <p style="font-size: 14px; color: #808080;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{ item.musicGroupName }}</p>
+                    <p style="font-size: 14px; color: #333;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">{{ item.musicGroupName }}</p>
                 </van-cell>
                 <van-cell is-link :clickable="false" center style="padding: 12px 12px 16px">
                     <template #title>
@@ -45,13 +38,13 @@
                                 <template #icon>{{ item.totalPlayTime }}分钟</template>
                             </van-grid-item>
                             <van-grid-item text="训练次数">
-                                <template #icon><span style="color: #01C1B5">{{ item.trainDay }}次</span></template>
+                                <template #icon><span style="color: #01C1B5">{{ item.trainNum }}次</span></template>
                             </van-grid-item>
                             <van-grid-item text="训练天数">
-                                <template #icon><span style="color: #01C1B5">{{ item.trainDay }}天</span></template>
+                                <template #icon><span style="color: #FF802C">{{ item.trainDay }}天</span></template>
                             </van-grid-item>
                             <van-grid-item text="评测次数">
-                                <template #icon><span style="color: #FF802C">{{ item.recordNum }}次</span></template>
+                                <template #icon><span style="color: #F79C00">{{ item.recordNum }}次</span></template>
                             </van-grid-item>
                         </van-grid>
                     </template>
@@ -60,55 +53,34 @@
         </van-list>
         <m-empty v-else msg="暂无训练统计" />
 
-        <van-popup v-model="dataForm.status" position="bottom" :style="{ height: '40%' }">
-            <van-datetime-picker
-                v-model="dataForm.currentDate"
-                :min-date="dataForm.minDate"
-                :max-date="dataForm.maxDate"
-                :formatter="formatter"
-                @cancel="dataForm.status = false"
-                type="date"
-                @confirm="chioseDate"
-            />
-        </van-popup>
     </div>
 </template>
 <script>
 import MHeader from "@/components/MHeader";
 import MEmpty from '@/components/MEmpty';
-import Search from '@/components/Search';
 import dayjs from "dayjs";
 import { browser } from "@/common/common";
 import { countStudentTrain } from './api.js'
+import trainModel from './trainModel.vue'
 export default {
-    components: { MHeader, MEmpty, Search },
+    components: { MHeader, MEmpty, trainModel },
     data() {
+        const activeType = sessionStorage.getItem('trainTab')
+        sessionStorage.removeItem('trainTab')
         return {
             headerStatus: true,
-            dataForm: {
-                // 时间下拉框
-                type: null,
-                status: false,
-                minDate: new Date(2000, 0, 1),
-                maxDate: new Date(2025, 10, 1),
-                currentDate: new Date(),
-            },
-            purposeStatus: true,
-            startDate: null,
-            endDate: null,
-            showStart: false,
-            showEnd: false,
-            formatEndTime: null,
-            formatStartTime: null,
+            active: activeType || 'all',
             list: [],
             loading: false,
             finished: false,
             params: {
-                search: null,
                 page: 1,
                 rows: 20,
             },
             dataShow: true,
+            // 类型为回访学员时
+            formatEndTime: null,
+            formatStartTime: null,
         };
     },
     mounted() {
@@ -121,9 +93,27 @@ export default {
             this.headerStatus = false;
         }
         document.title = '训练统计'
-        this.getList()
+
+        // this.getList()
     },
     methods: {
+        onLoad(value) {
+            this.params = Object.assign(this.params, value)
+            this.onResetList()
+        },
+        tabChange() {
+            if(this.$refs.trainModel1) {
+                this.$refs.trainModel1.changeDropDownItemStatus()
+            }
+            if(this.$refs.trainModel2) {
+                this.$refs.trainModel2.changeDropDownItemStatus()
+            }
+            if(this.active == 'visited' && this.$refs.trainModel2) {
+                this.$refs.trainModel2.onAllFilter()
+            } else if(this.active == 'all' && this.$refs.trainModel1) {
+                this.$refs.trainModel1.onAllFilter()
+            }
+        },
         search(val) {
             this.params.search = val
             this.onResetList()
@@ -137,70 +127,23 @@ export default {
             this.getList()
         },
         onHref(item) {
+            sessionStorage.setItem('trainTab', this.active)
             this.$router.push({
                 path: '/trainDetail',
                 query: {
                     userId: item.userId,
                     username: item.username,
                     musicGroupName: item.musicGroupName,
-                    avatar: item.avatar
+                    avatar: item.avatar,
+                    visitFlag: item.visitFlag
                 }
             })
         },
-        cancelBtn() {
-            this.formatStartTime = null;
-            this.formatEndTime = null;
-            this.onResetList()
-            this.$refs.item.toggle();
-        },
-        okBtn() {
-            // if(this.formatStartTime && this.formatEndTime) {
-            //     }
-            this.onResetList()
-            this.$refs.item.toggle();
-        },
-        onChangeDate(type) {
-            let dataForm = this.dataForm
-            if(type == 'showEnd') {
-                if(this.formatStartTime) {
-                dataForm.minDate = new Date(dayjs(this.formatStartTime))
-                }
-                setTimeout(() => {
-                    dataForm.currentDate = this.formatEndTime ? new Date(dayjs(this.formatEndTime)) : new Date()
-                }, 500)
-            } else if(type == 'showStart') {
-                dataForm.minDate = new Date(2000, 0, 1)
-                setTimeout(() => {
-                    dataForm.currentDate = this.formatStartTime ? new Date(dayjs(this.formatStartTime)) : new Date()
-                }, 500)
-            }
-            dataForm.status = true
-            dataForm.type = type
-        },
-        chioseDate(value) {
-            let dataForm = this.dataForm
-            if(dataForm.type == 'showStart') {
-                this.formatStartTime = dayjs(value).format('YYYY-MM-DD')
-                if(this.formatEndTime && dayjs(value).unix() > dayjs(this.formatEndTime).unix()) {
-                this.formatEndTime = null
-                }
-            } else if(dataForm.type == 'showEnd') {
-                this.formatEndTime = dayjs(value).format('YYYY-MM-DD')
-            }
-            dataForm.status = false
-        },
-        // onTypeChange() {
-        //   this.onResetList()
-        // },
-        onPurposeChange() {
-            this.onResetList()
-        },
         async getList() {
             let params = this.params;
-            params.startTime = this.formatStartTime || null
-            params.endTime = this.formatEndTime || null
+            let visitFlag = this.active != 'all' ? 1 : null
             try {
-                let res = await countStudentTrain(params)
+                let res = await countStudentTrain({...params, visitFlag})
                 let result = res.data;
                 this.loading = false;
                 params.page = result.pageNo;
@@ -218,17 +161,7 @@ export default {
                 this.finished = true;
                 this.dataShow = false;
             }
-        },
-        formatter(type, val) {
-        if (type === "year") {
-            return `${val}年`;
-        } else if (type === "month") {
-            return `${val}月`;
-        } else if (type == "day") {
-            return `${val}日`;
         }
-        return val;
-        },
     },
 };
 </script>
@@ -237,17 +170,25 @@ export default {
 
 .visitList {
     min-height: 100vh;
-    .visitTime {
-        .van-cell__right-icon{
-        // line-height: .36rem;
-        }
-    }
+    // .visitTime {
+    //     .van-cell__right-icon{
+    //     // line-height: .36rem;
+    //     }
+    // }
     /deep/.van-dropdown-menu__bar {
         box-shadow: none;
     }
 }
+
+/deep/.van-tab {
+    font-size: .16rem;
+}
+/deep/.search .van-search {
+    margin: 10px 0 ;
+}
+
 .data-content {
-    margin: .15rem .15rem 0;
+    margin: .1rem .15rem 0;
     border-radius: .1rem;
     overflow: hidden;
     .logo {
@@ -271,10 +212,12 @@ export default {
     }
     /deep/.van-grid-item__icon-wrapper {
         font-size: .15rem;
+        font-weight: 500;
         color: #000;
     }
     /deep/.van-grid-item__text {
-        font-size: .14rem;
+        padding-top: .03rem;
+        font-size: .12rem;
         color: #808080;
     }
     .teacher_info {
@@ -288,25 +231,6 @@ export default {
         }
     }
 }
-// .cellGroup {
-//   display: flex;
-//   align-items: center;
-//   line-height: .61rem;
-//   .logo {
-//     width: 0.35rem;
-//     height: 0.35rem;
-//     // margin-right: 0.12rem;
-//     border-radius: 100%;
-//   }
-//   .type {
-//       line-height: 1.2;
-//   }
-// }
-// /deep/.van-cell__title {
-//   font-size: 0.14rem;
-//   color: @mFontColor;
-//   flex: 1 auto;
-// }
 .btnWrap {
   display: flex;
   flex-direction: row;
@@ -327,15 +251,5 @@ export default {
     text-align: center;
   }
 }
-// .van-cell{
-//     color: #1A1A1A;
-//     line-height: .36rem!important;
-//     font-size: .16rem;
-// }
-// /deep/.van-col--9 {
-//     display: flex;
-// }
-// /deep/.van-col--5 {
-//     text-align: center;
-// }
+
 </style>

+ 21 - 14
src/views/trainStatistics/trainDetail.vue

@@ -20,7 +20,7 @@
         </van-cell>
     </div>
 
-    <van-row class="dataSearch" type="flex">
+    <van-row class="dataSearch" type="flex" v-if="!visitFlag">
         <van-col span="9" offset="1">
             <van-cell @click="onChangeDate('showStart')" is-link>
                 <template #right-icon>
@@ -55,14 +55,14 @@
             @confirm="chioseDate"
         />
     </van-popup>
-    <div class="specialList">
+    <div class="specialList" :class="{'bottomHeight': visitFlag}">
         <van-list v-model="loading"  v-if="show" key="trainDetail"
             :finished="finished"
             finished-text="- 没有更多内容 -"
             :immediate-check="false"
             @load="getList()">
-            <van-cell-group class="data-content" v-for="(item, index) in dataList" :key="index" @click="showDetail(item)">
-                <van-cell style="padding: 16px 12px; 12px" :center="true">
+            <van-cell-group class="data-content" :border="false" v-for="(item, index) in dataList" :key="index" @click="showDetail(item)">
+                <van-cell style="padding: 16px 12px; 12px" :center="true" title-style="flex-basis: 45%;">
                     <template #title>
                         <span style="font-size: .17rem; color:#333333; font-weight: 500; padding-right: .05rem;padding-bottom: .05rem;">{{ item.sysMusicScoreName }}</span>
                         <p style="font-size: 14px; color: #808080;">{{ item.createTime }}</p>
@@ -83,10 +83,10 @@
                                 <template #icon><span style="color: #01C1B5">{{ item.intonation }}分</span></template>
                             </van-grid-item>
                             <van-grid-item text="节奏" class="van-hairline--right">
-                                <template #icon><span style="color: #01C1B5">{{ item.cadence }}分</span></template>
+                                <template #icon><span style="color: #FF802C">{{ item.cadence }}分</span></template>
                             </van-grid-item>
                             <van-grid-item text="完成度">
-                                <template #icon><span style="color: #FF802C">{{ item.integrity }}分</span></template>
+                                <template #icon><span style="color: #F79C00">{{ item.integrity }}分</span></template>
                             </van-grid-item>
                         </van-grid>
                     </template>
@@ -95,7 +95,8 @@
         </van-list>
         <m-empty v-else key="trainDetail" msg="暂无训练详情" />
 
-        <div class="button-group">
+        <!-- 是否需要回访 -->
+        <div class="button-group" v-if="visitFlag">
             <van-button type="primary" size="large" round @click="addVisited">添加回访</van-button>
             <div class="placeholder-btn"></div>
         </div>
@@ -120,6 +121,7 @@ export default {
             avatar: query.avatar,
             username: query.username,
             musicGroupName: query.musicGroupName,
+            visitFlag: Number(query.visitFlag) || 0,
             searchList: {
                 startTime: null,
                 endTime: null,
@@ -161,7 +163,7 @@ export default {
         showDetail(item) {
             if(item.notesDataIndex > 0){
                 postMessage({
-                    api: "openAccompanyWebView",
+                    api: "openWebView",
                     content: {
                         url: location.origin + `/accompany/#/report/${item.id}`,
                         orientation: 0,
@@ -308,10 +310,12 @@ export default {
     }
     /deep/.van-grid-item__icon-wrapper {
         font-size: .15rem;
+        font-weight: 500;
         color: #000;
     }
     /deep/.van-grid-item__text {
-        font-size: .14rem;
+        padding-top: .03rem;
+        font-size: .12rem;
         color: #808080;
     }
     .teacher_info {
@@ -327,18 +331,21 @@ export default {
 }
 .specialList {
     padding-top: .1rem;
-    padding-bottom: 65px;
     // padding-bottom: calc(env(safe-area-inset-bottom) / 2);
+    &.bottomHeight {
+        padding-bottom: 65px;
+    }
 }
 .dataSearch {
-    padding: .12rem;
+    padding: .12rem .12rem .05rem;
     background-color: #F5F5F5;
     /deep/.van-cell {
         background: #fff;
-        padding: .05rem .16rem;
+        padding: .0rem .16rem;
         border-radius: 1rem;
         overflow: hidden;
-        height: .34rem;
+        height: .27rem;
+        line-height: .27rem;
     }
     /deep/.van-cell__value--alone {
         text-align: center;
@@ -352,7 +359,7 @@ export default {
         background: #01C1B5;
         font-size: 14px;
         color: #fff;
-        padding: 4px 9px;
+        padding: 3px 9px;
         border-radius: 15px;
     }
 }

+ 288 - 0
src/views/trainStatistics/trainModel.vue

@@ -0,0 +1,288 @@
+<template>
+    <div class="trainModel">
+        <div class="visit-tips" v-show="activeType == 'visited'">
+            <span>上周训练时长不足80分钟或训练次数小于4次的学员<br />
+            需在每周三24:00前完成回访</span>
+        </div>
+        <search @onSearch="onSearch" placeholder="学生姓名或手机号">
+            <template #left>
+                <van-dropdown-menu style="padding-right: .1rem" :close-on-click-outside="false" active-color="#01C1B5">
+                    <van-dropdown-item title="筛选" ref="item" class="visitTime">
+                        <van-cell title="日期" is-link @click="showCalendar = true" title-style="font-size: .14rem;" :value="calendarValue" value-class="calendarColor"></van-cell>
+                    </van-dropdown-item>
+                </van-dropdown-menu>
+            </template>
+        </search>
+        <van-row class="searchArray">
+            <van-col span="6" class="title-style" @click="onSort(0)">
+                训练时长
+                <div>
+                    <i class="box box-up" :class="{'active': searchArray[0] == 'ASC'}" style="margin-bottom: .03rem;"></i>
+                    <i class="box box-down" :class="{'active': searchArray[0] == 'DESC'}"></i>
+                </div>
+            </van-col>
+            <van-col span="6" class="title-style" @click="onSort(1)">
+                训练次数
+                <div>
+                    <i class="box box-up" :class="{'active': searchArray[1] == 'ASC'}" style="margin-bottom: .03rem;"></i>
+                    <i class="box box-down" :class="{'active': searchArray[1] == 'DESC'}"></i>
+                </div>
+            </van-col>
+            <van-col span="6" class="title-style" @click="onSort(2)">
+                训练天数
+                <div>
+                    <i class="box box-up" :class="{'active': searchArray[2] == 'ASC'}" style="margin-bottom: .03rem;"></i>
+                    <i class="box box-down" :class="{'active': searchArray[2] == 'DESC'}"></i>
+                </div>
+            </van-col>
+            <van-col span="6" class="title-style" @click="onSort(3)">
+                评测次数
+                <div>
+                    <i class="box box-up" :class="{'active': searchArray[3] == 'ASC'}" style="margin-bottom: .03rem;"></i>
+                    <i class="box box-down" :class="{'active': searchArray[3] == 'DESC'}"></i>
+                </div>
+            </van-col>
+        </van-row>
+        <van-calendar
+            v-model="showCalendar"
+            :minDate="minDate"
+            :default-date="defaultDate"
+            :first-day-of-week="1"
+            :formatter="formatterDay"
+            color="#01C1B5"
+            type="range"
+            get-container="body"
+            @select="selectDate"
+            @confirm="onConfirm"
+            @close="onClose"
+        />
+    </div>
+</template>
+
+<script>
+import Search from '@/components/Search';
+import dayjs from "dayjs";
+import { getNowDateAndMonday, getNowDateAndSunday } from '@/common/common'
+export default {
+    props: {
+        active: {
+            type: String,
+            default: 'all'
+        },
+        defaultTime: {
+            type: Number,
+            default: 0
+        }
+    },
+    components: { Search },
+    data() {
+        return {
+            showCalendar: false,
+            minDate: new Date(2000, 0, 1),
+            defaultDate:[],
+            // 类型为全部时
+            startDay: null,
+            endDay: null,
+            search: null,
+            searchArray: [null, null, null, null],
+            searchType: {
+                // ASC DESC
+                totalPlayTime: null,
+                trainNum: null,
+                trainDay: null,
+                recordNum: null,
+            },
+
+        }
+    },
+    async mounted() {
+        let defaultTime = this.defaultTime
+        let day = defaultTime * 7
+        let startTime = new Date(), endTime = new Date()
+        if(day > 0) {
+            startTime = getNowDateAndMonday(dayjs().add(day, 'day').format("YYYY-MM-DD"))
+            endTime = getNowDateAndSunday(dayjs().add(day, 'day').format("YYYY-MM-DD"))
+        } else {
+            startTime = getNowDateAndMonday(dayjs().subtract(Math.abs(day), 'day').format("YYYY-MM-DD"))
+            endTime = getNowDateAndSunday(dayjs().subtract(Math.abs(day), 'day').format("YYYY-MM-DD"))
+        }
+        this.defaultDate = [new Date(startTime), new Date(endTime)]
+        this.startDay = startTime
+        this.endDay = endTime
+
+        this.onSort()
+    },
+    computed: {
+        calendarValue() {
+            return `${dayjs(this.startDay).format("YYYY/MM/DD")} - ${dayjs(this.endDay).format("YYYY/MM/DD")}`;
+        },
+        activeType() {
+            return this.active
+        }
+    },
+    methods: {
+        onSort(type) {
+            let searchArray = this.searchArray
+            searchArray.forEach((item, index) => {
+                if(index != type) {
+                    searchArray[index] = null
+                }
+            });
+            if(searchArray[type] == 'ASC') {
+                searchArray[type] = 'DESC'
+            } else if(searchArray[type] == 'DESC') {
+                searchArray[type] = null
+            } else {
+                searchArray[type] = 'ASC'
+            }
+            this.$forceUpdate()
+            // console.log(searchArray)
+            this.onAllFilter()
+        },
+        onSearch(val) {
+            this.search = val
+            this.onAllFilter()
+        },
+        onAllFilter() {
+            const searchArray = this.searchArray
+            let currentIndex = null
+            let currentType = null
+            searchArray.forEach((item, index) => {
+                if(item) {
+                    currentIndex = index
+                    currentType = item
+                }
+            })
+            const searchType = ['totalPlayTime', 'trainNum', 'trainDay', 'recordNum']
+            let params = {
+                search: this.search,
+                startTime: this.startDay,
+                endTime: this.endDay,
+                page: 1,
+                sort: searchType[currentIndex],
+                order: currentType
+            }
+            this.$listeners.onLoad(params)
+        },
+        changeDropDownItemStatus() {
+            this.$refs.item.toggle(false)
+        },
+        selectDate(date) {
+            let [start, end] = date;
+            if (start) {
+                const num = dayjs(start).get("day");
+                if (num === 0) {
+                    start = dayjs(start).subtract(6, "day");
+                } else {
+                    start = dayjs(start).subtract(num - 1, "day");
+                }
+            }
+            if (start) {
+                const num = 7 - dayjs(start).get("day");
+                if (num < 7) {
+                    end = dayjs(start).add(num, "day");
+                }
+            }
+            this.defaultDate = [new Date(start.valueOf()),new Date(end.valueOf())]
+        },
+        onConfirm(date) {
+            let [start, end] = date;
+            this.showCalendar = false;
+            if (start) {
+                const num = dayjs(start).get("day");
+                if (num === 0) {
+                start = dayjs(start).subtract(6, "day");
+                } else {
+                start = dayjs(start).subtract(num - 1, "day");
+                }
+            }
+            if (end) {
+                const num = 7 - dayjs(end).get("day");
+                if (num < 7) {
+                end = dayjs(end).add(num, "day");
+                }
+            }
+            this.startDay = dayjs(start).format("YYYY-MM-DD");
+            this.endDay = dayjs(end).format("YYYY-MM-DD");
+            //
+            this.changeDropDownItemStatus()
+            this.onAllFilter()
+        },
+        onClose() {
+            // 关闭弹窗时初始化默认日期
+            this.defaultDate = [new Date(this.startDay), new Date(this.endDay)]
+        },
+        formatterDay(day) {
+            const month = day.date.getMonth() + 1;
+            const date = day.date.getDate();
+            let nowDate = new Date()
+            if(month == nowDate.getMonth() + 1 && date == nowDate.getDate()){
+                day.text = '今天'
+            }
+            return day
+        }
+    }
+}
+</script>
+
+<style lang="less" scoped>
+/deep/.van-dropdown-menu__title::after {
+    border-color: transparent transparent #01C1B5 #01C1B5;
+}
+.calendarColor {
+    color: #333;
+    font-size: .14rem;
+}
+.visit-tips {
+    background-color: #fff;
+    // padding: 10px 10px 0;
+    padding: 10px 12px 0;
+    text-align: center;
+    span {
+        display: block;
+        padding: 6px 12px;
+        background-color: #FFF6DE;
+        font-size: 12px;
+        color: #FF802C;
+        text-align: left;
+    }
+}
+.searchArray {
+    font-size: .14rem;
+    padding-top: .15rem;
+    padding-bottom: .12rem;
+    color: #1A1A1A;
+    background-color: #f5f5f5;
+}
+.title-style {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+.box {
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    margin-left: .02rem;
+}
+.box-up {
+    width: 0;
+    height: 0;
+    border-left: 4px solid transparent;
+    border-right: 4px solid transparent;
+    border-bottom: 5px solid #ccc;
+    &.active {
+        border-bottom-color: #01C1B5;
+    }
+}
+.box-down {
+    width: 0;
+    height: 0;
+    border-left: 4px solid transparent;
+    border-right: 4px solid transparent;
+    border-top: 5px solid #ccc;
+    &.active {
+        border-top-color: #01C1B5;
+    }
+}
+</style>

+ 7 - 3
src/views/visitManager/addVisit.vue

@@ -211,6 +211,7 @@ export default {
       id: query.id,
       name: query.name,
       userId: query.userId,
+      visitFlag: Number(query.visitFlag) || 0,
       dataForm: {
         // 时间下拉框
         status: false,
@@ -340,11 +341,13 @@ export default {
         this.$toast("添加成功");
         setTimeout(() => {
           if(this.userId) {
-            const query = this.$route.query
+            let { visitFlag ,...query } = this.$route.query
+            visitFlag = 0
             this.$router.replace({
               path: '/trainDetail',
               query: {
-                ...query
+                ...query,
+                visitFlag
               }
             });
           } else {
@@ -415,7 +418,8 @@ export default {
       this.dataForm.status = false;
     },
     onEnListShow() {
-      if (this.id) {
+      // 从云教练统计来的,不许改时间,默认当前时间
+      if (this.id || this.visitFlag) {
         return;
       }
       this.dataForm.status = true;