|
@@ -4,7 +4,10 @@ import {
|
|
|
queryLessonCourseware_gym,
|
|
|
getLessonCoursewareCourseList_gym,
|
|
|
getMyCourseware_gyt,
|
|
|
- getMyCoursewareDetail_gyt
|
|
|
+ getMyCoursewareDetail_gyt,
|
|
|
+ getuyAlbumInfo_klx,
|
|
|
+ queryLessonCourseware_klx,
|
|
|
+ getLessonCoursewareCourseList_klx
|
|
|
} from "@/api/cloudTextbooks.api"
|
|
|
|
|
|
import { httpAjaxErrMsg, httpAjax } from "@/plugin/httpAjax"
|
|
@@ -29,14 +32,47 @@ export const useDataList = () => {
|
|
|
const userStoreHook = userStore()
|
|
|
const listData = shallowRef<listType>([])
|
|
|
let storeData: listType[number] = []
|
|
|
+ // 专辑
|
|
|
+ const albumId = ref("")
|
|
|
+ const albumOpt = shallowRef<{ value: string; label: string }[]>([])
|
|
|
const loading = ref(false)
|
|
|
let coursewareController: AbortController
|
|
|
|
|
|
function handleGetList() {
|
|
|
- userStoreHook.roles === "GYM" ? handleGetList_gym("", "") : handleGetList_gyt()
|
|
|
+ // GYM,GYT,KLX 区分 获取列表数据
|
|
|
+ if (userStoreHook.roles === "GYM") {
|
|
|
+ handleGetList_gym("", "")
|
|
|
+ } else if (userStoreHook.roles === "GYT") {
|
|
|
+ handleGetList_gyt()
|
|
|
+ } else if (userStoreHook.roles === "KLX") {
|
|
|
+ httpAjax(getuyAlbumInfo_klx).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ // 专辑赋值
|
|
|
+ albumOpt.value = (res.data || []).reduce((arr: any[], item: any) => {
|
|
|
+ if (item.coursewareCounts > 0) {
|
|
|
+ arr.push({
|
|
|
+ value: item.id,
|
|
|
+ label: item.name
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ }, [])
|
|
|
+ // 默认取第一个专辑
|
|
|
+ albumOpt.value.length && (albumId.value = albumOpt.value[0].value)
|
|
|
+ handleGetList_klx("", albumId.value, "")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
function handleListQuery(type: string, queryStr: string) {
|
|
|
- userStoreHook.roles === "GYM" ? handleQueryGetList_gym(type, queryStr) : handleQueryGetList_gyt(type, queryStr)
|
|
|
+ // GYM,GYT,KLX 区分 查询列表数据
|
|
|
+ if (userStoreHook.roles === "GYM") {
|
|
|
+ handleQueryGetList_gym(type, queryStr)
|
|
|
+ } else if (userStoreHook.roles === "GYT") {
|
|
|
+ handleQueryGetList_gyt(type, queryStr)
|
|
|
+ } else if (userStoreHook.roles === "KLX") {
|
|
|
+ handleQueryGetList_klx(type, albumId.value, queryStr)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 获取管乐团数据
|
|
@@ -107,8 +143,53 @@ export const useDataList = () => {
|
|
|
function handleQueryGetList_gym(type: string, queryStr: string) {
|
|
|
handleGetList_gym(type, queryStr)
|
|
|
}
|
|
|
-
|
|
|
- return { loading, listData, handleGetList, handleListQuery }
|
|
|
+ // 获取酷乐秀数据
|
|
|
+ function handleGetList_klx(type: string, albumId: string, queryStr: string) {
|
|
|
+ // 当没有专辑id时候 不查询
|
|
|
+ if (!albumId) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (coursewareController) {
|
|
|
+ coursewareController.abort()
|
|
|
+ }
|
|
|
+ coursewareController = new AbortController()
|
|
|
+ loading.value = true
|
|
|
+ httpAjax(queryLessonCourseware_klx, type, albumId, coursewareController).then(res => {
|
|
|
+ // 自己关闭的时候不取消加载
|
|
|
+ if (res.code === CODE_ERR_CANCELED) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ loading.value = false
|
|
|
+ if (res.code === 200) {
|
|
|
+ const data = (res.data?.rows || []).reduce((arr: any[], item: any) => {
|
|
|
+ if (queryStr ? item.musicSheetName.includes(queryStr) : true) {
|
|
|
+ arr.push({
|
|
|
+ name: item.musicSheetName,
|
|
|
+ type: item.subjectId,
|
|
|
+ img: item.titleImg,
|
|
|
+ id: item.id,
|
|
|
+ courseNum: item.courseNum
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return arr
|
|
|
+ }, [])
|
|
|
+ listData.value = chunkArray(data, 5)
|
|
|
+ } else {
|
|
|
+ if (res.code !== 511) {
|
|
|
+ ElMessage({
|
|
|
+ showClose: true,
|
|
|
+ message: res.message,
|
|
|
+ type: "error"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 管乐迷数据查询
|
|
|
+ function handleQueryGetList_klx(type: string, albumId: string, queryStr: string) {
|
|
|
+ handleGetList_klx(type, albumId, queryStr)
|
|
|
+ }
|
|
|
+ return { loading, listData, albumId, albumOpt, handleGetList, handleListQuery }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -131,7 +212,14 @@ export const useDataDetailList = () => {
|
|
|
return [data[0] || [], data[1] || []]
|
|
|
})
|
|
|
function handleGetDetailList(id: string) {
|
|
|
- userStoreHook.roles === "GYM" ? handleGetDetaList_gym(id) : handleGetDetailList_gyt(id)
|
|
|
+ // GYM,GYT,KLX 区分 查询详情列表
|
|
|
+ if (userStoreHook.roles === "GYM") {
|
|
|
+ handleGetDetaList_gym(id)
|
|
|
+ } else if (userStoreHook.roles === "GYT") {
|
|
|
+ handleGetDetailList_gyt(id)
|
|
|
+ } else if (userStoreHook.roles === "KLX") {
|
|
|
+ handleGetDetailList_klx(id)
|
|
|
+ }
|
|
|
}
|
|
|
function handlePage(type: "next" | "prev") {
|
|
|
type === "next" ? pageNum.value++ : pageNum.value--
|
|
@@ -170,7 +258,22 @@ export const useDataDetailList = () => {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+ // 获取酷乐秀
|
|
|
+ function handleGetDetailList_klx(id: string) {
|
|
|
+ loading.value = true
|
|
|
+ httpAjaxErrMsg(getLessonCoursewareCourseList_klx, id).then(res => {
|
|
|
+ loading.value = false
|
|
|
+ if (res.code === 200) {
|
|
|
+ const data = (res.data || []).map((item: any) => {
|
|
|
+ return {
|
|
|
+ name: item.coursewareDetailName,
|
|
|
+ id: item.coursewareDetailId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ listData.value = chunkArray(chunkArray(data, 7), 2)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
return {
|
|
|
handleGetDetailList,
|
|
|
loading,
|