Commit 288adcf2 by ‘巴博尔’

视频、链接去除

parent 07925961
...@@ -56,13 +56,19 @@ export default { ...@@ -56,13 +56,19 @@ export default {
type: { type: {
type: String, type: String,
default: "url", default: "url",
} },
iconType: {
type: Array,
default: () => {
return ["link", "image", "video"]; // 链接、图片、视频
},
},
}, },
data() { data() {
return { return {
uploadUrl: process.env.VUE_APP_BASE_API + "/system/oss/upload", // 上传的图片服务器地址 uploadUrl: process.env.VUE_APP_BASE_API + "/system/oss/upload", // 上传的图片服务器地址
headers: { headers: {
Authorization: "Bearer " + getToken() Authorization: "Bearer " + getToken(),
}, },
Quill: null, Quill: null,
currentValue: "", currentValue: "",
...@@ -82,7 +88,7 @@ export default { ...@@ -82,7 +88,7 @@ export default {
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色 [{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
[{ align: [] }], // 对齐方式 [{ align: [] }], // 对齐方式
["clean"], // 清除文本格式 ["clean"], // 清除文本格式
["link", "image", "video"] // 链接、图片、视频 this.iconType, // 链接、图片、视频
], ],
}, },
placeholder: "请输入内容", placeholder: "请输入内容",
...@@ -126,7 +132,7 @@ export default { ...@@ -126,7 +132,7 @@ export default {
const editor = this.$refs.editor; const editor = this.$refs.editor;
this.Quill = new Quill(editor, this.options); this.Quill = new Quill(editor, this.options);
// 如果设置了上传地址则自定义图片上传事件 // 如果设置了上传地址则自定义图片上传事件
if (this.type == 'url') { if (this.type == "url") {
let toolbar = this.Quill.getModule("toolbar"); let toolbar = this.Quill.getModule("toolbar");
toolbar.addHandler("image", (value) => { toolbar.addHandler("image", (value) => {
this.uploadType = "image"; this.uploadType = "image";
...@@ -191,7 +197,8 @@ export default { ...@@ -191,7 +197,8 @@ export default {
</script> </script>
<style> <style>
.editor, .ql-toolbar { .editor,
.ql-toolbar {
white-space: pre-wrap !important; white-space: pre-wrap !important;
line-height: normal !important; line-height: normal !important;
} }
......
...@@ -407,11 +407,19 @@ ...@@ -407,11 +407,19 @@
</el-col> </el-col>
<el-col :span="18"> <el-col :span="18">
<el-form-item label="题目" prop="topic"> <el-form-item label="题目" prop="topic">
<editor v-model="form.topic" :min-height="192" /> <editor
v-model="form.topic"
:min-height="192"
:iconType="['image']"
/>
</el-form-item> </el-form-item>
<template v-if="[1, '1', 3, '3'].includes(form.species)"> <template v-if="[1, '1', 3, '3'].includes(form.species)">
<el-form-item label="答案" prop="answer"> <el-form-item label="答案" prop="answer">
<editor v-model="form.answer" :min-height="192" /> <editor
v-model="form.answer"
:min-height="192"
:iconType="['image']"
/>
</el-form-item> </el-form-item>
<el-form-item label="答案图片" prop="rightAnswersPic"> <el-form-item label="答案图片" prop="rightAnswersPic">
<imageUpload :limit="9" v-model="form.rightAnswersPic" /> <imageUpload :limit="9" v-model="form.rightAnswersPic" />
...@@ -443,7 +451,11 @@ ...@@ -443,7 +451,11 @@
v-else v-else
@click="clickCheckItemDel(index)" @click="clickCheckItemDel(index)"
></i> ></i>
<editor v-model="item.html" :min-height="192" /> <editor
v-model="item.html"
:min-height="192"
:iconType="['image']"
/>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
...@@ -472,7 +484,11 @@ ...@@ -472,7 +484,11 @@
</el-form-item> </el-form-item>
<template v-if="form.explain"> <template v-if="form.explain">
<el-form-item label="解答过程" prop="resolveCourse"> <el-form-item label="解答过程" prop="resolveCourse">
<editor v-model="form.resolveCourse" :min-height="192" /> <editor
v-model="form.resolveCourse"
:min-height="192"
:iconType="['image']"
/>
</el-form-item> </el-form-item>
<el-form-item label="解答视频" prop="resolveVideo"> <el-form-item label="解答视频" prop="resolveVideo">
<fileUpload <fileUpload
...@@ -760,7 +776,7 @@ export default { ...@@ -760,7 +776,7 @@ export default {
isKong = false; isKong = false;
if (index < 25) { if (index < 25) {
self.form.checkList.forEach((item, ik) => { self.form.checkList.forEach((item, ik) => {
if (self.IsEmptyStr(self.getWangEditorText(item.html + '') + "")) { if (self.IsEmptyStr(self.getWangEditorText(item.html + "") + "")) {
isKong = true; isKong = true;
} }
}); });
...@@ -839,7 +855,7 @@ export default { ...@@ -839,7 +855,7 @@ export default {
}); });
}, },
getWangEditorText(str) { getWangEditorText(str) {
console.log(str,"========str") console.log(str, "========str");
if (str) { if (str) {
return str return str
.replace(/<[^<p>]+>/g, "") // 将所有<p>标签 replace '' .replace(/<[^<p>]+>/g, "") // 将所有<p>标签 replace ''
...@@ -859,18 +875,19 @@ export default { ...@@ -859,18 +875,19 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
let self = this,isKong = false; let self = this,
isKong = false;
self.isEditor("topic"); self.isEditor("topic");
if(self.form.checkList && self.form.checkList.length) { if (self.form.checkList && self.form.checkList.length) {
self.form.checkList.forEach((item, ik) => { self.form.checkList.forEach((item, ik) => {
console.log(item.html) console.log(item.html);
if (self.IsEmptyStr(self.getWangEditorText(item.html + '') + "")) { if (self.IsEmptyStr(self.getWangEditorText(item.html + "") + "")) {
isKong = true; isKong = true;
} }
}); });
if (isKong) { if (isKong) {
self.$message.warning("请填写选项内容"); self.$message.warning("请填写选项内容");
self.$refs.form.validateField('checkList'); self.$refs.form.validateField("checkList");
} }
} }
if (self.form.explain) { if (self.form.explain) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment