修改试卷组别逻辑

This commit is contained in:
axlrose2333 2023-03-02 17:58:55 +08:00
parent 5d38863f4d
commit 33b290c61f
6 changed files with 324 additions and 150 deletions

View File

@ -0,0 +1,15 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myValues">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="scss" />
</list>
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
</profile>
</component>

View File

@ -28,6 +28,13 @@ const api = {
method: 'post',
data
})
}
},
getExamGroupList: data => { // 获取试卷组别
return service({
url: '/exam/type',
method: 'get',
params:data
})
},
}
export default api

View File

@ -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) {

View File

@ -49,6 +49,9 @@ async function getSubjectList() {
}
}
function addTreeFormatSubject(data) {
if(!data) {
return []
}
data.map( item => {
item.label = item.name
item.value = item.id

View File

@ -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)
}
else{
multipleTableRef.value.toggleRowSelection(row, false)
}
})
} else {
multipleTableRef.value.clearSelection()
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 viewCourseFunc(row) { //
router.push({name:'viewCourse',params:{course_id:row.course_id}})
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<has_exam_types.value.length;i++ ) {
if(has_exam_types.value[i].temp_id && has_exam_types.value[i].temp_id === gform.value.temp_id) {
has_exam_types.value[i] = _.cloneDeep(gform.value)
break;
}
}
for(let i=0; i<type_list.value.length;i++ ) {
if(type_list.value[i].temp_id && type_list.value[i].temp_id === gform.value.temp_id) {
type_list.value[i] = _.cloneDeep(gform.value)
break;
}
}
}
else{ // id
for(let i=0; i<has_exam_types.value.length;i++ ) {
if(has_exam_types.value[i].exam_id === gform.value.exam_id) {
has_exam_types.value[i] = _.cloneDeep(gform.value)
break;
}
}
for(let i=0; i<type_list.value.length;i++ ) {
if(type_list.value[i].exam_id === gform.value.exam_id) {
type_list.value[i] = _.cloneDeep(gform.value)
break;
}
}
}
}
closeDf()
}
function addFunc() { //
emit('addFunc',has_exam_types.value)
drawer.value = false
}
function changeFunc() {
gform.value.first = gform.value.persons
gform.value.second = gform.value.persons*0.04
gform.value.third = gform.value.persons*0.01
}
const edit_flag = ref(false)
function editGroupFunc(row) {
dlTitle.value = '编辑组别'
edit_flag.value = true
gform.value = _.cloneDeep(row)
openWindow()
}
function delGroupFunc(row) { //
let del_index = -1
for(let i=0;i<has_exam_types.value.length;i++) {
if(has_exam_types.value[i].exam_type_id === row.exam_type_id) {
del_index = i;
break;
}
}
has_exam_types.value.splice(del_index,1)
// ==
let del_index2 = -1
for(let i=0;i<type_list.value.length;i++) {
if(type_list.value[i].exam_type_id === row.exam_type_id) {
del_index2 = i;
break;
}
}
type_list.value.splice(del_index2,1)
}
function close_draw() {
has_exam_types.value = _.cloneDeep(props.exam_types) || []
}
</script>
<template>
<div>
<el-button v-if="selected_exam_ids.length==0" size="small" @click="chooseChapterChildExercises">添加组别</el-button>
<el-button v-else size="small" @click="chooseChapterChildExercises" type="plain">点击查看已选{{selected_exam_ids.length}}</el-button>
<div v-if="url_name">{{url_name}}</div>
<el-drawer v-model="drawer" title="课程库" size="60%">
<el-button v-if="has_exam_types.length==0" size="small" @click="chooseChapterChildExercises">添加组别</el-button>
<el-button v-else size="small" @click="chooseChapterChildExercises" type="plain">点击查看已发布{{has_exam_types.length}}</el-button>
<el-drawer v-model="drawer" @close="close_draw" title="组别库" size="60%">
<div class="drawer-section">
<!-- 搜索框-->
<!-- 搜索框-->
<div class="search-box gva-btn-list">
<el-form ref="searchForm" :inline="true" :model="queryParams">
<!-- <el-form-item label="分组历史">-->
<!-- <el-select v-model="queryParams.subject" clearable placeholder="请选择">-->
<!-- <el-option-->
<!-- v-for="item in custom.getExamGroupType()"-->
<!-- :key="item.id"-->
<!-- :label="item.name"-->
<!-- :value="item.id"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="分组历史">
<el-input type="number" v-model="queryParams.term" placeholder="请输入分组历史期数" />
</el-form-item>
<el-form-item label="组别分类">
<el-select v-model="queryParams.type" clearable placeholder="请选择">
<el-select v-model="queryParams.persons" clearable placeholder="请选择">
<el-option
v-for="item in custom.getExamGroupType()"
:key="item.value"
@ -162,18 +239,13 @@ function viewCourseFunc(row) { // 查看课程
<el-form-item>
<el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
<el-button size="small" icon="refresh" @click="onReset">重置</el-button>
<el-button size="small" type="primary" icon="plus" @click="addWindow">新增</el-button>
</el-form-item>
</el-form>
</div>
<!-- 数据列表-->
<div class="list-box">
<el-table ref="multipleTableRef" :data="exam_types">
<!-- <el-table-column-->
<!-- type="selection"-->
<!-- width="55"-->
<!-- reserve-selection="true"-->
<!-- />-->
<!-- <el-table-column align="left" label="id" min-width="60" prop="exam_id" sortable="custom" />-->
<el-table ref="multipleTableRef" :data="type_list">
<el-table-column align="left" label="人数级别" min-width="150" prop="persons">
<template #default="scope">{{custom.getSTdPerson(scope.row.persons)}}</template>
</el-table-column>
@ -185,7 +257,7 @@ function viewCourseFunc(row) { // 查看课程
</el-table-column>
<el-table-column align="left" label="版本" min-width="150" prop="status">
<template #default="scope">
ver{{scope.row.version}}
{{scope.row.term}}
</template>
</el-table-column>
<el-table-column align="left" label="报名人数" min-width="150" prop="enroll_num" />
@ -193,12 +265,20 @@ function viewCourseFunc(row) { // 查看课程
<el-table-column align="left" fixed="right" label="操作" width="200">
<template #default="scope">
<el-button
icon="view"
icon="edit"
size="small"
type="primary"
link
@click="viewCourseFunc(scope.row)"
>查看</el-button>
@click="editGroupFunc(scope.row)"
>编辑</el-button>
<el-button
icon="delete"
size="small"
type="danger"
link
v-if="!checkFunc(scope.row)"
@click="delGroupFunc(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
@ -216,13 +296,91 @@ function viewCourseFunc(row) { // 查看课程
</div>
<!-- 按钮-->
<div class="btn-box" style="text-align: right">
<el-button size="small" type="primary" icon="plus" @click="addFunc">添加</el-button>
<el-button size="small" type="primary" @click="addFunc">确认</el-button>
</div>
</div>
</el-drawer>
<el-dialog v-model="dfVisible" :before-close="closeDf" :title="dlTitle">
<el-form ref="apiForm" :model="gform" :rules="rules" label-width="80px">
<el-form-item label="报名人数" >
<el-select @change="changeFunc" v-model="gform.persons" clearable placeholder="请选择">
<el-option
v-for="item in custom.getExamGroupType()"
:key="item.value"
:label="item.name"
:value="item.value"
/>
</el-select>
<div class="more-info-text" v-if="gform.persons">
第一名{{gform.first}}第二名{{gform.second}}第三名{{gform.third}}*满员参加的情况下
</div>
<!-- <div class="operator-box" >-->
<!-- <div class="ob-btn ob-reduce" @click="oFunc(-1)">-->
<!-- <el-icon color="#000"><Minus /></el-icon>-->
<!-- </div>-->
<!-- <div class="ob-input">-->
<!-- {{times}}-->
<!-- </div>-->
<!-- <div class="ob-btn ob-add" @click="oFunc(1)">-->
<!-- <el-icon color="#000"><Plus /></el-icon>-->
<!-- </div>-->
<!-- </div>-->
</el-form-item>
<el-form-item label="截止时间" >
<el-date-picker class="oi-item" style="margin-left:5px"
v-model="gform.expiry_date"
type="date"
placeholder="截至日期"
format="YYYY-MM-DD"
value-format="x"
/>
</el-form-item>
<el-form-item label="公开时间" >
<el-date-picker class="oi-item" style="margin-left:5px"
v-model="gform.public_date"
type="date"
placeholder="截至日期"
format="YYYY-MM-DD"
value-format="x"
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button size="small" @click="closeDf"> </el-button>
<el-button size="small" type="primary" @click="enterDb"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<style scoped>
<style>
.el-form-item{
margin-bottom: 18px !important;
}
</style>
<style lang="scss" scoped>
.more-info-text{
color: gray;
font-size: 12px;
margin: 0 10px;
}
.operator-box{
display: flex;
align-items: center;
border: 1px solid #dfdfdf;
border-radius: 5px;
margin-left: 10px;
.ob-btn{
padding: 0 5px;
background: #dfdfdf;
cursor: pointer;
}
.ob-input{
padding: 0 10px;
}
}
.drawer-section{
padding: 10px;
}

View File

@ -112,7 +112,6 @@ function openDialog(type) {
// router.push({name:'addCourse',params})
}
async function onDelete() {
// console.log(question_ids.value)
const ids = exam_ids.value
const res = await api.delExamination({ exam_ids:ids })
if (res.code === 0) {
@ -128,15 +127,12 @@ async function onDelete() {
}
}
const handleSelectionChange = (val) => {
// console.log(val)
exam_ids.value = val.map((item) => {
return item.exam.exam_id
})
// console.log(exam_ids.value)
}
const exam_id = ref(null)
function editCourseFunc(row) {
console.log(row)
// row.exam.course_ids = JSON.parse(row.exam.course_ids)
// row.exam.question_ids = JSON.parse(row.exam.question_ids)
exam_id.value = row.exam.exam_id
@ -155,7 +151,6 @@ function editCourseFunc(row) {
openDialog('edit')
}
function deleteExamFunc(row) {
// console.log(row); return
ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@ -189,7 +184,6 @@ function closeDialog(){
form.value = {}
}
async function enterDialog() { //
// console.log(Object.keys(std_group.value))
form.value.teacher_id = 0
form.value.exam_type = exam_types.value.map((item) => {
for(let prop in item) {
@ -208,7 +202,6 @@ async function enterDialog() { // 提交
}
params.question_ids = JSON.stringify(form.value.question_ids)
params.course_ids = JSON.stringify(form.value.course_ids)
// console.log(params)
// return
let func_name = 'addExamination'
if(form.value.exam_id) { //
@ -228,7 +221,6 @@ function viewCourseFunc(row) { // 查看课程
router.push({name:'viewCourse',params:{question_id:row.question_id}})
}
function getExercisesName(row) {
// console.log(JSON.parse(row.question))
return JSON.parse(row.question).title
}
// const std_options_title = ref(['A','B','C','D','E','F'])
@ -274,8 +266,8 @@ function addExercisesFunc(data) {
function addCourseFunc(data) {
form.value.course_ids = data
}
function addGroupFunc() {
function addGroupFunc(data) {
exam_types.value = _.clone(data)
}
</script>
<template>
@ -414,48 +406,47 @@ function addGroupFunc() {
<el-form-item label="测试时长" >
<el-input type="number" v-model="form.duration" placeholder="请输入测试时长(分钟)" />
</el-form-item>
<!-- <el-form-item label="测试组别" >-->
<!-- <div class="options-box" style="width: 100%">-->
<!-- <div class="option-item" v-if="exam_types.length>0" v-for="(item,i) in exam_types">-->
<!-- <el-form :model="item" >-->
<!-- <div class="oi-row">-->
<!-- <div class="oi-item">{{i+1}}</div>-->
<!-- <el-input class="oi-item" type="number" style="margin-left:5px;width: 30%" v-model="item.persons" placeholder="请输入组别人数" />-->
<!-- <el-date-picker class="oi-item" style="margin-left:5px"-->
<!-- v-model="item.expiry_date"-->
<!-- type="date"-->
<!-- placeholder="截至日期"-->
<!-- format="YYYY-MM-DD"-->
<!-- value-format="x"-->
<!-- />-->
<!-- <el-date-picker class="oi-item" style="margin-left:5px"-->
<!-- v-model="item.public_date"-->
<!-- type="date"-->
<!-- placeholder="成绩公布日期"-->
<!-- format="YYYY-MM-DD"-->
<!-- value-format="x"-->
<!-- />-->
<!-- <el-icon class="oi-item" style="margin-left: 5px;cursor: pointer" @click="delet_func(i)"><Delete /></el-icon>-->
<!-- </div>-->
<!-- <div class="reward-box">-->
<!-- <el-form-item class="rb-item" style="margin-right:10px;display: flex" label="第一名">-->
<!-- <el-input style="width:auto;margin-right: 5px" type="number" v-model="item.first" placeholder="请输入第一名奖励" /><div></div>-->
<!-- </el-form-item>-->
<!-- <el-form-item class="rb-item" style="margin-right:10px;" label="第二名">-->
<!-- <el-input style="width:auto;margin-right: 5px" type="number" v-model="item.second" placeholder="请输入第二名奖励" />-->
<!-- </el-form-item>-->
<!-- <el-form-item class="rb-item" style="margin-right:10px;" label="第三名">-->
<!-- <el-input style="width:auto;margin-right: 5px" type="number" v-model="item.third" placeholder="请输入第三名奖励" />-->
<!-- </el-form-item>-->
<!-- </div>-->
<!-- </el-form>-->
<!-- </div>-->
<!-- <el-button @click="addOptionFunc">添加组别</el-button>-->
<!-- </div>-->
<!-- </el-form-item>-->
<el-form-item label="测试组别" >
<!-- <el-input v-model="form.score" placeholder="请输入分值" />-->
<div class="options-box" style="width: 100%">
<div class="option-item" v-if="exam_types.length>0" v-for="(item,i) in exam_types">
<el-form :model="item" >
<div class="oi-row">
<div class="oi-item">{{i+1}}</div>
<el-input class="oi-item" type="number" style="margin-left:5px;width: 30%" v-model="item.persons" placeholder="请输入组别人数" />
<el-date-picker class="oi-item" style="margin-left:5px"
v-model="item.expiry_date"
type="date"
placeholder="截至日期"
format="YYYY-MM-DD"
value-format="x"
/>
<el-date-picker class="oi-item" style="margin-left:5px"
v-model="item.public_date"
type="date"
placeholder="成绩公布日期"
format="YYYY-MM-DD"
value-format="x"
/>
<el-icon class="oi-item" style="margin-left: 5px;cursor: pointer" @click="delet_func(i)"><Delete /></el-icon>
</div>
<div class="reward-box">
<el-form-item class="rb-item" style="margin-right:10px;display: flex" label="第一名">
<el-input style="width:auto;margin-right: 5px" type="number" v-model="item.first" placeholder="请输入第一名奖励" /><div></div>
</el-form-item>
<el-form-item class="rb-item" style="margin-right:10px;" label="第二名">
<el-input style="width:auto;margin-right: 5px" type="number" v-model="item.second" placeholder="请输入第二名奖励" />
</el-form-item>
<el-form-item class="rb-item" style="margin-right:10px;" label="第三名">
<el-input style="width:auto;margin-right: 5px" type="number" v-model="item.third" placeholder="请输入第三名奖励" />
</el-form-item>
</div>
</el-form>
</div>
<el-button @click="addOptionFunc">添加组别</el-button>
</div>
</el-form-item>
<el-form-item label="测试组别" >
<groupPool @addFunc="addGroupFunc" :exam_types="exam_types" :exam_id="exam_id" :seleted_arr="exam_type_ids" />
<groupPool @addFunc="addGroupFunc" :exam_types="exam_types" :exam_id="form.exam_id" />
</el-form-item>
<el-form-item label="添加习题" >
<exercisesPool @addFunc="addExercisesFunc" :seleted_arr="form.question_ids" />