|
@@ -23,8 +23,22 @@
|
|
|
<a-button type="primary" @click="addPaper" style="width: 100px">选择试卷</a-button>
|
|
<a-button type="primary" @click="addPaper" style="width: 100px">选择试卷</a-button>
|
|
|
</a-input-group>
|
|
</a-input-group>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
- <a-form-item label="课程" name="chapterId">
|
|
|
|
|
- <a-select v-model:value="form.chapterId" placeholder="请选择课程(可选)" allowClear>
|
|
|
|
|
|
|
+ <a-form-item label="学期" name="semesterId">
|
|
|
|
|
+ <a-select v-model:value="form.semesterId" placeholder="请选择学期" allowClear @change="handleSemesterChange">
|
|
|
|
|
+ <a-select-option v-for="item in semesterList" :key="item.id" :value="item.id">
|
|
|
|
|
+ {{ item.name }}
|
|
|
|
|
+ </a-select-option>
|
|
|
|
|
+ </a-select>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ <a-form-item label="专业" name="majorId">
|
|
|
|
|
+ <a-select v-model:value="form.majorId" placeholder="请选择专业" allowClear @change="handleMajorChange">
|
|
|
|
|
+ <a-select-option v-for="item in majorList" :key="item.id" :value="item.id">
|
|
|
|
|
+ {{ item.majorName }}
|
|
|
|
|
+ </a-select-option>
|
|
|
|
|
+ </a-select>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ <a-form-item label="课程" name="courseId">
|
|
|
|
|
+ <a-select v-model:value="form.courseId" placeholder="请选择课程" allowClear :disabled="!form.majorId">
|
|
|
<a-select-option v-for="item in courseList" :key="item.courseId" :value="item.courseId">
|
|
<a-select-option v-for="item in courseList" :key="item.courseId" :value="item.courseId">
|
|
|
{{ item.courseName }}
|
|
{{ item.courseName }}
|
|
|
</a-select-option>
|
|
</a-select-option>
|
|
@@ -77,6 +91,7 @@
|
|
|
v-model:value="paperPage.queryParam.paperType"
|
|
v-model:value="paperPage.queryParam.paperType"
|
|
|
placeholder="请选择试卷类型"
|
|
placeholder="请选择试卷类型"
|
|
|
@change="paperTypeChange"
|
|
@change="paperTypeChange"
|
|
|
|
|
+ disabled
|
|
|
>
|
|
>
|
|
|
<a-select-option v-for="item in paperTypeEnum" :key="item.key" :value="item.key">
|
|
<a-select-option v-for="item in paperTypeEnum" :key="item.key" :value="item.key">
|
|
|
{{ item.value }}
|
|
{{ item.value }}
|
|
@@ -138,15 +153,19 @@
|
|
|
const { subjectEnumFormat } = examStore
|
|
const { subjectEnumFormat } = examStore
|
|
|
const paperTypeEnum = computed(() => examStore.paperTypeEnum)
|
|
const paperTypeEnum = computed(() => examStore.paperTypeEnum)
|
|
|
const formLoading = ref(false)
|
|
const formLoading = ref(false)
|
|
|
|
|
+ const semesterList = ref([])
|
|
|
|
|
+ const majorList = ref([])
|
|
|
const courseList = ref([])
|
|
const courseList = ref([])
|
|
|
const form = reactive({
|
|
const form = reactive({
|
|
|
id: null,
|
|
id: null,
|
|
|
examName: '',
|
|
examName: '',
|
|
|
paperId: null,
|
|
paperId: null,
|
|
|
- chapterId: null,
|
|
|
|
|
|
|
+ courseId: null,
|
|
|
startTime: null,
|
|
startTime: null,
|
|
|
endTime: null,
|
|
endTime: null,
|
|
|
- examStatus: 0
|
|
|
|
|
|
|
+ examStatus: 0,
|
|
|
|
|
+ semesterId: null,
|
|
|
|
|
+ majorId: null
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const rules = {
|
|
const rules = {
|
|
@@ -175,8 +194,8 @@
|
|
|
selectedPaper: null,
|
|
selectedPaper: null,
|
|
|
showDialog: false,
|
|
showDialog: false,
|
|
|
queryParam: {
|
|
queryParam: {
|
|
|
- subjectId: null,
|
|
|
|
|
- paperType: null,
|
|
|
|
|
|
|
+ paperId: null,
|
|
|
|
|
+ paperType: '6',
|
|
|
pageIndex: 1,
|
|
pageIndex: 1,
|
|
|
pageSize: 5
|
|
pageSize: 5
|
|
|
},
|
|
},
|
|
@@ -195,7 +214,52 @@
|
|
|
paperPage.selectedPaper = selectedRows[0] || null
|
|
paperPage.selectedPaper = selectedRows[0] || null
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+ // 学期变更处理函数
|
|
|
|
|
+ const handleSemesterChange = (value) => {
|
|
|
|
|
+ form.courseId = null
|
|
|
|
|
+ courseList.value = []
|
|
|
|
|
+
|
|
|
|
|
+ // 如果学期和专业都已选择,则查询课程列表
|
|
|
|
|
+ if (value && form.majorId) {
|
|
|
|
|
+ loadCourseList()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ // 专业变更处理函数
|
|
|
|
|
+ const handleMajorChange = (value) => {
|
|
|
|
|
+ form.courseId = null
|
|
|
|
|
+ courseList.value = []
|
|
|
|
|
+
|
|
|
|
|
+ // 如果学期和专业都已选择,则查询课程列表
|
|
|
|
|
+ if (value && form.semesterId) {
|
|
|
|
|
+ loadCourseList()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 加载课程列表
|
|
|
|
|
+ const loadCourseList = () => {
|
|
|
|
|
+ // 添加加载状态
|
|
|
|
|
+ const courseLoading = message.loading('正在加载课程列表...', 0)
|
|
|
|
|
+ // 根据选择的学期和专业加载课程列表
|
|
|
|
|
+ resourceAuditApi
|
|
|
|
|
+ .courseAllList({
|
|
|
|
|
+ semesterId: form.semesterId,
|
|
|
|
|
+ majorId: form.majorId
|
|
|
|
|
+ })
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ courseList.value = res.data
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.error('加载课程列表失败:' + (res.msg || '未知错误'))
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ message.error('加载课程列表失败:' + (err.message || '网络错误'))
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ courseLoading()
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
// 禁用开始时间大于今天的日期
|
|
// 禁用开始时间大于今天的日期
|
|
|
const disabledStartDate = (current) => {
|
|
const disabledStartDate = (current) => {
|
|
|
// 禁用大于今天的日期
|
|
// 禁用大于今天的日期
|
|
@@ -227,7 +291,7 @@
|
|
|
}
|
|
}
|
|
|
delete params.pageIndex
|
|
delete params.pageIndex
|
|
|
delete params.pageSize
|
|
delete params.pageSize
|
|
|
- const data = await examPaperApi.pageList(params)
|
|
|
|
|
|
|
+ const data = await examPaperApi.selectExamList(params)
|
|
|
const re = data
|
|
const re = data
|
|
|
paperPage.tableData = re.records
|
|
paperPage.tableData = re.records
|
|
|
paperPage.total = re.total
|
|
paperPage.total = re.total
|
|
@@ -296,12 +360,16 @@
|
|
|
form.id = lastId
|
|
form.id = lastId
|
|
|
form.examName = ''
|
|
form.examName = ''
|
|
|
form.paperId = null
|
|
form.paperId = null
|
|
|
- form.chapterId = null
|
|
|
|
|
|
|
+ form.semesterId = null // 重置学期
|
|
|
|
|
+ form.majorId = null // 重置专业
|
|
|
|
|
+ form.courseId = null
|
|
|
form.startTime = null
|
|
form.startTime = null
|
|
|
form.endTime = null
|
|
form.endTime = null
|
|
|
form.examStatus = 0
|
|
form.examStatus = 0
|
|
|
selectedPaperName.value = ''
|
|
selectedPaperName.value = ''
|
|
|
paperPage.queryParam.paperType = null
|
|
paperPage.queryParam.paperType = null
|
|
|
|
|
+ majorList.value = [] // 清空专业列表
|
|
|
|
|
+ courseList.value = [] // 清空课程列表
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 初始化
|
|
// 初始化
|
|
@@ -309,25 +377,70 @@
|
|
|
const id = props.id
|
|
const id = props.id
|
|
|
if (id && parseInt(id) !== 0) {
|
|
if (id && parseInt(id) !== 0) {
|
|
|
formLoading.value = true
|
|
formLoading.value = true
|
|
|
- examManagerApi.select(id).then((re) => {
|
|
|
|
|
- Object.assign(form, {
|
|
|
|
|
- ...re,
|
|
|
|
|
- startTime: re.startTime ? dayjs(re.startTime) : null,
|
|
|
|
|
- endTime: re.endTime ? dayjs(re.endTime) : null
|
|
|
|
|
|
|
+ examManagerApi
|
|
|
|
|
+ .select(id)
|
|
|
|
|
+ .then((re) => {
|
|
|
|
|
+ Object.assign(form, {
|
|
|
|
|
+ ...re,
|
|
|
|
|
+ startTime: re.startTime ? dayjs(re.startTime) : null,
|
|
|
|
|
+ endTime: re.endTime ? dayjs(re.endTime) : null
|
|
|
|
|
+ })
|
|
|
|
|
+ // 如果有试卷ID,需要获取试卷名称显示
|
|
|
|
|
+ if (re.paperId) {
|
|
|
|
|
+ paperPage.queryParam.paperId = re.paperId
|
|
|
|
|
+ // 这里可以根据需要调用接口获取试卷名称
|
|
|
|
|
+ examPaperApi.select(re.paperId).then((r) => {
|
|
|
|
|
+ selectedPaperName.value = r.name
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是编辑模式,需要根据已有数据加载相应的课程列表
|
|
|
|
|
+ if (re.semesterId && re.majorId) {
|
|
|
|
|
+ // 直接加载课程列表
|
|
|
|
|
+ loadCourseList()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ formLoading.value = false
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ message.error('加载考试信息失败:' + (err.message || '网络错误'))
|
|
|
|
|
+ formLoading.value = false
|
|
|
})
|
|
})
|
|
|
- // 如果有试卷ID,需要获取试卷名称显示
|
|
|
|
|
- if (re.paperId) {
|
|
|
|
|
- // 这里可以根据需要调用接口获取试卷名称
|
|
|
|
|
- selectedPaperName.value = '已选择试卷'
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 加载学期列表
|
|
|
|
|
+ const semesterLoading = message.loading('正在加载学期列表...', 0)
|
|
|
|
|
+ resourceAuditApi
|
|
|
|
|
+ .semesterDownList()
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ semesterList.value = res.data
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.error('加载学期列表失败:' + (res.msg || '未知错误'))
|
|
|
}
|
|
}
|
|
|
- formLoading.value = false
|
|
|
|
|
})
|
|
})
|
|
|
- }
|
|
|
|
|
- resourceAuditApi.courseAllList().then((re) => {
|
|
|
|
|
- if (re.code === 200) {
|
|
|
|
|
- courseList.value = re.data
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ message.error('加载学期列表失败:' + (err.message || '网络错误'))
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ semesterLoading()
|
|
|
|
|
+ })
|
|
|
|
|
+ // 加载专业
|
|
|
|
|
+ const majorLoading = message.loading('正在加载专业列表...', 0)
|
|
|
|
|
+ resourceAuditApi
|
|
|
|
|
+ .majordownList()
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ majorList.value = res.data
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.error('加载专业列表失败:' + (res.msg || '未知错误'))
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ message.error('加载专业列表失败:' + (err.message || '网络错误'))
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ majorLoading()
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|