|
@@ -1,35 +1,16 @@
|
|
|
import { defineComponent, nextTick, onMounted, reactive, ref } from 'vue'
|
|
|
-import {
|
|
|
- Sticky,
|
|
|
- List,
|
|
|
- Popup,
|
|
|
- Icon,
|
|
|
- Switch,
|
|
|
- Tabs,
|
|
|
- Tab,
|
|
|
- DropdownMenu,
|
|
|
- DropdownItem,
|
|
|
- Tag
|
|
|
-} from 'vant'
|
|
|
+import { List, DropdownMenu, DropdownItem, Tag, Sticky, Button } from 'vant'
|
|
|
import Search from '@/components/col-search'
|
|
|
import request from '@/helpers/request'
|
|
|
-// import Item from './item'
|
|
|
-import SelectTag from '../search/select-tag'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import ColResult from '@/components/col-result'
|
|
|
import styles from './index.module.less'
|
|
|
import { getRandomKey } from '../music'
|
|
|
import { openDefaultWebView, state as baseState } from '@/state'
|
|
|
-import SelectSubject from '../search/select-subject'
|
|
|
import { SubjectEnum, useSubjectId } from '@/helpers/hooks'
|
|
|
import Song from '../component/song'
|
|
|
import ColHeader from '@/components/col-header'
|
|
|
-import { useRect } from '@vant/use'
|
|
|
-import { useAsyncState } from '@vueuse/core'
|
|
|
import bgImg from '../../images/bg-image.png'
|
|
|
-import iconSearch from './icons/icon_search.png'
|
|
|
-import iconFree from './icons/icon-free.png'
|
|
|
-import { browser } from '@/helpers/utils'
|
|
|
import TheSticky from '@/components/the-sticky'
|
|
|
|
|
|
const noop = () => {
|
|
@@ -39,18 +20,6 @@ const noop = () => {
|
|
|
export default defineComponent({
|
|
|
name: 'MusicList',
|
|
|
props: {
|
|
|
- hideSearch: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
- defauleParams: {
|
|
|
- type: Object,
|
|
|
- default: () => ({})
|
|
|
- },
|
|
|
- onItemClick: {
|
|
|
- type: Function,
|
|
|
- default: noop
|
|
|
- },
|
|
|
teacherId: {
|
|
|
type: String || Number,
|
|
|
default: ''
|
|
@@ -60,77 +29,24 @@ export default defineComponent({
|
|
|
default: false
|
|
|
}
|
|
|
},
|
|
|
- setup(
|
|
|
- { hideSearch, defauleParams, onItemClick, teacherId, myself },
|
|
|
- { expose }
|
|
|
- ) {
|
|
|
- const teacherDetaultSubject = ref({
|
|
|
- id: '',
|
|
|
- name: ''
|
|
|
- })
|
|
|
- if (baseState.platformType === 'TEACHER') {
|
|
|
- // defaultSubject
|
|
|
- const users = baseState.user.data
|
|
|
- teacherDetaultSubject.value = {
|
|
|
- name: users.defaultSubjectName || '全部声部',
|
|
|
- id: users.defaultSubject || ''
|
|
|
- }
|
|
|
- } else {
|
|
|
- const subjects: any = useSubjectId(SubjectEnum.SEARCH)
|
|
|
- // 判断是否已有数据
|
|
|
- if (!subjects.id) {
|
|
|
- const users = baseState.user.data
|
|
|
- const subjectId = users.subjectId
|
|
|
- ? Number(users.subjectId.split(',')[0])
|
|
|
- : ''
|
|
|
- const subjectName = users.subjectName
|
|
|
- ? users.subjectName.split(',')[0]
|
|
|
- : ''
|
|
|
- if (subjectId) {
|
|
|
- useSubjectId(
|
|
|
- SubjectEnum.SEARCH,
|
|
|
- JSON.stringify({
|
|
|
- id: subjectId,
|
|
|
- name: subjectName
|
|
|
- }),
|
|
|
- 'set'
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ setup({ onItemClick }, { expose }) {
|
|
|
localStorage.setItem('behaviorId', getRandomKey())
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
- const tempParams: any = {}
|
|
|
- if (baseState.version) {
|
|
|
- tempParams.version = baseState.version || '' // 处理ios审核版本
|
|
|
- tempParams.platform =
|
|
|
- baseState.platformType === 'STUDENT' ? 'ios-student' : 'ios-teacher'
|
|
|
- }
|
|
|
- // 判断是否在搜索页面用过
|
|
|
- if (!hideSearch) {
|
|
|
- if (baseState.platformType === 'TEACHER') {
|
|
|
- tempParams.subjectIds = teacherDetaultSubject.value.id
|
|
|
- } else {
|
|
|
- const getSubject: any = useSubjectId(SubjectEnum.SEARCH)
|
|
|
- tempParams.subjectIds = getSubject.id
|
|
|
- }
|
|
|
-
|
|
|
- // const getMusic: any = useSubjectId(SubjectEnum.MUSIC_FREE)
|
|
|
- }
|
|
|
//
|
|
|
const params = reactive({
|
|
|
search: (route.query.search as string) || '',
|
|
|
subjectType: (route.query.subjectType as string) || '',
|
|
|
page: 1,
|
|
|
- ...tempParams
|
|
|
+ subjectId: null,
|
|
|
+ level: '',
|
|
|
+ type: ''
|
|
|
})
|
|
|
- const subjectList = ref<any>([])
|
|
|
const data = ref<any>(null)
|
|
|
const loading = ref(false)
|
|
|
const finished = ref(false)
|
|
|
const isError = ref(false)
|
|
|
+ const searchObj = ref<any>({})
|
|
|
|
|
|
const apiSuffix = ref(
|
|
|
baseState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
|
|
@@ -144,9 +60,6 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
const FetchList = async () => {
|
|
|
- if (loading.value) {
|
|
|
- return
|
|
|
- }
|
|
|
loading.value = true
|
|
|
isError.value = false
|
|
|
const tempParams = {
|
|
@@ -160,7 +73,6 @@ export default defineComponent({
|
|
|
data: tempParams
|
|
|
}
|
|
|
)
|
|
|
- console.log(res, 'res')
|
|
|
if (data.value) {
|
|
|
const result = (data.value?.rows || []).concat(res.data.rows || [])
|
|
|
data.value.rows = result
|
|
@@ -174,70 +86,6 @@ export default defineComponent({
|
|
|
loading.value = false
|
|
|
}
|
|
|
|
|
|
- // 设置默认声部
|
|
|
- const setDefaultSubject = async (subjectId: any) => {
|
|
|
- try {
|
|
|
- await request.post('/api-teacher/teacher/defaultSubject', {
|
|
|
- params: {
|
|
|
- subjectId
|
|
|
- }
|
|
|
- })
|
|
|
- } catch {
|
|
|
- //
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const onComfirmSubject = item => {
|
|
|
- params.page = 1
|
|
|
- params.subjectIds = item.id
|
|
|
- data.value = null
|
|
|
- if (baseState.platformType === 'TEACHER') {
|
|
|
- teacherDetaultSubject.value = {
|
|
|
- name: item.name,
|
|
|
- id: item.id
|
|
|
- }
|
|
|
- setDefaultSubject(item.id)
|
|
|
- } else {
|
|
|
- subject.id = item.id
|
|
|
- subject.name = item.name
|
|
|
- useSubjectId(
|
|
|
- SubjectEnum.SEARCH,
|
|
|
- JSON.stringify({
|
|
|
- id: item.id,
|
|
|
- name: item.name
|
|
|
- }),
|
|
|
- 'set'
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- FetchList()
|
|
|
- subject.show = false
|
|
|
- }
|
|
|
-
|
|
|
- const getSubject: any = useSubjectId(SubjectEnum.SEARCH)
|
|
|
- const subject = reactive({
|
|
|
- show: false,
|
|
|
- name: getSubject.id ? getSubject.name : '全部声部',
|
|
|
- id: getSubject.id || ''
|
|
|
- })
|
|
|
-
|
|
|
- const getSubjectList = async () => {
|
|
|
- const { data } = await request.get(
|
|
|
- `${apiSuffix.value}/subject/subjectSelect?type=MUSIC`
|
|
|
- )
|
|
|
- if (Array.isArray(data)) {
|
|
|
- const subject: any = []
|
|
|
- data.forEach((item: any) => {
|
|
|
- if (item.subjects && item.subjects.length) {
|
|
|
- item.subjects.forEach(s => {
|
|
|
- subject.push(s)
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- subjectList.value = subject || []
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
const getSelectCondition = async () => {
|
|
|
const { data } = await request.post(
|
|
|
`${apiSuffix.value}/tenantAlbumMusic/selectCondition`,
|
|
@@ -247,7 +95,7 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
- console.log(data)
|
|
|
+ searchObj.value = data || {}
|
|
|
}
|
|
|
|
|
|
onMounted(async () => {
|
|
@@ -261,87 +109,190 @@ export default defineComponent({
|
|
|
} else if (params.subjectType === 'ENSEMBLE') {
|
|
|
document.title = '合奏练习'
|
|
|
}
|
|
|
- getSubjectList()
|
|
|
- getSelectCondition()
|
|
|
- })
|
|
|
-
|
|
|
- expose({
|
|
|
- onSearch,
|
|
|
- onComfirmSubject
|
|
|
+ loading.value = true
|
|
|
+ await getSelectCondition()
|
|
|
+ await FetchList()
|
|
|
})
|
|
|
|
|
|
return () => {
|
|
|
return (
|
|
|
<>
|
|
|
- {!hideSearch && (
|
|
|
- <div class={styles.sticky}>
|
|
|
- <TheSticky>
|
|
|
- <ColHeader
|
|
|
- background="transparent"
|
|
|
- isFixed={false}
|
|
|
- border={false}
|
|
|
- color="#131415"
|
|
|
- />
|
|
|
- <Search
|
|
|
- onSearch={onSearch}
|
|
|
- type="tenant"
|
|
|
- background="transparent"
|
|
|
- inputBackground="transparent"
|
|
|
- // leftIcon={iconSearch}
|
|
|
- v-slots={{
|
|
|
- left: () => (
|
|
|
- <DropdownMenu>
|
|
|
- <DropdownItem title="筛选">
|
|
|
- <div
|
|
|
- class={styles.searchResult}
|
|
|
- style={{ maxHeight: '45vh', overflowY: 'auto' }}
|
|
|
- >
|
|
|
- <div class={styles.searchTitle}>声部</div>
|
|
|
- <div
|
|
|
- class={[
|
|
|
- styles['radio-group'],
|
|
|
- styles.radio,
|
|
|
- styles['organ-radio']
|
|
|
- ]}
|
|
|
- >
|
|
|
- {subjectList.value.map((subject: any) => {
|
|
|
- const isActive =
|
|
|
- subject.id ===
|
|
|
- Number(params.subjectIds || null)
|
|
|
- const type = isActive ? 'primary' : 'default'
|
|
|
- return (
|
|
|
- <Tag
|
|
|
- size="large"
|
|
|
- plain={isActive}
|
|
|
- type={type}
|
|
|
- round
|
|
|
- onClick={() => {
|
|
|
- console.log(subject, '1212')
|
|
|
- // this.subject = { ...subject }
|
|
|
- }}
|
|
|
- >
|
|
|
- {subject.name}
|
|
|
- </Tag>
|
|
|
- )
|
|
|
- })}
|
|
|
+ <div class={styles.sticky}>
|
|
|
+ <TheSticky>
|
|
|
+ <ColHeader
|
|
|
+ background="transparent"
|
|
|
+ isFixed={false}
|
|
|
+ border={false}
|
|
|
+ color="#131415"
|
|
|
+ />
|
|
|
+ <Search
|
|
|
+ onSearch={onSearch}
|
|
|
+ type="tenant"
|
|
|
+ background="transparent"
|
|
|
+ inputBackground="transparent"
|
|
|
+ // leftIcon={iconSearch}
|
|
|
+ v-slots={{
|
|
|
+ left: () => (
|
|
|
+ <DropdownMenu>
|
|
|
+ <DropdownItem title="筛选">
|
|
|
+ <div
|
|
|
+ class={styles.searchResult}
|
|
|
+ style={{ maxHeight: '45vh', overflowY: 'auto' }}
|
|
|
+ >
|
|
|
+ {searchObj.value.subjects &&
|
|
|
+ searchObj.value.subjects.length > 0 && (
|
|
|
+ <>
|
|
|
+ <div class={styles.searchTitle}>声部</div>
|
|
|
+ <div
|
|
|
+ class={[
|
|
|
+ styles['radio-group'],
|
|
|
+ styles.radio,
|
|
|
+ styles['organ-radio']
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ {searchObj.value.subjects.map(
|
|
|
+ (subject: any) => {
|
|
|
+ const isActive =
|
|
|
+ subject.id ===
|
|
|
+ Number(params.subjectId || null)
|
|
|
+ const type = isActive
|
|
|
+ ? 'primary'
|
|
|
+ : 'default'
|
|
|
+ return (
|
|
|
+ <Tag
|
|
|
+ size="large"
|
|
|
+ plain={isActive}
|
|
|
+ type={type}
|
|
|
+ round
|
|
|
+ onClick={() => {
|
|
|
+ console.log(subject, '1212')
|
|
|
+ // this.subject = { ...subject }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {subject.name}
|
|
|
+ </Tag>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ {searchObj.value.levels &&
|
|
|
+ searchObj.value.levels.length > 0 && (
|
|
|
+ <>
|
|
|
+ <div class={styles.searchTitle}>级别</div>
|
|
|
+ <div
|
|
|
+ class={[
|
|
|
+ styles['radio-group'],
|
|
|
+ styles.radio,
|
|
|
+ styles['organ-radio']
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ {searchObj.value.levels.map(
|
|
|
+ (subject: any) => {
|
|
|
+ const isActive = subject === params.level
|
|
|
+ const type = isActive
|
|
|
+ ? 'primary'
|
|
|
+ : 'default'
|
|
|
+ return (
|
|
|
+ <Tag
|
|
|
+ size="large"
|
|
|
+ plain={isActive}
|
|
|
+ type={type}
|
|
|
+ round
|
|
|
+ onClick={() => {
|
|
|
+ console.log(subject, '1212')
|
|
|
+ // this.subject = { ...subject }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {subject}
|
|
|
+ </Tag>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ {searchObj.value.types &&
|
|
|
+ searchObj.value.types.length > 0 && (
|
|
|
+ <>
|
|
|
+ <div class={styles.searchTitle}>类型</div>
|
|
|
+ <div
|
|
|
+ class={[
|
|
|
+ styles['radio-group'],
|
|
|
+ styles.radio,
|
|
|
+ styles['organ-radio']
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ {searchObj.value.types.map((subject: any) => {
|
|
|
+ const isActive = subject === params.type
|
|
|
+ const type = isActive
|
|
|
+ ? 'primary'
|
|
|
+ : 'default'
|
|
|
+ return (
|
|
|
+ <Tag
|
|
|
+ size="large"
|
|
|
+ plain={isActive}
|
|
|
+ type={type}
|
|
|
+ round
|
|
|
+ onClick={() => {
|
|
|
+ console.log(subject, '1212')
|
|
|
+ // this.subject = { ...subject }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {subject}
|
|
|
+ </Tag>
|
|
|
+ )
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+
|
|
|
+ <Sticky position="bottom" offsetBottom={0}>
|
|
|
+ <div class={['btnGroup', 'btnMore']}>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ round
|
|
|
+ onClick={() => {
|
|
|
+ params.subjectId = null
|
|
|
+ params.level = ''
|
|
|
+ params.type = ''
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 重 置
|
|
|
+ </Button>
|
|
|
+
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ round
|
|
|
+ block
|
|
|
+ onClick={() => {
|
|
|
+ // this.onComfirm({ ...this.subject })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 确 认
|
|
|
+ </Button>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- </DropdownItem>
|
|
|
- </DropdownMenu>
|
|
|
- )
|
|
|
- }}
|
|
|
- />
|
|
|
- </TheSticky>
|
|
|
- <img class={styles.bgImg} src={bgImg} />
|
|
|
- </div>
|
|
|
- )}
|
|
|
+ </Sticky>
|
|
|
+ </div>
|
|
|
+ </DropdownItem>
|
|
|
+ </DropdownMenu>
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </TheSticky>
|
|
|
+ <img class={styles.bgImg} src={bgImg} />
|
|
|
+ </div>
|
|
|
+
|
|
|
<div class={styles.alumnList}>
|
|
|
<List
|
|
|
- loading={loading.value}
|
|
|
+ // loading={loading.value}
|
|
|
finished={finished.value}
|
|
|
finished-text={data.value && data.value.rows.length ? '' : ''}
|
|
|
onLoad={FetchList}
|
|
|
error={isError.value}
|
|
|
+ immediateCheck={false}
|
|
|
>
|
|
|
{data.value && data.value.rows.length ? (
|
|
|
<Song
|