123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- // 处理 区分处理管乐迷 管乐团的数据
- import { queryTree_gym } from "@/api/cloudPractice.api"
- import { httpAjaxErrMsg, httpAjax } from "@/plugin/httpAjax"
- // import { CODE_ERR_CANCELED } from "@/libs/auth"
- // import { ElMessage } from "element-plus"
- import userStore from "@/store/modules/user"
- import { ref, shallowRef } from "vue"
- /**
- * 搜索数据
- */
- export const useDataSearchObj = () => {
- const userStoreHook = userStore()
- const loading = ref(false)
- // let coursewareController: AbortController
- const storeData = shallowRef<any[]>([])
- async function handleSearchList_gym() {
- loading.value = true
- await httpAjaxErrMsg(queryTree_gym).then(res => {
- loading.value = false
- if (res.code === 200) {
- storeData.value = res.data || []
- }
- })
- }
- function handleGetSearchList() {
- userStoreHook.roles === "GYM" ? handleSearchList_gym() : () => {}
- }
- return { loading, storeData, handleGetSearchList }
- }
- // type listType = {
- // type: string
- // name: string
- // img: string
- // id: string
- // courseNum: number // 课程数量
- // }[][]
- /**
- * 列表数据
- */
- // export const useDataList = () => {
- // const userStoreHook = userStore()
- // const listData = shallowRef<listType>([])
- // let storeData: listType[number] = []
- // const loading = ref(false)
- // let coursewareController: AbortController
- // function handleGetList() {
- // userStoreHook.roles === "GYM" ? handleGetList_gym("", "") : handleGetList_gyt()
- // }
- // function handleListQuery(type: string, queryStr: string) {
- // userStoreHook.roles === "GYM" ? handleQueryGetList_gym(type, queryStr) : handleQueryGetList_gyt(type, queryStr)
- // }
- // // 获取管乐团数据
- // function handleGetList_gyt() {
- // loading.value = true
- // httpAjaxErrMsg(getMyCourseware_gyt).then(res => {
- // loading.value = false
- // if (res.code === 200) {
- // storeData = (res.data || []).map((item: any) => {
- // return {
- // name: item.name,
- // type: item.courseTypeCode,
- // img: item.coverImg,
- // id: item.id,
- // courseNum: item.courseNum
- // }
- // })
- // listData.value = chunkArray(storeData, 5)
- // }
- // })
- // }
- // // 管乐团数据查询
- // function handleQueryGetList_gyt(type: string, queryStr: string) {
- // const computeData = storeData.filter(item => {
- // return (type ? item.type === type : true) && (queryStr ? item.name.includes(queryStr) : true)
- // })
- // listData.value = chunkArray(computeData, 5)
- // }
- // // 获取管乐迷数据
- // function handleGetList_gym(type: string, queryStr: string) {
- // if (coursewareController) {
- // coursewareController.abort()
- // }
- // coursewareController = new AbortController()
- // loading.value = true
- // httpAjax(queryLessonCourseware_gym, type, 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 ((type ? item.subjectId === type : true) && (queryStr ? item.name.includes(queryStr) : true)) {
- // arr.push({
- // name: item.name,
- // type: item.subjectId,
- // img: item.cover,
- // id: item.lessonCoursewareId,
- // 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_gym(type: string, queryStr: string) {
- // handleGetList_gym(type, queryStr)
- // }
- // return { loading, listData, handleGetList, handleListQuery }
- // }
- function chunkArray(array: any[], size: number) {
- const result = []
- for (let i = 0; i < array.length; i += size) {
- result.push(array.slice(i, i + size))
- }
- return result
- }
|