课程数据字典及题目批量新增和删除

This commit is contained in:
18571350067 2021-11-15 00:11:43 +08:00
parent d0e56e7b99
commit c85f134c9d
3 changed files with 194 additions and 122 deletions

View File

@ -2,13 +2,16 @@
<a-card :bordered="false" title="系統新增"> <a-card :bordered="false" title="系統新增">
<a-form-model :model="form"> <a-form-model :model="form">
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 80%"> <div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 80%">
<a-button type="primary" @click="goback">返回</a-button> <a-button type="primary" @click="goback">返回</a-button>
</div> </div>
<a-row> <a-row>
<!-- 课程名称 --> <!-- 课程名称 -->
<a-col :span="18" :offset="3"> <a-col :span="18" :offset="3">
<a-form-model-item label="课程名称" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }"> <a-form-model-item label="课程名称" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-input v-model="form.courseName" v-decorator="['courseName', { rules: [{ required: true, message: '请填写课程名称' }] }]" /> <a-input
v-model="form.courseName"
v-decorator="['courseName', { rules: [{ required: true, message: '请填写课程名称' }] }]"
/>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
@ -16,8 +19,7 @@
<a-col :span="9" :offset="3"> <a-col :span="9" :offset="3">
<a-form-model-item label="课程类别" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }"> <a-form-model-item label="课程类别" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-select v-model="form.courseType" placeholder="--请选择--"> <a-select v-model="form.courseType" placeholder="--请选择--">
<a-select-option value="1"> 商业 </a-select-option> <a-select-option v-for="(item,index) in dictCourseType" :key="index" :value="item.value"> {{item.name}} </a-select-option>
<a-select-option value="2"> 政务 </a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
@ -25,7 +27,14 @@
<!-- 课件大小 --> <!-- 课件大小 -->
<a-col :span="9"> <a-col :span="9">
<a-form-item label="课时" :label-col="{ span: 4 }" :wrapper-col="{ span: 10 }"> <a-form-item label="课时" :label-col="{ span: 4 }" :wrapper-col="{ span: 10 }">
<a-input-number id="hour" v-model="dataValue" :min="1" :max="1000" @change="onChange" :style="{ display: 'ln', width: '100%' }" /> <a-input-number
id="hour"
v-model="dataValue"
:min="1"
:max="1000"
@change="onChange"
:style="{ display: 'ln', width: '100%' }"
/>
{{ dataValue }}分钟 {{ dataValue }}分钟
</a-form-item> </a-form-item>
</a-col> </a-col>
@ -41,8 +50,7 @@
<a-col :span="9" :offset="3"> <a-col :span="9" :offset="3">
<a-form-model-item label="所属行业" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }"> <a-form-model-item label="所属行业" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-select v-model="form.industryInvolved" placeholder="--请选择--"> <a-select v-model="form.industryInvolved" placeholder="--请选择--">
<a-select-option value="1"> 医疗 </a-select-option> <a-select-option v-for="(item,index) in industry" :key="index" :value="item.value"> {{item.name}} </a-select-option>
<a-select-option value="0"> 建筑 </a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
@ -61,7 +69,7 @@
<a-col :span="9" :offset="3"> <a-col :span="9" :offset="3">
<a-form-model-item label="选择岗位" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }"> <a-form-model-item label="选择岗位" :label-col="{ span: 8 }" :wrapper-col="{ span: 12 }">
<a-select v-model="form.job" placeholder="--请选择--"> <a-select v-model="form.job" placeholder="--请选择--">
<a-select-option v-for="item in personType" :key="item.id"> {{ item.name }} </a-select-option> <a-select-option v-for="(item,index) in dictPerson" :key="index" :value="item.value"> {{ item.name }} </a-select-option>
</a-select> </a-select>
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
@ -76,7 +84,14 @@
<!-- 上传封面图片 --> <!-- 上传封面图片 -->
<a-col :span="18" :offset="3"> <a-col :span="18" :offset="3">
<a-form-model-item label="上传封面图片" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }"> <a-form-model-item label="上传封面图片" :label-col="{ span: 4 }" :wrapper-col="{ span: 15 }">
<a-upload action="/dawa/sys/oss/upload?sourceId=course" list-type="picture-card" :file-list="fileList" :headers="getToken()" @change="handleChange" @preview="handlePreview"> <a-upload
action="/dawa/sys/oss/upload?sourceId=course"
list-type="picture-card"
:file-list="fileList"
:headers="getToken()"
@change="handleChange"
@preview="handlePreview"
>
<div v-if="fileList.length < 1"> <div v-if="fileList.length < 1">
<a-icon type="plus" /> <a-icon type="plus" />
<div class="ant-upload-text">上传</div> <div class="ant-upload-text">上传</div>
@ -96,9 +111,9 @@
</a-form-model-item> </a-form-model-item>
</a-col> </a-col>
</a-row> </a-row>
<div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 50%"> <div style="width: 100%; height: 40px; margin-bottom: 8px; margin-left: 50%">
<a-button type="primary" @click="save">保存</a-button> <a-button type="primary" @click="save">保存</a-button>
</div> </div>
</a-form-model> </a-form-model>
</a-card> </a-card>
</template> </template>
@ -109,6 +124,7 @@
import { courseAdd, getCourseDetails } from '@/api/course/course' import { courseAdd, getCourseDetails } from '@/api/course/course'
import storage from 'store' import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
export default { export default {
name: 'step1', name: 'step1',
@ -116,38 +132,37 @@ export default {
return { return {
dataValue: 1, dataValue: 1,
form: { form: {
coverPath:'', coverPath: '',
}, },
personType: [ url: '',
{ id: '1', name: '人员类别1' },
{ id: '2', name: '人员类别2' },
{ id: '3', name: '人员类别3' },
],
url:'',
previewVisible: false, previewVisible: false,
fileList: [], fileList: [],
previewImage :[ previewImage: [],
dictPerson:[],
] dictCourseType:[],
industry:[]
} }
}, },
components: { components: {
courseAdd, courseAdd,
getCourseDetails getCourseDetails,
}, },
created() { created() {
if (this.$route.query.id) { if (this.$route.query.id) {
getCourseDetails({ id: this.$route.query.id }).then(res => { getCourseDetails({ id: this.$route.query.id }).then((res) => {
this.form = res.data; this.form = res.data
this.form.courseType = this.form.courseType + ''; // this.form.courseType = this.form.courseType + ''
this.form.industryInvolved = this.form.industryInvolved + ''; // this.form.industryInvolved = this.form.industryInvolved + ''
this.form.isRequired = this.form.isRequired + ''; this.form.isRequired = this.form.isRequired + ''
// this.form.is
}); this.dictEcho();
})
} }
this.dictionaryDropDown()
}, },
methods: { methods: {
// getPersonType() { // getPersonType() {
// return dictGet(Object.assign(parameter)).then((res) => { // return dictGet(Object.assign(parameter)).then((res) => {
@ -170,60 +185,75 @@ export default {
}) })
}, },
dictionaryDropDown () {
this.formLoading = true
//
dictionaryDropDown({ dictionaryCode: '0007' }).then((res) => {
this.industry = res.data
this.formLoading = false
})
//
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.dictCourseType = res.data
this.formLoading = false
})
//
dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => {
this.dictPerson = res.data
this.formLoading = false
})
},
//
dictEcho(){
console.log("form___",this.form)
},
// //
goback(){ goback() {
this.$router.push({path:"/course/CourseList",query:{ this.$router.push({
courseName:this.$route.query.courseName path: '/course/CourseList',
} }) query: {
courseName: this.$route.query.courseName,
},
})
}, },
getToken() { getToken() {
let hreader = {}; let hreader = {}
hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN); hreader[ACCESS_TOKEN] = storage.get(ACCESS_TOKEN)
return hreader; return hreader
}, },
onSuccess(file) { onSuccess(file) {
console.log('1---', file); console.log('1---', file)
}, },
handleCancel() { handleCancel() {
this.previewVisible = false; this.previewVisible = false
}, },
async handlePreview(file) { async handlePreview(file) {
if (!file.url && !file.preview) { if (!file.url && !file.preview) {
file.preview = await getBase64(file.originFileObj); file.preview = await getBase64(file.originFileObj)
} }
this.previewImage = file.url || file.preview; this.previewImage = file.url || file.preview
this.previewVisible = true; this.previewVisible = true
}, },
handleChange({ fileList }) { handleChange({ fileList }) {
this.fileList = fileList; this.fileList = fileList
console.log("fileList-------",fileList); this.fileList.file = fileList[0]
this.fileList.file=fileList[0]; this.form.coverPath = this.fileList.file.response.url
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)
}, },
}, },
} }
// Base64 // Base64
function getBase64(file) { function getBase64(file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader(); const reader = new FileReader()
reader.readAsDataURL(file); reader.readAsDataURL(file)
reader.onload = () => resolve(reader.result); reader.onload = () => resolve(reader.result)
reader.onerror = error => reject(error); reader.onerror = (error) => reject(error)
}); })
} }
</script> </script>

View File

@ -1,45 +1,69 @@
<template> <template>
<a-card :bordered="false" title="课程详情"> <a-card :bordered="false" title="课程详情">
<a-descriptions layout="horizontal" bordered size="small" :column="1"> <a-descriptions layout="horizontal" bordered size="small" :column="1">
<a-descriptions-item label="课程编号"> {{ detailData.courseCode }} </a-descriptions-item> <a-descriptions-item label="课程编号"> {{ detailData.courseCode }} </a-descriptions-item>
<a-descriptions-item label="课程名称"> {{ detailData.courseName }} </a-descriptions-item> <a-descriptions-item label="课程名称"> {{ detailData.courseName }} </a-descriptions-item>
<a-descriptions-item label="课程类别"> {{ detailData.courseType }} </a-descriptions-item> <a-descriptions-item label="课程类别" v-for="(item,index) in dictCourseType" :key="index" :value="item.value"> {{ item.name }} </a-descriptions-item>
<a-descriptions-item label="课时"> {{ detailData.hour }} </a-descriptions-item> <a-descriptions-item label="课时"> {{ detailData.hour }} </a-descriptions-item>
<a-descriptions-item label="试题数量"> {{ detailData.questionCount }} </a-descriptions-item> <a-descriptions-item label="学习内容"> {{ detailData.learningContent }} </a-descriptions-item>
<a-descriptions-item label="学习内容"> {{ detailData.learningContent }} </a-descriptions-item> <a-descriptions-item label="试题数量"> {{ detailData.questionCount }} </a-descriptions-item>
<a-descriptions-item label="备注"> {{ detailData.remark }} </a-descriptions-item> <a-descriptions-item label="备注"> {{ detailData.remark }} </a-descriptions-item>
</a-descriptions> <a-descriptions-item label="课程封面图">
<div class="buttonGroup"> <viewer :images="detailData.coverPath">
<a-button type="primary" @click="close"> 返回 </a-button> <img :src="detailData.coverPath" />
<a-button type="primary" @click="edit"> 编辑 </a-button> </viewer>
</div> <!-- <div>
</a-card> <img :src="detailData.coverPath" v-image-preview width="100" height="100">
</div> -->
</a-descriptions-item>
</a-descriptions>
<div class="buttonGroup">
<a-button type="primary" @click="close"> 返回 </a-button>
<a-button type="primary" @click="edit"> 编辑 </a-button>
</div>
</a-card>
</template> </template>
<script> <script>
import { getCourseDetails } from '@/api/course/course' import { getCourseDetails } from '@/api/course/course'
import { dictionaryDropDown } from '@/api/sys/dictionaryItem'
export default { export default {
name: 'details', name: 'details',
components: {}, components: {},
data() { data() {
return { return {
queryParam: { id: this.$route.query.id }, queryParam: { id: this.$route.query.id },
detailData: {} detailData: {
coverPath: [],
},
dictCourseType:[]
} }
}, },
created: function() { created: function () {
let parameter = {}; let parameter = {}
getCourseDetails(Object.assign(parameter, this.queryParam)).then(res => { this.detailData = res.data }); getCourseDetails(Object.assign(parameter, this.queryParam)).then((res) => {
this.detailData = res.data
})
//
this.dictionaryDropDown();
}, },
methods: { methods: {
close () { close() {
this.$router.push({ path: '/course/CourseList', query: { } }); this.$router.push({ path: '/course/CourseList', query: {} })
}, },
edit(record) { edit(record) {
this.$router.push({ path : '/course/CourseAdd', query:{ id: this.queryParam.id }}); this.$router.push({ path: '/course/CourseAdd', query: { id: this.queryParam.id } })
} },
},
//
dictionaryDropDown() {
//
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.dictCourseType = res.data
this.formLoading = false
})
},
},
} }
</script> </script>
@ -48,7 +72,7 @@ export default {
width: 100px; width: 100px;
text-align: center; text-align: center;
} }
.buttonGroup{ .buttonGroup {
width: 100%; width: 100%;
height: auto; height: auto;
text-align: center; text-align: center;

View File

@ -1,5 +1,4 @@
<template> <template>
<!-- <page-header-wrapper> -->
<a-card :bordered="false" title="题库管理"> <a-card :bordered="false" title="题库管理">
<template slot="extra"> <template slot="extra">
<a-button size="small" @click="questionColse">返回</a-button> <a-button size="small" @click="questionColse">返回</a-button>
@ -20,33 +19,39 @@
<div class="questionDetail"> <div class="questionDetail">
<br /> <br />
<a-button <div>
type="primary" <a-button
class="create-button" type="primary"
style="font-size: 15px; margin: 0px 10px 10px 0px" class="create-button"
@click="questionSave" style="font-size: 15px; margin: 0px 10px 10px 0px"
>新增题目</a-button @click="questionSave"
> >新增题目</a-button
<a-button >
type="primary" <a-button
class="create-button" type="primary"
style="font-size: 15px; margin: 0px 10px 10px 0px" class="create-button"
@click="questionBatch" style="font-size: 15px; margin: 0px 10px 10px 0px"
> @click="questionBatch"
批量导入 >
</a-button> 批量导入
<a-button </a-button>
type="primary" <a-button
class="create-button" type="primary"
style="font-size: 15px; margin: 0px 10px 10px 0px" class="create-button"
@click="questionBatchDownload" style="font-size: 15px; margin: 0px 10px 10px 0px"
> @click="showModal"
模板下载 >
</a-button> 模板下载
</a-button>
<a-modal v-model="visible" title="模板下载" cancelText="关闭" :ok-button-props="{ style: { display: 'none' } }">
<a-button type="primary" class="create-button" style="font-size: 15px; margin:-15px 50px 3px 50px" @click="questionBatchDownloadDemo">示例模板</a-button>
<a-button type="primary" class="create-button" style="font-size: 15px; margin:-15px 30px 3px 70px" @click="questionBatchDownload">纯净模板</a-button>
</a-modal>
</div>
<b><h1 class="questionContent">课程题目库预览</h1></b> <b><h1 class="questionContent">课程题目库预览</h1></b>
<a-divider :style="{ backgroundColor: '#000' }" /> <a-divider :style="{ backgroundColor: '#000' }" />
<div class="question"> <div class="question">
<h1 class="questionName" v-if="quesitonList != null && quesitonList.length !=0"> <h1 class="questionName" v-if="quesitonList != null && quesitonList.length != 0">
{{ questionDetail.questionTypeName }}{{ questionDetail.questionName }} {{ questionDetail.questionTypeName }}{{ questionDetail.questionName }}
<span class="edit" @click="edit(questionDetail.id)">编辑</span> <span class="edit" @click="edit(questionDetail.id)">编辑</span>
<a-popconfirm title="确定要删除此题?" ok-text="确定" cancel-text="取消" @confirm="del(questionDetail.id)"> <a-popconfirm title="确定要删除此题?" ok-text="确定" cancel-text="取消" @confirm="del(questionDetail.id)">
@ -74,7 +79,7 @@
</div> </div>
</div> </div>
<div class="info_parent" v-if="quesitonList != null && quesitonList.length !=0"> <div class="info_parent" v-if="quesitonList != null && quesitonList.length != 0">
<div class="info">解析</div> <div class="info">解析</div>
<div class="info_main"> <div class="info_main">
{{ questionDetail.asnwerParse }} {{ questionDetail.asnwerParse }}
@ -86,7 +91,6 @@
<input ref="inputFile" type="file" style="display: none" @change="questionBatchImport" /> <input ref="inputFile" type="file" style="display: none" @change="questionBatchImport" />
</a-card> </a-card>
<!-- </page-header-wrapper> -->
</template> </template>
<script> <script>
@ -104,6 +108,7 @@ export default {
quesitonList: [], quesitonList: [],
questionDetail: {}, questionDetail: {},
isactive: 1, isactive: 1,
visible: false,
} }
}, },
@ -123,8 +128,9 @@ export default {
//ID //ID
quesionId: function (i, index) { quesionId: function (i, index) {
if (this.quesitonList != null && this.quesitonList.length != 0) {//ID if (this.quesitonList != null && this.quesitonList.length != 0) {
console.log("题目!!!!",this.quesitonList.length) //ID
console.log('题目!!!!', this.quesitonList.length)
this.isactive = index this.isactive = index
this.questionId = i this.questionId = i
@ -145,8 +151,8 @@ export default {
this.$router.push({ this.$router.push({
path: '/course/CourseList', path: '/course/CourseList',
query: { query: {
courseName:this.$route.query.courseName, courseName: this.$route.query.courseName,
pageNum:this.$route.query.pageNum pageNum: this.$route.query.pageNum,
}, },
}) })
}, },
@ -217,10 +223,22 @@ export default {
}) })
}, },
showModal() {
this.visible = true
},
handleOk(e) {
console.log(e)
this.visible = false
},
// //
questionBatchDownload() { questionBatchDownload() {
window.location.href = '/dawa/sys/oss/show/20211108/2420f1de94174bb8a0fb1a2f1e9e1742.xlsx' window.location.href = '/dawa/sys/oss/show/20211108/2420f1de94174bb8a0fb1a2f1e9e1742.xlsx'
}, },
//
questionBatchDownloadDemo() {
window.location.href = '/dawa/sys/oss/show/20211114/d82abc89cfba4e18b3f4bc0f9dfa6b96.xlsx'
},
}, },
} }
</script> </script>