|
@@ -35,27 +35,40 @@ export default defineComponent({
|
|
|
null
|
|
|
)
|
|
|
|
|
|
- const subjects: any = useSubjectId(SubjectEnum.SEARCH)
|
|
|
- // 判断是否已有数据
|
|
|
- if (!subjects.id) {
|
|
|
+ const teacherDetaultSubject = ref({
|
|
|
+ id: '',
|
|
|
+ name: ''
|
|
|
+ })
|
|
|
+ if (baseState.platformType === 'TEACHER') {
|
|
|
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'
|
|
|
- )
|
|
|
+ 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'
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
const router = useRouter()
|
|
|
const route = useRoute()
|
|
|
const tempParams: any = {}
|
|
@@ -66,8 +79,12 @@ export default defineComponent({
|
|
|
}
|
|
|
tempParams.myself = false
|
|
|
if (!hideSearch) {
|
|
|
- const getSubject: any = useSubjectId(SubjectEnum.SEARCH)
|
|
|
- tempParams.subjectIds = getSubject.id
|
|
|
+ if (baseState.platformType === 'TEACHER') {
|
|
|
+ tempParams.subjectIds = teacherDetaultSubject.value.id
|
|
|
+ } else {
|
|
|
+ const getSubject: any = useSubjectId(SubjectEnum.SEARCH)
|
|
|
+ tempParams.subjectIds = getSubject.id
|
|
|
+ }
|
|
|
}
|
|
|
const params = reactive({
|
|
|
search: (route.query.search as string) || '',
|
|
@@ -107,7 +124,7 @@ export default defineComponent({
|
|
|
}
|
|
|
})
|
|
|
if (data.value) {
|
|
|
- let result = (data.value?.rows || []).concat(res.data.rows || [])
|
|
|
+ const result = (data.value?.rows || []).concat(res.data.rows || [])
|
|
|
data.value.rows = result
|
|
|
}
|
|
|
data.value = data.value || res.data
|
|
@@ -119,6 +136,19 @@ export default defineComponent({
|
|
|
loading.value = false
|
|
|
}
|
|
|
|
|
|
+ // 设置默认声部
|
|
|
+ const setDefaultSubject = async (subjectId: any) => {
|
|
|
+ try {
|
|
|
+ await request.post('/api-teacher/teacher/defaultSubject', {
|
|
|
+ params: {
|
|
|
+ subjectId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const onComfirm = tags => {
|
|
|
const d = Object.values(tags).flat().filter(Boolean).join(',')
|
|
|
params.albumTagIds = d
|
|
@@ -131,17 +161,26 @@ export default defineComponent({
|
|
|
const onComfirmSubject = item => {
|
|
|
params.page = 1
|
|
|
params.subjectIds = item.id
|
|
|
- subject.id = item.id
|
|
|
- subject.name = item.name
|
|
|
+
|
|
|
data.value = null
|
|
|
- useSubjectId(
|
|
|
- SubjectEnum.SEARCH,
|
|
|
- JSON.stringify({
|
|
|
- id: item.id,
|
|
|
- name: item.name
|
|
|
- }),
|
|
|
- 'set'
|
|
|
- )
|
|
|
+ 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
|
|
|
}
|
|
@@ -184,7 +223,9 @@ export default defineComponent({
|
|
|
class={styles.label}
|
|
|
onClick={() => (subject.show = true)}
|
|
|
>
|
|
|
- {subject.name}
|
|
|
+ {baseState.platformType === 'TEACHER'
|
|
|
+ ? teacherDetaultSubject.value.name
|
|
|
+ : subject.name}
|
|
|
<Icon
|
|
|
classPrefix="iconfont"
|
|
|
name="down"
|
|
@@ -265,7 +306,11 @@ export default defineComponent({
|
|
|
>
|
|
|
<SelectSubject
|
|
|
type="ALBUM"
|
|
|
- searchParams={subject}
|
|
|
+ searchParams={
|
|
|
+ baseState.platformType === 'TEACHER'
|
|
|
+ ? teacherDetaultSubject.value
|
|
|
+ : subject
|
|
|
+ }
|
|
|
onComfirm={onComfirmSubject}
|
|
|
/>
|
|
|
</Popup>
|