lex 1 year ago
parent
commit
b878c6e9d7

+ 19 - 5
src/views/train-statistics/index.tsx

@@ -15,6 +15,17 @@ import SkeletionIndexModal from './skeletion-index.modal';
 export default defineComponent({
   name: 'train-statistics',
   setup() {
+    const trainParams = sessionStorage.getItem('trainParams');
+    sessionStorage.removeItem('trainParams');
+    let params = null;
+    if (trainParams) {
+      const tempResult = JSON.parse(trainParams);
+      params = {
+        ...tempResult,
+        page: 1,
+        rows: 20
+      };
+    }
     const router = useRouter();
     const forms = reactive({
       isClick: false,
@@ -24,10 +35,12 @@ export default defineComponent({
         finished: false,
         refreshing: false
       },
-      params: {
-        page: 1,
-        rows: 20
-      },
+      params: params
+        ? params
+        : {
+            page: 1,
+            rows: 20
+          },
       list: []
     });
 
@@ -76,6 +89,7 @@ export default defineComponent({
     };
 
     const onHref = (item: any) => {
+      sessionStorage.setItem('trainParams', JSON.stringify(forms.params));
       router.push({
         path: '/train-detail',
         query: {
@@ -106,7 +120,7 @@ export default defineComponent({
       <div class={styles.visitList}>
         <MSticky position="top">
           <MHeader />
-          <TrainModel onLoad={onLoad} />
+          <TrainModel onLoad={onLoad} selectValues={forms.params} />
         </MSticky>
 
         <SkeletionIndexModal v-model:show={forms.listState.loading}>

+ 1 - 1
src/views/train-statistics/train-detail.tsx

@@ -164,7 +164,7 @@ export default defineComponent({
           api: 'openWebView',
           content: {
             url: location.origin + `/accompany?school=1/#/report/${item.id}`,
-            orientation: 0,
+            orientation: 1,
             isHideTitle: true,
             statusBarTextColor: false,
             isOpenLight: true

+ 84 - 38
src/views/train-statistics/train-model.tsx

@@ -68,9 +68,9 @@ export function getNowDateAndSunday(time: any) {
 
 export default defineComponent({
   props: {
-    active: {
-      type: String,
-      default: 'all'
+    selectValues: {
+      type: Object,
+      default: () => {}
     },
     defaultTime: {
       type: Number,
@@ -89,12 +89,12 @@ export default defineComponent({
       minDate: new Date(2000, 0, 1),
       defaultDate: [] as any,
       memberFlag: '',
-      studentType: '', // 1 -> musicFlag,2 -> hasEndVipFlag,3 -> hasNotStartVipFlag
+      // studentType: '', // 1 -> musicFlag,2 -> hasEndVipFlag,3 -> hasNotStartVipFlag
       // 类型为全部时
       startDay: null as any,
       endDay: null as any,
       calendarStatus: false,
-      search: null,
+      search: null as any,
       searchArray: [null, null, null, null],
       searchType: {
         // ASC DESC
@@ -106,8 +106,10 @@ export default defineComponent({
       organId: '',
       organName: '全部分部',
       musicGroupId: '',
+      popupMusicGroupId: [] as any,
       musicGroupName: '全部乐团',
       classId: '',
+      popupClassId: [] as any,
       className: '全部班级'
     });
     const dropDownRef = ref();
@@ -186,24 +188,27 @@ export default defineComponent({
       if (type === 'member') {
         state.memberFlag = value;
       } else if (type === 'type') {
-        state.studentType = value;
+        // state.studentType = value;
       }
     };
 
     const onSort = (type?: any) => {
-      let searchArray: any = state.searchArray;
-      searchArray.forEach((item: any, index: any) => {
-        if (index != type) {
-          searchArray[index] = null;
+      if (type !== undefined && type !== null) {
+        let searchArray: any = state.searchArray;
+        searchArray.forEach((item: any, index: any) => {
+          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';
         }
-      });
-      if (searchArray[type] == 'ASC') {
-        searchArray[type] = 'DESC';
-      } else if (searchArray[type] == 'DESC') {
-        searchArray[type] = null;
-      } else {
-        searchArray[type] = 'ASC';
       }
+
       onAllFilter();
     };
 
@@ -222,9 +227,9 @@ export default defineComponent({
       let params = {
         search: state.search,
         memberFlag: state.memberFlag,
-        musicFlag: state.studentType === '1' ? true : false,
-        hasEndVipFlag: state.studentType === '2' ? true : false,
-        hasNotStartVipFlag: state.studentType === '3' ? true : false,
+        // musicFlag: state.studentType === '1' ? true : false,
+        // hasEndVipFlag: state.studentType === '2' ? true : false,
+        // hasNotStartVipFlag: state.studentType === '3' ? true : false,
         startTime: state.startDay,
         endTime: state.endDay,
         classGroupId: state.classId,
@@ -268,7 +273,7 @@ export default defineComponent({
       state.startDay = startTime;
       state.endDay = endTime;
       state.memberFlag = '';
-      state.studentType = '';
+      // state.studentType = '';
       state.musicGroupId = '';
       state.musicGroupName = '全部乐团';
       state.classId = '';
@@ -319,32 +324,69 @@ export default defineComponent({
       //   this.onAllFilter();
     };
 
-    onMounted(() => {
+    onMounted(async () => {
       let defaultTime = props.defaultTime;
       let day = defaultTime * 7;
       let startTime: any = new Date(),
         endTime: any = 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')
+
+      const searchType = ['totalPlayTime', 'trainNum', 'trainDay', 'recordNum'];
+      if (props.selectValues.sort) {
+        const index = searchType.findIndex(
+          item => item === props.selectValues.sort
         );
+        state.searchArray[index] = props.selectValues.order;
+      }
+      if (props.selectValues.startTime && props.selectValues.endTime) {
+        startTime = props.selectValues.startTime;
+        endTime = props.selectValues.endTime;
       } 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')
-        );
+        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')
+          );
+        }
       }
+
       state.defaultDate = [new Date(startTime), new Date(endTime)];
       state.startDay = startTime;
       state.endDay = endTime;
 
+      state.memberFlag = props.selectValues.memberFlag || '';
+      state.musicGroupId = props.selectValues.musicGroupId;
+      await getOrchestraList();
+
+      if (props.selectValues.musicGroupId) {
+        state.popupMusicGroupId = [props.selectValues.musicGroupId];
+        await getClassList();
+        state.musicGroupList.forEach((item: any) => {
+          if (item.value === state.musicGroupId) {
+            state.musicGroupName = item.text;
+          }
+        });
+      }
+
+      if (props.selectValues.classGroupId) {
+        state.classId = props.selectValues.classGroupId;
+        state.popupClassId = [state.classId];
+        state.classList.forEach((item: any) => {
+          if (item.value === state.className) {
+            state.className = item.text;
+          }
+        });
+      }
+
       onSort();
-      getOrchestraList();
     });
     return () => (
       <div class={styles.trainModel}>
@@ -355,6 +397,8 @@ export default defineComponent({
             // forms.params.keyword = val;
             // forms.listState.refreshing = true;
             // onRefresh();
+            state.search = val;
+            onAllFilter();
           }}>
           {{
             left: () => (
@@ -376,7 +420,7 @@ export default defineComponent({
                       valueClass={styles.calendarColor}
                       class={styles.studentCell}></Cell>
                     <Cell
-                      title={'是否员'}
+                      title={'是否员'}
                       titleClass={styles.cellTitle}
                       class={styles.studentCell}>
                       {{
@@ -413,7 +457,7 @@ export default defineComponent({
                         )
                       }}
                     </Cell>
-                    <Cell
+                    {/* <Cell
                       title={'是否学员'}
                       titleClass={styles.cellTitle}
                       class={styles.studentCell}>
@@ -465,7 +509,7 @@ export default defineComponent({
                           </div>
                         )
                       }}
-                    </Cell>
+                    </Cell> */}
                     <Cell
                       title={'乐团'}
                       isLink
@@ -604,6 +648,7 @@ export default defineComponent({
           <Picker
             columns={state.musicGroupList}
             showToolbar
+            v-model={state.popupMusicGroupId}
             onCancel={() => (state.showMusicGroup = false)}
             onConfirm={onSetMusicGrouop}
           />
@@ -613,6 +658,7 @@ export default defineComponent({
           <Picker
             columns={state.classList}
             showToolbar
+            v-model={state.popupClassId}
             onCancel={() => (state.showClass = false)}
             onConfirm={onSetClass}
           />