修改教师管理和试卷管理逻辑,优化手机端样式
This commit is contained in:
@@ -51,6 +51,7 @@ const content = ref(null)
|
||||
// const options = ref([]) // 答案选项数组
|
||||
const exam_types = ref([])
|
||||
const exam_ids = ref([])
|
||||
const price_props = ['first','second','third']
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
getExaminationList()
|
||||
@@ -58,6 +59,14 @@ onMounted(() => {
|
||||
})
|
||||
provide('subjectList', subjectList)
|
||||
provide('current_subject', current_subject)
|
||||
const std_group = ref({
|
||||
persons:'',
|
||||
expiry_date:'',
|
||||
public_date:'',
|
||||
first:'',
|
||||
second:'',
|
||||
third:''
|
||||
})
|
||||
// 方法
|
||||
async function getExaminationList() {
|
||||
const res = await api.getExaminationList(queryParams.value)
|
||||
@@ -131,7 +140,12 @@ function editCourseFunc(row) {
|
||||
form.value.course_ids = JSON.parse(row.exam.course_ids)
|
||||
form.value.question_ids = JSON.parse(row.exam.question_ids)
|
||||
exam_types.value = row.exam_types.map((item) => {
|
||||
return item.persons
|
||||
for(let prop in item) {
|
||||
if(price_props.includes(prop)) {
|
||||
item[prop] /= 100
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
current_subject.value = form.value.subject
|
||||
openDialog('edit')
|
||||
@@ -145,7 +159,7 @@ function deleteExamFunc(row) {
|
||||
})
|
||||
.then(async() => {
|
||||
const res = await api.delExamination({
|
||||
exam_ids:[row.exam_id]
|
||||
exam_ids:[row.exam.exam_id]
|
||||
})
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
@@ -171,18 +185,27 @@ 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) => {
|
||||
return item = parseInt(item)
|
||||
for(let prop in item) {
|
||||
if(Object.keys(std_group.value).includes(prop)) {
|
||||
item[prop] = Number(item[prop])
|
||||
if(price_props.includes(prop)) {
|
||||
item[prop] *= 100
|
||||
}
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
form.value.duration = parseInt(form.value.duration)
|
||||
// console.log(form.value,exam_types.value)
|
||||
// return
|
||||
const params = {
|
||||
...form.value
|
||||
}
|
||||
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) { // 编辑
|
||||
func_name = 'editExamination'
|
||||
@@ -206,10 +229,10 @@ function getExercisesName(row) {
|
||||
}
|
||||
// const std_options_title = ref(['A','B','C','D','E','F'])
|
||||
function addOptionFunc() {
|
||||
exam_types.value.push('')
|
||||
exam_types.value.push(_.cloneDeep(std_group.value))
|
||||
}
|
||||
function delet_func() {
|
||||
exam_types.value.pop()
|
||||
function delet_func(i) {
|
||||
exam_types.value.splice(i,1)
|
||||
}
|
||||
function getStateName(state) {
|
||||
let str = ''
|
||||
@@ -386,14 +409,43 @@ function addCourseFunc(data) {
|
||||
</el-form-item>
|
||||
<el-form-item label="测试组别" >
|
||||
<!-- <el-input v-model="form.score" placeholder="请输入分值" />-->
|
||||
<view class="options-box">
|
||||
<view class="option-item" v-if="exam_types.length>0" v-for="(item,i) in exam_types">
|
||||
<view>{{i+1}}</view>
|
||||
<el-input type="number" style="margin-left:5px" v-model="exam_types[i]" placeholder="请输入组别人数" />
|
||||
<el-icon style="margin-left: 5px;cursor: pointer" v-if="(i+1) == exam_types.length" @click="delet_func(item)"><Delete /></el-icon>
|
||||
</view>
|
||||
<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>
|
||||
</view>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="添加习题" >
|
||||
<exercisesPool @addFunc="addExercisesFunc" :seleted_arr="form.question_ids" />
|
||||
@@ -421,14 +473,24 @@ function addCourseFunc(data) {
|
||||
</div>
|
||||
</template>
|
||||
<style scoped lang="scss">
|
||||
.rb-item{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.e-img{
|
||||
width: 150px;
|
||||
height: 100px;
|
||||
}
|
||||
.option-item{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #ebebeb;
|
||||
margin-bottom: 10px;
|
||||
.oi-row{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
.oi-item{
|
||||
//color: red;
|
||||
}
|
||||
}
|
||||
}
|
||||
.button-box {
|
||||
padding: 10px 20px;
|
||||
|
Reference in New Issue
Block a user