试卷大纲模板

master
yujialong 7 months ago
parent 479aba93eb
commit 2ae0f95eaf
  1. 1
      src/api/index.js
  2. 2
      src/components/ueditor/index.vue
  3. 28
      src/libs/util.js
  4. 2
      src/pages/quesBank/index.vue
  5. 75
      src/pages/testPaper/detail/index.vue
  6. 174
      src/pages/testPaper/detail/manual.vue
  7. 236
      src/pages/testPaper/detail/template.vue
  8. 22
      src/pages/testPaperLibraryType/index.vue

@ -51,4 +51,5 @@ export default {
deleteTemplate: `/exam/exam/paperTemplate/deleteTemplate`,
examPaperTemplateList: `/exam/exam/paperTemplate/examPaperTemplateList`,
saveExamPaperTemplate: `/exam/exam/paperTemplate/saveExamPaperTemplate`,
templateDetails: `/exam/exam/paperTemplate/templateDetails`,
}

@ -43,8 +43,6 @@ export default {
},
methods: {
initEditor () {
console.log(44, UE.Editor.prototype.getActionUrl)
this.$nextTick(() => {
// eslint-disable-next-line no-undef
this.instance = UE.getEditor(this.randomId)

@ -106,6 +106,34 @@ const util = {
Message.closeAll();
return Message.error({ message, showClose: true, offset: (document.documentElement.clientHeight - 40) / 2, duration });
},
// 阿拉伯数字转化为中文数字
arabicToChinese (num) {
const arr1 = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
const arr2 = ['', '十', '百', '千', '万', '亿', '点', ''];
const a = `${num}`.replace(/(^0*)/g, '').split('.');
let k = 0;
let re = '';
for (let i = a[0].length - 1; i >= 0; i--) {
switch (k) {
case 0:
re = arr2[7] + re;
break;
case 4:
if (!new RegExp(`0{4}//d{${a[0].length - i - 1}}$`).test(a[0])) re = arr2[4] + re;
break;
case 8:
re = arr2[5] + re;
arr2[7] = arr2[5];
k = 0;
break;
default:
}
if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) == 0) re = arr1[0] + re;
if (a[0].charAt(i) != 0) re = arr1[a[0].charAt(i)] + arr2[k % 4] + re;
k++;
}
return num > 9 && num < 20 ? re.slice(1) : re;
}
};
export default util;

@ -91,7 +91,7 @@
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="quesBankVisible = false"> </el-button>
<el-button type="primary" @click="quesBankSubmit"> </el-button>
<el-button type="primary" v-loading="submiting" @click="quesBankSubmit"> </el-button>
</span>
</el-dialog>
</div>

@ -50,12 +50,13 @@
<div class="flex j-between m-b-20">
<p>默认模板</p>
<p>目标总题数30目标总分100</p>
<el-button type="primary" size="small" @click="showTemplate">选择大纲模板</el-button>
</div>
<el-table :data="form.paperOutline" stripe header-align="center" row-key="id">
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column prop="outlineName" label="大题" align="center" min-width="120"></el-table-column>
<el-table-column prop="outlineName" label="大题" align="center" min-width="120">
<template slot-scope="scope">{{ arabicToChinese(scope.$index + 1) }}大题</template>
</el-table-column>
<el-table-column prop="name" label="题型" align="center" min-width="120">
<template slot-scope="scope">
<el-select v-model="scope.row.questionType" placeholder="请选择题型">
@ -65,7 +66,7 @@
</el-table-column>
<el-table-column prop="name" label="目标题数" align="center" min-width="120">
<template slot-scope="scope">
<el-input placeholder="请输入目标题数" v-model="scope.row.questionNum" type="number" />
<el-input placeholder="请输入目标题数" v-model.number="scope.row.questionNum" type="number" />
</template>
</el-table-column>
<el-table-column prop="name" label="目标分值" align="center" min-width="120">
@ -80,6 +81,34 @@
</template>
</el-table-column>
</el-table>
<p class="m-t-10 m-b-20 text-right">目标总题数{{ questionCount }}目标总分{{ score }}</p>
<div class="line"></div>
<div class="flex j-between a-center">
<p>选择试题</p>
<div>
<el-button type="primary" @click="submit(0)">一键分配分值</el-button>
<el-button type="primary" @click="submit(1)">自动选题</el-button>
</div>
</div>
<ul class="ques">
<li v-for="(item, i) in form.paperOutline" :key="i">
<div class="top">
<div>
<span class="serial">{{ arabicToChinese(i + 1) }}大题</span>
<el-input placeholder="请输入大题名称" v-model="item.outlineName" />
</div>
<div>
<el-button type="primary" @click="submit(0)">一键分配分值</el-button>
<el-button type="primary" @click="submit(1)">批量添加</el-button>
<el-button type="danger" @click="submit(1)">批量删除试题</el-button>
</div>
</div>
<p class="sum">本大题共{{ item.questionNum }}小题{{ item.targetScore }}</p>
</li>
</ul>
</el-form>
<div class="btns">
@ -89,7 +118,7 @@
<el-button @click="back">取消</el-button>
</div>
<Template :visible="templateVisible" />
<Template :visible.sync="templateVisible" />
</div>
</template>
<script>
@ -115,6 +144,7 @@ export default {
headers: {
token: Util.local.get(Setting.tokenKey)
},
arabicToChinese: Util.arabicToChinese,
types: [],
cascaderValue: [],
cascaderProps: {
@ -187,9 +217,9 @@ export default {
paperType: '',
particularYear: '',
professionalId: '',
questionCount: '',
remarks: '',
score: '',
questionCount: 0,
suggestTime: '',
paperOutline: [
{
@ -249,6 +279,14 @@ export default {
templateVisible: false,
};
},
computed: {
questionCount () {
return this.form.paperOutline.reduce((e, j) => (e += +j.questionNum), 0)
},
score () {
return this.form.paperOutline.reduce((e, j) => (e += +j.targetScore), 0)
}
},
mounted () {
this.getType()
this.getProfessional()
@ -308,7 +346,7 @@ export default {
},
//
delLine (i) {
this.form.paperOutline.splice(i, 1)
this.form.paperOutline.length > 1 && this.form.paperOutline.splice(i, 1)
},
//
submit () {
@ -329,4 +367,29 @@ export default {
color: $main-color;
cursor: pointer;
}
.ques {
li {
padding: 15px;
margin: 20px 0 10px;
border: 1px solid #dbdbdb;
}
.top {
display: flex;
justify-content: space-between;
align-items: center;
}
.serial {
margin-right: 10px;
font-size: 13px;
}
.sum {
margin: 15px 0;
font-size: 13px;
color: $main-color;
}
}
</style>

@ -0,0 +1,174 @@
<template>
<div>
<el-dialog title="批量添加单选题" :visible.sync="quesVisible" 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="keyword"
clearable />
</li>
</ul>
<div>
<el-button type="primary" @click="add">新增模板</el-button>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="quesVisible = false">关闭</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 {
quesVisible: false,
keyword: '',
searchTimer: null,
submiting: false,
};
},
watch: {
'keyword': function (val) {
clearTimeout(this.searchTimer)
// this.searchTimer = setTimeout(this.initData, 500)
},
visible () {
this.quesVisible = this.visible
this.visible && this.getList()
}
},
mounted () {
},
methods: {
//
async getList () {
try {
const res = await this.$post(this.api.examPaperTemplateList, {
pageNum: this.page,
pageSize: this.pageSize,
...this.filter
})
this.list = res.pageList.records
this.total = res.pageList.total
} catch (e) { }
},
//
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.closeDia()
},
//
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>
.action-icon {
margin-right: 10px;
font-size: 18px;
color: $main-color;
cursor: pointer;
}
</style>

@ -1,18 +1,19 @@
<template>
<div>
<el-dialog title="选择试卷大纲模板" :visible.sync="listVisible" width="1000px" :close-on-click-modal="false">
<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-select v-model="form.questionType" clearable placeholder="请选择题目类型" @change="initData">
<el-select v-model="filter.questionType" clearable placeholder="请选择题目类型" @change="initData">
<el-option v-for="(item, i) in questionTypes" :key="i" :value="item.name"></el-option>
</el-select>
</li>
<li>
<label>搜索</label>
<el-input style="width: 250px;" placeholder="请输入模板名称" prefix-icon="el-icon-search"
v-model="form.templateName" clearable />
v-model="filter.templateName" clearable />
</li>
</ul>
<div>
@ -22,14 +23,14 @@
<el-table :data="list" stripe header-align="center" row-key="libraryId">
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column prop="libraryName" label="模板名称" align="center" min-width="120"></el-table-column>
<el-table-column prop="题型" label="题型" align="center" min-width="120"></el-table-column>
<el-table-column prop="libraryClassificationName" label="大题数" align="center" min-width="120"></el-table-column>
<el-table-column prop="examPaperNum" label="小题总数" align="center" width="100"></el-table-column>
<el-table-column prop="examPaperNum" label="总分" align="center" width="100"></el-table-column>
<el-table-column prop="createTime" label="创建时间" align="center" width="160" sortable="custom"></el-table-column>
<el-table-column prop="createUserName" label="创建人" align="center" width="100"></el-table-column>
<el-table-column label="操作" align="center" width="280">
<el-table-column prop="templateName" label="模板名称" align="center" min-width="100"></el-table-column>
<el-table-column prop="questionType" label="题型" align="center" min-width="140"></el-table-column>
<el-table-column prop="outlineNum" label="大题数" align="center" width="60"></el-table-column>
<el-table-column prop="questionNum" label="小题总数" align="center" width="80"></el-table-column>
<el-table-column prop="totalScore" label="总分" align="center" width="60"></el-table-column>
<el-table-column prop="createTime" label="创建时间" align="center" width="160"></el-table-column>
<el-table-column prop="createUser" label="创建人" align="center" width="80"></el-table-column>
<el-table-column label="操作" align="center" width="150">
<template slot-scope="scope">
<el-button type="text" @click="useTemplate(scope.row, 0)">使用模板</el-button>
<el-button type="text" @click="edit(scope.row, 1)">编辑</el-button>
@ -46,34 +47,46 @@
</span>
</el-dialog>
<el-dialog title="新增模板" :visible.sync="detailVisible" width="600px" :close-on-click-modal="false">
<el-dialog title="新增模板" :visible.sync="detailVisible" width="800px" :close-on-click-modal="false">
<el-form :model="form" :rules="rules" label-width="100px">
<el-form-item prop="userName" label="模板名称">
<el-input placeholder="请输入模板名称" prefix-icon="el-icon-search"
v-model="name" />
</el-form-item>
</el-form>
<el-form-item prop="templateName" label="模板名称">
<el-input placeholder="请输入模板名称" v-model="form.templateName" />
</el-form-item>
</el-form>
<el-table :data="list" stripe header-align="center" row-key="libraryId">
<el-table :data="form.paperOutline" stripe header-align="center" row-key="id">
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
<el-table-column prop="libraryName" label="模板名称" align="center" min-width="120"></el-table-column>
<el-table-column prop="题型" label="题型" align="center" min-width="120"></el-table-column>
<el-table-column prop="libraryClassificationName" label="大题数" align="center" min-width="120"></el-table-column>
<el-table-column prop="examPaperNum" label="小题总数" align="center" width="100"></el-table-column>
<el-table-column prop="examPaperNum" label="总分" align="center" width="100"></el-table-column>
<el-table-column prop="createTime" label="创建时间" align="center" width="160" sortable="custom"></el-table-column>
<el-table-column prop="createUserName" label="创建人" align="center" width="100"></el-table-column>
<el-table-column label="操作" align="center" width="280">
<el-table-column prop="outlineName" label="大题" align="center" min-width="120">
<template slot-scope="scope">{{ arabicToChinese(scope.$index + 1) }}大题</template>
</el-table-column>
<el-table-column prop="name" label="题型" align="center" min-width="120">
<template slot-scope="scope">
<el-button type="text" @click="useTemplate(scope.row, 0)">使用模板</el-button>
<el-button type="text" @click="edit(scope.row, 1)">编辑</el-button>
<el-button type="text" @click="del(scope.row)">删除</el-button>
<el-select v-model="scope.row.questionType" placeholder="请选择题型">
<el-option v-for="(item, i) in questionTypes" :key="i" :label="item.name" :value="item.id"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="name" label="目标题数" align="center" min-width="120">
<template slot-scope="scope">
<el-input placeholder="请输入目标题数" v-model="scope.row.questionNum" type="number" />
</template>
</el-table-column>
<el-table-column prop="name" label="目标分值" align="center" min-width="120">
<template slot-scope="scope">
<el-input placeholder="请输入目标分值" v-model="scope.row.targetScore" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="120">
<template slot-scope="scope">
<i class="el-icon-circle-plus-outline action-icon" @click="addLine(scope.$index)"></i>
<i class="el-icon-remove-outline action-icon" @click="delLine(scope.$index)"></i>
</template>
</el-table-column>
</el-table>
<p class="m-t-10 text-right">目标总题数{{ questionNum }}目标总分{{ totalScore }}</p>
<span slot="footer" class="dialog-footer">
<el-button @click="detailVisible = false">取消</el-button>
<el-button type="primary" @click="submit">保存模板</el-button>
<el-button type="primary" v-loading="submiting" @click="submit">保存模板</el-button>
</span>
</el-dialog>
</div>
@ -81,10 +94,12 @@
<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: [
@ -105,7 +120,7 @@ export default {
},
],
form: {
filter: {
templateName: '',
questionType: '',
},
@ -115,19 +130,76 @@ export default {
total: 0,
detailVisible: false,
originForm: {},
form: {
templateName: '',
paperOutline: [
{
examQuestions: [],
outlineName: '单选题',
questionNum: '',
questionType: '单选题',
targetScore: '',
},
{
examQuestions: [],
outlineName: '多选题',
questionNum: '',
questionType: '多选题',
targetScore: '',
},
{
examQuestions: [],
outlineName: '判断题',
questionNum: '',
questionType: '判断题',
targetScore: '',
},
{
examQuestions: [],
outlineName: '填空题',
questionNum: '',
questionType: '填空题',
targetScore: '',
},
{
examQuestions: [],
outlineName: '问答题',
questionNum: '',
questionType: '问答题',
targetScore: '',
},
],
},
rules: {
templateName: [
{ required: true, message: '请输入模板名称', trigger: 'blur' }
],
},
submiting: false,
};
},
computed: {
questionNum () {
return this.form.paperOutline.reduce((e, j) => (e += +j.questionNum), 0)
},
totalScore () {
return this.form.paperOutline.reduce((e, j) => (e += +j.targetScore), 0)
}
},
watch: {
'form.templateName': function (val) {
'filter.templateName': function (val) {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(this.initData, 500)
},
visible () {
this.listVisible = this.visible
this.visible && this.getList()
}
},
mounted () {
this.getList()
this.originForm = _.cloneDeep(this.form)
},
methods: {
//
@ -136,9 +208,9 @@ export default {
const res = await this.$post(this.api.examPaperTemplateList, {
pageNum: this.page,
pageSize: this.pageSize,
...this.form
...this.filter
})
this.types = res.pageList.records
this.list = res.pageList.records
this.total = res.pageList.total
} catch (e) { }
},
@ -153,27 +225,101 @@ export default {
},
//
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)
},
// 使
useTemplate (row) {
async useTemplate (row) {
const data = await this.getDetail(row.templateId)
this.$parent.form.paperOutline = data.paperOutline
this.closeDia()
},
//
async getDetail (id) {
const res = await this.$get(this.api.templateDetails, {
id
})
return res.template
},
//
edit (row) {
async edit (row) {
this.detailVisible = true
const data = await this.getDetail(row.templateId)
this.form = data
},
//
del (row) {
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
}
},
//
back () {
//
closeDia () {
this.$emit('update:visible', false)
}
}
};

@ -196,15 +196,19 @@ export default {
if (this.submiting) return false
const { form, parentId } = this
if (!form.libraryClassificationName) return Util.warningMsg('请输入试卷库分类名称')
this.submiting = true
if (parentId.length) form.parentId = parentId[parentId.length - 1]
// form.systemId = this.systemId
form.createSource = 1
await this.$post(this.api[form.libraryClassificationId ? 'libraryClassificationUpdate' : 'libraryClassificationSave'], form)
Util.successMsg('保存成功')
this.typeVisible = false
this.submiting = false
this.getData()
try {
this.submiting = true
if (parentId.length) form.parentId = parentId[parentId.length - 1]
// form.systemId = this.systemId
form.createSource = 1
await this.$post(this.api[form.libraryClassificationId ? 'libraryClassificationUpdate' : 'libraryClassificationSave'], form)
Util.successMsg('保存成功')
this.typeVisible = false
this.submiting = false
this.getData()
} catch (e) {
this.submiting = false
}
},
//
del (row) {

Loading…
Cancel
Save