This commit is contained in:
yanran200730
2023-02-13 18:08:17 +08:00
parent 708a2193b0
commit d433c503e4
3 changed files with 355 additions and 191 deletions

View File

@@ -1,5 +1,5 @@
<template> <template>
<ai-detail class="content-add" v-loading="isLoading"> <ai-detail class="AppExaminationManage-add">
<template slot="title"> <template slot="title">
<ai-title :title="params.id ? '编辑' + '考试' : '添加' + '考试'" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title> <ai-title :title="params.id ? '编辑' + '考试' : '添加' + '考试'" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template> </template>
@@ -7,124 +7,208 @@
<ai-card title="基本信息"> <ai-card title="基本信息">
<template #content> <template #content>
<el-form class="ai-form" :model="form" label-width="120px" ref="form"> <el-form class="ai-form" :model="form" label-width="120px" ref="form">
<el-form-item label="标题" style="width: 100%;" prop="title" :rules="[{required: true, message: '请输入标题', trigger: 'blur'}]"> <el-form-item label="考试名称" prop="examinationName" :rules="[{required: true, message: '请输入考试名称', trigger: 'blur'}]">
<el-input size="small" v-model="form.title" clearable placeholder="请输入..." :maxlength="50" :show-word-limit="true"></el-input> <el-input size="small" v-model="form.examinationName" clearable placeholder="请输入考试名称" :maxlength="50" :show-word-limit="true"></el-input>
</el-form-item> </el-form-item>
<el-form-item prop="showIndex" label="排序" :rules="[{required: true, message: '请选择文章类型', trigger: 'change'}]"> <el-form-item prop="showIndex" label="排序" :rules="[{required: true, message: '请选择排序', trigger: 'change'}]">
<el-input-number size="small" v-model="form.showIndex" :min="0"></el-input-number> <el-input-number size="small" v-model="form.showIndex" :min="0"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item v-if="form.contentType === '0'" label="正文" prop="content" style="width: 100%;" :rules="[{required: true, message: '请输入内容', trigger: 'change'}]"> <el-form-item prop="chooseType" style="width: 100%" label="成绩评核" :rules="[{required: true, message: '请选择成绩评核', trigger: 'change'}]">
<ai-editor v-model="form.content" :instance="instance"/> <div class="type-list">
</el-form-item> <div class="type-item" v-for="(item, index) in form.assessments" :key="index">
<el-form-item v-if="form.contentType === '0' && !isHideCoverimg" label="封面图片" prop="files" style="width: 100%;"> <span class="type-name">{{ dict.getLabel('qjEAType', item.assessmentType) }}</span>
<ai-uploader <ai-select
:instance="instance" style="width: 180px;"
v-model="form.files" v-model="item.qjEACondition"
key="file" clearable
:limit="9"> placeholder="请选择"
<template slot="tips"> :selectList="dict.getDict('qjEACondition')">
<p>最多上传9张图片,单个文件最大10MB支持jpgjpegpng格式</p> </ai-select>
</template> <el-input size="small" style="width: 180px;" v-model="item.upScore" placeholder="请输入"></el-input>
</ai-uploader> <span></span>
</el-form-item> <ai-select
<el-form-item v-if="form.contentType === '1'" label="视频" prop="files" style="width: 100%;" :rules="[{required: true, message: '请上传视频', trigger: 'change'}]"> style="width: 180px;"
<el-upload :show-file-list="false" ref="upload1" action :http-request="submitUpload" :accept="accept" :limit="1"> v-model="item.downCondition"
<div class="video" v-if="!form.files.length"> clearable
<div class="icon"> placeholder="请选择"
<ai-icon type="svg" icon="iconVideo"/> :selectList="dict.getDict('qjEACondition')">
<span>上传视频</span> </ai-select>
</div> <el-input size="small" style="width: 180px;" v-model="item.downScore" placeholder="请输入"></el-input>
<span class="tips">支持mp4格式单个文件最大100MB</span>
</div> </div>
</el-upload> </div>
<video class="video-com" style="width:100%; height:100%; object-fit: fill;" muted
:src="form.files[0].url" controls="controls" v-if="form.files.length"></video>
<el-upload :show-file-list="false" ref="upload2" action :http-request="submitUpload" :accept="accept"
:limit="1" v-if="form.files.length">
<el-button style="margin-top: 10px;">重新选择</el-button>
</el-upload>
</el-form-item> </el-form-item>
<el-form-item label="视频封面" prop="pictureUrl" style="width: 100%;" v-if="form.contentType === '1'" :rules="[{required: true, message: '请上传视频封面', trigger: 'change'}]"> <el-form-item prop="chooseType" label="选题方式" :rules="[{required: true, message: '请选择选题方式', trigger: 'change'}]">
<ai-uploader <el-radio-group v-model="form.chooseType">
:instance="instance" <el-radio :label="item.dictValue" :key="item.dictValue" v-for="item in dict.getDict('qjEIChooseType')">{{ item.dictName }}</el-radio>
isShowTip </el-radio-group>
v-model="form.pictureUrl" </el-form-item>
:limit="1" <el-form-item prop="subjectConfigs" style="width: 100%;" label="题目设置" :rules="[{required: true, message: '请选择题目设置', trigger: 'change'}]">
:cropOps="cropOps" <div class="type-list">
is-crop> <div class="choose-item" v-for="(item, index) in form.subjectConfigs" :key="index">
<template slot="tips"> <span class="type-name">{{ dict.getLabel('qjQBType', item.subjectType) }}</span>
<p>最多上传1张图片,单个文件最大10MB支持jpgjpegpng格式</p> <div class="form-wrapper">
<p>图片比例1.61</p> <div class="form-item">
</template> <span>总题数</span>
</ai-uploader> <el-input-number size="small" v-model="item.subjectNumber" :min="0"></el-input-number>
</div>
<div class="form-item">
<span>每题分数</span>
<el-input-number size="small" v-model="item.eachScore" :min="0"></el-input-number>
</div>
</div>
</div>
</div>
</el-form-item>
<el-form-item style="width: 100%;" label="">
<el-button size="small" type="primary" style="width: 100px;" @click="toAdd">确定设置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<ai-dialog
:visible.sync="isShow"
width="890px"
title="选择试题">
<ai-search-bar class="search-bar">
<template #left>
<ai-select
style="width: 180px;"
v-model="search.type"
clearable
placeholder="请选择试题类型"
:selectList="dict.getDict('qjQBType')"
@change="search.current = 1, getList()">
</ai-select>
</template>
<template #right>
<el-input
v-model="search.title"
class="search-input"
size="small"
v-throttle="() => {search.current = 1, getList()}"
placeholder="请输入标题"
clearable
@clear="search.current = 1, getList()"
suffix-icon="iconfont iconSearch">
</el-input>
</template>
</ai-search-bar>
<el-checkbox-group v-model="ids">
<el-checkbox style="width: 100%;" :label="item.id" v-for="(item, index) in tableData" :key="index">
<span>{{ dict.getLabel('qjQBType', item.type) }}</span>
<span :title="item.title">{{ item.title }}</span>
</el-checkbox>
</el-checkbox-group>
<el-pagination
style="margin-top: 20px;"
background
:current-page.sync="search.current"
:total="total"
:page-size="search.size"
:page-sizes="[10, 20, 50, 100]"
layout="slot,->, prev, pager, next, sizes, jumper"
:pager-count="search.current"
@size-change="getList"
@current-change="getList">
<!-- <div class="paginationPre" v-if="isMultiple">
<el-checkbox :disabled="!list.length" :indeterminate="isIndeterminate" @change="onAllChange" v-model="isCheckAll">全选</el-checkbox>
</div> -->
</el-pagination>
</ai-dialog>
</template> </template>
</ai-card> </ai-card>
</template> </template>
<template #footer> <template #footer>
<el-button @click="cancel">取消</el-button> <el-button @click="cancel">取消</el-button>
<el-button type="primary" :loading="isLoading" @click="confirm">提交</el-button> <el-button type="primary" @click="confirm">提交</el-button>
</template> </template>
</ai-detail> </ai-detail>
</template> </template>
<script> <script>
import mp4box from 'mp4box'
import { mapState } from 'vuex'
export default { export default {
name: 'Add', name: 'Add',
props: { props: {
instance: Function, instance: Function,
dict: Object, dict: Object,
params: Object, params: Object
areaId: String
}, },
data () { data () {
return { return {
info: {}, info: {},
accept: '.mp4',
form: { form: {
title: '', title: '',
content: '',
showIndex: '', showIndex: '',
files: [], chooseType: '0',
pictureUrl: [], questions: [],
contentType: '0', assessments: [{
thumbUrl: [] assessmentType: '0',
downCondition: '',
downScore: '',
status: '',
upCondition: '',
upScore: ''
}, {
assessmentType: '1',
downCondition: '',
downScore: '',
status: '',
upCondition: '',
upScore: ''
}, {
assessmentType: '2',
downCondition: '',
downScore: '',
status: '',
upCondition: '',
upScore: ''
}, {
assessmentType: '3',
downCondition: '',
downScore: '',
status: '',
upCondition: '',
upScore: ''
}],
subjectConfigs: [{
eachScore: '',
subjectNumber: '',
subjectType: '0'
}, {
eachScore: '',
subjectNumber: '',
subjectType: '1'
}, {
eachScore: '',
subjectNumber: '',
subjectType: '2'
}]
}, },
isLoading: false, search: {
cropOps: { current: 1,
width: "336px", size: 10,
height: "210px" title: '',
type: ''
}, },
id: '', total: 10,
contentTypeList: [ colConfigs: [
{ { type: 'selection' },
name: '图文', { prop: 'type', label: '题目类型', align: 'left', format: v => this.dict.getLabel('qjQBType', v) + '题' },
value: '0' { prop: 'title', label: '题目', align: 'center' },
},
{
name: '视频',
value: '1'
}
], ],
isHideCoverimg: false, tableData: [],
cateList: [], isShow: false,
needExamine: '0' ids: []
} }
}, },
computed: {
...mapState(['user'])
},
created () { created () {
if (this.params && this.params.id) { this.getList()
this.id = this.params.id this.dict.load(['qjQBType', 'qjEIChooseType', 'qjEACondition', 'qjEAType']).then(() => {
this.getInfo(this.params.id) if (this.params && this.params.id) {
} this.id = this.params.id
this.getInfo(this.params.id)
}
})
}, },
methods: { methods: {
@@ -132,87 +216,80 @@
this.instance.post(`/app/appcontentinfo/queryDetailById?id=${id}`).then(res => { this.instance.post(`/app/appcontentinfo/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) { if (res.code === 0) {
this.form = res.data this.form = res.data
this.form.pictureUrl = res.data.pictureUrl ? [{
url: res.data.pictureUrl
}] : []
} }
}) })
}, },
onChange () { onChange (e) {
this.form.files = [] this.getList()
this.initChoose()
}, },
submitUpload(file) { initChoose () {
this.$refs['upload1']?.clearFiles(); console.log(1)
this.$refs['upload2']?.clearFiles(); this.ids.forEach(v => {
this.$refs['ruleForm']?.clearValidate('videoFile'); this.$refs.aitable.toggleRowSelection(v, true)
const fileType = file.file.name.split(".")[1]; })
const size = file.file.size / 1024 / 1024 > 100; },
let mp4boxfile = mp4box.createFile();
const reader = new FileReader(); handleSelectionChange (e) {
reader.readAsArrayBuffer(file.file); this.ids = e
reader.onload = (e) => { console.log(this.ids)
const arrayBuffer = e.target.result; },
arrayBuffer.fileStart = 0;
mp4boxfile.appendBuffer(arrayBuffer); getList() {
}; this.instance.post(`/app/appquestionbank/list`, null, {
mp4boxfile.onReady = (info) => { params: {
let codec = info.mime.match(/codecs="(\S*),/)[1] ...this.search
if (codec.indexOf('avc') === -1) {
return this.$message.error("视频编码格式不支持")
} }
}).then(res => {
if (size) { if (res.code == 0) {
return this.$message.error("视频大小不能超过100M"); this.tableData = res.data.records
this.total = res.data.total
} }
})
},
if (fileType && this.accept.indexOf(fileType.toLocaleLowerCase()) > -1) { toAdd () {
let formData = new FormData() if (this.form.chooseType === '0') {
formData.append('file', file.file); this.getRandomChoose()
this.isLoading = true } else {
this.instance.post(`/admin/file/add-unlimited`, formData).then(res => { this.isShow = true
if (res && res.data) {
let videoList = res.data[0].split(";");
this.form.files = [{
id: videoList[1],
url: videoList[0]
}]
}
this.isLoading = false
}).catch(() => {
this.isLoading = false
})
} else {
return this.$message.error("视频格式错误")
}
} }
}, },
getRandomChoose() {
let subjectNumber = 0
let eachScore = 0
this.form.subjectConfigs.forEach(v => {
eachScore = Number(v.eachScore) + eachScore
subjectNumber = Number(v.subjectNumber) + subjectNumber
})
if (subjectNumber === 0 || eachScore === 0) {
return this.$message.error('请进行题目设置')
}
this.instance.post(`/app/appquestionbank/randomChoose`, this.form.subjectConfigs).then(res => {
if (res.code == 0) {
this.form.questions = res.data
}
})
},
confirm () { confirm () {
this.$refs.form.validate((valid) => { this.$refs.form.validate((valid) => {
if (valid) { if (valid) {
this.isLoading = true this.instance.post(`/app/appexaminationinfo/addOrUpdate`, {
this.instance.post(`/app/appcontentinfo/addOrUpdate`, {
...this.form, ...this.form,
pictureUrl: this.form.pictureUrl.length ? this.form.pictureUrl[0].url : '' id: this.params.id || ''
}).then(res => { }).then(res => {
if (res.code == 0) { if (res.code == 0) {
if (this.needExamine === '1') { this.$message.success('提交成功')
this.$message.success('提交成功,等待管理员审核')
} else {
this.$message.success('提交成功')
}
setTimeout(() => { setTimeout(() => {
this.cancel(true) this.cancel(true)
}, 600) }, 600)
} else {
this.isLoading = false
} }
}).catch(() => {
this.isLoading = false
}) })
} }
}) })
@@ -229,52 +306,136 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.content-add { .AppExaminationManage {
.video { .el-checkbox-group {
width: 640px; width: 100%;
height: 360px;
border-radius: 4px;
border: 1px dashed #D0D4DC;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.icon { :deep( .el-checkbox__label ) {
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; width: 100%;
span:nth-child(2) {
display: inline-block;
font-size: 16px;
color: #333333;
line-height: 30px;
}
.iconfont {
display: inline-block;
font-size: 40px;
color: #2266FF;
}
}
.tips {
display: inline-block;
font-size: 12px;
color: #999999;
line-height: 26px;
} }
} }
.video-com { :deep( .el-pagination ){
width: 640px; position: absolute;
height: 360px; bottom: 0px;
background: rgba(0, 0, 0, 0.5); left: 0;
border-radius: 2px; z-index: 11;
border: 1px solid #D0D4DC; width: 100%;
margin-top: -40px; display: flex;
align-items: center;
flex-direction: row-reverse;
justify-content: flex-end;
background: #fcfcfc;
padding: 10px 10px;
.paginationPre {
display: flex;
align-items: center;
}
.el-pagination__rightwrapper {
display: flex;
align-items: center;
justify-content: flex-end;
flex: 1;
.el-pagination__sizes {
margin: 0;
input {
height: 22px;
line-height: 22px;
}
}
}
.el-checkbox {
display: flex;
align-items: center;
.el-checkbox__input, .el-checkbox__inner {
width: 14px;
height: 14px;
min-width: 0 !important;
line-height: 1 !important;
}
.el-checkbox__label {
font-size: 12px;
color: #222222;
height: auto !important;
line-height: 1 !important;
padding-left: 3px !important;
}
}
}
.el-checkbox {
display: flex;
align-items: center;
width: 100%;
padding: 10px 20px;
&:nth-of-type(2n - 1) {
background: #F5F6F9;
}
span:first-child {
margin-right: 80px;
}
span:last-child {
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: center;
}
}
.choose-item {
display: flex;
align-items: center;
.type-name {
width: 80px;
color: #666;
}
.form-wrapper {
display: flex;
align-items: center;
.form-item:first-child {
margin-right: 40px;
}
.el-input-number {
margin: 0 10px;
}
span {
margin-right: 10px;
color: #999;
}
}
}
.type-item {
display: flex;
align-items: center;
.el-input {
margin: 0 10px;
}
.type-name {
width: 50px;
}
span {
margin-right: 10px;
color: #666;
}
} }
} }
</style> </style>

View File

@@ -10,7 +10,7 @@
v-model="search.status" v-model="search.status"
clearable clearable
placeholder="请选择课程状态" placeholder="请选择课程状态"
:selectList="statusList" :selectList="dict.getDict('qjEIStatus')"
@change="search.current = 1, getList()"> @change="search.current = 1, getList()">
</ai-select> </ai-select>
<el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button> <el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button>
@@ -21,7 +21,7 @@
class="search-input" class="search-input"
size="small" size="small"
v-throttle="() => {search.current = 1, getList()}" v-throttle="() => {search.current = 1, getList()}"
placeholder="请输入标题" placeholder="请输入考试名称"
clearable clearable
@clear="search.current = 1, getList()" @clear="search.current = 1, getList()"
suffix-icon="iconfont iconSearch"> suffix-icon="iconfont iconSearch">
@@ -69,12 +69,12 @@
}, },
total: 10, total: 10,
colConfigs: [ colConfigs: [
{ prop: 'title', label: '考试名称', align: 'left' }, { prop: 'examinationName', label: '考试名称', align: 'left' },
{ prop: 'createUserName', label: '试题总数', align: 'center' }, { prop: 'allSubjectNumber', label: '试题总数', align: 'center' },
{ prop: 'beginTime', label: '通过分数', align: 'center' }, { prop: 'beginTime', label: '通过分数', align: 'center' },
{ prop: 'endTime', label: '状态', align: 'center' }, { prop: 'status', label: '状态', align: 'center', format: v => this.dict.getLable('qjEIStatus', v) },
{ prop: 'createTime', label: '考试人数', align: 'center' }, { prop: 'examinationNumber', label: '考试人数', align: 'center' },
{ prop: 'createTime', label: '通过人数', align: 'center' } { prop: 'passNumber', label: '通过人数', align: 'center' }
], ],
tableData: [], tableData: [],
statusList: [ statusList: [
@@ -95,12 +95,14 @@
}, },
created() { created() {
this.getList() this.dict.load('qjEIStatus').then(() => {
this.getList()
})
}, },
methods: { methods: {
getList() { getList() {
this.instance.post(`/app/appmarketingactivityinfo/list`, null, { this.instance.post(`/app/appexaminationinfo/list`, null, {
params: { params: {
...this.search ...this.search
} }
@@ -114,7 +116,7 @@
remove (id) { remove (id) {
this.$confirm('确定删除该活动?').then(() => { this.$confirm('确定删除该活动?').then(() => {
this.instance.post(`/app/appmarketingactivityinfo/delete?id=${id}`).then(res => { this.instance.post(`/app/appexaminationinfo/delete?id=${id}`).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.$message.success('删除成功!') this.$message.success('删除成功!')
this.getList() this.getList()

View File

@@ -192,6 +192,7 @@ export default {
this.$refs[this.refName].clearSelection() this.$refs[this.refName].clearSelection()
}, },
toggleRowSelection() { toggleRowSelection() {
console.log(22)
this.$refs[this.refName].toggleRowSelection(...arguments) this.$refs[this.refName].toggleRowSelection(...arguments)
}, },
toggleAllSelection() { toggleAllSelection() {