修改试卷管理和积分管理逻辑

This commit is contained in:
axlrose2333 2023-03-01 18:02:47 +08:00
parent f9d865b615
commit 5d38863f4d
5 changed files with 296 additions and 4 deletions

View File

@ -4,4 +4,4 @@ VITE_CLI_PORT = 8080
VITE_SERVER_PORT = 8888
VITE_BASE_API = /api
#下方修改为你的线上ip
VITE_BASE_PATH = http://118.31.78.83
VITE_BASE_PATH = https://admin.api.gwkjxb.com

View File

@ -66,7 +66,58 @@ const custom = {
getProvinceName(province) {
if(province < 0 || !province) return ''
return cityList[province].name
},
getExamGroupType() {
return [
{
name:'1',
value:1
},
{
name:'10',
value:10
},{
name:'100',
value:100
},{
name:'1000',
value:1000
},
{
name:'1万',
value:10000
},
{
name:'10万',
value:100000
},
{
name:'100万',
value:1000000
},
{
name:'1000万',
value:10000000
},
]
},
timestampToDate(stamp) { // 时间戳转日期
var time = new Date(stamp);
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
const date = `${y}-${m}-${d}`
console.log(date)
return date
},
getSTdPerson(num) {
const flag = 10000
if(num<flag) {
return num
}
else{
return num/flag+'万'
}
}
}
export default custom

View File

@ -0,0 +1,229 @@
<script setup>
//
// import api from '@/api/course'
// import com_api from '@/api/common'
// import WarningBar from '@/components/warningBar/warningBar.vue'
import api from '@/api/course'
import { ref, onMounted, watch, inject, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
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 emit = defineEmits(['addFunc'])
// 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 || []
})
//
const exam_types = ref([])
const selected_exam_ids = ref(props.seleted_arr || [])
console.log(props.exam_types)
// const headers = ref({ Authorization: 'Bearer ' + getToken() })
const drawer = ref(false)
const queryParams =ref({
page:1,
pageSize:10,
version:'',
type:'',
})
// const typeList = custom.getExercisesTypeList()
const tableData =ref([])
const total = ref(0)
const course_ids = 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()
})
//
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)
if(res.code === 0) {
tableData.value = res.data.records
total.value = res.data.total
await nextTick()
toggleSelection(tableData.value)
}
}
function chooseChapterChildExercises() {
drawer.value = true
// getCourseList()
onSubmit()
}
function onSubmit() {
queryParams.value.page = 1
getCourseList()
}
function onReset() {
queryParams.value = {
page:1,
pageSize:10,
name:'',
subject:'',
status:'',
}
}
const handleSelectionChange = (val) => {
course_ids.value = val
}
function handleCurrentChange(val) {
queryParams.value.page = val
getCourseList()
}
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
}
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 viewCourseFunc(row) { //
router.push({name:'viewCourse',params:{course_id:row.course_id}})
}
</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%">
<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-select v-model="queryParams.type" clearable placeholder="请选择">
<el-option
v-for="item in custom.getExamGroupType()"
:key="item.value"
:label="item.name"
:value="item.value"
/>
</el-select>
</el-form-item>
<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-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-column align="left" label="人数级别" min-width="150" prop="persons">
<template #default="scope">{{custom.getSTdPerson(scope.row.persons)}}</template>
</el-table-column>
<el-table-column align="left" label="截止时间" min-width="150" prop="expiry_date">
<template #default="scope">{{custom.timestampToDate(scope.row.expiry_date)}}</template>
</el-table-column>
<el-table-column align="left" label="公开时间" min-width="150" prop="public_date">
<template #default="scope">{{custom.timestampToDate(scope.row.public_date)}}</template>
</el-table-column>
<el-table-column align="left" label="版本" min-width="150" prop="status">
<template #default="scope">
ver{{scope.row.version}}
</template>
</el-table-column>
<el-table-column align="left" label="报名人数" min-width="150" prop="enroll_num" />
<el-table-column align="left" label="提交人数" min-width="150" prop="finish_num" />
<el-table-column align="left" fixed="right" label="操作" width="200">
<template #default="scope">
<el-button
icon="view"
size="small"
type="primary"
link
@click="viewCourseFunc(scope.row)"
>查看</el-button>
</template>
</el-table-column>
</el-table>
<div class="gva-pagination">
<el-pagination
:current-page="queryParams.page"
:page-size="queryParams.pageSize"
:page-sizes="[10, 30, 50, 100]"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</div>
<!-- 按钮-->
<div class="btn-box" style="text-align: right">
<el-button size="small" type="primary" icon="plus" @click="addFunc">添加</el-button>
</div>
</div>
</el-drawer>
</div>
</template>
<style scoped>
.drawer-section{
padding: 10px;
}
</style>

View File

@ -11,6 +11,8 @@ import WarningBar from '@/components/warningBar/warningBar.vue'
// import ckEditor from '@/components/richText/ckEditor5.vue'
import coursePool from './components/coursePool.vue'
import exercisesPool from '@/view/course/components/exercisesPool.vue'
import groupPool from './components/groupPool.vue'
import {ref,onMounted,provide } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter, useRoute } from 'vue-router'
@ -52,6 +54,7 @@ const content = ref(null)
const exam_types = ref([])
const exam_ids = ref([])
const price_props = ['first','second','third']
const exam_type_ids = ref([])
//
onMounted(() => {
getExaminationList()
@ -131,11 +134,12 @@ const handleSelectionChange = (val) => {
})
// 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
form.value = _.cloneDeep(row.exam)
form.value.course_ids = JSON.parse(row.exam.course_ids)
form.value.question_ids = JSON.parse(row.exam.question_ids)
@ -269,6 +273,9 @@ function addExercisesFunc(data) {
}
function addCourseFunc(data) {
form.value.course_ids = data
}
function addGroupFunc() {
}
</script>
<template>
@ -447,6 +454,9 @@ function addCourseFunc(data) {
<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" />
</el-form-item>
<el-form-item label="添加习题" >
<exercisesPool @addFunc="addExercisesFunc" :seleted_arr="form.question_ids" />
</el-form-item>

View File

@ -116,7 +116,9 @@ function editCourseFunc(row) {
question_id.value = form.value.question_id
content.value = JSON.parse(form.value.question).title
question_form.value = JSON.parse(form.value.question)
console.log(question_form.value)
if(!question_form.value.options) {
question_form.value.options = []
}
openDialog('edit')
}
function deleteCourseFunc(row) {