diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..cc78b20 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/src/api/examination.js b/src/api/examination.js index 2d0f406..2f0e9d0 100644 --- a/src/api/examination.js +++ b/src/api/examination.js @@ -28,6 +28,13 @@ const api = { method: 'post', data }) - } + }, + getExamGroupList: data => { // 获取试卷组别 + return service({ + url: '/exam/type', + method: 'get', + params:data + }) + }, } export default api diff --git a/src/utils/custom.js b/src/utils/custom.js index d52a88b..38702cf 100644 --- a/src/utils/custom.js +++ b/src/utils/custom.js @@ -107,7 +107,7 @@ const custom = { var m = time.getMonth()+1; var d = time.getDate(); const date = `${y}-${m}-${d}` - console.log(date) + // console.log(date) return date }, getSTdPerson(num) { diff --git a/src/view/course/courseCategory/index.vue b/src/view/course/courseCategory/index.vue index 8706b99..3047751 100644 --- a/src/view/course/courseCategory/index.vue +++ b/src/view/course/courseCategory/index.vue @@ -49,6 +49,9 @@ async function getSubjectList() { } } function addTreeFormatSubject(data) { + if(!data) { + return [] + } data.map( item => { item.label = item.name item.value = item.id diff --git a/src/view/examinationManage/components/groupPool.vue b/src/view/examinationManage/components/groupPool.vue index 92559bd..128cfd8 100644 --- a/src/view/examinationManage/components/groupPool.vue +++ b/src/view/examinationManage/components/groupPool.vue @@ -3,7 +3,8 @@ // import api from '@/api/course' // import com_api from '@/api/common' // import WarningBar from '@/components/warningBar/warningBar.vue' -import api from '@/api/course' +import _ from "lodash" +import api from '@/api/examination' import { ref, onMounted, watch, inject, nextTick } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import { useRouter, useRoute } from 'vue-router' @@ -12,76 +13,52 @@ const route = useRoute() import { useUserStore } from '@/pinia/modules/user' const userStore = useUserStore() // import chapterCom from '../components/chapter.vue' -const props = defineProps(['exam_types','exam_id','seleted_arr']) +const props = defineProps(['exam_types','exam_id']) const emit = defineEmits(['addFunc']) +// const history_num = ref('') // import { clients, getNowDate } from '@/utils' import custom from '@/utils/custom' // import { getToken } from '@/utils/auth' // 监听 watch(props,(val1,val2) => { - selected_exam_ids.value = val1.seleted_arr || [] - exam_types.value = val1.exam_types || [] + has_exam_types.value = _.cloneDeep(val1.exam_types) || [] }) // 变量 -const exam_types = ref([]) -const selected_exam_ids = ref(props.seleted_arr || []) -console.log(props.exam_types) -// const headers = ref({ Authorization: 'Bearer ' + getToken() }) +const has_exam_types = ref(_.cloneDeep(props.exam_types) || []) + const drawer = ref(false) const queryParams =ref({ page:1, pageSize:10, - version:'', - type:'', + term:'', + persons:'', + examId:'' }) -// const typeList = custom.getExercisesTypeList() const tableData =ref([]) const total = ref(0) -const course_ids = ref([]) +const dfVisible = ref(false) +const type_list = ref([]) // 生命周期 -const typeList = inject('typeList') -// console.log(typeList.value) -// const current_subject =getSubjectId(inject('current_subject')) -const current_subject_str = inject('current_subject') -const current_subject = ref(null) -watch(current_subject_str,(val1,val2) => { - console.log(val1) - queryParams.value.subject = getSubjectId(val1) - console.log(queryParams.value.subject) -}) -// queryParams.value.subject = current_subject onMounted(() => { - // console.log(headers.value) - // getCourseList() + queryParams.value.examId = props.exam_id + getExamGroupList() }) // 方法 -function getSubjectId(str) { - // console.log(str) - let s_id = null - for(let item of typeList.value) { - if(item.name === str) { - s_id = item.id - } - } - return s_id -} -async function getCourseList() { - const res = await api.getCourseList(queryParams.value) +async function getExamGroupList() { + const res = await api.getExamGroupList(queryParams.value) if(res.code === 0) { - tableData.value = res.data.records + type_list.value = res.data.records total.value = res.data.total - await nextTick() - toggleSelection(tableData.value) } } function chooseChapterChildExercises() { + has_exam_types.value = _.cloneDeep(props.exam_types) || [] drawer.value = true - // getCourseList() onSubmit() } function onSubmit() { queryParams.value.page = 1 - getCourseList() + getExamGroupList() } function onReset() { queryParams.value = { @@ -92,65 +69,165 @@ function onReset() { status:'', } } -const handleSelectionChange = (val) => { - course_ids.value = val -} function handleCurrentChange(val) { queryParams.value.page = val - getCourseList() + getExamGroupList() } function handleSizeChange(val) { queryParams.value.pageSize = val - getCourseList() -} -function addFunc() { - const list = course_ids.value.map((item,i) => { - return item.course_id - }) - emit('addFunc',list) - drawer.value = false + getExamGroupList() } + const multipleTableRef = ref(null) -const toggleSelection = (rows) => { // 判断是否被选中 - if (rows) { - rows.forEach((row) => { - if(selected_exam_ids.value.length>0 && selected_exam_ids.value.includes(row.course_id)) { - multipleTableRef.value.toggleRowSelection(row, true) +function closeDf() { + gform.value = {} + dfVisible.value = false +} +// 新增组别 +const rules = ref({ + persons: [{ required: true, message: '请输入报名人数', trigger: 'blur' }] +}) +const gform = ref({}) +const times = ref(1) +const dlTitle = ref('新增组别') +function addWindow() { + edit_flag.value = false + openWindow() +} +function openWindow() { + dfVisible.value = true +} +function oFunc(val) { + if(times.value+val<1 || times.value+val>9) { + return + } + else{ + times.value+=val + } +} +function checkFunc(row) { // 检查合法性 + let flag = true + for(let item of has_exam_types.value) { + if(item.persons == row.persons) { // 相同人数(级别) + if( item.expiry_date > Date.parse(new Date())) { // 没有过期 + flag = false + } + } + } + return flag +} +function assigntTermFunc() { // 赋值期数 + let term = 1 + for(let item of has_exam_types.value) { + if(item.persons == gform.value.persons) { // 相同人数(级别) + term++ + } + } + return term +} +function enterDb() { // 确认新增/编辑 + if(edit_flag.value) { // 编辑 + + } + else{ // 新增 + let f = checkFunc(gform.value) + if(!f) { // 有相同人数且没有过期,无法再次创建 + ElMessage.error('该级别组数已存在!') + return + } + } + if(!edit_flag.value) { // 新增 + gform.value.term = assigntTermFunc() + // 添加临时id + gform.value.temp_id = Date.parse(new Date()) + has_exam_types.value.push(_.cloneDeep(gform.value)) + type_list.value.push(_.cloneDeep(gform.value)) + } + else{ // 编辑 + if(gform.value.temp_id) { // 临时数据编辑 + for(let i=0; i - +