mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-14 05:16:43 +08:00
2022年5月29日从svn移到git
This commit is contained in:
125
src/components/Qa/addQuestion.vue
Normal file
125
src/components/Qa/addQuestion.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<!--
|
||||
* @Author: zhaohg
|
||||
* @Date: 2022-03-14 09:54:51
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
<el-dialog :close-on-click-modal='false' title="发布问题" width="800px" :visible.sync="askQuestionDialog">
|
||||
<el-form ref="askForm" :model="askForm" :rules="askFormRules" label-position="right" label-width="60px">
|
||||
<el-form-item label="标题:" prop="title"><el-input type="text" v-model="askForm.title" show-word-limit placeholder="请输入问题标题,字符长度不能高于100" maxlength="100"></el-input></el-form-item>
|
||||
<el-form-item label="内容:" prop="content">
|
||||
<el-input type="textarea" v-model="askForm.content" placeholder="请输入问题内容" :rows="6"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="图片" class="imageUrls">
|
||||
<imageUpload dir="qa" :value="imageShowUrl" @success="handleUploadSuccess" @remove="handleRemoveSuccess"></imageUpload>
|
||||
<!-- <el-upload
|
||||
:action="uploadFileUrl"
|
||||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
list-type="picture-card"
|
||||
:on-success="handleAvatarSuccess"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
class="avatar-uploader"
|
||||
>
|
||||
<i class="el-icon-plus avatar-uploader-icon"></i>
|
||||
<span class="icon-text">上传图片</span>
|
||||
</el-upload> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer" style="text-align: left;margin-left:60px">
|
||||
<el-button type="primary" @click="addQaData" :disabled="!askForm.checked">发布问题</el-button>
|
||||
<el-button @click="askQuestionDialog = false">取 消</el-button>
|
||||
<el-checkbox style="margin-left:10px" v-model="askForm.checked"> </el-checkbox><span style="font-size:14px;color:#787878;margin-left:10px">我已阅读并遵守</span><span style="font-size:14px;color:#588afc;margin-right:10px;cursor: pointer;" @click="askFormCheckedShow = true">平台内容发布要求</span>
|
||||
</div>
|
||||
<el-dialog class="checked-show" :visible.sync="askFormCheckedShow" width="800px" :show-close="false" :modal="false">
|
||||
<agreement></agreement>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<!-- <el-button @click="askFormCheckedShow = false">取 消</el-button> -->
|
||||
<el-button type="primary" @click="askFormCheckedShow = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import apiQa from '@/api/modules/qa.js';
|
||||
import imageUpload from '@/components/ImageUpload/index.vue';
|
||||
import agreement from '@/components/Portal/agreement.vue'
|
||||
export default{
|
||||
data(){
|
||||
return {
|
||||
askFormCheckedShow:false,
|
||||
askFormRules: {
|
||||
title: [{ required: true, message: '请输入问题标题', trigger: 'blur' }, { max: 100, message: '字符长度不能高于100', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '请输入问题内容', trigger: 'blur' }]
|
||||
}, //表单验证
|
||||
askForm: {}, //发布问答绑定的数据
|
||||
imageShowUrl: '', //组件绑定的值,不知道用处
|
||||
askQuestionDialog: false, //控制提问题弹窗
|
||||
}
|
||||
},
|
||||
components:{imageUpload,agreement},
|
||||
methods:{
|
||||
handleClose(done) {
|
||||
this.$confirm('确认关闭?')
|
||||
.then(_ => {
|
||||
done();
|
||||
})
|
||||
.catch(_ => {});
|
||||
},
|
||||
handleUploadSuccess(file) {
|
||||
// console.log(file.result.httpPath,'是否会fig以后关于和',file.result.filePath)
|
||||
this.imageShowUrl=file.result.httpPath;
|
||||
this.askForm.images=file.result.filePath
|
||||
},
|
||||
handleRemoveSuccess(file) {
|
||||
this.imageShowUrl=''
|
||||
this.askForm.images=''
|
||||
// console.log(file);//移除页面的触发事件没有
|
||||
},
|
||||
//发布问答时点击发布时的增加接口
|
||||
addQaData() {
|
||||
this.$refs.askForm.validate(valid => {
|
||||
if (valid) {
|
||||
apiQa.save(this.askForm).then(res => {
|
||||
if (res.status == 200) {
|
||||
if(res.message=='服务处理成功'){
|
||||
this.$message.success("发布问题成功")
|
||||
}
|
||||
if(res.message.indexOf('审核')!=-1){
|
||||
this.$message.warning("发布失败,因包含敏感词,请等待人工审核")
|
||||
}
|
||||
this.askForm = {};
|
||||
this.imageShowUrl='',
|
||||
this.askQuestionDialog = false;
|
||||
this.$emit('sure',true,res.result)
|
||||
} else {
|
||||
this.$message({
|
||||
type:'error',
|
||||
message:res.message
|
||||
});
|
||||
}
|
||||
}).catch(err=>{
|
||||
// this.message({
|
||||
// message:'发布问答失败',
|
||||
// type:'error'
|
||||
// })
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
::v-deep .checked-show{
|
||||
.el-dialog__header{
|
||||
padding:0;
|
||||
}
|
||||
.el-dialog__footer{
|
||||
border-top: 1px solid #F5F5F6;
|
||||
background-color: #F5F5F6;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user