|
@@ -158,6 +158,23 @@ const selectedGrade = ref('')
|
|
|
|
|
|
|
|
// 添加抽屉显示状态
|
|
// 添加抽屉显示状态
|
|
|
const drawerVisible = ref(true)
|
|
const drawerVisible = ref(true)
|
|
|
|
|
+
|
|
|
|
|
+// 统一函数来获取课程大纲数据
|
|
|
|
|
+const fetchClassOutline = async (classId) => {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await ClassOutline(classId)
|
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
|
+ classOutlineData.value = res.data
|
|
|
|
|
+ classOutlineData.value.map((item, index) => {
|
|
|
|
|
+ item.ctTypeSort = index + 1
|
|
|
|
|
+ item.ctTypeSort = item.ctTypeSort > 9 ? item.ctTypeSort : "0" + item.ctTypeSort
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取课程大纲数据失败:', error)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 处理下拉菜单选择
|
|
// 处理下拉菜单选择
|
|
|
const handleGradeSelect = command => {
|
|
const handleGradeSelect = command => {
|
|
|
selectedGrade.value = command
|
|
selectedGrade.value = command
|
|
@@ -168,17 +185,8 @@ const handleGradeSelect = command => {
|
|
|
// 存储年级id
|
|
// 存储年级id
|
|
|
if (selectedItem) {
|
|
if (selectedItem) {
|
|
|
localStorage.setItem('selectedGradeId', selectedItem.id)
|
|
localStorage.setItem('selectedGradeId', selectedItem.id)
|
|
|
- }
|
|
|
|
|
- if (selectedItem) {
|
|
|
|
|
- ClassOutline(selectedItem.id).then(res => {
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- classOutlineData.value = res.data
|
|
|
|
|
- classOutlineData.value.map((item, index) => {
|
|
|
|
|
- item.ctTypeSort = index + 1
|
|
|
|
|
- item.ctTypeSort = item.ctTypeSort > 9 ? item.ctTypeSort : "0" + item.ctTypeSort
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // 获取课程大纲
|
|
|
|
|
+ fetchClassOutline(selectedItem.id)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 添加切换抽屉显示状态的函数
|
|
// 添加切换抽屉显示状态的函数
|
|
@@ -190,6 +198,8 @@ const classData = ref([])
|
|
|
// 添加接口返回的数据引用,用于存储 ClassOutline 结果
|
|
// 添加接口返回的数据引用,用于存储 ClassOutline 结果
|
|
|
const classOutlineData = ref([])
|
|
const classOutlineData = ref([])
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const fetchCtTypes = async () => {
|
|
const fetchCtTypes = async () => {
|
|
|
try {
|
|
try {
|
|
|
const response = await ClassList()
|
|
const response = await ClassList()
|
|
@@ -205,16 +215,8 @@ const fetchCtTypes = async () => {
|
|
|
classData.value.find(item => item.ctType === selectedGrade.value) ||
|
|
classData.value.find(item => item.ctType === selectedGrade.value) ||
|
|
|
classData.value[0]
|
|
classData.value[0]
|
|
|
if (selectedItem) {
|
|
if (selectedItem) {
|
|
|
- ClassOutline(selectedItem.id).then(res => {
|
|
|
|
|
- console.log(res);
|
|
|
|
|
- if (res.code === 0) {
|
|
|
|
|
- classOutlineData.value = res.data
|
|
|
|
|
- classOutlineData.value.map((item, index) => {
|
|
|
|
|
- item.ctTypeSort = index + 1
|
|
|
|
|
- item.ctTypeSort = item.ctTypeSort > 9 ? item.ctTypeSort : "0" + item.ctTypeSort
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // 使用新函数获取课程大纲
|
|
|
|
|
+ fetchClassOutline(selectedItem.id)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (error) {
|
|
} catch (error) {
|