提交 34690d24 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 优化考试页面

上级 0d3e3613
...@@ -102,7 +102,8 @@ export default { ...@@ -102,7 +102,8 @@ export default {
hasPagination: { type: Boolean, default: true }, hasPagination: { type: Boolean, default: true },
// 每页多少条数据 // 每页多少条数据
limit: { type: Number, default: 10 }, limit: { type: Number, default: 10 },
pagationLayout: { type: String, default: 'total, prev, pager, next, sizes, jumper' } pagationLayout: { type: String, default: 'total, prev, pager, next, sizes, jumper' },
isFilterChangeRoute: { type: Boolean, default: false }
}, },
data() { data() {
return { return {
...@@ -124,6 +125,16 @@ export default { ...@@ -124,6 +125,16 @@ export default {
handler(data) { handler(data) {
this.dataList = data this.dataList = data
} }
},
$route: {
immediate: true,
handler(route) {
if (this.isFilterChangeRoute) {
this.params = Object.assign({}, this.remote.params, route.query)
this.page.currentPage = parseInt(route.query.page) || 1
this.page.size = parseInt(route.query['per-page']) || this.limit
}
}
} }
}, },
computed: { computed: {
...@@ -132,7 +143,11 @@ export default { ...@@ -132,7 +143,11 @@ export default {
} }
}, },
methods: { methods: {
fetchList(isReset) { updateRoute(params) {
const query = Object.assign({}, this.$route.query, params)
this.$router.push({ path: this.$route.path, query })
},
fetchList(isReset, isInit) {
/** /**
* @param function httpRequest api接口 * @param function httpRequest api接口
* @param function beforeRequest 接口请求之前 * @param function beforeRequest 接口请求之前
...@@ -154,10 +169,14 @@ export default { ...@@ -154,10 +169,14 @@ export default {
if (beforeRequest) { if (beforeRequest) {
params = beforeRequest(params, isReset) params = beforeRequest(params, isReset)
} }
for (const key in params) { // for (const key in params) {
if (params[key] === '' || params[key] === undefined || params[key] === null) { // if (params[key] === '' || params[key] === undefined || params[key] === null) {
delete params[key] // delete params[key]
} // }
// }
if (this.isFilterChangeRoute && !isInit) {
this.updateRoute(params)
return
} }
this.loading = true this.loading = true
httpRequest(params) httpRequest(params)
...@@ -181,6 +200,7 @@ export default { ...@@ -181,6 +200,7 @@ export default {
}, },
// 重置 // 重置
reset() { reset() {
this.params = this.remote.params || {}
// 清空筛选条件 // 清空筛选条件
this.$refs.filterForm && this.$refs.filterForm.resetFields() this.$refs.filterForm && this.$refs.filterForm.resetFields()
// 初始化页码 // 初始化页码
...@@ -203,7 +223,7 @@ export default { ...@@ -203,7 +223,7 @@ export default {
} }
}, },
beforeMount() { beforeMount() {
this.fetchList() this.fetchList(false, true)
} }
} }
</script> </script>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<app-breadcrumb v-if="hasBreadcrumb"></app-breadcrumb> <app-breadcrumb v-if="hasBreadcrumb"></app-breadcrumb>
</div> </div>
<div class="app-main-container"> <div class="app-main-container">
<router-view></router-view> <router-view :key="$route.fullPath"></router-view>
</div> </div>
</div> </div>
</section> </section>
......
...@@ -74,6 +74,7 @@ export default { ...@@ -74,6 +74,7 @@ export default {
}, },
data() { data() {
return { return {
bc: null,
questionData: {}, questionData: {},
showComment: false, showComment: false,
comment: '' comment: ''
...@@ -98,6 +99,9 @@ export default { ...@@ -98,6 +99,9 @@ export default {
this.questionData = JSON.parse(JSON.stringify(this.question.item)) this.questionData = JSON.parse(JSON.stringify(this.question.item))
// if (this.questionType === 3) console.log(this.questionData) // if (this.questionType === 3) console.log(this.questionData)
}, },
destroyed() {
this.bc && this.bc.close()
},
methods: { methods: {
fetchComment() { fetchComment() {
const params = { const params = {
...@@ -113,6 +117,8 @@ export default { ...@@ -113,6 +117,8 @@ export default {
} else { } else {
this.$message.success('提交点评失败') this.$message.success('提交点评失败')
} }
this.bc = new BroadcastChannel('exam')
this.bc.postMessage({ action: 'refetch' })
}) })
} }
} }
......
...@@ -102,12 +102,14 @@ export default { ...@@ -102,12 +102,14 @@ export default {
multipleSelection: [], // 选择项 multipleSelection: [], // 选择项
dialogVisible: false, dialogVisible: false,
transferList: [], transferList: [],
transfer_exam_id: '' transfer_exam_id: '',
bc: null
} }
}, },
computed: { computed: {
tableOptions() { tableOptions() {
return { return {
isFilterChangeRoute: true,
remote: { remote: {
httpRequest: getExamPaperDetail, httpRequest: getExamPaperDetail,
params: { params: {
...@@ -288,6 +290,15 @@ export default { ...@@ -288,6 +290,15 @@ export default {
mounted() { mounted() {
// 获取转移列表 // 获取转移列表
this.getTransferList() this.getTransferList()
this.bc = new BroadcastChannel('exam')
this.bc.onmessage = ({ data }) => {
if (data.action === 'refetch') {
this.$refs.list.refetch()
}
}
},
destroyed() {
this.bc && this.bc.close()
} }
} }
</script> </script>
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
</div> </div>
<div style="text-align: center; margin-top: 15px"> <div style="text-align: center; margin-top: 15px">
<el-button size="mini" @click="cancel">取消</el-button> <el-button size="mini" @click="cancel">取消</el-button>
<el-button type="primary" size="mini" @click="submitUpload" style="margin-right: 5px"> 确认提交</el-button> <el-button type="primary" size="mini" :disabled="submitLoading" @click="submitUpload" style="margin-right: 5px">
确认提交</el-button
>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
...@@ -45,7 +47,8 @@ export default { ...@@ -45,7 +47,8 @@ export default {
}, },
data() { data() {
return { return {
fileList: [] fileList: [],
submitLoading: false
} }
}, },
computed: { computed: {
...@@ -64,12 +67,17 @@ export default { ...@@ -64,12 +67,17 @@ export default {
} }
}, },
fetchFileUpload(data) { fetchFileUpload(data) {
importQuestion(this.activeProject.tag, { file: data.file, exam_id: this.id }).then(res => { this.submitLoading = true
if (res.code === 0) { importQuestion(this.activeProject.tag, { file: data.file, exam_id: this.id })
this.$message.success('导入数据成功') .then(res => {
history.go(0) if (res.code === 0) {
} this.$message.success('导入数据成功')
}) history.go(0)
}
})
.finally(() => {
this.submitLoading = false
})
}, },
submitUpload() { submitUpload() {
this.$refs.upload.submit() this.$refs.upload.submit()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论