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>
<ai-detail class="content-add" v-loading="isLoading">
<ai-detail class="AppExaminationManage-add">
<template slot="title">
<ai-title :title="params.id ? '编辑' + '考试' : '添加' + '考试'" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template>
@@ -7,124 +7,208 @@
<ai-card title="基本信息">
<template #content>
<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-input size="small" v-model="form.title" clearable placeholder="请输入..." :maxlength="50" :show-word-limit="true"></el-input>
<el-form-item label="考试名称" prop="examinationName" :rules="[{required: true, message: '请输入考试名称', trigger: 'blur'}]">
<el-input size="small" v-model="form.examinationName" clearable placeholder="请输入考试名称" :maxlength="50" :show-word-limit="true"></el-input>
</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-form-item>
<el-form-item v-if="form.contentType === '0'" label="正文" prop="content" style="width: 100%;" :rules="[{required: true, message: '请输入内容', trigger: 'change'}]">
<ai-editor v-model="form.content" :instance="instance"/>
</el-form-item>
<el-form-item v-if="form.contentType === '0' && !isHideCoverimg" label="封面图片" prop="files" style="width: 100%;">
<ai-uploader
:instance="instance"
v-model="form.files"
key="file"
:limit="9">
<template slot="tips">
<p>最多上传9张图片,单个文件最大10MB支持jpgjpegpng格式</p>
</template>
</ai-uploader>
</el-form-item>
<el-form-item v-if="form.contentType === '1'" label="视频" prop="files" style="width: 100%;" :rules="[{required: true, message: '请上传视频', trigger: 'change'}]">
<el-upload :show-file-list="false" ref="upload1" action :http-request="submitUpload" :accept="accept" :limit="1">
<div class="video" v-if="!form.files.length">
<div class="icon">
<ai-icon type="svg" icon="iconVideo"/>
<span>上传视频</span>
</div>
<span class="tips">支持mp4格式单个文件最大100MB</span>
<el-form-item prop="chooseType" style="width: 100%" label="成绩评核" :rules="[{required: true, message: '请选择成绩评核', trigger: 'change'}]">
<div class="type-list">
<div class="type-item" v-for="(item, index) in form.assessments" :key="index">
<span class="type-name">{{ dict.getLabel('qjEAType', item.assessmentType) }}</span>
<ai-select
style="width: 180px;"
v-model="item.qjEACondition"
clearable
placeholder="请选择"
:selectList="dict.getDict('qjEACondition')">
</ai-select>
<el-input size="small" style="width: 180px;" v-model="item.upScore" placeholder="请输入"></el-input>
<span></span>
<ai-select
style="width: 180px;"
v-model="item.downCondition"
clearable
placeholder="请选择"
:selectList="dict.getDict('qjEACondition')">
</ai-select>
<el-input size="small" style="width: 180px;" v-model="item.downScore" placeholder="请输入"></el-input>
</div>
</el-upload>
<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>
</div>
</el-form-item>
<el-form-item label="视频封面" prop="pictureUrl" style="width: 100%;" v-if="form.contentType === '1'" :rules="[{required: true, message: '请上传视频封面', trigger: 'change'}]">
<ai-uploader
:instance="instance"
isShowTip
v-model="form.pictureUrl"
:limit="1"
:cropOps="cropOps"
is-crop>
<template slot="tips">
<p>最多上传1张图片,单个文件最大10MB支持jpgjpegpng格式</p>
<p>图片比例1.61</p>
</template>
</ai-uploader>
<el-form-item prop="chooseType" label="选题方式" :rules="[{required: true, message: '请选择选题方式', trigger: 'change'}]">
<el-radio-group v-model="form.chooseType">
<el-radio :label="item.dictValue" :key="item.dictValue" v-for="item in dict.getDict('qjEIChooseType')">{{ item.dictName }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item prop="subjectConfigs" style="width: 100%;" label="题目设置" :rules="[{required: true, message: '请选择题目设置', trigger: 'change'}]">
<div class="type-list">
<div class="choose-item" v-for="(item, index) in form.subjectConfigs" :key="index">
<span class="type-name">{{ dict.getLabel('qjQBType', item.subjectType) }}</span>
<div class="form-wrapper">
<div class="form-item">
<span>总题数</span>
<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>
<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>
</ai-card>
</template>
<template #footer>
<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>
</ai-detail>
</template>
<script>
import mp4box from 'mp4box'
import { mapState } from 'vuex'
export default {
name: 'Add',
props: {
instance: Function,
dict: Object,
params: Object,
areaId: String
params: Object
},
data () {
return {
info: {},
accept: '.mp4',
form: {
title: '',
content: '',
showIndex: '',
files: [],
pictureUrl: [],
contentType: '0',
thumbUrl: []
chooseType: '0',
questions: [],
assessments: [{
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,
cropOps: {
width: "336px",
height: "210px"
search: {
current: 1,
size: 10,
title: '',
type: ''
},
id: '',
contentTypeList: [
{
name: '图文',
value: '0'
},
{
name: '视频',
value: '1'
}
total: 10,
colConfigs: [
{ type: 'selection' },
{ prop: 'type', label: '题目类型', align: 'left', format: v => this.dict.getLabel('qjQBType', v) + '题' },
{ prop: 'title', label: '题目', align: 'center' },
],
isHideCoverimg: false,
cateList: [],
needExamine: '0'
tableData: [],
isShow: false,
ids: []
}
},
computed: {
...mapState(['user'])
},
created () {
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
this.getList()
this.dict.load(['qjQBType', 'qjEIChooseType', 'qjEACondition', 'qjEAType']).then(() => {
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
})
},
methods: {
@@ -132,87 +216,80 @@
this.instance.post(`/app/appcontentinfo/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = res.data
this.form.pictureUrl = res.data.pictureUrl ? [{
url: res.data.pictureUrl
}] : []
}
})
},
onChange () {
this.form.files = []
onChange (e) {
this.getList()
this.initChoose()
},
submitUpload(file) {
this.$refs['upload1']?.clearFiles();
this.$refs['upload2']?.clearFiles();
this.$refs['ruleForm']?.clearValidate('videoFile');
const fileType = file.file.name.split(".")[1];
const size = file.file.size / 1024 / 1024 > 100;
let mp4boxfile = mp4box.createFile();
const reader = new FileReader();
reader.readAsArrayBuffer(file.file);
reader.onload = (e) => {
const arrayBuffer = e.target.result;
arrayBuffer.fileStart = 0;
mp4boxfile.appendBuffer(arrayBuffer);
};
mp4boxfile.onReady = (info) => {
let codec = info.mime.match(/codecs="(\S*),/)[1]
if (codec.indexOf('avc') === -1) {
return this.$message.error("视频编码格式不支持")
initChoose () {
console.log(1)
this.ids.forEach(v => {
this.$refs.aitable.toggleRowSelection(v, true)
})
},
handleSelectionChange (e) {
this.ids = e
console.log(this.ids)
},
getList() {
this.instance.post(`/app/appquestionbank/list`, null, {
params: {
...this.search
}
if (size) {
return this.$message.error("视频大小不能超过100M");
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
},
if (fileType && this.accept.indexOf(fileType.toLocaleLowerCase()) > -1) {
let formData = new FormData()
formData.append('file', file.file);
this.isLoading = true
this.instance.post(`/admin/file/add-unlimited`, formData).then(res => {
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("视频格式错误")
}
toAdd () {
if (this.form.chooseType === '0') {
this.getRandomChoose()
} else {
this.isShow = true
}
},
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 () {
this.$refs.form.validate((valid) => {
if (valid) {
this.isLoading = true
this.instance.post(`/app/appcontentinfo/addOrUpdate`, {
this.instance.post(`/app/appexaminationinfo/addOrUpdate`, {
...this.form,
pictureUrl: this.form.pictureUrl.length ? this.form.pictureUrl[0].url : ''
id: this.params.id || ''
}).then(res => {
if (res.code == 0) {
if (this.needExamine === '1') {
this.$message.success('提交成功,等待管理员审核')
} else {
this.$message.success('提交成功')
}
this.$message.success('提交成功')
setTimeout(() => {
this.cancel(true)
}, 600)
} else {
this.isLoading = false
}
}).catch(() => {
this.isLoading = false
})
}
})
@@ -229,52 +306,136 @@
</script>
<style scoped lang="scss">
.content-add {
.video {
width: 640px;
height: 360px;
border-radius: 4px;
border: 1px dashed #D0D4DC;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.AppExaminationManage {
.el-checkbox-group {
width: 100%;
.icon {
:deep( .el-checkbox__label ) {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
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;
width: 100%;
}
}
.video-com {
width: 640px;
height: 360px;
background: rgba(0, 0, 0, 0.5);
border-radius: 2px;
border: 1px solid #D0D4DC;
margin-top: -40px;
:deep( .el-pagination ){
position: absolute;
bottom: 0px;
left: 0;
z-index: 11;
width: 100%;
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>

View File

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

View File

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