Merge branch 'develop' of https://gitee.com/siwa-team/dawa-vue into develop

This commit is contained in:
Yuanjianghong 2021-11-12 14:16:16 +08:00
commit 5c3c8179c5
11 changed files with 648 additions and 174 deletions

View File

@ -0,0 +1,64 @@
import request from '@/utils/request'
const api = {
list: '/sys/dictionary/item/list',
findMaxValue: '/sys/dictionary/item/findMaxValue',
get: '/sys/dictionary/item/get',
add: '/sys/dictionary/item/add',
del: '/sys/dictionary/item/del',
edit: '/sys/dictionary/item/edit'
}
// 证书类型 列表
export function getCertificateTypeList(params) {
return request({
url: api.list,
method: 'get',
params: params
})
}
// 查询最大词典项值 列表
export function getCertificateTypeMaxValue(params) {
return request({
url: api.findMaxValue,
method: 'get',
params: params
})
}
// 根据ID查询证书类型 列表
export function getCertificateType(params) {
return request({
url: api.get,
method: 'post',
params: params
})
}
// 证书类型 新增
export function addCertificateType(params) {
return request({
url: api.add,
method: 'post',
data: params
})
}
// 证书类型 删除
export function delCertificateType(params) {
return request({
url: api.del,
method: 'post',
params: params
})
}
// 证书类型 修改
export function editCertificateType(params) {
return request({
url: api.edit,
method: 'post',
data: params
})
}

View File

@ -4,11 +4,12 @@ const questionApi = {
add: 'courseManagement/question/addOrUpdate',
get: '/courseManagement/question/details',
// update: 'sys/menu/update',
del: 'courseManagement/course/delete',
del: 'courseManagement/question/delete',
// updateStatus: 'sys/menu/updateStatus',
// list: '/courseManagement/course/listPage',
// coursewareList:'/courseManagement/course/courseware/details',
// questionList:'/courseManagement/course/questionList'
// questionList:'/courseManagement/course/questionList',
importTemplate: "courseManagement/question/importTemplate"
}
@ -54,5 +55,13 @@ export function getQuestionDeatil (params) {
})
}
// 题目批量导入
export function importTemplate (params) {
return request({
url: questionApi.importTemplate,
method: 'post',
params: params
})
}

View File

@ -1,7 +1,8 @@
import request from '@/utils/request'
const ossApi = {
list: '/sys/oss/list'
list: '/sys/oss/list',
upload: '/sys/oss/upload'
}
export function ossList (params) {
@ -11,3 +12,7 @@ export function ossList (params) {
params: params
})
}
export function ossUpload () {
return process.env.VUE_APP_API_BASE_URL + ossApi.upload;
}

View File

@ -0,0 +1,155 @@
<template>
<a-card :bordered="false" title="证书类型">
<template slot="extra">
<a-button size="small" @click="close">返回</a-button>
</template>
<div class="table-page-search-wrapper">
<div style="width: 100%; height: 32px; margin-bottom: 8px;">
<a-button type="primary" @click="addCertificateType()">新增证书类型</a-button>
</div>
</div>
<s-table ref="table" size="small" rowKey="id" :columns="columns" :data="loadData" :showPagination="false">
<template slot="action" slot-scope="text, record">
<a href="javascript:;" @click="edit(record)">编辑</a>
&nbsp;&nbsp;&nbsp;&nbsp;
<a-popconfirm title="确定要删除该证书类型?" ok-text="确认" cancel-text="取消" @confirm="del(record)">
<a href="javascript:;">删除</a>
</a-popconfirm>
</template>
</s-table>
<a-modal v-model="isAdd" :width="700" title="新增证书类型" ok-text="确认" cancel-text="取消" @ok="addCertificateTypeQR">
<a-form-model :model="addForm" :label-col="{span: 5}" :wrapper-col="{span: 19}">
<a-form-model-item label="证书类型名称" :rules="{ required: true, message: '请输入证书类型名称!' }">
<a-input v-model="addForm.name" />
</a-form-model-item>
</a-form-model>
</a-modal>
</a-card>
</template>
<script>
import { STable } from '@/components'
import { getCertificateTypeList, getCertificateType, getCertificateTypeMaxValue, addCertificateType, delCertificateType, editCertificateType } from '@/api/archives/certificate'
export default {
// import使
components: { STable },
props: {},
data() {
//
return {
isAdd: false,
addForm: {
name: ''
},
editForm: {},
queryParam: { dictionaryCode: '0001' },
columns: [
{ title: '证书类型', width: 'auto', align: 'center', dataIndex: 'name', key: 'name' },
{ title: '操作', width: '170px', key: 'operation', align: 'center', scopedSlots: { customRender: 'action' } }
],
loadData: parameter => { return getCertificateTypeList(Object.assign(parameter, this.queryParam)).then((res) => { return res.data; }); },
};
},
// data
computed: {},
// data
watch: {},
//
methods: {
//
close() {
this.$router.push({
path: '/archives/certificate/Index', query: {
}
});
},
//
addCertificateType() {
this.addForm.name = "";
this.isAdd = true;
},
addCertificateTypeQR() {
if (!this.addForm.name || this.addForm.name === '') {
this.$message.error("请输入证书类型名称!");
return;
}
// form
if (this.editForm.id) {
if (this.editForm.name === this.addForm.name) {
this.$message.success("证书类型名称与之前一致,不需要发起修改");
this.isAdd = false;
return;
}
this.editForm.name = this.addForm.name;
editCertificateType(this.editForm).then(res => {
this.$message.success("修改成功!");
this.editForm = {};
this.isAdd = false;
this.$refs.table.refresh(true);
});
return;
}
let certificateType = {};
certificateType.dictionaryCode = '0001';
certificateType.name = this.addForm.name;
certificateType.parentid = 0;
// value
getCertificateTypeMaxValue(certificateType).then(res => {
certificateType.value = res.data;
//
addCertificateType(certificateType).then(res => {
this.$message.success("新增成功!");
this.isAdd = false;
this.$refs.table.refresh(true);
});
});
},
//
edit(record) {
getCertificateType({ id: record.id }).then(res => {
this.isAdd = true;
this.addForm.name = res.data.name;
this.editForm = res.data;
});
},
//
del(record) {
delCertificateType({ ids: record.id, deleteReason: '' }).then(res => { this.$refs.table.refresh(true); });
}
},
// - 访this
created() { },
// - 访DOM
mounted() { },
// -
beforeCreate() { },
// -
beforeMount() { },
// -
beforeUpdate() { },
// -
updated() { },
// -
beforeDestroy() { },
// -
destroyed() { },
// keep-alive
activated() { }
};
</script>
<style scoped>
</style>

View File

@ -0,0 +1,81 @@
<template>
<a-card :bordered="false" title="证书档案">
<div class="table-page-search-wrapper">
<SearchCom :form="queryParam" :list="queryOptions" @search="handleRefresh" @reset="() => {queryParam = {}, handleRefresh()}"></SearchCom>
<div style="width: 100%; height: 32px; margin-bottom: 8px;">
<a-button type="primary" @click="editCertificateType()">编辑证书类型</a-button>
</div>
</div>
</a-card>
</template>
<script>
import { STable, SearchCom } from '@/components'
import { getCertificateTypeList } from '@/api/archives/certificate'
export default {
// import使
components: { STable, SearchCom },
props: {},
data() {
//
return {
queryParam: { orgId: '', name: '', type: '' },
type: []
};
},
// data
computed: {
queryOptions: function () {
return [
{ type: 'input', placeholder: '证书名称', key: 'name' },
{ type: 'select', placeholder: '培训种类', key: 'type', options: [{ id: '', name: '全部' }, ...this.type] },
]
},
},
// data
watch: {},
//
methods: {
//
editCertificateType() {
this.$router.push({
path: '/archives/certificate/CertificateType', query: {
}
});
}
},
// - 访this
created() {
//
getCertificateTypeList({ dictionaryCode: '0001' }).then(res => {
for (let index in res.data) {
let item = {};
item.id = res.data[index].value;
item.name = res.data[index].name;
this.type.push(item)
}
});
},
// - 访DOM
mounted() { },
// -
beforeCreate() { },
// -
beforeMount() { },
// -
beforeUpdate() { },
// -
updated() { },
// -
beforeDestroy() { },
// -
destroyed() { },
// keep-alive
activated() { }
};
</script>
<style scoped>
</style>

View File

@ -115,13 +115,15 @@ export default {
data() {
return {
dataValue: 1,
form: {},
form: {
coverPath:'',
},
personType: [
{ id: '1', name: '人员类别1' },
{ id: '2', name: '人员类别2' },
{ id: '3', name: '人员类别3' },
],
url:'',
previewVisible: false,
fileList: [],
previewImage :[
@ -147,7 +149,6 @@ export default {
}
},
methods: {
//
// getPersonType() {
// return dictGet(Object.assign(parameter)).then((res) => {
// return res
@ -171,7 +172,9 @@ export default {
//
goback(){
this.$router.push({path:"/course/CourseList",query:{} })
this.$router.push({path:"/course/CourseList",query:{
courseName:this.$route.query.courseName
} })
},
getToken() {
@ -195,6 +198,17 @@ export default {
},
handleChange({ fileList }) {
this.fileList = fileList;
console.log("fileList-------",fileList);
this.fileList.file=fileList[0];
console.log('file``````',this.fileList.file)
console.log('response``````',this.fileList.file.response.url)
this.form.coverPath = this.fileList.file.response.url;
console.log("url",this.form.coverPath)
},
},

View File

@ -1,87 +1,109 @@
<template>
<a-card :bordered="false" title="课程列表">
<div class="table-page-search-wrapper">
<SearchCom :form="queryParam" :list="queryOptions" @search="handleRefresh" @reset="() => {queryParam = {}, handleRefresh()}" ></SearchCom>
<div style="width: 100%; height: 32px; margin-bottom: 8px;">
<a-button type="primary" @click="courseAdd">新建课程</a-button>
</div>
<a-card :bordered="false" title="课程列表">
<div class="table-page-search-wrapper">
<SearchCom
:form="queryParam"
:list="queryOptions"
@search="handleRefresh"
@reset="
() => {
;(queryParam = {}), handleRefresh()
}
"
></SearchCom>
<div style="width: 100%; height: 32px; margin-bottom: 8px">
<a-button type="primary" @click="courseAdd">新建课程</a-button>
</div>
<s-table ref="table" size="default" rowKey="id" :columns="columns" :data="loadData" :pageNum="Number(this.$route.query.PageNum) || 1">
<template slot="action" slot-scope="text, record">
<a href="javascript:;" @click="detail(record)">详情</a>
<a-divider type="vertical" />
<a href="javascript:;" @click="courseWare(record)">课件</a>
<a-divider type="vertical" />
<a href="javascript:;" @click="courseWare(record)">课件预览</a>
<a-divider type="vertical" />
<a-popconfirm title="是否删除?" @confirm="() => del(record)">
<a href="javascript:;">删除</a>
</a-popconfirm>
<a-divider type="vertical" />
<a href="javascript:;" @click="courseQuestion(record)">题库</a>
</template>
</s-table>
</a-card>
</div>
<s-table
ref="table"
size="default"
rowKey="id"
:columns="columns"
:data="loadData"
:pageNum="Number(this.$route.query.PageNum) || 1"
>
<template slot="action" slot-scope="text, record">
<a href="javascript:;" @click="detail(record)">详情</a>
<a-divider type="vertical" />
<a href="javascript:;" @click="courseWare(record)">课件</a>
<a-divider type="vertical" />
<a href="javascript:;" @click="courseWare(record)">课件预览</a>
<a-divider type="vertical" />
<a-popconfirm title="是否删除?" @confirm="() => del(record)">
<a href="javascript:;">删除</a>
</a-popconfirm>
<a-divider type="vertical" />
<a href="javascript:;" @click="courseQuestion(record)">题库</a>
</template>
</s-table>
</a-card>
</template>
<script>
import { STable, SearchCom } from '@/components'
import { getCourseList,deleteCourse } from '@/api/course/course'
import { getCourseList, deleteCourse } from '@/api/course/course'
export default {
components: {
STable, SearchCom
STable,
SearchCom,
},
data() {
return {
queryParam: { courseName : this.$route.query.courseName || ''},//, orgId: this.$route.query.courseUserOrgId || ''
queryOptions: [
{ type: 'input', placeholder: '课程名称', key: 'courseName' },
],
loadData: parameter => {
return getCourseList(Object.assign(parameter, this.queryParam)).then(res => { return res });
queryParam: { courseName: this.$route.query.courseName || '' }, //, orgId: this.$route.query.courseUserOrgId || ''
queryOptions: [{ type: 'input', placeholder: '课程名称', key: 'courseName' }],
loadData: (parameter) => {
return getCourseList(Object.assign(parameter, this.queryParam)).then((res) => {
return res
})
},
columns: [
{ title: '课程编号', width: '160px', align: 'center', dataIndex: 'courseCode', key: 'courseCode' },
{ title: '课程名称', width: 'auto', align: 'center', dataIndex: 'courseName', key: 'courseName' },
{ title: '课时/分', width: '160px', align: 'center', dataIndex: 'hour', key: 'hour' },
{ title: '数量', width: '160px', align: 'center', dataIndex: 'questionCount', key: 'questionCount' },
{ title: '操作', key: 'operation', width: '300px', align: 'center', scopedSlots: { customRender: 'action' } }
{ title: '操作', key: 'operation', width: '300px', align: 'center', scopedSlots: { customRender: 'action' } },
],
}
},
created() {
},
created() {},
methods: {
handleRefresh () {
handleRefresh() {
this.$refs.table.refresh(true)
},
detail(record){
this.$router.push({ path: '/course/CourseDetail', query: { id: record.id } });
detail(record) {
this.$router.push({ path: '/course/CourseDetail', query: { id: record.id } })
},
courseWare(record){
this.$router.push({ path: '/course/CoursewareList', query: { id: record.id } });
courseWare(record) {
this.$router.push({ path: '/course/CoursewareList', query: { id: record.id } })
},
del(record){
deleteCourse({ids:record.id}).then(res => {
if(res.code == 200) this.$refs.table.refresh(true);
});
del(record) {
deleteCourse({ ids: record.id }).then((res) => {
if (res.code == 200) this.$refs.table.refresh(true)
})
},
//
courseAdd(){
this.$router.push({ path : '/course/CourseAdd' , query : {}})
courseAdd() {
this.$router.push({
path: '/course/CourseAdd',
query: {
courseName: this.queryParam.courseName
},
})
},
//
courseQuestion(record){
courseQuestion(record) {
this.$router.push({
path: '/course/question/QuestionList', query :{
id: record.id,
courseName : this.queryParam.courseName,
// courseUserOrgId : this.queryParam.orgId,
PageNum : this.$refs.table.localPagination.current
}});
path: '/course/question/QuestionList',
query: {
id: record.id,
courseName: this.queryParam.courseName,
pageNum: this.$refs.table.localPagination.current
},
})
},
},
}

View File

@ -1,5 +1,5 @@
<template>
<a-card :bordered="false" title="项目档案">
<a-card :bordered="false" title="课件信息">
<template slot="extra">
<a-button size="small" @click="goback">返回</a-button>
</template>

View File

@ -1,7 +1,6 @@
<template>
<page-header-wrapper :title="false">
<a-card :bordered="false">
<a-descriptions title="课程详情" layout="horizontal" bordered size="small" :column="1">
<a-card :bordered="false" title="课程详情">
<a-descriptions layout="horizontal" bordered size="small" :column="1">
<a-descriptions-item label="课程编号"> {{ detailData.courseCode }} </a-descriptions-item>
<a-descriptions-item label="课程名称"> {{ detailData.courseName }} </a-descriptions-item>
<a-descriptions-item label="课程类别"> {{ detailData.courseType }} </a-descriptions-item>
@ -15,7 +14,6 @@
<a-button type="primary" @click="edit"> 编辑 </a-button>
</div>
</a-card>
</page-header-wrapper>
</template>
<script>
import { getCourseDetails } from '@/api/course/course'

View File

@ -6,7 +6,7 @@
</template>
<a-tabs :animated="false" :default-active-key="tabKey" @change="callback" :headStyle="{ paddingTop: '0px' }">
<!-- 单选题 -->
<a-tab-pane key="1" tab="单选">
<a-tab-pane key="1" tab="单选" :disabled="radio.disabled">
<a-radio-group v-model="radio.rightAnswers" style="width: 100%">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="radio.questionName" style="width: 100%" />
@ -46,7 +46,7 @@
</a-tab-pane>
<!-- 多选题 -->
<a-tab-pane key="2" tab="多选">
<a-tab-pane key="2" tab="多选" :disabled="multiselect.disabled">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="multiselect.questionName" style="width: 100%" />
</a-card>
@ -84,7 +84,7 @@
</a-tab-pane>
<!-- 判断题 -->
<a-tab-pane key="3" tab="判断">
<a-tab-pane key="3" tab="判断" :disabled="estimate.disabled">
<a-radio-group v-model="estimate.rightAnswers" style="width: 100%">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="estimate.questionName" style="width: 100%" />
@ -92,8 +92,8 @@
<a-card :bordered="false">
<template slot="title">
选项从选项中选择一个作为答案<br />
<a-radio :value="1"> 正确 </a-radio>
<a-radio :value="2"> 错误 </a-radio>
<a-radio value="1"> 正确 </a-radio>
<a-radio value="2"> 错误 </a-radio>
</template>
</a-card>
<a-card title="答案解析" :bordered="false">
@ -103,7 +103,7 @@
</a-tab-pane>
<!-- 简答题 -->
<a-tab-pane key="4" tab="简答">
<a-tab-pane key="4" tab="简答" :disabled="shortAnswer.disabled">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="shortAnswer.questionName" style="width: 100%" />
</a-card>
@ -117,7 +117,7 @@
</a-tab-pane>
<!-- 填空题 -->
<a-tab-pane key="5" tab="填空">
<a-tab-pane key="5" tab="填空" :disabled="Completion.disabled">
<a-card title="题目(题干内容)" :bordered="false">
<a-textarea placeholder="" :rows="6" v-model="Completion.questionName" style="width: 100%" />
</a-card>
@ -126,8 +126,8 @@
<a-button type="primary" style="width: 40%" @click="addAnswerSize">添加一个新填空</a-button>
<a-button style="width: 40%" @click="delAnswerSize">刪除一个新填空</a-button>
</div>
<div v-for="(answer, index) in answerList" :key="index" style="margin-bottom: 10px">
<a-input :value="answerList[index]" @change="onChangeInput">
<div v-for="(answer, index) in Completion.answerList" :key="index" style="margin-bottom: 10px">
<a-input v-model="Completion.answerList[index]">
<template slot="addonBefore">
<b>填空{{ index+1 }}:</b>
</template>
@ -155,21 +155,39 @@ export default {
multiselect: {},
estimate: {},
shortAnswer: {},
answerList: ["111","222","333"],
Completion: { },
Completion: { answerList: [''] },
tabKey: this.$route.query.questionType ? this.$route.query.questionType : '1'
// tabKey,
}
},
created() {
if (this.$route.query.id) {
//
if (this.$route.query.id && !this.$route.query.opt) {
this.radio.disabled = true;
this.multiselect.disabled = true;
this.estimate.disabled = true;
this.shortAnswer.disabled = true;
this.Completion.disabled = true;
getQuestionDeatil({ id: this.$route.query.id }).then((res) => {
console.log(this.tabKey)
if (this.tabKey == '1') {
this.radio = res.data
this.radio = res.data;
this.radio.disabled = false;
} else if (this.tabKey == '2') {
this.multiselect = res.data
this.multiselect = res.data;
this.multiselect.disabled = false;
this.getRightAnswer();
} else if(this.tabKey == '3') {
this.estimate = res.data;
this.estimate.disabled = false;
} else if (this.tabKey == '4') {
this.shortAnswer = res.data;
this.shortAnswer.disabled = false;
} else if (this.tabKey == '5') {
this.Completion = res.data;
this.Completion.disabled = false;
}
})
}
@ -181,41 +199,36 @@ export default {
path: '/course/question/QuestionList',
query: {
id: this.$route.query.courseId,
questionId: this.$route.query.id,
isactive: this.$route.query.isactive,
},
})
},
// getQuestionType() {
// if (!this.$route.query.questionType || this.$route.query.questionType === '') tabKey = '1'
// tabKey = this.$route.query.questionType
// },
callback(key) {
this.radio = {}
this.multiselect = {}
this.estimate = {}
this.shortAnswer = {}
this.Completion = { answerSize: 2 }
this.Completion = { answerList: [''] }
this.tabKey = key
},
onChangeInput(e) {
},
//
addAnswerSize() {
if (this.answerList.length == 10) {
if (this.Completion.answerList.length == 10) {
this.$message.error('填空数量最多不能超过10个')
return
}
this.answerList.push('')
this.Completion.answerList.push('')
},
//
delAnswerSize() {
if (this.answerList.length == 1) {
if (this.Completion.answerList.length == 1) {
this.$message.error('填空数量最少不能少于1个')
return
}
this.Completion.answerSize--
this.Completion.answerList.splice(this.Completion.answerList.length-1, 1);
},
//
@ -239,7 +252,6 @@ export default {
console.log('5---', this.Completion)
}
console.log('a--')
from.courseId = this.$route.query.courseId
questionAdd(from).then((res) => {
@ -368,25 +380,20 @@ export default {
this.$message.error('题干不能为空!')
return false
}
console.log(this.Completion.conten)
// if (!this.Completion.rightAnswers || this.Completion.rightAnswers === '') {
// this.$message.error('')
// return false
// }
// let answer =[];
// for(i in answerSize) {
// let daan ={};
// }
let tiank = this.Completion
console.log('tiank ', tiank)
let from = this.Completion
from.questionType = 5
return from
},
//
getRightAnswer(){
if(this.multiselect.rightAnswers.indexOf('A') > -1) this.multiselect.a = true;
if(this.multiselect.rightAnswers.indexOf('B') > -1) this.multiselect.b = true;
if(this.multiselect.rightAnswers.indexOf('C') > -1) this.multiselect.c = true;
if(this.multiselect.rightAnswers.indexOf('D') > -1) this.multiselect.d = true;
console.log('1---', this.multiselect)
},
},
}
</script>

View File

@ -1,113 +1,226 @@
<template>
<page-header-wrapper>
<a-card :bordered="false">
<div class="questionLeft">
<div class="div-button">
<a-button type="primary" class="close-button" style="font-size: 15px" @click="questionColse"> 关闭 </a-button>
<a-button type="primary" class="create-button" style="font-size: 15px" @click="questionSave"> 新增 </a-button>
</div>
<h1 class="questionNumber">题序</h1>
<!-- 题目序号 -->
<div v-for="(item, index) in quesitonList" :key="item" class="questionLeftItem" @click="quesionId(item)">
{{ index+1 }}
</div>
<!-- <page-header-wrapper> -->
<a-card :bordered="false" title="题库管理">
<template slot="extra">
<a-button size="small" @click="questionColse">返回</a-button>
</template>
<div class="questionLeft">
<h1 class="questionNumber">题序</h1>
<!-- 题目序号 -->
<div
v-for="(item, index) in quesitonList"
:key="item"
class="questionLeftItem"
@click="quesionId(item, index)"
:class="{ active_color: index == isactive }"
>
{{ index + 1 }}
</div>
</div>
<div class="questionDetail">
<br />
<a-button type="primary" class="create-button" style="font-size: 15px; margin:0px 10px 10px 0px" @click="questionBatch" > 批量导入 </a-button>
<a-button type="primary" class="create-button" style="font-size: 15px; margin:0px 10px 10px 0px" @click="questionBatchDownload" > 模板下载 </a-button>
<b><h1 class="questionContent">课程题目库预览</h1></b>
<a-divider :style="{ backgroundColor: '#000' }" />
<div class="question">
<h1 class="questionName">
{{ questionDetail.questionType }}{{questionDetail.questionName}}
<span class="edit" @click="edit(questionDetail.id)">编辑</span>
<span class="edit" @click="del(questionDetail.id)">删除</span>
</h1>
<div class="questionDetail">
<br />
<a-button
type="primary"
class="create-button"
style="font-size: 15px; margin: 0px 10px 10px 0px"
@click="questionSave"
>新增题目</a-button
>
<a-button
type="primary"
class="create-button"
style="font-size: 15px; margin: 0px 10px 10px 0px"
@click="questionBatch"
>
批量导入
</a-button>
<a-button
type="primary"
class="create-button"
style="font-size: 15px; margin: 0px 10px 10px 0px"
@click="questionBatchDownload"
>
模板下载
</a-button>
<b><h1 class="questionContent">课程题目库预览</h1></b>
<a-divider :style="{ backgroundColor: '#000' }" />
<div class="question">
<h1 class="questionName" v-if="quesitonList != null && quesitonList.length !=0">
{{ questionDetail.questionTypeName }}{{ questionDetail.questionName }}
<span class="edit" @click="edit(questionDetail.id)">编辑</span>
<a-popconfirm title="确定要删除此题?" ok-text="确定" cancel-text="取消" @confirm="del(questionDetail.id)">
<span class="edit">删除</span>
</a-popconfirm>
</h1>
<!-- 显示单选题和多选题 -->
<div v-if="questionDetail.questionType == 1 || questionDetail.questionType == 2">
<div class="answer">A. {{ questionDetail.answerA }}</div>
<div class="answer">B. {{ questionDetail.answerB }}</div>
<div class="answer">C. {{ questionDetail.answerC }}</div>
<div class="answer">D. {{ questionDetail.answerD }}</div>
<div class="info_parent">
<div class="info">解析</div>
<div class="info_main">
{{questionDetail.asnwerParse}}
</div>
</div>
<a-divider :style="{ backgroundColor: '#000' }" />
</div>
<!-- 显示简答题 -->
<div v-if="questionDetail.questionType == 4">
<div class="answer">正确答案:&nbsp;&nbsp;&nbsp;&nbsp;{{ questionDetail.rightAnswers }}</div>
</div>
<!-- 显示填空题 -->
<div v-if="questionDetail.questionType == 5">
<div class="answer" v-for="(item, ind) in questionDetail.answerList" :key="ind">
正确答案{{ ind + 1 }}:&nbsp;&nbsp;&nbsp;&nbsp;{{ item }}
</div>
</div>
<div class="info_parent" v-if="quesitonList != null && quesitonList.length !=0">
<div class="info">解析</div>
<div class="info_main">
{{ questionDetail.asnwerParse }}
</div>
</div>
<a-divider :style="{ backgroundColor: '#000' }" />
</div>
</a-card>
</page-header-wrapper>
</div>
<input ref="inputFile" type="file" style="display: none" @change="questionBatchImport" />
</a-card>
<!-- </page-header-wrapper> -->
</template>
<script>
import { getQuestionListByCourseId } from '@/api/course/course'
import { getQuestionDeatil,deleteQuestion } from '@/api/course/question/question'
import { getQuestionDeatil, deleteQuestion, importTemplate } from '@/api/course/question/question'
import { ossUpload } from '@/api/sys/oss'
import axios from 'axios'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default {
data() {
return {
quesitonList: [],
questionDetail: {},
isactive: 1,
}
},
created: function () {
let parameter = {id : this.$route.query.id}
// id
getQuestionListByCourseId(parameter).then((res) => {
this.quesitonList = res.data
if (!res.data.length) return
this.quesionId(this.quesitonList[0])
})
this.getQuestion()
},
methods: {
//ID
quesionId: function (i) {
getQuestionDeatil({ id: i }).then((res) => {
this.questionDetail = res.data
getQuestion() {
// id
getQuestionListByCourseId({ id: this.$route.query.id }).then((res) => {
this.quesitonList = res.data
if (!res.data) return
this.quesionId(this.$route.query.questionId || this.quesitonList[0], this.$route.query.isactive || 0)
})
},
//ID
quesionId: function (i, index) {
if (this.quesitonList != null && this.quesitonList.length != 0) {//ID
console.log("题目!!!!",this.quesitonList.length)
this.isactive = index
this.questionId = i
getQuestionDeatil({ id: i }).then((res) => {
this.questionDetail = res.data
//
if (this.questionDetail.questionType == '1') this.questionDetail.questionTypeName = '单选题'
if (this.questionDetail.questionType == '2') this.questionDetail.questionTypeName = '多选题'
if (this.questionDetail.questionType == '3') this.questionDetail.questionTypeName = '判断题'
if (this.questionDetail.questionType == '4') this.questionDetail.questionTypeName = '简答题'
if (this.questionDetail.questionType == '5') this.questionDetail.questionTypeName = '填空题'
})
}
},
//
questionColse() {
this.$router.push({
path: '/course/CourseList',
query: {
courseName:this.$route.query.courseName,
pageNum:this.$route.query.pageNum
},
})
},
questionSave() {
this.$router.push({
path: '/course/question/QuestionAdd', query :{
courseId: this.$route.query.id,
}});
path: '/course/question/QuestionAdd',
query: {
courseId: this.$route.query.id,
isactive: this.isactive,
id: this.questionId,
opt: 'add',
},
})
},
edit(record) {
console.log(record)
this.$router.push({ path : '/course/question/QuestionAdd', query:{ id: record , questionType:this.questionDetail.questionType ,courseId:this.$route.query.id}});
},
del(record){
console.log(record)
deleteQuestion({id:record}).then(res => {
if(res.code == 200) this.$refs.table.refresh(true);
this.$router.push({
path: '/course/question/QuestionAdd',
query: {
id: record,
isactive: this.isactive,
questionType: this.questionDetail.questionType,
courseId: this.$route.query.id,
},
})
},
//
del(id) {
deleteQuestion({ id: id }).then((res) => {
if (res.code == 200) this.getQuestion()
})
},
//
questionBatch(){
alert('批量导入')
courseId:this.$route.query.id
questionBatch() {
this.$refs.inputFile.click()
},
questionBatchImport() {
if (!this.$refs.inputFile.value || this.$refs.inputFile.value === '') return
const data = new FormData()
data.append('file', this.$refs.inputFile.files[0])
data.append('sourceId', 'questionImport')
data.append('fileType', 'excel')
const header = {}
header['Content-Type'] = 'multipart/form-data'
header[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN)
axios
.post(ossUpload(), data, { headers: header })
.then((res) => {
if (res.data.code === 200) {
let params = { fileUrl: res.data.url, courseId: this.$route.query.id }
importTemplate(params).then((res1) => {
this.$refs.inputFile.value = ''
this.$message.success('题目导入成功!')
this.getQuestion()
})
} else {
this.$message.error(res.data.msg)
this.$refs.inputFile.value = ''
}
})
.catch((err) => {
this.$message.error(res)
this.$refs.inputFile.value = ''
})
},
//
questionBatchDownload() {
window.location.href = '/dawa/sys/oss/show/20211108/2420f1de94174bb8a0fb1a2f1e9e1742.xlsx'
},
questionBatchDownload(){
window.location.href="/dawa/sys/oss/show/20211108/2420f1de94174bb8a0fb1a2f1e9e1742.xlsx";
}
},
}
</script>
@ -128,8 +241,14 @@ export default {
border: 1px solid #000;
margin: 5px 5px;
cursor: pointer;
background-color: white;
}
.active_color {
background-color: wheat;
}
/* wheat */
.questionDetail {
width: calc(100% - 300px - 20px);
height: auto;
@ -158,7 +277,7 @@ export default {
font-size: 23px;
font: bold;
background-color: gainsboro;
margin-top: 45px;
/* margin-top: 45px; */
}
.questionContent {
margin-left: 10px;