提交 4018d931 authored 作者: matian's avatar matian

代码优化

上级 efec2dc5
......@@ -50,7 +50,7 @@
</template>
<script>
import { updateExam } from '../api'
import { updateExam, getExamPaperDetail } from '../api'
import VEditor from '@/components/tinymce/Index.vue'
export default {
components: { VEditor },
......@@ -81,23 +81,32 @@ export default {
end_time() {
return this.exam_time[1]
},
row() {
return JSON.parse(this.$route.query.row)
exam_id() {
return this.$route.query.exam_id
}
},
mounted() {
if (this.$route.query.isEdit === '2' && this.row) {
this.exam_time = [this.row.start_time, this.row.end_time]
this.name = this.row.name
this.config.enabled_before = this.row.config.enabled_before
this.config.enabled_after = this.row.config.enabled_after
this.config.before_login = this.row.config.before_login
this.config.after_login = this.row.config.after_login
this.config.welcome_message = this.row.config.welcome_message
this.config.waiting_message = this.row.config.waiting_message
if (this.$route.query.isEdit === '2' && this.exam_id) {
this.getDetailInfo()
}
},
methods: {
getDetailInfo() {
getExamPaperDetail({ id: this.exam_id }).then(res => {
console.log(res)
const detailList = res.data.exam_info
// this.exam_time = [detailList.start_time, detailList.end_time]
this.name = detailList.name
const config = JSON.parse(detailList.config)
this.config.enabled_before = config.enabled_before
this.config.enabled_after = config.enabled_after
this.config.before_login = config.before_login
this.config.after_login = config.after_login
this.config.welcome_message = config.welcome_message
this.config.waiting_message = config.waiting_message
})
},
// 下一步
nextStep() {
const params = {
name: this.name,
......@@ -124,7 +133,7 @@ export default {
},
saveExamInfo() {
const params = {
id: this.row.exam_id,
id: this.exam_id,
type: 'basic',
name: this.name,
start_time: this.start_time,
......
......@@ -26,7 +26,7 @@
</template>
<script>
import { getExamPaperList, updateExam } from '../api'
import { getExamPaperList, updateExam, getExamPaperDetail } from '../api'
export default {
data() {
return {
......@@ -54,7 +54,10 @@ export default {
this.ExamParerList.push({ label: b.paper_title, key: b.id })
return this.ExamParerList
}, [])
this.getCheckedExam()
// this.getCheckedExam()
if (this.$route.query.exam_id && this.$route.query.isEdit === '2') {
this.getDetailInfo() // 获取详情
}
})
},
lastStep() {
......@@ -80,23 +83,24 @@ export default {
this.$emit('getCheckPaperList', this.checkedArrs)
},
saveExamInfo() {
const params = { id: this.$route.query.id, type: 'paper', exam_paper: this.q.toString() }
const params = { id: this.$route.query.exam_id, type: 'paper', exam_paper: this.q.toString() }
updateExam(params).then(res => {
history.go(-1)
})
},
getCheckedExam() {
if (this.$route.query.papers) {
const papers = JSON.parse(this.$route.query.papers)
getDetailInfo() {
getExamPaperDetail({ id: this.$route.query.exam_id }).then(res => {
const parperList = res.data.exam_info.paper_list
console.log(parperList)
const arr = []
papers.forEach(element => {
parperList.forEach(element => {
const findItem = this.ExamParerList.find(item => {
return item.label === element
return item.label === element.paper_title
}).key
findItem && arr.push(findItem)
})
this.q = arr
}
})
}
},
mounted() {
......
......@@ -95,11 +95,7 @@ export default {
}
}
},
computed: {
row() {
return JSON.parse(this.$route.query.row)
}
},
methods: {
lastStep() {
this.$parent.$parent.lastStep()
......@@ -110,7 +106,7 @@ export default {
},
saveExamInfo() {
const params = {
id: JSON.parse(this.$route.query.row).exam_id,
id: this.$route.query.exam_id,
type: 'config',
config: {
enabled_ip_limit: this.config.enabled_ip_limit,
......@@ -131,7 +127,7 @@ export default {
},
getDetail() {
const params = {
id: JSON.parse(this.$route.query.row).exam_id
id: this.$route.query.exam_id
}
getExamPaperDetail(params).then(res => {
const config = JSON.parse(res.data.exam_info.config)
......@@ -149,7 +145,7 @@ export default {
}
},
mounted() {
if (this.$route.query.isEdit === '2' && JSON.parse(this.$route.query.row)) {
if (this.$route.query.isEdit === '2' && this.$route.query.exam_id) {
this.getDetail()
}
}
......
......@@ -135,7 +135,7 @@ export default {
},
getDetail() {
const params = {
id: JSON.parse(this.$route.query.row).exam_id
id: this.$route.query.exam_id
}
getExamPaperDetail(params).then(res => {
const list = JSON.parse(res.data.exam_info.config).info
......@@ -148,7 +148,7 @@ export default {
},
saveExamInfo() {
const params = {
id: JSON.parse(this.$route.query.row).exam_id,
id: this.$route.query.exam_id,
type: 'student',
config: {
info: {
......@@ -170,7 +170,7 @@ export default {
}
},
mounted() {
if (this.$route.query.isEdit === '2') {
if (this.$route.query.isEdit === '2' && this.$route.query.exam_id) {
this.getDetail()
}
}
......
......@@ -84,7 +84,7 @@ export default {
remote: {
httpRequest: getExamPaperDetail,
params: {
id: this.row.exam_id
id: this.exam_id
}
},
filters: [
......@@ -125,8 +125,8 @@ export default {
]
}
},
row() {
return JSON.parse(this.$route.query.row)
exam_id() {
return this.$route.query.exam_id
}
},
methods: {
......@@ -155,14 +155,14 @@ export default {
},
// 考试信息编辑
editExamInfo() {
this.$router.push({ path: 'baseInfo', query: { row: JSON.stringify(this.row), isEdit: '2' } })
this.$router.push({ path: 'baseInfo', query: { exam_id: this.exam_id, isEdit: '2' } })
},
// 考试试卷编辑
editExam() {
console.log(this.row)
this.$router.push({
path: 'checkPaper',
query: { papers: JSON.stringify(this.row.papers), isEdit: '2', id: this.row.exam_id }
query: { exam_id: this.exam_id, isEdit: '2' }
})
},
// 信息采集编辑
......@@ -170,7 +170,7 @@ export default {
this.$router.push({
path: 'personalInfo',
query: {
row: JSON.stringify(this.row),
exam_id: this.exam_id,
isEdit: '2'
}
})
......@@ -180,7 +180,7 @@ export default {
this.$router.push({
path: 'examSetting',
query: {
row: JSON.stringify(this.row),
exam_id: this.exam_id,
isEdit: '2'
}
})
......@@ -196,7 +196,7 @@ export default {
// 导出明细
exportDetail() {
const params = {
id: this.row.exam_id,
id: this.exam_id,
name: '',
relation_status: '',
school: ''
......@@ -221,7 +221,7 @@ export default {
confirmButtonText: '确定'
}).then(() => {
const studentId = this.multipleSelection.map(item => item.student_id).toString()
const params = { exam_id: this.row.exam_id, students_id: studentId }
const params = { exam_id: this.exam_id, students_id: studentId }
sendMessage(params).then(res => {
this.$message.success('信息发送成功')
})
......@@ -229,7 +229,7 @@ export default {
},
// 获取转移考生列表
getTransferList() {
getTranserList({ exam_id: this.row.exam_id }).then(res => {
getTranserList({ exam_id: this.exam_id }).then(res => {
this.transferList = res.data.list
})
},
......@@ -237,7 +237,7 @@ export default {
transferStudent() {
const params = {
transfer_exam_id: this.transfer_exam_id,
exam_id: this.row.exam_id,
exam_id: this.exam_id,
student_ids: this.multipleSelection.map(item => item.student_id).toString()
}
transferStudent(params).then(res => {
......
......@@ -95,7 +95,7 @@ export default {
this.$router.push({
path: 'examDetail',
query: {
row: JSON.stringify(row)
exam_id: row.exam_id
}
})
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论