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

代码优化

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