|  | @@ -1,7 +1,18 @@
 | 
	
		
			
				|  |  |  import request from '@/helpers/request'
 | 
	
		
			
				|  |  |  import { state } from '@/state'
 | 
	
		
			
				|  |  | -import { Button, Empty, Grid, GridItem, Icon, showToast, Toast } from 'vant'
 | 
	
		
			
				|  |  | -import { defineComponent, onMounted, reactive } from 'vue'
 | 
	
		
			
				|  |  | +import {
 | 
	
		
			
				|  |  | +  ActionSheet,
 | 
	
		
			
				|  |  | +  ActionSheetAction,
 | 
	
		
			
				|  |  | +  Button,
 | 
	
		
			
				|  |  | +  Empty,
 | 
	
		
			
				|  |  | +  Grid,
 | 
	
		
			
				|  |  | +  GridItem,
 | 
	
		
			
				|  |  | +  Icon,
 | 
	
		
			
				|  |  | +  Popover,
 | 
	
		
			
				|  |  | +  showToast,
 | 
	
		
			
				|  |  | +  Toast
 | 
	
		
			
				|  |  | +} from 'vant'
 | 
	
		
			
				|  |  | +import { computed, defineComponent, onMounted, reactive } from 'vue'
 | 
	
		
			
				|  |  |  import styles from './index.module.less'
 | 
	
		
			
				|  |  |  import iconLook from './image/look.svg'
 | 
	
		
			
				|  |  |  import { useRoute, useRouter } from 'vue-router'
 | 
	
	
		
			
				|  | @@ -9,6 +20,8 @@ import OEmpty from '@/components/o-empty'
 | 
	
		
			
				|  |  |  import OSticky from '@/components/o-sticky'
 | 
	
		
			
				|  |  |  import OHeader from '@/components/o-header'
 | 
	
		
			
				|  |  |  import CourseItem from './component/CourseItem'
 | 
	
		
			
				|  |  | +import { courseEmnu } from '@/constant'
 | 
	
		
			
				|  |  | +import { browser } from '@/helpers/utils'
 | 
	
		
			
				|  |  |  export default defineComponent({
 | 
	
		
			
				|  |  |    name: 'lessonCourseware',
 | 
	
		
			
				|  |  |    setup() {
 | 
	
	
		
			
				|  | @@ -16,12 +29,16 @@ export default defineComponent({
 | 
	
		
			
				|  |  |      const router = useRouter()
 | 
	
		
			
				|  |  |      const data = reactive({
 | 
	
		
			
				|  |  |        loading: true,
 | 
	
		
			
				|  |  | -      list: [] as any
 | 
	
		
			
				|  |  | +      list: [] as any,
 | 
	
		
			
				|  |  | +      actionShow: false,
 | 
	
		
			
				|  |  | +      actionName: '课程类型' as string | undefined,
 | 
	
		
			
				|  |  | +      actionKey: '',
 | 
	
		
			
				|  |  | +      showRight: route.query.code != 'select' && browser().isTeacher
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |      const filterData = (list: any[]) => {
 | 
	
		
			
				|  |  |        const schoolTerm = {}
 | 
	
		
			
				|  |  | -      for(let i = 0; i < list.length; i++){
 | 
	
		
			
				|  |  | -        if (schoolTerm[list[i].sortNo]){
 | 
	
		
			
				|  |  | +      for (let i = 0; i < list.length; i++) {
 | 
	
		
			
				|  |  | +        if (schoolTerm[list[i].sortNo]) {
 | 
	
		
			
				|  |  |            schoolTerm[list[i].sortNo].push(list[i])
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |            schoolTerm[list[i].sortNo] = [list[i]]
 | 
	
	
		
			
				|  | @@ -52,7 +69,10 @@ export default defineComponent({
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |            const res: any = await request.post(state.platformApi + '/courseSchedule/myCourseware')
 | 
	
		
			
				|  |  |            if (Array.isArray(res?.data)) {
 | 
	
		
			
				|  |  | -            data.list = filterData(res.data)
 | 
	
		
			
				|  |  | +            const _data = data.actionKey
 | 
	
		
			
				|  |  | +              ? res.data.filter((n: any) => n.courseTypeCode === data.actionKey)
 | 
	
		
			
				|  |  | +              : res.data
 | 
	
		
			
				|  |  | +            data.list = filterData(_data)
 | 
	
		
			
				|  |  |            }
 | 
	
		
			
				|  |  |          } catch (error) {}
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -80,8 +100,26 @@ export default defineComponent({
 | 
	
		
			
				|  |  |        })
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    const actions = computed(() => {
 | 
	
		
			
				|  |  | +      return Object.entries(courseEmnu).map(([key, value]) => {
 | 
	
		
			
				|  |  | +        return {
 | 
	
		
			
				|  |  | +          id: key,
 | 
	
		
			
				|  |  | +          name: value,
 | 
	
		
			
				|  |  | +          color: key === data.actionKey ? 'var(--van-primary)' : ''
 | 
	
		
			
				|  |  | +        } as ActionSheetAction
 | 
	
		
			
				|  |  | +      })
 | 
	
		
			
				|  |  | +    })
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const handleSelect = (action: any) => {
 | 
	
		
			
				|  |  | +      data.actionKey = action.id
 | 
	
		
			
				|  |  | +      data.actionName = action.name
 | 
	
		
			
				|  |  | +      data.actionShow = false
 | 
	
		
			
				|  |  | +      getList()
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      return () => (
 | 
	
		
			
				|  |  | -      <div class={[styles.lessonCourseware, !Object.values(data.list).length && 'emptyRootContainer']}>
 | 
	
		
			
				|  |  | +      <div
 | 
	
		
			
				|  |  | +        class={[styles.lessonCourseware, !Object.values(data.list).length && 'emptyRootContainer']}
 | 
	
		
			
				|  |  | +      >
 | 
	
		
			
				|  |  |          <OSticky
 | 
	
		
			
				|  |  |            onGetHeight={(height: number) => {
 | 
	
		
			
				|  |  |              document.documentElement.style.setProperty('--header-height', height + 'px')
 | 
	
	
		
			
				|  | @@ -92,13 +130,37 @@ export default defineComponent({
 | 
	
		
			
				|  |  |              background="rgba(255, 232, 206, 1)"
 | 
	
		
			
				|  |  |              color="rgba(124, 61, 18, 1)"
 | 
	
		
			
				|  |  |              title="我的教材"
 | 
	
		
			
				|  |  | -          />
 | 
	
		
			
				|  |  | +          >
 | 
	
		
			
				|  |  | +            {{
 | 
	
		
			
				|  |  | +              right: () => (
 | 
	
		
			
				|  |  | +                <>
 | 
	
		
			
				|  |  | +                  {data.showRight && (
 | 
	
		
			
				|  |  | +                    <div class={styles.filter} onClick={() => (data.actionShow = true)}>
 | 
	
		
			
				|  |  | +                      {data.actionName} <Icon style={{ transform: 'rotate(90deg)' }} name="play" />{' '}
 | 
	
		
			
				|  |  | +                    </div>
 | 
	
		
			
				|  |  | +                  )}
 | 
	
		
			
				|  |  | +                </>
 | 
	
		
			
				|  |  | +              )
 | 
	
		
			
				|  |  | +            }}
 | 
	
		
			
				|  |  | +          </OHeader>
 | 
	
		
			
				|  |  |          </OSticky>
 | 
	
		
			
				|  |  |          {Object.keys(data.list).map((key: any) => {
 | 
	
		
			
				|  |  | -          console.error(key)
 | 
	
		
			
				|  |  | -          return <CourseItem term={key} list={data.list[key]} onItemClick={(row) => handleClick(row)} />
 | 
	
		
			
				|  |  | +          return (
 | 
	
		
			
				|  |  | +            <CourseItem term={key} list={data.list[key]} onItemClick={(row) => handleClick(row)} />
 | 
	
		
			
				|  |  | +          )
 | 
	
		
			
				|  |  |          })}
 | 
	
		
			
				|  |  |          {!data.loading && !Object.values(data.list).length && <OEmpty tips="没有课件" />}
 | 
	
		
			
				|  |  | +        <ActionSheet
 | 
	
		
			
				|  |  | +          v-model:show={data.actionShow}
 | 
	
		
			
				|  |  | +          cancelText="全部课程类型"
 | 
	
		
			
				|  |  | +          actions={actions.value}
 | 
	
		
			
				|  |  | +          onCancel={() => {
 | 
	
		
			
				|  |  | +            data.actionKey = ''
 | 
	
		
			
				|  |  | +            data.actionName = '课程类型'
 | 
	
		
			
				|  |  | +            getList()
 | 
	
		
			
				|  |  | +          }}
 | 
	
		
			
				|  |  | +          onSelect={handleSelect}
 | 
	
		
			
				|  |  | +        />
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |      )
 | 
	
		
			
				|  |  |    }
 |