|
@@ -61,10 +61,22 @@
|
|
|
</div>
|
|
</div>
|
|
|
<!-- 添加章节模态框 -->
|
|
<!-- 添加章节模态框 -->
|
|
|
<a-modal v-model:visible="modalVisible" :title="dialogTitle" @ok="handleOk" @cancel="handleCancel">
|
|
<a-modal v-model:visible="modalVisible" :title="dialogTitle" @ok="handleOk" @cancel="handleCancel">
|
|
|
- <a-form :model="formState">
|
|
|
|
|
- <a-form-item label="章节名称">
|
|
|
|
|
|
|
+ <a-form :model="formState" ref="formRef" :rules="rules" :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
|
|
|
|
|
+ <a-form-item label="章节名称" name="chapterName">
|
|
|
<a-input v-model:value="formState.chapterName" placeholder="请输入章节名称" />
|
|
<a-input v-model:value="formState.chapterName" placeholder="请输入章节名称" />
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
|
|
+ <a-form-item label="知识点" name="knowledgeIds">
|
|
|
|
|
+ <a-select
|
|
|
|
|
+ mode="multiple"
|
|
|
|
|
+ v-model:value="formState.knowledgeIds"
|
|
|
|
|
+ placeholder="请选择知识点"
|
|
|
|
|
+ style="width: 220px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <a-select-option v-for="(item, index) in knowledgeOptions" :key="index" :value="item.value"
|
|
|
|
|
+ >{{ item.label }}
|
|
|
|
|
+ </a-select-option>
|
|
|
|
|
+ </a-select>
|
|
|
|
|
+ </a-form-item>
|
|
|
</a-form>
|
|
</a-form>
|
|
|
</a-modal>
|
|
</a-modal>
|
|
|
<!-- 添加课时模态框 -->
|
|
<!-- 添加课时模态框 -->
|
|
@@ -78,12 +90,15 @@
|
|
|
import courseProductionApi from '@/api/courseCenter/courseProduction.js'
|
|
import courseProductionApi from '@/api/courseCenter/courseProduction.js'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { del, edit as editApi } from '@/api/hour/index'
|
|
import { del, edit as editApi } from '@/api/hour/index'
|
|
|
|
|
+ import tool from '@/utils/tool'
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
|
const popoverVisible = ref({})
|
|
const popoverVisible = ref({})
|
|
|
|
|
+ const formRef = ref(null)
|
|
|
const modeTag = ref('add')
|
|
const modeTag = ref('add')
|
|
|
const dialogTitle = ref('添加章节')
|
|
const dialogTitle = ref('添加章节')
|
|
|
|
|
+ const knowledgeOptions = tool.dictList('knowledge')
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
//课程id
|
|
//课程id
|
|
@@ -102,8 +117,6 @@
|
|
|
addDialogRef.value.edit(item)
|
|
addDialogRef.value.edit(item)
|
|
|
}
|
|
}
|
|
|
const handleDel = (item) => {
|
|
const handleDel = (item) => {
|
|
|
- console.log('删除', item)
|
|
|
|
|
-
|
|
|
|
|
del([{ id: item.id }]).then(() => {
|
|
del([{ id: item.id }]).then(() => {
|
|
|
getList()
|
|
getList()
|
|
|
})
|
|
})
|
|
@@ -116,8 +129,13 @@
|
|
|
// 表单状态
|
|
// 表单状态
|
|
|
const formState = reactive({
|
|
const formState = reactive({
|
|
|
id: '',
|
|
id: '',
|
|
|
- chapterName: ''
|
|
|
|
|
|
|
+ chapterName: undefined,
|
|
|
|
|
+ knowledgeIds: []
|
|
|
})
|
|
})
|
|
|
|
|
+ const rules = {
|
|
|
|
|
+ chapterName: [{ required: true, message: '请输入章节名称', trigger: 'blur' }],
|
|
|
|
|
+ knowledgeIds: [{ required: true, message: '请选择知识点', trigger: 'blur' }]
|
|
|
|
|
+ }
|
|
|
const pagination = reactive({
|
|
const pagination = reactive({
|
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
@@ -129,45 +147,49 @@
|
|
|
dialogTitle.value = '添加章节'
|
|
dialogTitle.value = '添加章节'
|
|
|
modeTag.value = 'add'
|
|
modeTag.value = 'add'
|
|
|
modalVisible.value = true
|
|
modalVisible.value = true
|
|
|
|
|
+
|
|
|
formState.chapterName = ''
|
|
formState.chapterName = ''
|
|
|
|
|
+ formState.knowledgeIds = []
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 确认按钮点击事件
|
|
// 确认按钮点击事件
|
|
|
const handleOk = () => {
|
|
const handleOk = () => {
|
|
|
- let courseInfoId = props.courseInfoId
|
|
|
|
|
- if (formState.chapterName && modeTag.value == 'add') {
|
|
|
|
|
- courseProductionApi
|
|
|
|
|
- .add({
|
|
|
|
|
- courseId: courseInfoId,
|
|
|
|
|
- name: formState.chapterName
|
|
|
|
|
- })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
- console.log(res, '章节添加')
|
|
|
|
|
- getList()
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- console.log(err)
|
|
|
|
|
- })
|
|
|
|
|
- formState.chapterName = '' // 清空表单
|
|
|
|
|
- modalVisible.value = false // 关闭模态框
|
|
|
|
|
- }
|
|
|
|
|
- if (formState.chapterName && modeTag.value == 'edit') {
|
|
|
|
|
- courseProductionApi
|
|
|
|
|
- .edit({
|
|
|
|
|
- id: formState.id,
|
|
|
|
|
- courseId: courseInfoId,
|
|
|
|
|
- name: formState.chapterName
|
|
|
|
|
- })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
- console.log(res, '章节添加')
|
|
|
|
|
- getList()
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- console.log(err)
|
|
|
|
|
- })
|
|
|
|
|
- formState.chapterName = '' // 清空表单
|
|
|
|
|
- modalVisible.value = false // 关闭模态框
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ formRef.value.validate().then(() => {
|
|
|
|
|
+ let courseInfoId = props.courseInfoId
|
|
|
|
|
+ if (formState.chapterName && modeTag.value == 'add') {
|
|
|
|
|
+ courseProductionApi
|
|
|
|
|
+ .add({
|
|
|
|
|
+ courseId: courseInfoId,
|
|
|
|
|
+ name: formState.chapterName,
|
|
|
|
|
+ knowledgeIds: formState.knowledgeIds
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ getList()
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ console.log(err)
|
|
|
|
|
+ })
|
|
|
|
|
+ formState.chapterName = '' // 清空表单
|
|
|
|
|
+ modalVisible.value = false // 关闭模态框
|
|
|
|
|
+ }
|
|
|
|
|
+ if (formState.chapterName && modeTag.value == 'edit') {
|
|
|
|
|
+ courseProductionApi
|
|
|
|
|
+ .edit({
|
|
|
|
|
+ id: formState.id,
|
|
|
|
|
+ courseId: courseInfoId,
|
|
|
|
|
+ name: formState.chapterName,
|
|
|
|
|
+ knowledgeIds: formState.knowledgeIds
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ getList()
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ console.log(err)
|
|
|
|
|
+ })
|
|
|
|
|
+ formState.chapterName = '' // 清空表单
|
|
|
|
|
+ modalVisible.value = false // 关闭模态框
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 取消按钮点击事件
|
|
// 取消按钮点击事件
|
|
@@ -182,8 +204,12 @@
|
|
|
modalVisible.value = true
|
|
modalVisible.value = true
|
|
|
dialogTitle.value = '修改章节'
|
|
dialogTitle.value = '修改章节'
|
|
|
modeTag.value = 'edit'
|
|
modeTag.value = 'edit'
|
|
|
|
|
+
|
|
|
|
|
+ formRef.value.resetFields()
|
|
|
|
|
+
|
|
|
formState.id = item.id
|
|
formState.id = item.id
|
|
|
formState.chapterName = item.name
|
|
formState.chapterName = item.name
|
|
|
|
|
+ formState.knowledgeIds = item.knowledeges
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 编辑课时
|
|
// 编辑课时
|
|
@@ -191,7 +217,6 @@
|
|
|
// 实现编辑逻辑
|
|
// 实现编辑逻辑
|
|
|
}
|
|
}
|
|
|
const delChapter = (chapterIndex) => {
|
|
const delChapter = (chapterIndex) => {
|
|
|
- console.log('删除', chapterIndex)
|
|
|
|
|
// 实现编辑逻辑
|
|
// 实现编辑逻辑
|
|
|
let item = chapters.value[chapterIndex]
|
|
let item = chapters.value[chapterIndex]
|
|
|
popoverVisible.value[chapterIndex] = false
|
|
popoverVisible.value[chapterIndex] = false
|
|
@@ -199,7 +224,6 @@
|
|
|
courseProductionApi
|
|
courseProductionApi
|
|
|
.delete([{ id: item.id }])
|
|
.delete([{ id: item.id }])
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- console.log('章节列表', res)
|
|
|
|
|
getList()
|
|
getList()
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
@@ -211,7 +235,6 @@
|
|
|
courseProductionApi
|
|
courseProductionApi
|
|
|
.allList({ courseId: props.courseInfoId })
|
|
.allList({ courseId: props.courseInfoId })
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- console.log('章节列表', res)
|
|
|
|
|
chapters.value = res.data
|
|
chapters.value = res.data
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
@@ -232,7 +255,6 @@
|
|
|
}
|
|
}
|
|
|
// 显示课时模态框
|
|
// 显示课时模态框
|
|
|
const onAddClassHoursOk = (data) => {
|
|
const onAddClassHoursOk = (data) => {
|
|
|
- console.log(data, 'onAddClassHoursOk')
|
|
|
|
|
// addLessonModalVisible.value = true
|
|
// addLessonModalVisible.value = true
|
|
|
}
|
|
}
|
|
|
const onAddChapter = () => {
|
|
const onAddChapter = () => {
|
|
@@ -244,11 +266,9 @@
|
|
|
if (newVal) {
|
|
if (newVal) {
|
|
|
getList()
|
|
getList()
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- { deep: true }
|
|
|
|
|
|
|
+ }
|
|
|
)
|
|
)
|
|
|
// onMounted(() => {
|
|
// onMounted(() => {
|
|
|
- // console.log('有没有id呢', props.courseInfoId)
|
|
|
|
|
// getList()
|
|
// getList()
|
|
|
// })
|
|
// })
|
|
|
</script>
|
|
</script>
|