|
@@ -13,10 +13,10 @@
|
|
|
style="width: 100%">
|
|
|
<el-form-item label="标题"
|
|
|
prop="title">
|
|
|
- <el-input v-model.trim="form.title"></el-input>
|
|
|
+ <el-input v-model.trim="form.title" placeholder="请输入标题"></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="排序值">
|
|
|
- <el-input v-model.trim="form.order"></el-input>
|
|
|
+ <el-form-item label="排序值" prop="order">
|
|
|
+ <el-input v-model.trim="form.order" placeholder=""></el-input>
|
|
|
</el-form-item>
|
|
|
<!-- 平台的功能不需要选择分部 -->
|
|
|
<el-form-item label="所属分部"
|
|
@@ -46,19 +46,23 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
- <!-- banner图 && app按钮管理,才需要添加版本号 -->
|
|
|
- <el-form-item label="版本号"
|
|
|
+ <!-- banner图 && app按钮管理, 广告管理才需要添加版本号 -->
|
|
|
+ <el-form-item label="版本号" prop="memo"
|
|
|
v-if="type == 3 || type == 6 || type == 8">
|
|
|
<el-input v-model="form.memo"></el-input>
|
|
|
</el-form-item>
|
|
|
- <!-- -->
|
|
|
- <!-- <el-form-item v-if="type == 3 || type == 6 || type == 5 || type == 8" label="链接地址">
|
|
|
- <el-input v-model.trim="form.linkUrl"></el-input>
|
|
|
- </el-form-item> -->
|
|
|
+
|
|
|
+ <!-- 1 2 4 7 -->
|
|
|
+ <el-form-item label="跳转方式" v-if="type == 1 || type == 2 || type == 4 || type == 7">
|
|
|
+ <el-radio-group v-model="outUrlRadio">
|
|
|
+ <el-radio :label="1">外部链接</el-radio>
|
|
|
+ <el-radio :label="0">内容跳转</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
<!-- :rules='[{ required: type == 3 || type == 6 || type == 5 || type == 8 ? false : true, message: "请输入链接地址", trigger: "blur" }]' -->
|
|
|
- <el-form-item label="链接地址"
|
|
|
- prop="linkUrl"
|
|
|
- >
|
|
|
+ <!-- 1 2 4 7 -->
|
|
|
+ <el-form-item label="链接地址" prop="linkUrl" v-if="outUrlRadio == 1"
|
|
|
+ :rules='[{ required: (type == 3 || type == 6 || type == 5 || type == 8) ? false : true, message: "请输入链接地址", trigger: "blur" }]'>
|
|
|
<el-input v-model.trim="form.linkUrl"></el-input>
|
|
|
</el-form-item>
|
|
|
|
|
@@ -108,24 +112,23 @@
|
|
|
key="coverImage"
|
|
|
:label="type == 8 ? '广告图' : '封面图'"
|
|
|
prop="coverImage">
|
|
|
- <el-upload class="avatar-uploader"
|
|
|
+ <!-- <el-upload class="avatar-uploader"
|
|
|
action="/api-web/uploadFile"
|
|
|
:headers="headers"
|
|
|
:show-file-list="false"
|
|
|
+ v-loading="uploadCoverLoading"
|
|
|
accept=".jpg, .jpeg, .png, .gif"
|
|
|
:on-success="handleAvatarSuccess"
|
|
|
+ :on-error="handleAvatarError"
|
|
|
:before-upload="beforeAvatarUpload">
|
|
|
- <!-- 判断是图片还是视频 -->
|
|
|
<img v-if="form.coverImage"
|
|
|
:src="form.coverImage"
|
|
|
class="avatar" />
|
|
|
<i v-else
|
|
|
class="el-icon-plus avatar-uploader-icon"></i>
|
|
|
- </el-upload>
|
|
|
- <p class="imageSize"
|
|
|
- v-if="imageSize">
|
|
|
- <template v-if="type == 4 || type == 5 || type == 6 || type == 7">上传图片尺寸为:</template>
|
|
|
- {{ imageSize }}</p>
|
|
|
+ </el-upload> -->
|
|
|
+ <image-cropper :options="cropperOptions" :imgSize="2" :imageUrl="form.coverImage" @crop-upload-success="cropSuccess" />
|
|
|
+ <p class="imageSize">图片不能超过 2M;</p>
|
|
|
</el-form-item>
|
|
|
<!-- 广告管理才有时长 -->
|
|
|
<el-form-item label="显示时长(秒)"
|
|
@@ -144,19 +147,11 @@
|
|
|
:rules="[{ required: true, message: (type == 7 ? '请选择知识类别' : '请选择资讯类别'), trigger: 'change' }]">
|
|
|
<el-select v-model="form.subType" style="width: 400px !important">
|
|
|
<el-option v-for="item in typeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
|
|
- <!-- <el-option label="演奏小技巧"
|
|
|
- :value="1"></el-option>
|
|
|
- <el-option label="乐理基础"
|
|
|
- :value="2"></el-option>
|
|
|
- <el-option label="乐器保养"
|
|
|
- :value="3"></el-option>
|
|
|
- <el-option label="乐曲演奏展示"
|
|
|
- :value="4"></el-option> -->
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<!-- 闪页管理 BANNER管理 APP按钮管理 广告管理 -->
|
|
|
<el-form-item label="内容"
|
|
|
- v-show="type != 8 && type != 5 && type != 3 && type != 6"
|
|
|
+ v-show="type != 8 && type != 5 && type != 3 && type != 6 && outUrlRadio != 1"
|
|
|
prop="content"
|
|
|
:rules="[{ required: type != 8 && type != 5 && type != 3 && type != 6 ? true : false, message: '请编辑内容', trigger: 'blur' }]">
|
|
|
<quill-editor class="ql-editor"
|
|
@@ -287,8 +282,6 @@ import { newsQueryId, newsAdd, newsUpdate, newsTypeList } from "@/api/contentMan
|
|
|
import store from "@/store";
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
import { vaildStudentUrl } from "@/utils/validate";
|
|
|
-// import E from 'wangeditor'
|
|
|
-// require styles
|
|
|
import "quill/dist/quill.core.css";
|
|
|
import "quill/dist/quill.snow.css";
|
|
|
import "quill/dist/quill.bubble.css";
|
|
@@ -348,6 +341,7 @@ let validNum = (rule, value, callback) => {
|
|
|
callback()
|
|
|
}
|
|
|
}
|
|
|
+import ImageCropper from '@/components/ImageCropper'
|
|
|
// 这里引入修改过的video模块并注册
|
|
|
import Video from "../quill/video.js";
|
|
|
import dayjs from 'dayjs'
|
|
@@ -355,7 +349,8 @@ Quill.register(Video, true);
|
|
|
export default {
|
|
|
name: "contentOperation",
|
|
|
components: {
|
|
|
- quillEditor
|
|
|
+ quillEditor,
|
|
|
+ ImageCropper
|
|
|
},
|
|
|
data () {
|
|
|
let that = this;
|
|
@@ -391,6 +386,7 @@ export default {
|
|
|
updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
content: null
|
|
|
},
|
|
|
+ outUrlRadio: 1, // 默认使用内部连接跳转
|
|
|
editorIndex: 0, // 光标位置
|
|
|
editorOption: {
|
|
|
placeholder: "请输入内容",
|
|
@@ -424,8 +420,9 @@ export default {
|
|
|
url: null,
|
|
|
videoUrl: null
|
|
|
},
|
|
|
- uploadLoading: false,
|
|
|
- uploadImgLoading: false,
|
|
|
+ uploadCoverLoading: false,
|
|
|
+ uploadLoading: false, // 上传视屏loading
|
|
|
+ uploadImgLoading: false, // 上传封面图地址 loading
|
|
|
fileList: [],
|
|
|
dialogFormRules: {
|
|
|
url: [{ required: true, message: "请输入视频地址", trigger: "blur" }],
|
|
@@ -445,7 +442,7 @@ export default {
|
|
|
content: null,
|
|
|
subType: null,
|
|
|
actionTime: null,
|
|
|
- organIdList: null,
|
|
|
+ organIdList: [],
|
|
|
},
|
|
|
rules: {
|
|
|
title: [
|
|
@@ -457,38 +454,22 @@ export default {
|
|
|
],
|
|
|
organIdList: [{ required: true, message: "请选择分部", trigger: "change" }],
|
|
|
},
|
|
|
- imageSize: null,
|
|
|
typeList: [], //子分类列表
|
|
|
+ cropperOptions: {
|
|
|
+ autoCrop: true, //是否默认生成截图框
|
|
|
+ autoCropWidth: 300, //默认生成截图框宽度
|
|
|
+ autoCropHeight: 300, //默认生成截图框高度
|
|
|
+ fixedBox: true, //是否固定截图框大小 不允许改变
|
|
|
+ previewsCircle: false, //预览图是否是圆形
|
|
|
+ full: true,
|
|
|
+ title: '上传图片', //模态框上显示的标题
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
created () { },
|
|
|
mounted () {
|
|
|
const query = this.$route.query
|
|
|
if (query.pageType == "create") {
|
|
|
- let url = ''
|
|
|
- if (query.type == 7) {
|
|
|
- url = vaildStudentUrl() + "/#/knowledge"
|
|
|
- } else if (query.type == 8 || query.type == 5) {
|
|
|
- url = ''
|
|
|
- } else {
|
|
|
- url = vaildStudentUrl() + "/#/specialdetail"
|
|
|
- }
|
|
|
- this.form = {
|
|
|
- title: null,
|
|
|
- order: null,
|
|
|
- coverImage: null,
|
|
|
- videoCoverImage: null,
|
|
|
- attribute1: null,
|
|
|
- linkUrl: null,
|
|
|
- type: query.type,
|
|
|
- subjectIdList: null,
|
|
|
- status: 1,
|
|
|
- content: null,
|
|
|
- // tenantId: null,
|
|
|
- organIdList: null,
|
|
|
- subType: null,
|
|
|
- actionTime: null
|
|
|
- };
|
|
|
this.$refs["form"].clearValidate();
|
|
|
|
|
|
this.dialogForm = {
|
|
@@ -507,27 +488,84 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
init () {
|
|
|
- this.getList();
|
|
|
- this.addQuillTitle();
|
|
|
const query = this.$route.query
|
|
|
this.type = query.type;
|
|
|
this.pageType = query.pageType;
|
|
|
-
|
|
|
- // this.form.type
|
|
|
- let tempTitle = {
|
|
|
- 1: "468px * 552px;图片不能超过 2M;",
|
|
|
- 2: "456px * 288px; 图片不能超过 2M;",
|
|
|
- 3: "686px * 140px; 图片不能超过 2M;",
|
|
|
- 4: "图片不能超过 2M;",
|
|
|
- 5: "图片不能超过 2M;",
|
|
|
- 6: "图片不能超过 2M;",
|
|
|
- 7: "图片不能超过 2M;",
|
|
|
- 8: "1242px * 2208px; 图片不能超过 2M;"
|
|
|
- };
|
|
|
- this.imageSize = tempTitle[this.form.type];
|
|
|
-
|
|
|
+ this.initCrop()
|
|
|
+ this.getList();
|
|
|
+ this.addQuillTitle();
|
|
|
this.$refs["form"].clearValidate();
|
|
|
},
|
|
|
+ initCrop() {
|
|
|
+ // this.form.type
|
|
|
+ // 1: "精彩活动",
|
|
|
+ // 2: "热门资讯",
|
|
|
+ // 4: "专项训练",
|
|
|
+ // 5: "闪页管理",
|
|
|
+ // 3: "BANNER管理",
|
|
|
+ // 6: "APP按钮管理",
|
|
|
+ // 7: "知识库管理",
|
|
|
+ // 8: "广告管理"
|
|
|
+ // let tempTitle = {
|
|
|
+ // 1: "468px * 552px;图片不能超过 2M;", 2
|
|
|
+ // 2: "456px * 288px; 图片不能超过 2M;", 1.56
|
|
|
+ // 3: "686px * 140px; 图片不能超过 2M;", 2.63
|
|
|
+ // 4: "图片不能超过 2M;", 1
|
|
|
+ // 5: "图片不能超过 2M;", 0.73
|
|
|
+ // 6: "图片不能超过 2M;", 60 * 60 1
|
|
|
+ // 7: "图片不能超过 2M;", 2
|
|
|
+ // 8: "1242px * 2208px; 图片不能超过 2M;" 1.77
|
|
|
+ // };
|
|
|
+ // this.imageSize = tempTitle[this.form.type];
|
|
|
+ // console.log(this.imageSize)
|
|
|
+ let type = Number(this.type)
|
|
|
+ let corp = {}
|
|
|
+ switch(type) {
|
|
|
+ case 1: case 7:
|
|
|
+ corp = {
|
|
|
+ enlarge: 2,
|
|
|
+ autoCropWidth: 200,
|
|
|
+ autoCropHeight: 80
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ corp = {
|
|
|
+ enlarge: 2,
|
|
|
+ autoCropWidth: 350,
|
|
|
+ autoCropHeight: 224
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ corp = {
|
|
|
+ enlarge: 2.63,
|
|
|
+ autoCropWidth: 350,
|
|
|
+ autoCropHeight: 133
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ corp = {
|
|
|
+ enlarge: 0.73,
|
|
|
+ autoCropWidth: 255,
|
|
|
+ autoCropHeight: 350
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ corp = {
|
|
|
+ enlarge: 1,
|
|
|
+ autoCropWidth: 112,
|
|
|
+ autoCropHeight: 134
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ const { cropperOptions } = this
|
|
|
+ this.cropperOptions = Object.assign({}, cropperOptions, corp)
|
|
|
+ console.log(this.cropperOptions, cropperOptions, type, corp)
|
|
|
+ },
|
|
|
+ //上传图片成功
|
|
|
+ cropSuccess(data) {
|
|
|
+ // this.imgUrl = data.data.avatar
|
|
|
+ this.form.coverImage = data.data.url;
|
|
|
+ },
|
|
|
addAdvVideo () {
|
|
|
this.dialogFormVisible = true
|
|
|
let dialogForm = this.dialogForm
|
|
@@ -585,23 +623,28 @@ export default {
|
|
|
this.$refs[diologForm].resetFields()
|
|
|
},
|
|
|
addQuillTitle () {
|
|
|
- const oToolBar = document.querySelector(".ql-toolbar"),
|
|
|
- aButton = oToolBar.querySelectorAll("button"),
|
|
|
- aSelect = oToolBar.querySelectorAll("select");
|
|
|
- aButton.forEach(function (item) {
|
|
|
- if (item.className === "ql-script") {
|
|
|
- item.value === "sub" ? (item.title = "下标") : (item.title = "上标");
|
|
|
- } else if (item.className === "ql-indent") {
|
|
|
- item.value === "+1"
|
|
|
- ? (item.title = "向右缩进")
|
|
|
- : (item.title = "向左缩进");
|
|
|
- } else {
|
|
|
- item.title = titleConfig[item.classList[0]];
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const oToolBar = document.querySelector(".ql-toolbar")
|
|
|
+ console.log(oToolBar)
|
|
|
+ if(oToolBar) {
|
|
|
+ const aButton = oToolBar.querySelectorAll("button")
|
|
|
+ const aSelect = oToolBar.querySelectorAll("select");
|
|
|
+ aButton.forEach(function (item) {
|
|
|
+ if (item.className === "ql-script") {
|
|
|
+ item.value === "sub" ? (item.title = "下标") : (item.title = "上标");
|
|
|
+ } else if (item.className === "ql-indent") {
|
|
|
+ item.value === "+1"
|
|
|
+ ? (item.title = "向右缩进")
|
|
|
+ : (item.title = "向左缩进");
|
|
|
+ } else {
|
|
|
+ item.title = titleConfig[item.classList[0]];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ aSelect.forEach(function (item) {
|
|
|
+ item.parentNode.title = titleConfig[item.classList[0]];
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
- aSelect.forEach(function (item) {
|
|
|
- item.parentNode.title = titleConfig[item.classList[0]];
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
onSubmit (formName) {
|
|
|
this.$refs[formName].validate(valid => {
|
|
@@ -688,14 +731,6 @@ export default {
|
|
|
},
|
|
|
onReSet (formName) {
|
|
|
const query = this.$route.query
|
|
|
- let url = ''
|
|
|
- if (query.type == 7) {
|
|
|
- url = vaildStudentUrl() + "/#/knowledge"
|
|
|
- } else if (query.type == 8 || query.type == 5) {
|
|
|
- url = ''
|
|
|
- } else {
|
|
|
- url = vaildStudentUrl() + "/#/specialdetail"
|
|
|
- }
|
|
|
this.form = {
|
|
|
title: null,
|
|
|
order: null,
|
|
@@ -764,6 +799,11 @@ export default {
|
|
|
}
|
|
|
let subject = result.subjectIdList ? result.subjectIdList.split(',') : []
|
|
|
let organ = result.organIdList ? result.organIdList.split(',') : []
|
|
|
+ if(result.linkUrl) {
|
|
|
+ this.outUrlRadio = 1
|
|
|
+ } else {
|
|
|
+ this.outUrlRadio = 0
|
|
|
+ }
|
|
|
this.form = {
|
|
|
id: result.id,
|
|
|
title: result.title,
|
|
@@ -820,12 +860,16 @@ export default {
|
|
|
return isImage && isLt2M;
|
|
|
},
|
|
|
handleAvatarSuccess (res, file) {
|
|
|
+ this.uploadCoverLoading = false
|
|
|
if (res.code == 200) {
|
|
|
this.form.coverImage = res.data.url;
|
|
|
} else {
|
|
|
this.$message.error('上传失败')
|
|
|
}
|
|
|
},
|
|
|
+ handleAvatarError() {
|
|
|
+ this.uploadCoverLoading = false
|
|
|
+ },
|
|
|
beforeAvatarUpload (file) {
|
|
|
const imageType = {
|
|
|
"image/png": true,
|
|
@@ -841,6 +885,7 @@ export default {
|
|
|
if (!isLt2M) {
|
|
|
this.$message.error("上传图片大小不能超过 2M!");
|
|
|
}
|
|
|
+ this.uploadCoverLoading = true
|
|
|
return isImage && isLt2M;
|
|
|
},
|
|
|
typeChange (type) {
|