parent
b8a41a5e23
commit
3668825847
9 changed files with 689 additions and 295 deletions
@ -0,0 +1,34 @@ |
||||
export default { |
||||
difficults: [ |
||||
{ |
||||
id: 1, |
||||
name: '简单' |
||||
}, |
||||
{ |
||||
id: 2, |
||||
name: '普通' |
||||
}, |
||||
{ |
||||
id: 3, |
||||
name: '较难' |
||||
}, |
||||
{ |
||||
id: 4, |
||||
name: '难' |
||||
}, |
||||
], |
||||
paperTypes: [ |
||||
{ |
||||
id: 0, |
||||
name: '练习' |
||||
}, |
||||
{ |
||||
id: 1, |
||||
name: '考核' |
||||
}, |
||||
{ |
||||
id: 2, |
||||
name: '竞赛' |
||||
}, |
||||
], |
||||
} |
@ -0,0 +1,235 @@ |
||||
<template> |
||||
<!-- 理论考试选择试卷 --> |
||||
<div> |
||||
<el-dialog title="请选择试卷" :visible.sync="listVisible" width="1200px" :close-on-click-modal="false" |
||||
@closed="closeDia"> |
||||
<div class="tool"> |
||||
<ul class="filter"> |
||||
<li> |
||||
<label>搜索</label> |
||||
<el-input style="width: 250px;" placeholder="请输入模板名称" prefix-icon="el-icon-search" v-model="filter.keyWord" |
||||
clearable /> |
||||
</li> |
||||
</ul> |
||||
<div> |
||||
<el-button type="primary" @click="add">新增模板</el-button> |
||||
</div> |
||||
</div> |
||||
|
||||
<el-table :data="projects" class="table" stripe header-align="center"> |
||||
<el-table-column width="60" label="选择" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-radio v-model="scope.row.paperId" :label="scope.row.paperId"> </el-radio> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column> |
||||
<el-table-column prop="name" label="试卷名称" min-width="140" align="center"></el-table-column> |
||||
<el-table-column prop="questionCount" label="试题总数" align="center" min-width="70"></el-table-column> |
||||
<el-table-column prop="score" label="总分" align="center" min-width="70"></el-table-column> |
||||
<el-table-column prop="difficult" label="试卷难度" align="center" min-width="70" sortable="custom"> |
||||
<template slot-scope="scope">{{ difficults.find(e => e.id === scope.row.difficult) ? difficults.find(e => |
||||
e.id === scope.row.difficult).name : '' }}</template> |
||||
</el-table-column> |
||||
<el-table-column prop="suggestTime" label="建议用时" align="center" min-width="70"> |
||||
<template slot-scope="scope">{{ scope.row.suggestTime }}min</template> |
||||
</el-table-column> |
||||
<el-table-column prop="classificationPath" label="试卷分类" align="center" min-width="70" |
||||
show-overflow-tooltip></el-table-column> |
||||
<el-table-column label="建议用途" align="center" min-width="70"> |
||||
<template slot-scope="scope">{{ paperTypes.find(e => e.id === scope.row.paperType) ? paperTypes.find(e => |
||||
e.id === scope.row.paperType).name : '' }}</template> |
||||
</el-table-column> |
||||
<el-table-column prop="updateTime" label="最近编辑时间" align="center" width="170"></el-table-column> |
||||
<el-table-column prop="createUser" label="最近编辑人" align="center" width="110"></el-table-column> |
||||
</el-table> |
||||
<div class="pagination"> |
||||
<el-pagination background :page-size="pageSize" @current-change="handleCurrentChange" |
||||
layout="total,prev, pager, next" :total="total"></el-pagination> |
||||
</div> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button @click="selectQuesVisible = false">取消</el-button> |
||||
<el-button type="primary" :loading="submiting" @click="submit">确定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import Setting from '@/setting' |
||||
import Util from '@/libs/util' |
||||
import _ from 'lodash' |
||||
export default { |
||||
props: ['visible'], |
||||
data () { |
||||
return { |
||||
arabicToChinese: Util.arabicToChinese, |
||||
listVisible: false, |
||||
searchTimer: null, |
||||
questionTypes: [ |
||||
{ |
||||
name: '单选题' |
||||
}, |
||||
{ |
||||
name: '多选题' |
||||
}, |
||||
{ |
||||
name: '判断题' |
||||
}, |
||||
{ |
||||
name: '填空题' |
||||
}, |
||||
{ |
||||
name: '问答题' |
||||
}, |
||||
], |
||||
|
||||
filter: { |
||||
keyWord: '', |
||||
}, |
||||
list: [], |
||||
page: 1, |
||||
pageSize: 10, |
||||
total: 0, |
||||
submiting: false, |
||||
|
||||
}; |
||||
}, |
||||
watch: { |
||||
'filter.keyWord': function (val) { |
||||
clearTimeout(this.searchTimer) |
||||
this.searchTimer = setTimeout(this.initData, 500) |
||||
}, |
||||
visible () { |
||||
this.listVisible = this.visible |
||||
this.visible && this.getList() |
||||
} |
||||
}, |
||||
mounted () { |
||||
this.originForm = _.cloneDeep(this.form) |
||||
}, |
||||
methods: { |
||||
// 获取试卷列表 |
||||
async getList () { |
||||
try { |
||||
const res = await this.$post(this.api.examPaperList, { |
||||
pageNum: this.page, |
||||
pageSize: this.pageSize, |
||||
type: 1, |
||||
keyWord: this.keyword, |
||||
libraryId: this.systemId |
||||
}) |
||||
this.projects = res.pageList.records |
||||
this.total = res.pageList.total |
||||
} catch (e) { } |
||||
}, |
||||
// 切换页码 |
||||
currentChange (val) { |
||||
this.page = val |
||||
this.getList() |
||||
}, |
||||
initData () { |
||||
this.page = 1 |
||||
this.getList() |
||||
}, |
||||
// 新增 |
||||
add () { |
||||
this.form = _.cloneDeep(this.originForm) |
||||
this.detailVisible = true |
||||
}, |
||||
// 试卷大纲添加行 |
||||
addLine (i) { |
||||
this.form.paperOutline.splice(i + 1, 0, { |
||||
examQuestions: [], |
||||
outlineName: '', |
||||
questionNum: '', |
||||
questionType: '', |
||||
targetScore: '', |
||||
}) |
||||
}, |
||||
// 试卷大纲移除行 |
||||
delLine (i) { |
||||
this.form.paperOutline.length > 1 && this.form.paperOutline.splice(i, 1) |
||||
}, |
||||
// 使用模板 |
||||
async useTemplate (row) { |
||||
const data = await this.getDetail(row.templateId) |
||||
this.$parent.form.paperOutline = data.paperOutline |
||||
this.listVisible = false |
||||
}, |
||||
// 获取详情 |
||||
async getDetail (id) { |
||||
const res = await this.$get(this.api.templateDetails, { |
||||
id |
||||
}) |
||||
return res.template |
||||
}, |
||||
// 编辑 |
||||
async edit (row) { |
||||
this.detailVisible = true |
||||
const data = await this.getDetail(row.templateId) |
||||
this.form = data |
||||
}, |
||||
// 删除 |
||||
async del (row) { |
||||
try { |
||||
await this.$confirm(`确认要删除【${row.templateName}】吗?`, '提示', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning', |
||||
closeOnClickModal: false, |
||||
}) |
||||
await this.$post(this.api.deleteTemplate, { |
||||
ids: [row.templateId] |
||||
}) |
||||
Util.successMsg('删除成功') |
||||
this.getList() |
||||
} catch (e) { } |
||||
}, |
||||
// 提交 |
||||
async submit () { |
||||
if (this.submiting) return false |
||||
const { form } = this |
||||
if (!form.templateName) return Util.warningMsg('请输入模板名称') |
||||
let invalid = 0 |
||||
for (const e of form.paperOutline) { |
||||
if (!e.questionType) { |
||||
Util.warningMsg('请选择题型') |
||||
invalid = 1 |
||||
break |
||||
} |
||||
if (!e.questionNum) { |
||||
Util.warningMsg('请输入目标题数') |
||||
invalid = 1 |
||||
break |
||||
} |
||||
if (!e.targetScore) { |
||||
Util.warningMsg('请输入目标分值') |
||||
invalid = 1 |
||||
break |
||||
} |
||||
} |
||||
if (invalid) return false |
||||
this.submiting = true |
||||
form.createSource = 1 |
||||
form.questionNum = this.questionNum |
||||
form.totalScore = this.totalScore |
||||
form.outlineNum = form.paperOutline.length |
||||
form.questionType = [...new Set(form.paperOutline.map(e => e.questionType))].join('、') |
||||
try { |
||||
await this.$post(this.api.saveExamPaperTemplate, form) |
||||
Util.successMsg('保存成功') |
||||
this.detailVisible = false |
||||
this.submiting = false |
||||
this.getList() |
||||
} catch (e) { |
||||
this.submiting = false |
||||
} |
||||
}, |
||||
// 弹框关闭回调 |
||||
closeDia () { |
||||
this.$emit('update:visible', false) |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped></style> |
Loading…
Reference in new issue