feat: 问题修复

This commit is contained in:
cgd_mac 2022-02-24 10:33:50 +08:00
parent 4b9e970a6e
commit b3b9720595
8 changed files with 161 additions and 109 deletions

View File

@ -10,12 +10,12 @@
<!-- <li :class="{'success-li' : index == 2}" v-for="(item, index) in options" :key="index"> <!-- <li :class="{'success-li' : index == 2}" v-for="(item, index) in options" :key="index">
<span>{{ optionKeys[index] }}</span>{{ item.label }} <span>{{ optionKeys[index] }}</span>{{ item.label }}
</li> --> </li> -->
<li v-if="data.answerA || data.answerA === 0" :class="{'success-li' : data.rightAnswers.indexOf('A') !== -1}"><span>A</span>{{ data.answerA }}</li> <li v-if="data.answerA || data.answerA === 0" :class="[{'error-li': data.myAnswerList.indexOf('A') !== -1},{'success-li' : data.rightAnswers.indexOf('A') !== -1}]"><span>A</span>{{ data.answerA }}</li>
<li v-if="data.answerB || data.answerB === 0" :class="{'success-li' : data.rightAnswers.indexOf('B') !== -1}"><span>B</span>{{ data.answerB }}</li> <li v-if="data.answerB || data.answerB === 0" :class="[{'error-li': data.myAnswerList.indexOf('B') !== -1},{'success-li' : data.rightAnswers.indexOf('B') !== -1}]"><span>B</span>{{ data.answerB }}</li>
<li v-if="data.answerC || data.answerC === 0" :class="{'success-li' : data.rightAnswers.indexOf('C') !== -1}"><span>C</span>{{ data.answerC }}</li> <li v-if="data.answerC || data.answerC === 0" :class="[{'error-li': data.myAnswerList.indexOf('C') !== -1},{'success-li' : data.rightAnswers.indexOf('C') !== -1}]"><span>C</span>{{ data.answerC }}</li>
<li v-if="data.answerD || data.answerD === 0" :class="{'success-li' : data.rightAnswers.indexOf('D') !== -1}"><span>D</span>{{ data.answerD }}</li> <li v-if="data.answerD || data.answerD === 0" :class="[{'error-li': data.myAnswerList.indexOf('D') !== -1},{'success-li' : data.rightAnswers.indexOf('D') !== -1}]"><span>D</span>{{ data.answerD }}</li>
<li v-if="data.answerE || data.answerE === 0" :class="{'success-li' : data.rightAnswers.indexOf('E') !== -1}"><span>E</span>{{ data.answerE }}</li> <li v-if="data.answerE || data.answerE === 0" :class="[{'error-li': data.myAnswerList.indexOf('E') !== -1},{'success-li' : data.rightAnswers.indexOf('E') !== -1}]"><span>E</span>{{ data.answerE }}</li>
<li v-if="data.answerF || data.answerF === 0" :class="{'success-li' : data.rightAnswers.indexOf('F') !== -1}"><span>F</span>{{ data.answerF }}</li> <li v-if="data.answerF || data.answerF === 0" :class="[{'error-li': data.myAnswerList.indexOf('F') !== -1},{'success-li' : data.rightAnswers.indexOf('F') !== -1}]"><span>F</span>{{ data.answerF }}</li>
</ul> </ul>
</div> </div>
<div class="flex-center justify-between" style="margin-top: 10px;"> <div class="flex-center justify-between" style="margin-top: 10px;">
@ -101,6 +101,9 @@ export default {
li{ li{
line-height: 2; line-height: 2;
} }
.error-li{
color: red;
}
.success-li{ .success-li{
color: #52c41a; color: #52c41a;
} }

View File

@ -1,6 +1,8 @@
import T from 'ant-design-vue/es/table/Table' import T from 'ant-design-vue/es/table/Table'
import get from 'lodash.get' import get from 'lodash.get'
const defaultPagination = {
pageSizeOptions: ['5', '10', '20', '30', '40']
}
export default { export default {
data () { data () {
return { return {
@ -9,7 +11,7 @@ export default {
selectedRowKeys: [], selectedRowKeys: [],
localLoading: false, localLoading: false,
localDataSource: [], localDataSource: [],
localPagination: Object.assign({}, this.pagination) localPagination: Object.assign({}, defaultPagination)
} }
}, },
props: Object.assign({}, T.props, { props: Object.assign({}, T.props, {
@ -121,7 +123,7 @@ export default {
* 如果参数为 true, 则强制刷新到第一页 * 如果参数为 true, 则强制刷新到第一页
* @param Boolean bool * @param Boolean bool
*/ */
refresh (bool = false) { refresh (bool = true) {
bool && (this.localPagination = Object.assign({}, { bool && (this.localPagination = Object.assign({}, {
current: 1, pageSize: this.pageSize current: 1, pageSize: this.pageSize
})) }))

View File

@ -41,43 +41,50 @@ const user = {
// 登录 // 登录
Login ({ commit }, userInfo) { Login ({ commit }, userInfo) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login(userInfo).then(response => { login(userInfo)
storage.set(ACCESS_TOKEN, response.token, 24 * 60 * 60 * 1000) .then(response => {
commit('SET_TOKEN', response.token) storage.set(ACCESS_TOKEN, response.token, 24 * 60 * 60 * 1000)
resolve() commit('SET_TOKEN', response.token)
}).catch(error => { resolve()
reject('后端未启动或代理错误') })
}) .catch(error => {
reject(error)
})
}) })
}, },
// 获取用户信息 // 获取用户信息
GetInfo ({ commit, state }) { GetInfo ({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getLoginUser().then(response => { getLoginUser()
if (response.code === 200) { .then(response => {
const data = response.data if (response.code === 200) {
commit('SET_ROLES', 1) const data = response.data
commit('SET_BUTTONS', data.permissions) commit('SET_ROLES', 1)
commit('SET_INFO', data.user) commit('SET_BUTTONS', data.permissions)
state.person = data.person commit('SET_INFO', data.user)
commit('SET_NAME', { name: data.user.userName, welcome: welcome() }) state.person = data.person
if (data.user.avatar != null) { commit('SET_NAME', { name: data.user.userName, welcome: welcome() })
commit('SET_AVATAR', process.env.VUE_APP_API_BASE_URL + '/sysFileInfo/preview?id=' + data.user.avatar) if (data.user.avatar != null) {
commit(
'SET_AVATAR',
process.env.VUE_APP_API_BASE_URL + '/sysFileInfo/preview?id=' + data.user.avatar
)
}
resolve(data)
} else {
reject(new Error(response.msg))
} }
resolve(data) })
} else { .catch(error => {
reject(new Error(response.msg)) reject(error)
} })
}).catch(error => {
reject(error)
})
}) })
}, },
// 登出 // 登出
Logout ({ commit, state }) { Logout ({ commit, state }) {
return new Promise((resolve) => { return new Promise(resolve => {
const clear = function () { const clear = function () {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ROLES', []) commit('SET_ROLES', [])
@ -85,17 +92,20 @@ const user = {
commit('SET_ROUTERS', []) commit('SET_ROUTERS', [])
storage.remove(ACCESS_TOKEN) storage.remove(ACCESS_TOKEN)
} }
logout().then(() => { logout()
clear() .then(() => {
setTimeout(() => { clear()
setTimeout(() => {
resolve()
}, 300)
resolve() resolve()
}, 300) })
resolve() .catch(() => {
}).catch(() => { resolve()
resolve() })
}).finally(() => { .finally(() => {
clear() clear()
}) })
}) })
} }
} }

View File

@ -1,111 +1,127 @@
<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.courseTypeName}} </a-descriptions-item> <a-descriptions-item label="课程类别">
<a-descriptions-item label="课时"> {{ detailData.hour }} </a-descriptions-item> {{ getDictLabelByKey('dictCourseType', detailData.courseType) }}
<a-descriptions-item label="学习内容"> {{ detailData.learningContent }} </a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="试题数量"> {{ detailData.questionCount }} </a-descriptions-item> <a-descriptions-item label="课时">{{ detailData.hour }}</a-descriptions-item>
<a-descriptions-item label="备注"> {{ detailData.remark }} </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="课程封面图"> <a-descriptions-item label="课程封面图">
<div> <div>
<img style="width:75px;height:75px" :src="detailData.imagePath"> <img style="width:75px;height:75px" :src="detailData.imagePath" />
</div> </div>
</a-descriptions-item> </a-descriptions-item>
<a-descriptions-item label="标签"> <a-descriptions-item label="标签">
<a-tag color="blue" v-for="(item,index) in detailData.tags" :key="index "> <a-tag color="blue" v-for="(item, index) in detailData.courseTags" :key="index">
{{item}} {{ getDictLabelByKey('dictCourseTag', item.dictValue) }}
</a-tag> </a-tag>
</a-descriptions-item> </a-descriptions-item>
</a-descriptions> </a-descriptions>
<div class="buttonGroup"> <div class="buttonGroup">
<a-button type="primary" @click="close"> 返回 </a-button> <a-button type="primary" @click="close">返回</a-button>
<a-button type="primary" @click="edit"> 编辑 </a-button> <a-button type="primary" @click="edit">编辑</a-button>
</div> </div>
</a-card> </a-card>
</template> </template>
<script> <script>
import _ from 'lodash'
import { getCourseDetails } from '@/api/course/course' import { getCourseDetails } from '@/api/course/course'
import { dictionaryDropDown } from '@/api/sys/dictionaryItem' 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: {
imagePath: '', // imagePath: '', //
coverPath:[], coverPath: []
}, },
dictCourseType: [], dictCourseType: [],
dictCourseTag: [], dictCourseTag: [],
tags: [], // tags: [] //
} }
}, },
created: function () { created: function () {
// //
this.loadData() this.loadData()
this.dictionaryDropDown() this.dictionaryDropDown()
this.getTagName() this.getTagName()
}, },
methods: { methods: {
// //
loadData() { loadData () {
let parameter = {} const parameter = {}
getCourseDetails(Object.assign(parameter, this.queryParam)).then((res) => { getCourseDetails(Object.assign(parameter, this.queryParam)).then(res => {
this.detailData = res.data this.detailData = res.data
this.detailData.coverPath = JSON.parse(res.data.coverPath) this.detailData.coverPath = JSON.parse(res.data.coverPath)
console.log('JSON:::::',this.detailData.coverPath) console.log('JSON:::::', this.detailData.coverPath)
if(this.detailData.coverPath.length != 0)
this.detailData.imagePath = this.detailData.coverPath[0].url;
console.log('url',this.detailData.imagePath)
if (this.detailData.coverPath.length != 0) {
this.detailData.imagePath = this.detailData.coverPath[0].url
}
console.log('url', this.detailData.imagePath)
}) })
}, },
close() { close () {
this.$router.push({ path: '/course/CourseList/' + this.$route.query.type, query: {} }) this.$router.push({ path: '/course/CourseList/' + this.$route.query.type, query: {} })
}, },
edit(record) { edit (record) {
this.$router.push({ path: '/course/CourseAdd', query: { id: this.queryParam.id, type: this.$route.query.type } }) this.$router.push({
}, path: '/course/CourseAdd',
query: { id: this.queryParam.id, type: this.$route.query.type }
//
dictionaryDropDown() {
//
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => {
this.dictCourseType = res.data
//valuename
for (let i = 0; i < this.dictCourseType.length; i++) {
if (this.dictCourseType[i].value == this.detailData.courseType) {
this.detailData.courseTypeName = this.dictCourseType[i].name
}
}
}) })
}, },
getTagName() { getDictLabelByKey (name, value) {
dictionaryDropDown({ dictionaryCode: '0008' }).then((res) => { let result = '-'
const list = this[name]
if (Array.isArray(list)) {
const item = _.find(list, ['value', value])
if (item) {
result = item.name
}
}
return result
},
//
dictionaryDropDown () {
//
dictionaryDropDown({ dictionaryCode: '0006' }).then(res => {
this.dictCourseType = res.data
// // valuename
// for (let i = 0; i < this.dictCourseType.length; i++) {
// if (this.dictCourseType[i].value == this.detailData.courseType) {
// this.detailData.courseTypeName = this.dictCourseType[i].name
// }
// }
})
},
getTagName () {
dictionaryDropDown({ dictionaryCode: '0008' }).then(res => {
this.dictCourseTag = res.data this.dictCourseTag = res.data
console.log(this.dictCourseTag) console.log(this.dictCourseTag)
let tags = [] // const tags = []
for (let i = 0; i < this.dictCourseTag.length; i++) { // for (let i = 0; i < this.dictCourseTag.length; i++) {
for (let j = 0; j < this.detailData.courseTags.length; j++) { // for (let j = 0; j < this.detailData.courseTags.length; j++) {
if (this.dictCourseTag[i].value == this.detailData.courseTags[j].dictValue) { // if (this.dictCourseTag[i].value == this.detailData.courseTags[j].dictValue) {
tags.push(this.dictCourseTag[i].name) // tags.push(this.dictCourseTag[i].name)
} // }
} // }
} // }
console.log('tagagagaga', tags) // console.log('tagagagaga', tags)
this.detailData.tags = tags // this.detailData.tags = tags
}) })
}, }
}, }
} }
</script> </script>
@ -120,4 +136,4 @@ export default {
text-align: center; text-align: center;
margin-top: 10px; margin-top: 10px;
} }
</style> </style>

View File

@ -181,11 +181,16 @@ export default {
title: '课中检查', title: '课中检查',
content: content:
'课程学习完成后都会随机出现1道小题答对题目方可继续下一部分学习您有2次机会。否则之前上一小段学习时间不计算学时需要重新学习!', '课程学习完成后都会随机出现1道小题答对题目方可继续下一部分学习您有2次机会。否则之前上一小段学习时间不计算学时需要重新学习!',
okCancel: false,
onOk () { onOk () {
_this.$refs.examDialog.show() _this.$refs.examDialog.show()
_this.$refs.examDialog.getExamQuestion() _this.$refs.examDialog.getExamQuestion()
}, },
onCancel () {} onCancel () {
return new Promise((resolve, reject) => {
}).catch(() => console.log('Oops errors!'))
},
wrapClassName: 'dialogTest'
}) })
}, },
// //
@ -230,4 +235,8 @@ export default {
width: 100%; width: 100%;
margin: 0 auto; margin: 0 auto;
} }
.learn-exam-dialog ::v-deep .ant-modal-confirm-btns:first-child{
display: none;
}
</style> </style>

View File

@ -151,7 +151,7 @@ export default {
}, },
// //
dictionaryDropDown () { dictionaryDropDown () {
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => { dictionaryDropDown({ dictionaryCode: '0009' }).then((res) => {
this.queryOptions[1].options = dictToTree(res.data, [], 0) this.queryOptions[1].options = dictToTree(res.data, [], 0)
this.loading = false this.loading = false
}) })

View File

@ -123,10 +123,10 @@ export default {
tabChange (key) { tabChange (key) {
console.log('key', key) console.log('key', key)
if (key == 1) { if (key == 1) {
this.$refs.yearTable.refresh() this.$refs.yearTable && this.$refs.yearTable.refresh()
} }
if (key == 2) { if (key == 2) {
this.$refs.unitTable.refresh() this.$refs.unitTable && this.$refs.unitTable.refresh()
} }
}, },
// //
@ -134,7 +134,19 @@ export default {
this.$refs.aycourseDetail.visible = true this.$refs.aycourseDetail.visible = true
}, },
handlerAddCourse (row) { handlerAddCourse (row) {
this.$emit('add', { row: row }) const _this = this
const activeTab = this.activeTab
this.$emit('add', {
row: row,
callback: function () {
if (activeTab == 1) {
_this.$refs.yearTable && _this.$refs.yearTable.refresh()
}
if (activeTab == 2) {
_this.$refs.unitTable && _this.$refs.unitTable.refresh()
}
}
})
}, },
handlerContinue (row) { handlerContinue (row) {
this.$emit('continue', { row: row }) this.$emit('continue', { row: row })

View File

@ -187,7 +187,7 @@ export default {
}, },
methods: { methods: {
dictionaryDropDown () { dictionaryDropDown () {
dictionaryDropDown({ dictionaryCode: '0006' }).then((res) => { dictionaryDropDown({ dictionaryCode: '0009' }).then((res) => {
const result = dictToTree(res.data, [], 0) const result = dictToTree(res.data, [], 0)
this.queryOptions[0].options = result this.queryOptions[0].options = result
this.loading = false this.loading = false