Commit 284f1701 by xinla

删除uploadToCos,替换为upload

1 parent 1b70635a
......@@ -199,7 +199,6 @@ import { templateAdd, templateDetail } from '@/api/contentCenter/modleCenter'
import DragTable from '@/components/DragTable'
import MaterialCenter from '@/components/ContentCenter/MaterialCenter'
import { string } from 'clipboard'
import UploadToCos from '@/components/UploadToCos'
import { getPosterInfo } from '@/api/material/poster'
import TemplateLibrary from '@/components/ContentCenter/TemplateLibrary'
import MessageContentForm from '@/components/MessageContentForm'
......@@ -209,7 +208,6 @@ export default {
PreviewInPhone,
DragTable,
MaterialCenter,
UploadToCos,
getPosterInfo,
TemplateLibrary,
MessageContentForm,
......
......@@ -38,7 +38,7 @@
<!-- 图片 -->
<template v-else-if="type === '0'">
<el-form-item label="图片" prop="weMaterialImgAoList" v-if="!isedit">
<UploadToCos
<Upload
v-if="dialogVisible"
:fileList.sync="form.weMaterialImgAoList"
:maxSize="20"
......@@ -46,17 +46,17 @@
:multiple="true"
:limit="picMaxlength">
<div slot="tip">支持jpg/jpeg/png格式,图片大小不超过20M,支持最多{{ picMaxlength }}张批量上传</div>
</UploadToCos>
</Upload>
</el-form-item>
<el-form-item label="图片" prop="materialUrl" v-else>
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:maxSize="20"
type="0"
v-if="dialogVisible">
<div slot="tip">支持jpg/jpeg/png格式,图片大小不超过20M</div>
</UploadToCos>
</Upload>
</el-form-item>
</template>
......@@ -86,9 +86,9 @@
placeholder="请输入图文描述"></el-input>
</el-form-item>
<el-form-item label="图文封面">
<UploadToCos :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<Upload :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<div slot="tip">支持jpg/jpeg/png格式,建议200*200</div>
</UploadToCos>
</Upload>
</el-form-item>
</template>
......@@ -130,22 +130,22 @@
</div>
</el-form-item>
<el-form-item label="封面" prop="coverUrl">
<UploadToCos :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<Upload :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<div slot="tip">支持jpg/jpeg/png格式,建议520*416</div>
</UploadToCos>
</Upload>
</el-form-item>
</template>
<template v-else-if="type === '1'">
<el-form-item label="语音" prop="materialUrl">
<Voice v-if="form.materialUrl" :amrUrl="form.materialUrl"></Voice>
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName || '点击上传'"
:type="type"
:format="audioType">
<div slot="tip">只能上传amr格式的语音文件。单个文件大小不超过2M,时长不超过1分钟</div>
</UploadToCos>
</Upload>
</el-form-item>
<el-form-item label="名称" prop="materialName">
<el-input v-model="form.materialName" placeholder="请输入"></el-input>
......@@ -170,14 +170,14 @@
show-word-limit></el-input>
</el-form-item>
<el-form-item label="上传视频" prop="materialUrl">
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:type="type"
@getPicUrl="getPicUrl"
v-if="dialogVisible">
<div slot="tip">支持mp4/mov格式,视频大小不超过100M</div>
</UploadToCos>
</Upload>
</el-form-item>
</template>
......@@ -200,13 +200,13 @@
:autosize="{ minRows: 2, maxRows: 10 }"></el-input>
</el-form-item>
<el-form-item label="上传文件" prop="materialUrl">
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:type="type"
v-if="dialogVisible">
<div slot="tip">支持pdf/ppt/word文件,单个文件大小不超过50M</div>
</UploadToCos>
</Upload>
</el-form-item>
</template>
<!-- 文章 -->
......
<script>
import { getCosConfig, getVideoPic, upload } from '@/api/common'
import { dateFormat, uuid } from '@/utils/index'
// import Video from 'video.js'
import Cos from 'cos-js-sdk-v5'
import BenzAMRRecorder from 'benz-amr-recorder'
import MP4Box from 'mp4box'
import OSS from 'ali-oss'
export default {
components: {},
props: {
// 单文件上传时使用
fileUrl: {
type: String,
default: ''
},
fileName: {
type: String,
default: ''
},
// 多文件上传时使用,例如: [{name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg'}]
fileList: {
type: Array,
default: () => []
},
// 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file)
type: {
type: String,
default: '0',
validator: function (value) {
// 这个值必须匹配下列字符串中的一个
return ['0', '1', '2', '3'].includes(value)
}
},
// 上传文件大小不能超过 maxSize MB, 各类型有默认限制 参见: maxSizeDefault
maxSize: {
type: Number,
default: undefined
},
// 图片的宽高像素限制 [width(number), height(number)],默认null不限制
maxImgPx: {
type: Array,
default: null // () => [100, 100]
},
// 允许上传的文件格式后缀名 eg:["jpg", "png"],['*']为不限制,各类型有默认限制 参见: formatDefault
format: {
type: Array,
default: undefined
},
// 选择上传文件类型, 用于过滤系统选择文件类型, 默认根据类型自动匹配:见 acceptAuto,
accept: {
type: String,
default: ''
},
// 是否能上传多个
multiple: {
type: Boolean,
default: false
},
// multiple为true时有效,最多上传几个,默认不限制,最小为1
limit: {
type: Number,
default: undefined
}
// onProgress: {
// type: Function,
// default: null,
// },
// beforeUpload: {
// type: Function,
// default: function() {
// return function() {}
// },
// },
// 图片操作 目前支持有 view:查看,remove:删除,download:下载
// action: {
// type: Array,
// default: () => ["view", "remove"],
// },
},
data() {
return {
loading: false,
fileUrlWatch: this.fileUrl,
fileNameWatch: this.fileName,
fileListWatch: this.fileList,
picUrl: '', // 视频第一帧
file: undefined,
speed: 0, // 上传网速
percentage: 0, //上传进度
// cos配置信息
cosConfig: { bucketName: '', cosImgUrlPrefix: '', region: '' },
cosInstance: undefined, // cos实例
ossObj: undefined
}
},
watch: {
fileUrl: {
handler(value) {
this.fileUrlWatch = value
}
},
fileName: {
handler(value) {
this.fileNameWatch = value
}
},
fileList: {
handler(value) {
this.fileListWatch = value
}
},
loading(val) {
this.$emit('loadingChange', val)
}
},
computed: {
// 识别选择文件类型
acceptAuto() {
return ['image/*', 'amr/*', 'video/*'][this.type]
}
},
created() {
getCosConfig().then((res) => {
this.cosConfig = res
if (this.cosConfig.fileObject == 'tencentOss') {
this.cosInstance = new Cos({
SecretId: res.secretId,
SecretKey: res.secretKey
})
} else if (this.cosConfig.fileObject == 'local') {
} else {
let region =
this.cosConfig.region.indexOf('//') != -1 ? this.cosConfig.region.split('//')[1] : this.cosConfig.region
this.ossObj = new OSS({
// yourRegion填写Bucket所在地域。Region填写为oss-cn-hangzhou。
region: region.split('.')[0],
// 从STS服务获取的临时访问密钥(AccessKey ID和AccessKey Secret)。
accessKeyId: this.cosConfig.secretId,
accessKeySecret: this.cosConfig.secretKey,
// 填写Bucket名称。
bucket: this.cosConfig.bucketName
})
}
})
},
mounted() {
// const cosInstance = new Cos({
// // getAuthorization 必选参数
// getAuthorization: function (options, callback) {
// // 服务端例子:https://github.com/tencentyun/qcloud-cos-sts-sdk/blob/master/scope.md
// // 异步获取临时密钥
// var url = window.lwConfig.SYSTEM_API + '/file/get/config' // url替换成您自己的后端服务
// var xhr = new XMLHttpRequest()
// xhr.open('get', url, true)
// xhr.setRequestHeader('Content-Type', 'application/json')
// xhr.onload = function (e) {
// try {
// var data = JSON.parse(e.target.responseText)
// var credentials = data.credentials
// } catch (e) {}
// if (!data || !credentials) {
// return console.error('credentials invalid:\n' + JSON.stringify(data, null, 2))
// }
// callback({
// TmpSecretId: decrypt(credentials.secretId),
// TmpSecretKey: credentials.secretKey,
// SecurityToken: credentials.sessionToken,
// // 建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
// StartTime: data.startTime, // 时间戳,单位秒,如:1580000000
// ExpiredTime: data.expiredTime, // 时间戳,单位秒,如:1580000000
// // ScopeLimit: true, // 细粒度控制权限需要设为 true,会限制密钥只在相同请求时重复使用
// })
// }
// xhr.send()
// // xhr.send(JSON.stringify(options.Scope))
// },
// })
},
methods: {
upload() {
if (this.cosConfig.fileObject == 'tencentOss') {
this.tencentFn()
} else if (this.cosConfig.fileObject == 'local') {
this.localFn()
} else if (this.cosConfig.fileObject == 'aliOss') {
this.aliOss()
}
},
localFn() {
this.loading = true
let file = undefined
if (!this.multiple || this.limit == 1) {
file = this.file
} else {
// 多选上传是多次调用单传的
file = this.file.shift()
}
let formData = new FormData()
formData.append('file', file)
upload(formData).then((dd) => {
if (dd.code == 200) {
let location = dd.data.url
this.$emit('upSuccess', location)
this.type == 2
? //获取视频第一帧画面
getVideoPic({ url: location }).then((res) => {
this.loading = false
this.$emit('getPicUrl', res.data.url)
})
: (this.loading = false)
// 使用本地链接提供预览,避免上传后下载的问题
let url = window.URL.createObjectURL(file)
let name = file.name
if (!this.multiple) {
this.fileUrlWatch = url
this.$emit('update:fileUrl', location)
this.$emit('update:fileName', (this.fileNameWatch = name))
} else {
this.fileListWatch = this.fileListWatch.concat({ name, url })
this.$emit('update:fileList', this.fileList.concat({ name, url: location }))
}
} else {
this.loading = false
this.$message.error('上传失败,请稍后再试')
}
})
},
async aliOss() {
this.loading = true
let file = undefined
if (!this.multiple || this.limit == 1) {
file = this.file
} else {
// 多选上传是多次调用单传的
file = this.file.shift()
}
let date = new Date()
let format = file.name.match(/\.(\w+)$/g)
format = format && format[0]
// 实例可能未初始化完成
if (!this.ossObj) {
this.$message.error('存储空间正忙,请稍后再试')
return
}
let name = `${dateFormat(date, 'yyyy-MM-dd')}/t${date.getTime()}-${uuid()}${format}`
try {
const data = await this.ossObj.multipartUpload(name, file, {
progress: (progressData) => {
this.percentage = progressData * 100
// this.speed = (progressData.speed / 1024 / 1024).toFixed(2)
}
})
if (data) {
this.percentage = this.speed = 0
let location = this.cosConfig.cosImgUrlPrefix + data.name
this.$emit('upSuccess', location)
this.type == 2
? //获取视频第一帧画面
getVideoPic({ url: location }).then((res) => {
this.loading = false
this.$emit('getPicUrl', res.data.url)
})
: (this.loading = false)
// 使用本地链接提供预览,避免上传后下载的问题
let url = window.URL.createObjectURL(file)
let name = file.name
if (!this.multiple) {
this.fileUrlWatch = url
this.$emit('update:fileUrl', location)
this.$emit('update:fileName', (this.fileNameWatch = name))
} else {
this.fileListWatch = this.fileListWatch.concat({ name, url })
this.$emit('update:fileList', this.fileList.concat({ name, url: location }))
}
}
} catch (e) {
this.loading = false
this.$message.error('上传失败,请稍后再试')
}
},
tencentFn() {
this.loading = true
let file = undefined
if (!this.multiple || this.limit == 1) {
file = this.file
} else {
// 多选上传是多次调用单传的
file = this.file.shift()
}
let date = new Date()
let format = file.name.match(/\.(\w+)$/g)
format = format && format[0]
const params = {
Bucket: this.cosConfig.bucketName /* 填入您自己的存储桶,必须字段 */,
Region: this.cosConfig.region /* 存储桶所在地域,例如ap-beijing,必须字段 */,
Key: `/${dateFormat(date, 'yyyy-MM-dd')}/t${date.getTime()}-${uuid()}${format}`
/* 存储在桶里的对象键(例如1.jpg,a/b/test.txt),必须字段。*/
// 此处使用的格式: /日期/t时间戳-uid-文件后缀名
}
// 实例可能未初始化完成
if (!this.cosInstance) {
this.$message.error('存储空间正忙,请稍后再试')
return
}
this.cosInstance.uploadFile(
{
...params,
Body: file /* 必须,上传文件对象,可以是input[type="file"]的file对象 */,
onProgress: (progressData) => {
this.percentage = progressData.percent * 100
this.speed = (progressData.speed / 1024 / 1024).toFixed(2)
// this.onProgress && this.onProgress(this.percentage, this.speed)
}
},
(err1, data) => {
this.percentage = this.speed = 0
if (err1) {
this.loading = false
this.$message.error('上传失败,请稍后再试')
} else {
let location = 'https://' + data.Location
this.$emit('upSuccess', location)
this.type == 2
? //获取视频第一帧画面
getVideoPic({ url: location }).then((res) => {
this.loading = false
this.$emit('getPicUrl', res.data.url)
})
: (this.loading = false)
// 使用本地链接提供预览,避免上传后下载的问题
let url = window.URL.createObjectURL(file)
let name = file.name
if (!this.multiple) {
this.fileUrlWatch = url
this.$emit('update:fileUrl', location)
this.$emit('update:fileName', (this.fileNameWatch = name))
} else {
this.fileListWatch = this.fileListWatch.concat({ name, url })
this.$emit('update:fileList', this.fileList.concat({ name, url: location }))
}
}
}
)
},
remove(i) {
this.$confirm('确定要删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let clone = JSON.parse(JSON.stringify(this.fileList))
this.fileListWatch.splice(i, 1)
clone.splice(i, 1)
this.$emit('update:fileList', clone)
})
},
handleExceed(file, fileList) {
this.$message.error('最多上传' + this.limit + '张')
this.loading = false
},
async handleBeforeUpload(file, filelist) {
this.loading = true
let isFormat = true
let isSize = true
// type: 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file)
// 统一校验文件后缀名格式
// 如果没有显示配置 format 格式限制,则使用默认下面校验
let format = this.format
let tip = ''
if (!format || !format.length) {
let formatDefault = {
0: { tip: 'png/jpg', value: ['png', 'jpg', 'jpeg'] },
1: { value: ['amr'] },
2: { value: ['mp4'] },
3: { tip: 'word/pdf/ppt', value: ['doc', 'docx', 'pdf', 'ppt', 'pptx', 'pps', 'pptsx'] }
}
format = formatDefault[this.type].value
tip = formatDefault[this.type].tip
}
let match = file.name.match(/\.(\w+)$/g)
let fileFormat = match && match[0].replace('.', '').toLowerCase()
isFormat = format[0] === '*' || format.includes(fileFormat)
if (!isFormat) {
this.$message.error('文件格式错误,仅支持 ' + (tip || format.join(',')) + ' 格式!')
this.loading = false
return Promise.reject()
}
// 统一校验文件体积
// 如果没有显式配置 maxSize 限制大小,则使用下面默认值,单位 MB,
let maxSize = this.maxSize
if (!maxSize) {
let maxSizeDefault = { 0: 2, 1: 2, 2: 100, 3: 50 }
maxSize || (maxSize = maxSizeDefault[this.type])
}
isSize = file.size / 1024 / 1024 < maxSize
if (!isSize) {
this.$message.error('上传文件大小不能超过 ' + maxSize + 'MB!')
this.loading = false
return Promise.reject()
}
// 各类型独有的校验
let validate = true
if (this.type === '0') {
// 图片
let maxImgPx = this.maxImgPx
if (maxImgPx) {
try {
await new Promise((resolve) => {
let width, height
let image = new Image()
//加载图片获取图片真实宽度和高度
image.onload = () => {
width = image.width
height = image.height
if (width > maxImgPx[0]) {
validate = false
this.$message.error(`图片“宽”度超过${maxImgPx[0]}像素,请重新选择`)
} else if (height > maxImgPx[1]) {
this.$message.error(`图片“高”度超过${maxImgPx[1]}像素,请重新选择`)
validate = false
}
window.URL && window.URL.revokeObjectURL(image.src)
resolve()
}
if (window.URL) {
let url = window.URL.createObjectURL(file)
image.src = url
} else if (window.FileReader) {
let reader = new FileReader()
reader.onload = function (e) {
let data = e.target.result
image.src = data
}
reader.readAsDataURL(file)
}
})
} catch (e) {
console.error(e)
}
}
} else if (this.type === '1') {
// 语音
let amr = new BenzAMRRecorder()
try {
await amr.initWithBlob(file)
validate = amr.getDuration() <= 60
if (!validate) {
this.$message.error('上传文件时长不能超过 60秒!')
}
} catch (error) {
console.log(error)
this.$message.error('文件已损坏')
}
} else if (this.type === '2') {
// 视频
let result = await this.checkVideoCode(file)
if (result.mime.indexOf('video/mp4') === -1) {
this.$message.error('mp4 格式不正确, 请使用标准编码视频!')
this.loading = false
return Promise.reject()
}
} else if (this.type === '3') {
// 普通文件
}
if (!validate) {
this.loading = false
}
// if (beforeUpload) {
// return beforeUpload(file)
// }
if (!this.multiple || this.limit == 1) {
this.file = file
} else {
Array.isArray(this.file) || (this.file = []) // 多选
this.file.push(file)
}
return validate || Promise.reject()
},
onError(err, file, fileList) {
this.loading = false
this.$message.error('上传文件失败')
},
checkVideoCode(file) {
return new Promise((resolve, reject) => {
const mp4boxFile = MP4Box.createFile()
const reader = new FileReader()
reader.readAsArrayBuffer(file)
reader.onload = function (e) {
const arrayBuffer = e.target.result
arrayBuffer.fileStart = 0
mp4boxFile.appendBuffer(arrayBuffer)
}
mp4boxFile.onReady = function (info) {
resolve(info)
}
mp4boxFile.onError = function (info) {
reject(info)
}
})
},
showView(index) {
let imager = index !== undefined ? this.$refs.image[index] : this.$refs.image
imager.clickHandler()
this.$nextTick(() => {
// 为遮罩层添加关闭事件
let maskEl = imager.$children[0].$refs['el-image-viewer__wrapper'].firstChild
maskEl.addEventListener('click', () => {
event.stopPropagation()
imager.closeViewer()
})
})
// this.$refs.image.$refs.closeViewer();
}
}
}
</script>
<template>
<div>
<!-- 多个上传文件列表展示 -->
<template v-if="multiple">
<!-- 图片 -->
<template v-if="type == 0">
<!-- <transition-group> -->
<div v-for="(item, index) in fileListWatch" :key="index" class="img-item upload-item">
<el-image
ref="image"
class="upload-img uploader-size"
:src="item.url"
fit="contain"
:preview-src-list="fileListWatch.map((e) => e.url)"
alt=""
/>
<div class="action-mask">
<i class="el-icon-search mr5" @click="showView(index)"></i>
<!-- <span v-if="action.includes('download')" @click="download(item)">
<i class="el-icon-download"></i>
</span> -->
<i class="el-icon-delete mr5" @click="remove(index)"></i>
</div>
</div>
<!-- </transition-group> -->
</template>
<!-- 后续再这里扩展其他文件列表 -->
</template>
<el-upload
v-if="!multiple || !limit || fileListWatch.length < limit"
class="uploader"
action="/api"
:accept="accept || acceptAuto"
:http-request="upload"
:data="{ mediaType: type }"
:show-file-list="false"
:file-list="fileListWatch"
:disabled="loading"
:multiple="multiple && limit != 1"
:limit="limit"
:on-error="onError"
:on-exceed="handleExceed"
:before-upload="handleBeforeUpload"
>
<!--
element-loading-text="正在上传..."
:on-success="onSuccess"
-->
<slot>
<i v-if="!loading && !fileUrlWatch" class="el-icon-plus uploader-icon upload-action uploader-size"></i>
<transition>
<!-- 上传进度条 -->
<div class="upload-action uploader-size" v-if="loading">
<el-progress class="progress cc" type="circle" :percentage="percentage"></el-progress>
<div class="el-loading-spinner">
<svg viewBox="25 25 50 50" class="circular">
<circle cx="50" cy="50" r="20" fill="none" class="path"></circle>
</svg>
</div>
<div class="cc" style="margin-top: 35px;" v-if="speed">
{{ speed + 'M/s' }}
</div>
</div>
<!-- 单文件上传的文件展示 -->
<div v-if="!loading && fileUrlWatch && !multiple" class="upload-item">
<template v-if="type === '0'">
<el-image
v-if="fileUrlWatch"
ref="image"
:src="fileUrlWatch"
class="upload-img upload-img-single uploader-size"
:preview-src-list="[fileUrlWatch]"
fit="contain"
/>
<div class="action-mask" @click.self.stop>
<i class="el-icon-search" @click.prevent.stop="showView()"></i>
<i class="el-icon-edit"></i>
<!-- <span v-if="action.includes('download')" @click.prevent.stop="download(item)">
<i class="el-icon-download"></i>
</span> -->
<!-- <span @click.prevent.stop="remove()">
<i class="el-icon-delete"></i>
</span> -->
</div>
</template>
<template v-else-if="type === '2'">
<video
ref="video"
id="myVideo"
class="upload-video"
width="100%"
controls
webkit-playsinline="true"
playsinline="true"
:autoplay="false"
:key="fileUrlWatch"
preload="auto"
>
<source :src="fileUrlWatch" type="video/mp4" />
</video>
<div class="action-mask" style="height: 30%;" @click.self.stop>
<i class="el-icon-edit"></i>
</div>
</template>
<template v-else class="al">
{{ fileNameWatch || fileUrlWatch }}
<i class="el-icon-edit ml10"></i>
<!-- a链接用本地视频打不开,视频地址使用远程地址 -->
<a @click.stop :href="/\.mp4$/.test(fileNameWatch) ? fileUrl : fileUrlWatch" target="_blank">
<i class="el-icon-view ml10" style="vertical-align: middle;"></i>
</a>
</template>
</div>
</transition>
</slot>
</el-upload>
<!-- 上传格式,大小等提示语 -->
<div class="tip">
<slot name="tip"></slot>
</div>
</div>
</template>
<style lang="scss" scoped>
::v-deep.uploader {
display: inline-block;
vertical-align: middle;
.el-upload {
display: block;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
}
// 默认组件大小,如需修改,请通过外部重写该类样式
.uploader-size {
width: 178px;
height: 178px;
}
.upload-action {
position: relative;
text-align: center;
}
.uploader-icon {
display: flex;
font-size: 28px;
align-items: center;
justify-content: center;
color: #8c939d;
border-radius: 6px;
border: 1px dashed #d9d9d9;
transition: all 0.3s;
&:hover {
border-color: var(--color);
color: var(--color);
}
}
.progress {
overflow: hidden;
}
.upload-img-single {
border: 1px dashed #eee;
}
.upload-img {
display: block;
}
.upload-video {
display: block;
width: 300px;
height: 150px;
box-sizing: border-box;
color: #fff;
background-color: #000;
position: relative;
padding: 0;
font-size: 10px;
line-height: 1;
font-weight: normal;
font-style: normal;
word-break: initial;
}
.tip {
margin-top: 10px;
color: #aaa;
font-size: 12px;
}
.img-item {
position: relative;
display: inline-block;
vertical-align: middle;
margin: 0 10px 10px 0;
transition: all 0.3s;
}
.action-mask {
position: absolute;
display: flex;
justify-content: space-around;
align-items: center;
padding: 0 30px;
width: 100%;
height: 100%;
left: 0;
top: 0;
cursor: pointer;
text-align: center;
color: #fff;
opacity: 0;
font-size: 20px;
transition: opacity 0.3s;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1;
}
.upload-item {
&:hover {
.action-mask {
opacity: 1;
}
}
}
</style>
<template>
<div class="quill-wrap" v-loading="uploadLoading">
<quill-editor v-model="content" ref="quill" @change="onEditorChange($event)" :options="editorOption"></quill-editor>
<UploadToCos
v-show="false"
:fileUrl.sync="imgUrl"
type="0"
@loadingChange="(val) => (uploadLoading = val)"></UploadToCos>
<Upload v-show="false" :fileUrl.sync="imgUrl" type="0" @loadingChange="(val) => (uploadLoading = val)"></Upload>
<SelectEmoji ref="emoji" @select="insertContent" />
</div>
</template>
......
......@@ -27,7 +27,6 @@ import './permission' // permission control
Vue.component('Pagination', () => import('@/components/Pagination'))
Vue.component('RightToolbar', () => import('@/components/RightToolbar'))
Vue.component('Upload', () => import('@/components/Upload'))
Vue.component('UploadToCos', () => import('@/components/UploadToCos'))
Vue.component('ButtonSync', () => import('@/components/ButtonSync'))
Vue.component('TagEllipsis', () => import('@/components/TagEllipsis'))
Vue.component('SelectUser', () => import('@/components/SelectUser'))
......
<template>
<div>
<el-form-item :label="lableOne" style="margin-right: 200px !important;" :error="templateInfo">
<div v-if="showModle && !isDetail" style="margin-bottom: 10px;">
<el-form-item :label="lableOne" style="margin-right: 200px !important" :error="templateInfo">
<div v-if="showModle && !isDetail" style="margin-bottom: 10px">
<el-button type="primary" @click="welcomVisible = true">从模板库中选择</el-button>
</div>
<TextareaExtend
......@@ -14,8 +14,7 @@
:autosize="{ minRows: 5, maxRows: 20 }"
clearable
:autofocus="false"
@input="changeInfo"
/>
@input="changeInfo" />
</el-form-item>
<el-form-item>
<div slot="label" class="title" v-if="otherType !== 3">
......@@ -26,19 +25,17 @@
</div>
<div>
<div>
<div style="text-align: left;" class="flex">
<div style="text-align: left" class="flex">
<el-popover
v-if="!isDetail"
trigger="hover"
:content="'最多添加' + maxlength + '个' + fontType + ',如需修改请删除已有' + fontType + '后重新尝试'"
placement="top-start"
:disabled="talkList.length < maxlength"
>
:disabled="talkList.length < maxlength">
<el-dropdown
slot="reference"
@command="moveGroup"
:disabled="talkList.length > maxlength || talkList.length === maxlength"
>
:disabled="talkList.length > maxlength || talkList.length === maxlength">
<el-button type="primary">+ {{ '新建' + fontType }}</el-button>
<el-dropdown-menu slot="dropdown" trigger="click">
<!-- <el-dropdown-item :command="'4'" v-if="!this.templateType && this.moduleType !== 4">
......@@ -73,13 +70,11 @@
trigger="hover"
:content="'最多添加' + maxlength + '个' + fontType + ',如需修改请删除已有' + fontType + '后重新尝试'"
placement="top-start"
:disabled="talkList.length < maxlength"
>
:disabled="talkList.length < maxlength">
<div slot="reference" class="ml20">
<el-button
@click="choseCenter"
:disabled="talkList.length > maxlength || talkList.length === maxlength"
>
:disabled="talkList.length > maxlength || talkList.length === maxlength">
从素材中心选择
</el-button>
</div>
......@@ -95,8 +90,7 @@
:tableData2="talkList"
@setData="setData"
@getEdit="getEdit"
:dargAble="[2].includes(moduleType)"
/>
:dargAble="[2].includes(moduleType)" />
</div>
</el-form-item>
......@@ -112,8 +106,7 @@
@dialogClose="dialogClose"
:materialTalkList="talkList"
:moduleType="moduleType"
:maxlength="maxlength"
/>
:maxlength="maxlength" />
<!-- 模板库 -->
<el-dialog
:title="otherType === 2 ? '选择群发模板' : '选择欢迎语模板'"
......@@ -121,8 +114,7 @@
width="60%"
append-to-body
:close-on-click-modal="false"
v-if="welcomVisible"
>
v-if="welcomVisible">
<TemplateLibrary @changeObj="changeObj" :isGroup="otherType === 2" />
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="selectModle" :loading="libraryLoading">确 定</el-button>
......@@ -137,676 +129,672 @@
:tplType="tplType"
:moduleType="moduleType"
:maxlength="maxlength"
:noApplets="otherType === 3"
/>
:noApplets="otherType === 3" />
<SelectUser
:defaultValues="selectedUserList"
:visible.sync="dialogVisibleSelectUser"
title="选择使用员工"
@success="selectedUser"
></SelectUser>
@success="selectedUser"></SelectUser>
</div>
</template>
<script>
import PreviewInPhone from '@/components/ContentCenter/PreviewInPhone'
import { getTree } from '@/api/material'
import { lexicalAdd, lexicalDetail } from '@/api/contentCenter/scriptCenter'
import { templateAdd, templateDetail } from '@/api/contentCenter/modleCenter'
import DragTable from './DragTable'
import MaterialCenter from '@/components/ContentCenter/MaterialCenter'
import { string } from 'clipboard'
import UploadToCos from '@/components/UploadToCos'
import { getPosterInfo } from '@/api/material/poster'
import TemplateLibrary from '@/components/ContentCenter/TemplateLibrary'
import MessageContentForm from '@/components/MessageContentForm'
export default {
name: 'add-material',
components: {
PreviewInPhone,
DragTable,
MaterialCenter,
UploadToCos,
getPosterInfo,
TemplateLibrary,
MessageContentForm
},
data() {
return {
titleOne: '欢迎语',
lableOne: '推广语',
titleTwo: '推广语附件',
templateInfo: '',
userInfo: '',
editMaterialForm: {},
choseDialog: false,
ids: [],
// materialIds: [], //素材id
// 分组props
groupProps: {
expandTrigger: 'hover',
checkStrictly: true,
children: 'children',
label: 'name',
value: 'id',
emitPath: false
},
mobForm: {
welcomeMsg: '',
materialMsgList: [],
userIds: '',
userNames: ''
},
form: {
weMaterialImgAoList: []
},
talkForm: {}, // 话术表单
treeData: [{}], // 树
talkRules: Object.freeze({
categoryId: [{ required: true, message: '不能为空', trigger: 'change' }],
talkTitle: [{ required: true, message: '不能为空', trigger: 'blur' }]
}),
type: undefined,
dialogVisible: false, // 新建素材表格对话框显隐
talkLoading: false,
talkList: [],
users: [],
selectedUserList: [],
dialogVisibleSelectUser: false,
isedit: false, // 是否为图片编辑
welcomVisible: false,
fontType: '',
maxlength: 8,
libraryLoading: false
}
},
props: {
baseData: {
type: Object,
default: () => {
return {
templateInfo: '',
attachments: []
}
import PreviewInPhone from '@/components/ContentCenter/PreviewInPhone'
import { getTree } from '@/api/material'
import { lexicalAdd, lexicalDetail } from '@/api/contentCenter/scriptCenter'
import { templateAdd, templateDetail } from '@/api/contentCenter/modleCenter'
import DragTable from './DragTable'
import MaterialCenter from '@/components/ContentCenter/MaterialCenter'
import { string } from 'clipboard'
import { getPosterInfo } from '@/api/material/poster'
import TemplateLibrary from '@/components/ContentCenter/TemplateLibrary'
import MessageContentForm from '@/components/MessageContentForm'
export default {
name: 'add-material',
components: {
PreviewInPhone,
DragTable,
MaterialCenter,
getPosterInfo,
TemplateLibrary,
MessageContentForm,
},
data() {
return {
titleOne: '欢迎语',
lableOne: '推广语',
titleTwo: '推广语附件',
templateInfo: '',
userInfo: '',
editMaterialForm: {},
choseDialog: false,
ids: [],
// materialIds: [], //素材id
// 分组props
groupProps: {
expandTrigger: 'hover',
checkStrictly: true,
children: 'children',
label: 'name',
value: 'id',
emitPath: false,
},
mobForm: {
welcomeMsg: '',
materialMsgList: [],
userIds: '',
userNames: '',
},
form: {
weMaterialImgAoList: [],
},
talkForm: {}, // 话术表单
treeData: [{}], // 树
talkRules: Object.freeze({
categoryId: [{ required: true, message: '不能为空', trigger: 'change' }],
talkTitle: [{ required: true, message: '不能为空', trigger: 'blur' }],
}),
type: undefined,
dialogVisible: false, // 新建素材表格对话框显隐
talkLoading: false,
talkList: [],
users: [],
selectedUserList: [],
dialogVisibleSelectUser: false,
isedit: false, // 是否为图片编辑
welcomVisible: false,
fontType: '',
maxlength: 8,
libraryLoading: false,
}
},
props: {
baseData: {
type: Object,
default: () => {
return {
templateInfo: '',
attachments: [],
}
},
},
// 查询会话详情的id
talkId: {
type: string,
default: null
},
// 查询模板中心详情的id
modelId: {
type: string,
default: null
},
// 话术类形 0企业话术1客服话术
talkType: {
type: string,
default: null
},
// 1欢迎语 2群发 3sop
templateType: {
type: Number,
default: 1
},
// 1:活码欢迎语;2:员工欢迎语;3:入群欢迎语
tplType: {
type: String,
default: null
},
// 模块类型 1:素材;2:话术;3:模板;4:其他模块
moduleType: {
type: Number,
default: 4
},
// 是否为欢迎语模板
iswelcom: {
type: Boolean,
default: false
},
// 是否显示模板库
showModle: {
type: Boolean,
default: false
},
// 1.员工活码;2:企微营销;3:企业动态;4:门店活码
otherType: {
type: Number,
default: null
},
// 是否显示手机
showPhone: {
type: Boolean,
default: true
},
// 直播链接
liveUrl: {
type: String,
default: null
},
// 是否显示提交取消按钮
showFooter: {
type: Boolean,
default: true
},
isDetail: {
type: Boolean,
default: false
}
// 查询会话详情的id
talkId: {
type: string,
default: null,
},
watch: {
baseData(val) {
if (val.templateInfo) {
this.form.templateInfo = val.templateInfo
this.form.attachments = val.attachments
// if (this.form.templateInfo) {
// this.form.templateInfo = this.baseData.templateInfo
this.talkForm = this.form
this.talkList = this.form.attachments
// }
this.$forceUpdate()
}
},
talkId: {
handler(val) {
if (val) {
this.getDeatil(val)
}
},
immediate: true
},
modelId: {
handler(val) {
if (val) {
this.getTelDeatil(val)
}
},
immediate: true
// 查询模板中心详情的id
modelId: {
type: string,
default: null,
},
// 话术类形 0企业话术1客服话术
talkType: {
type: string,
default: null,
},
// 1欢迎语 2群发 3sop
templateType: {
type: Number,
default: 1,
},
// 1:活码欢迎语;2:员工欢迎语;3:入群欢迎语
tplType: {
type: String,
default: null,
},
// 模块类型 1:素材;2:话术;3:模板;4:其他模块
moduleType: {
type: Number,
default: 4,
},
// 是否为欢迎语模板
iswelcom: {
type: Boolean,
default: false,
},
// 是否显示模板库
showModle: {
type: Boolean,
default: false,
},
// 1.员工活码;2:企微营销;3:企业动态;4:门店活码
otherType: {
type: Number,
default: null,
},
// 是否显示手机
showPhone: {
type: Boolean,
default: true,
},
// 直播链接
liveUrl: {
type: String,
default: null,
},
// 是否显示提交取消按钮
showFooter: {
type: Boolean,
default: true,
},
isDetail: {
type: Boolean,
default: false,
},
},
watch: {
baseData(val) {
if (val.templateInfo) {
this.form.templateInfo = val.templateInfo
this.form.attachments = val.attachments
// if (this.form.templateInfo) {
// this.form.templateInfo = this.baseData.templateInfo
this.talkForm = this.form
this.talkList = this.form.attachments
// }
this.$forceUpdate()
}
},
methods: {
changeInfo(val) {
this.$emit('changeInfo', val)
},
dialogClose(val, list) {
this.dialogVisible = val
if (list) {
this.talkList = [...list]
this.$emit('phoneData', this.talkList)
this.$emit('success', this.setResult())
talkId: {
handler(val) {
if (val) {
this.getDeatil(val)
}
},
setResult() {
let arr = []
this.talkList.forEach((item) => {
let attachments = {}
attachments.title = item.materialName
attachments.realType = +item.mediaType
attachments.materialId = item.id //素材
switch (item.mediaType) {
case '0':
// 图片
attachments.picUrl = item.materialUrl
attachments.msgType = 'image'
break
case '2':
// 视频
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'video'
break
case '3':
// 文件
attachments.picUrl = this.filPicType(item.materialUrl)
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'file'
break
case '4':
// 文本
attachments.content = item.content
attachments.msgType = 'text'
break
case '5':
// 海报
attachments.fileUrl = item.materialUrl
attachments.msgType = 'posters'
break
case '9':
// 图文
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.linkUrl = item.materialUrl
attachments.msgType = 'link'
if (this.otherType === 3) {
attachments.materialName = item.materialName
}
break
case '11':
// 小程序
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.appId = item.digest
attachments.msgType = 'miniprogram'
break
case '12':
// 文章
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.msgType = 'news'
break
}
arr.push(attachments)
})
return arr
},
filPicType(file) {
let filecontent = JSON.parse(JSON.stringify(file))
filecontent = filecontent.split('.')
let type = filecontent[filecontent.length - 1]
if (type === 'pdf') {
return window.lwConfig.DEFAULT_H5_PDF
} else if (['doc', 'docx'].includes(type)) {
return window.lwConfig.DEFAULT_H5_WORDE
} else if (['ppt', 'pptx', 'pps', 'pptsx'].includes(type)) {
return window.lwConfig.DEFAULT_H5_PPT
} else {
return ''
}
},
// 模板库点击确定
selectModle() {
this.libraryLoading = true
if (this.selectObj) {
this.talkForm = this.selectObj
this.welcomVisible = false
this.talkList = [...this.selectObj.weMaterialList]
this.$emit('phoneData', [...this.selectObj.weMaterialList])
this.$emit('changeInfo', this.selectObj.templateInfo)
this.$emit('success', this.setResult())
} else {
this.$message.error('请选择模板')
}
this.libraryLoading = false
},
changeObj(id) {
if (id) {
templateDetail(id).then((res) => {
this.selectObj = res.data
})
}
},
setUserData() {
this.selectedUserList = []
let arr = []
if (this.talkForm.userIds) {
arr = this.talkForm.userIds.split(',').map((dd, index) => {
return {
userId: dd,
name: this.talkForm.userNames.split(',')[index]
}
})
}
this.users = arr
},
onSelectUser() {
this.selectedUserList = []
let arr = []
if (this.talkForm.userIds) {
arr = this.talkForm.userIds.split(',').map((dd, index) => {
return {
userId: dd,
name: this.talkForm.userNames.split(',')[index]
}
})
immediate: true,
},
modelId: {
handler(val) {
if (val) {
this.getTelDeatil(val)
}
this.selectedUserList = arr
this.dialogVisibleSelectUser = true
},
selectedUser(users) {
let ids = []
let names = []
const selectedUserList = users.map((d) => {
ids.push(d.userId)
names.push(d.name)
return {
userId: d.userId,
name: d.name
}
})
this.users = selectedUserList
this.talkForm.userIds = ids.join(',')
this.talkForm.userNames = names.join(',')
},
// 获取详情
getDeatil(id) {
lexicalDetail(id)
.then((res) => {
this.talkForm = res.data
this.talkList = res.data.weMaterialList
})
.catch(() => {})
},
// 获取模板中心详情
getTelDeatil(id) {
templateDetail(id)
.then((res) => {
this.talkForm = res.data
this.talkList = res.data.weMaterialList
this.setUserData()
})
.catch(() => {})
},
getEdit(val) {
this.type = val.mediaType
this.editMaterialForm = JSON.parse(JSON.stringify(val))
},
setData(val) {
this.talkList = val
this.$emit('phoneData', this.talkList)
this.$emit('success', this.setResult())
},
getItemArry(val) {
this.talkList = this.talkList.concat(val)
// 当手机为非内嵌时
immediate: true,
},
},
methods: {
changeInfo(val) {
this.$emit('changeInfo', val)
},
dialogClose(val, list) {
this.dialogVisible = val
if (list) {
this.talkList = [...list]
this.$emit('phoneData', this.talkList)
this.$emit('success', this.setResult())
},
centerSubmit() {},
selectCenter() {},
choseCenter() {
this.choseDialog = true
},
getIds(value) {
this.ids = value
},
moveGroup(type) {
this.type = ''
this.type = type
if (this.otherType === 3 && type == '2') {
this.choseDialog = true
} else {
this.dialogVisible = true
}
},
// 获取类目树
getTree() {
var mediaType = null
if (this.talkType == 0) {
mediaType = 13
} else if (this.talkType == 1) {
mediaType = 14
}
if (this.templateType == 2) {
mediaType = 17
} else if (this.templateType == 3) {
mediaType = 16
}
getTree(mediaType).then(({ data }) => {
this.treeData = [
{
id: '',
name: '全部',
parentId: '0',
hasParent: false,
hasChildren: true,
children: data || []
}
},
setResult() {
let arr = []
this.talkList.forEach((item) => {
let attachments = {}
attachments.title = item.materialName
attachments.realType = +item.mediaType
attachments.materialId = item.id //素材
switch (item.mediaType) {
case '0':
// 图片
attachments.picUrl = item.materialUrl
attachments.msgType = 'image'
break
case '2':
// 视频
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'video'
break
case '3':
// 文件
attachments.picUrl = this.filPicType(item.materialUrl)
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'file'
break
case '4':
// 文本
attachments.content = item.content
attachments.msgType = 'text'
break
case '5':
// 海报
attachments.fileUrl = item.materialUrl
attachments.msgType = 'posters'
break
case '9':
// 图文
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.linkUrl = item.materialUrl
attachments.msgType = 'link'
if (this.otherType === 3) {
attachments.materialName = item.materialName
}
]
})
},
// 新建话术
tackSubmit() {
this.talkLoading = true
if ([3, 4].includes(this.moduleType) && !this.talkForm.templateInfo) {
this.templateInfo = '请输入' + this.lableOne
this.talkLoading = false
return
} else {
this.templateInfo = ''
break
case '11':
// 小程序
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.appId = item.digest
attachments.msgType = 'miniprogram'
break
case '12':
// 文章
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.msgType = 'news'
break
}
if (!this.talkForm.userIds && this.tplType == 2) {
this.userInfo = '请选择员工'
this.talkLoading = false
return
} else {
this.userInfo = ''
}
if (this.talkType === '0') {
this.talkForm.talkType = 0
} else if (this.talkType === '1') {
this.talkForm.talkType = 1
}
if (!this.templateType) {
this.talkForm.talkMaterialList = []
this.talkList.forEach((item, index) => {
this.talkForm.talkMaterialList.push({ materialId: item.id, sort: index })
})
}
this.$refs['talkform'].validate((valid) => {
if (valid) {
let talkForm = JSON.parse(JSON.stringify(this.talkForm))
// 如果是关联模块
if (this.moduleType === 4) {
this.talkLoading = true
talkForm.attachments = []
if (this.talkList.length !== 0) {
this.dealOtherModleType(talkForm)
}
this.$emit('submit', talkForm)
// this.$refs['talkForm'].resetFields()
// this.talkForm = {}
setTimeout(() => {
this.talkLoading = false
}, 5000)
} else {
talkForm.attachmentList = []
talkForm.weTlpMaterialList = []
this.talkId ? (talkForm.talkId = this.talkId) : ''
this.modelId ? (talkForm.modelId = this.modelId) : ''
if (this.templateType) {
// 如果是模板中心
this.talkForm.weTlpMaterialList = []
this.dealTemplateType(talkForm)
}
;(this.templateType ? templateAdd : lexicalAdd)(talkForm)
.then(() => {
this.msgSuccess('操作成功')
// this.getList()
this.$router.push('list')
this.$refs['talkForm'].resetFields()
this.talkForm = {}
this.talkLoading = false
})
.catch(() => {
this.talkLoading = false
})
}
} else {
this.talkLoading = false
}
arr.push(attachments)
})
return arr
},
filPicType(file) {
let filecontent = JSON.parse(JSON.stringify(file))
filecontent = filecontent.split('.')
let type = filecontent[filecontent.length - 1]
if (type === 'pdf') {
return window.lwConfig.DEFAULT_H5_PDF
} else if (['doc', 'docx'].includes(type)) {
return window.lwConfig.DEFAULT_H5_WORDE
} else if (['ppt', 'pptx', 'pps', 'pptsx'].includes(type)) {
return window.lwConfig.DEFAULT_H5_PPT
} else {
return ''
}
},
// 模板库点击确定
selectModle() {
this.libraryLoading = true
if (this.selectObj) {
this.talkForm = this.selectObj
this.welcomVisible = false
this.talkList = [...this.selectObj.weMaterialList]
this.$emit('phoneData', [...this.selectObj.weMaterialList])
this.$emit('changeInfo', this.selectObj.templateInfo)
this.$emit('success', this.setResult())
} else {
this.$message.error('请选择模板')
}
this.libraryLoading = false
},
changeObj(id) {
if (id) {
templateDetail(id).then((res) => {
this.selectObj = res.data
})
},
dealOtherModleType(talkForm) {
this.talkList.forEach((item) => {
let attachments = {}
attachments.title = item.materialName
attachments.realType = +item.mediaType
attachments.materialId = item.id //素材
switch (item.mediaType) {
case '0':
// 图片
attachments.picUrl = item.materialUrl
attachments.msgType = 'image'
break
case '2':
// 视频
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'video'
break
case '3':
// 文件
attachments.picUrl = this.filPicType(item.materialUrl)
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'file'
break
case '4':
// 文本
attachments.content = item.content
attachments.msgType = 'text'
break
case '5':
// 海报
attachments.fileUrl = item.materialUrl
attachments.msgType = 'posters'
break
case '9':
// 图文
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.linkUrl = item.materialUrl
attachments.msgType = 'link'
if (this.otherType === 3) {
attachments.materialName = item.materialName
}
break
case '11':
// 小程序
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.appId = item.digest
attachments.msgType = 'miniprogram'
break
case '12':
// 文章
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.msgType = 'news'
break
}
},
setUserData() {
this.selectedUserList = []
let arr = []
if (this.talkForm.userIds) {
arr = this.talkForm.userIds.split(',').map((dd, index) => {
return {
userId: dd,
name: this.talkForm.userNames.split(',')[index],
}
talkForm.attachments.push(attachments)
})
},
dealTemplateType(talkForm) {
this.talkList.forEach((item) => {
let attachmentFrom = {}
attachmentFrom.msgType = item.mediaType
attachmentFrom.mediaId = item.id
if (item.mediaType != '0') {
attachmentFrom.title = item.materialName
}
switch (item.mediaType) {
case '0':
case '5':
// 图片
attachmentFrom.picUrl = item.materialUrl
break
case '2':
// 视频
attachmentFrom.picUrl = item.coverUrl
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.description = item.digest
break
case '3':
// 文件
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.description = item.digest
break
case '4':
// 文本
attachmentFrom.content = item.content
break
case '4':
// 海报
break
case '9':
// 图文
attachmentFrom.content = item.content
attachmentFrom.picUrl = item.coverUrl
attachmentFrom.linkUrl = item.materialUrl
break
case '11':
// 小程序
attachmentFrom.picUrl = item.coverUrl
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.appId = item.digest
break
case '12':
// 文章
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.description = item.digest
attachmentFrom.content = item.content
attachmentFrom.picUrl = item.coverUrl
break
}
this.users = arr
},
onSelectUser() {
this.selectedUserList = []
let arr = []
if (this.talkForm.userIds) {
arr = this.talkForm.userIds.split(',').map((dd, index) => {
return {
userId: dd,
name: this.talkForm.userNames.split(',')[index],
}
talkForm.attachmentList.push(attachmentFrom)
talkForm.weTlpMaterialList.push({ materialId: item.id })
})
talkForm.templateType = this.templateType
talkForm.tplType = this.tplType
},
getCancel() {
this.$router.back()
},
goBack() {
let talkForm = JSON.parse(JSON.stringify(this.talkForm))
talkForm.attachments = []
if (this.talkList.length !== 0) {
this.dealOtherModleType(talkForm)
}
this.$emit('update', talkForm)
}
this.selectedUserList = arr
this.dialogVisibleSelectUser = true
},
selectedUser(users) {
let ids = []
let names = []
const selectedUserList = users.map((d) => {
ids.push(d.userId)
names.push(d.name)
return {
userId: d.userId,
name: d.name,
}
})
this.users = selectedUserList
this.talkForm.userIds = ids.join(',')
this.talkForm.userNames = names.join(',')
},
// 获取详情
getDeatil(id) {
lexicalDetail(id)
.then((res) => {
this.talkForm = res.data
this.talkList = res.data.weMaterialList
})
.catch(() => {})
},
// 获取模板中心详情
getTelDeatil(id) {
templateDetail(id)
.then((res) => {
this.talkForm = res.data
this.talkList = res.data.weMaterialList
this.setUserData()
})
.catch(() => {})
},
getEdit(val) {
this.type = val.mediaType
this.editMaterialForm = JSON.parse(JSON.stringify(val))
},
setData(val) {
this.talkList = val
this.$emit('phoneData', this.talkList)
this.$emit('success', this.setResult())
},
mounted() {
if (this.$route.query.categoryId) {
let form = { categoryId: this.$route.query.categoryId }
this.talkForm = { ...form }
getItemArry(val) {
this.talkList = this.talkList.concat(val)
// 当手机为非内嵌时
this.$emit('phoneData', this.talkList)
this.$emit('success', this.setResult())
},
centerSubmit() {},
selectCenter() {},
choseCenter() {
this.choseDialog = true
},
getIds(value) {
this.ids = value
},
moveGroup(type) {
this.type = ''
this.type = type
if (this.otherType === 3 && type == '2') {
this.choseDialog = true
} else {
this.dialogVisible = true
}
if (this.templateType != 1 && this.moduleType != 4) {
this.getTree()
},
// 获取类目树
getTree() {
var mediaType = null
if (this.talkType == 0) {
mediaType = 13
} else if (this.talkType == 1) {
mediaType = 14
}
if (this.baseData.templateInfo) {
// this.form.templateInfo = this.baseData.templateInfo
this.talkForm = this.baseData
this.talkList = this.baseData.attachments
if (this.templateType == 2) {
mediaType = 17
} else if (this.templateType == 3) {
mediaType = 16
}
// this.dealType()
if (this.otherType === 3 || this.tplType == 3) {
this.maxlength = 1
getTree(mediaType).then(({ data }) => {
this.treeData = [
{
id: '',
name: '全部',
parentId: '0',
hasParent: false,
hasChildren: true,
children: data || [],
},
]
})
},
// 新建话术
tackSubmit() {
this.talkLoading = true
if ([3, 4].includes(this.moduleType) && !this.talkForm.templateInfo) {
this.templateInfo = '请输入' + this.lableOne
this.talkLoading = false
return
} else {
this.maxlength = 8
this.templateInfo = ''
}
if ([3, 4].includes(this.moduleType)) {
this.fontType = '附件'
if (!this.talkForm.userIds && this.tplType == 2) {
this.userInfo = '请选择员工'
this.talkLoading = false
return
} else {
this.fontType = '素材'
this.userInfo = ''
}
if (this.talkType === '0') {
this.talkForm.talkType = 0
} else if (this.talkType === '1') {
this.talkForm.talkType = 1
}
if (!this.templateType) {
this.talkForm.talkMaterialList = []
this.talkList.forEach((item, index) => {
this.talkForm.talkMaterialList.push({ materialId: item.id, sort: index })
})
}
this.$refs['talkform'].validate((valid) => {
if (valid) {
let talkForm = JSON.parse(JSON.stringify(this.talkForm))
// 如果是关联模块
if (this.moduleType === 4) {
this.talkLoading = true
talkForm.attachments = []
if (this.talkList.length !== 0) {
this.dealOtherModleType(talkForm)
}
this.$emit('submit', talkForm)
// this.$refs['talkForm'].resetFields()
// this.talkForm = {}
setTimeout(() => {
this.talkLoading = false
}, 5000)
} else {
talkForm.attachmentList = []
talkForm.weTlpMaterialList = []
this.talkId ? (talkForm.talkId = this.talkId) : ''
this.modelId ? (talkForm.modelId = this.modelId) : ''
if (this.templateType) {
// 如果是模板中心
this.talkForm.weTlpMaterialList = []
this.dealTemplateType(talkForm)
}
;(this.templateType ? templateAdd : lexicalAdd)(talkForm)
.then(() => {
this.msgSuccess('操作成功')
// this.getList()
this.$router.push('list')
this.$refs['talkForm'].resetFields()
this.talkForm = {}
this.talkLoading = false
})
.catch(() => {
this.talkLoading = false
})
}
} else {
this.talkLoading = false
}
})
},
dealOtherModleType(talkForm) {
this.talkList.forEach((item) => {
let attachments = {}
attachments.title = item.materialName
attachments.realType = +item.mediaType
attachments.materialId = item.id //素材
switch (item.mediaType) {
case '0':
// 图片
attachments.picUrl = item.materialUrl
attachments.msgType = 'image'
break
case '2':
// 视频
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'video'
break
case '3':
// 文件
attachments.picUrl = this.filPicType(item.materialUrl)
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.msgType = 'file'
break
case '4':
// 文本
attachments.content = item.content
attachments.msgType = 'text'
break
case '5':
// 海报
attachments.fileUrl = item.materialUrl
attachments.msgType = 'posters'
break
case '9':
// 图文
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.linkUrl = item.materialUrl
attachments.msgType = 'link'
if (this.otherType === 3) {
attachments.materialName = item.materialName
}
break
case '11':
// 小程序
attachments.picUrl = item.coverUrl
attachments.fileUrl = item.materialUrl
attachments.appId = item.digest
attachments.msgType = 'miniprogram'
break
case '12':
// 文章
attachments.fileUrl = item.materialUrl
attachments.description = item.digest
attachments.content = item.content
attachments.picUrl = item.coverUrl
attachments.msgType = 'news'
break
}
talkForm.attachments.push(attachments)
})
},
dealTemplateType(talkForm) {
this.talkList.forEach((item) => {
let attachmentFrom = {}
attachmentFrom.msgType = item.mediaType
attachmentFrom.mediaId = item.id
if (item.mediaType != '0') {
attachmentFrom.title = item.materialName
}
switch (item.mediaType) {
case '0':
case '5':
// 图片
attachmentFrom.picUrl = item.materialUrl
break
case '2':
// 视频
attachmentFrom.picUrl = item.coverUrl
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.description = item.digest
break
case '3':
// 文件
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.description = item.digest
break
case '4':
// 文本
attachmentFrom.content = item.content
break
case '4':
// 海报
break
case '9':
// 图文
attachmentFrom.content = item.content
attachmentFrom.picUrl = item.coverUrl
attachmentFrom.linkUrl = item.materialUrl
break
case '11':
// 小程序
attachmentFrom.picUrl = item.coverUrl
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.appId = item.digest
break
case '12':
// 文章
attachmentFrom.fileUrl = item.materialUrl
attachmentFrom.description = item.digest
attachmentFrom.content = item.content
attachmentFrom.picUrl = item.coverUrl
break
}
talkForm.attachmentList.push(attachmentFrom)
talkForm.weTlpMaterialList.push({ materialId: item.id })
})
talkForm.templateType = this.templateType
talkForm.tplType = this.tplType
},
getCancel() {
this.$router.back()
},
goBack() {
let talkForm = JSON.parse(JSON.stringify(this.talkForm))
talkForm.attachments = []
if (this.talkList.length !== 0) {
this.dealOtherModleType(talkForm)
}
this.$emit('update', talkForm)
},
},
mounted() {
if (this.$route.query.categoryId) {
let form = { categoryId: this.$route.query.categoryId }
this.talkForm = { ...form }
}
}
if (this.templateType != 1 && this.moduleType != 4) {
this.getTree()
}
if (this.baseData.templateInfo) {
// this.form.templateInfo = this.baseData.templateInfo
this.talkForm = this.baseData
this.talkList = this.baseData.attachments
}
// this.dealType()
if (this.otherType === 3 || this.tplType == 3) {
this.maxlength = 1
} else {
this.maxlength = 8
}
if ([3, 4].includes(this.moduleType)) {
this.fontType = '附件'
} else {
this.fontType = '素材'
}
},
}
</script>
<style lang="scss" scoped>
::v-deep .ql-editor {
min-height: 200px;
.ql-container {
.ql-snow {
.ql-tooltip {
left: 0px !important;
}
::v-deep .ql-editor {
min-height: 200px;
.ql-container {
.ql-snow {
.ql-tooltip {
left: 0px !important;
}
}
}
::v-deep .el-button.is-disabled {
}
::v-deep .el-button.is-disabled {
color: #fff;
background-color: #cccccc;
border-color: #cccccc;
......@@ -816,20 +804,20 @@
background-color: #cccccc;
border-color: #cccccc;
}
.footer {
display: flex;
justify-content: space-between;
}
.footerColor {
font-weight: 500;
font-size: 18px;
color: var(--color);
margin: 0 4px;
}
.radius {
border-radius: 4px;
}
.boxClass {
padding: 20px 10px 0 0;
}
.footer {
display: flex;
justify-content: space-between;
}
.footerColor {
font-weight: 500;
font-size: 18px;
color: var(--color);
margin: 0 4px;
}
.radius {
border-radius: 4px;
}
.boxClass {
padding: 20px 10px 0 0;
}
</style>
......@@ -51,7 +51,7 @@
<div v-if="type === '0'">
<div v-if="!disabled">
<!-- <el-form-item label="图片">
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:maxSize="20"
......@@ -60,7 +60,7 @@
<div slot="tip">
支持jpg/jpeg/png格式,图片大小不超过20M,支持最多10张批量上传
</div>
</UploadToCos>
</Upload>
</el-form-item> -->
</div>
<div v-else>
......@@ -76,9 +76,9 @@
<div v-if="type === '9'">
<div v-if="!disabled">
<el-form-item label="图文封面">
<UploadToCos :fileUrl.sync="form.coverUrl" type="0">
<Upload :fileUrl.sync="form.coverUrl" type="0">
<div slot="tip">支持jpg/jpeg/png格式,建议200*200</div>
</UploadToCos>
</Upload>
</el-form-item>
<el-form-item label="图文描述">
<el-input
......@@ -119,9 +119,9 @@
<div v-if="type === '11'">
<div v-if="!disabled">
<el-form-item label="封面" prop="coverUrl">
<UploadToCos :fileUrl.sync="form.coverUrl" type="0">
<Upload :fileUrl.sync="form.coverUrl" type="0">
<div slot="tip">支持jpg/jpeg/png格式,建议520*416</div>
</UploadToCos>
</Upload>
</el-form-item>
<el-form-item label="小程序ID" prop="digest">
<el-input v-model="form.digest" placeholder="小程序AppID"></el-input>
......
......@@ -12,7 +12,6 @@ import { delAndRemoves } from '@/api/contentCenter/common'
import { importTemplate, importData } from '@/api/contentCenter/basicMaterials'
import PreviewInPhone from '@/components/ContentCenter/PreviewInPhone'
import { download, toFormData } from '@/utils/common'
import UploadToCos from '@/components/UploadToCos'
import { dateFormat } from '@/utils/index'
var validateHtml = (rule, value, callback) => {
......@@ -35,7 +34,6 @@ export default {
quillEditor,
Voice,
PreviewInPhone,
UploadToCos,
},
props: {
// 0 图片(image)、1 语音(voice)、2 视频(video),3 普通文件(file), 4 文本, 5 海报, 6 活码, 7 人群, 8 旅程,9 图文,10 链接,11 小程序
......@@ -686,7 +684,7 @@ export default {
<!-- 图片 -->
<template v-else-if="type === '0'">
<el-form-item label="图片" prop="weMaterialImgAoList" v-if="!form.id">
<UploadToCos
<Upload
v-if="dialogVisible"
:fileList.sync="form.weMaterialImgAoList"
:maxSize="20"
......@@ -694,7 +692,7 @@ export default {
:multiple="true"
:limit="10">
<div slot="tip">支持jpg/jpeg/png格式,图片大小不超过20M,支持最多10张批量上传</div>
</UploadToCos>
</Upload>
</el-form-item>
<el-form-item label="图片标题" prop="materialName" v-else>
<el-input
......@@ -732,9 +730,9 @@ export default {
placeholder="请输入图文描述"></el-input>
</el-form-item>
<el-form-item label="图文封面">
<UploadToCos :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<Upload :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<div slot="tip">支持jpg/jpeg/png格式,建议200*200</div>
</UploadToCos>
</Upload>
</el-form-item>
<!-- <el-form-item label="内容">
富文本content
......@@ -782,22 +780,22 @@ export default {
</div>
</el-form-item>
<el-form-item label="封面" prop="coverUrl">
<UploadToCos :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<Upload :fileUrl.sync="form.coverUrl" type="0" v-if="dialogVisible">
<div slot="tip">支持jpg/jpeg/png格式,建议520*416</div>
</UploadToCos>
</Upload>
</el-form-item>
</template>
<template v-else-if="type === '1'">
<el-form-item label="语音" prop="materialUrl">
<Voice v-if="form.materialUrl" :amrUrl="form.materialUrl"></Voice>
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName || '点击上传'"
:type="type"
:format="audioType">
<div slot="tip">只能上传amr格式的语音文件。单个文件大小不超过2M,时长不超过1分钟</div>
</UploadToCos>
</Upload>
</el-form-item>
<el-form-item label="名称" prop="materialName">
<el-input v-model="form.materialName" placeholder="请输入"></el-input>
......@@ -822,7 +820,7 @@ export default {
show-word-limit></el-input>
</el-form-item>
<el-form-item label="上传视频" prop="materialUrl" v-if="!form.id">
<UploadToCos
<Upload
v-if="dialogVisible"
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
......@@ -830,7 +828,7 @@ export default {
@getPicUrl="getPicUrl"
:type="type">
<div slot="tip">支持mp4/mov格式,视频大小不超过100M</div>
</UploadToCos>
</Upload>
</el-form-item>
<!-- <el-form-item label="封面">
<upload :fileUrl.sync="form.coverUrl" type="0">
......@@ -858,14 +856,14 @@ export default {
:autosize="{ minRows: 3, maxRows: 10 }"></el-input>
</el-form-item>
<el-form-item label="上传文件" prop="materialUrl" v-if="!form.id">
<UploadToCos
<Upload
v-if="dialogVisible"
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:type="type"
:format="['doc', 'docx', 'pdf', 'ppt', 'pptx', 'pps', 'pptsx']">
<div slot="tip">支持pdf/ppt/word文件,单个文件大小不超过50M</div>
</UploadToCos>
</Upload>
</el-form-item>
</template>
</el-form>
......
......@@ -44,11 +44,7 @@
<!-- <div class="tips upload">
<i class="el-icon-plus"></i><span> 本地上传</span>
</div> -->
<UploadToCos
:fileUrl.sync="form.backgroundImgPath"
:maxSize="20"
type="0"
@upSuccess="upSuccess"></UploadToCos>
<Upload :fileUrl.sync="form.backgroundImgPath" :maxSize="20" type="0" @upSuccess="upSuccess"></Upload>
<el-button
size="mini"
type="text"
......@@ -224,7 +220,7 @@
fit="fit"></el-image>
</div>
<div class="up-style" v-else>
<UploadToCos :fileUrl.sync="formDate.imgUrl" :maxSize="20" type="0"></UploadToCos>
<Upload :fileUrl.sync="formDate.imgUrl" :maxSize="20" type="0"></Upload>
<el-button size="mini" type="text" style="margin-left: 10px" @click="addObj('imageShow')">
从素材库中选取
</el-button>
......@@ -436,6 +432,8 @@ export default {
materialName: data.materialName,
digest: data.digest,
backgroundImgPath: data.backgroundImgPath,
width: data.width,
height: data.height,
posterJSON: JSON.parse(data.otherField),
}
this.posterSubassemblyList = data.posterSubassemblyList || []
......@@ -671,10 +669,15 @@ export default {
scaleY: canvas.width / img.width,
})
canvas.setWidth(375)
canvas.setHeight(img.height * (canvas.width / img.width))
let height = img.height * (canvas.width / img.width)
canvas.setHeight(height)
this.form.width = 375
this.form.height = height
} else {
canvas.setWidth(img.width)
canvas.setHeight(img.height)
this.form.width = img.width
this.form.height = img.height
}
canvas.setBackgroundImage(img, canvas.renderAll.bind(canvas))
......
......@@ -38,13 +38,13 @@
<div v-if="type === '2'">
<div v-if="!disabled">
<!-- <el-form-item label="上传视频" prop="materialUrl">
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:type="type"
>
<div slot="tip">支持mp4/mov格式,视频大小不超过100M</div>
</UploadToCos>
</Upload>
</el-form-item> -->
<el-form-item label="视频描述">
<el-input
......@@ -74,13 +74,13 @@
<div v-if="type === '3'">
<div v-if="!disabled">
<!-- <el-form-item label="上传文件" prop="materialUrl">
<UploadToCos
<Upload
:fileUrl.sync="form.materialUrl"
:fileName.sync="form.materialName"
:type="type"
>
<div slot="tip">支持pdf/ppt/word文件,单个文件大小不超过50M</div>
</UploadToCos>
</Upload>
</el-form-item> -->
<el-form-item label="文件描述">
<el-input
......@@ -138,9 +138,9 @@
<div v-if="type === '5'">
<div v-if="!disabled">
<el-form-item label="封面" prop="materialUrl">
<UploadToCos :fileUrl.sync="form.materialUrl" :fileName.sync="form.materialName" :type="type">
<Upload :fileUrl.sync="form.materialUrl" :fileName.sync="form.materialName" :type="type">
<div slot="tip">支持pdf/ppt/word文件,单个文件大小不超过50M</div>
</UploadToCos>
</Upload>
</el-form-item>
<el-form-item label="文件描述">
<el-input
......
<template>
<div>
<el-form-item
:label="lableOne"
required
style="margin-right: 200px !important"
:error="templateInfo"
>
<el-form-item :label="lableOne" required style="margin-right: 200px !important" :error="templateInfo">
<div v-if="showModle" style="margin-bottom: 10px">
<el-button type="primary" @click="welcomVisible = true">从模板库中选择</el-button>
</div>
......@@ -18,17 +13,12 @@
:autosize="{ minRows: 5, maxRows: 20 }"
clearable
:autofocus="true"
@input="changeInfo"
/>
@input="changeInfo" />
</el-form-item>
<el-form-item>
<div slot="label" class="title" v-if="otherType !== 3">
{{ titleTwo }}
<el-popover
trigger="hover"
:content="'最多添加' + maxlength + '个素材'"
placement="top-start"
>
<el-popover trigger="hover" :content="'最多添加' + maxlength + '个素材'" placement="top-start">
<i slot="reference" class="el-icon-question"></i>
</el-popover>
</div>
......@@ -37,23 +27,13 @@
<div style="text-align: left" class="flex">
<el-popover
trigger="hover"
:content="
'最多添加' +
maxlength +
'个' +
fontType +
',如需修改请删除已有' +
fontType +
'后重新尝试'
"
:content="'最多添加' + maxlength + '个' + fontType + ',如需修改请删除已有' + fontType + '后重新尝试'"
placement="top-start"
:disabled="talkList.length < maxlength"
>
:disabled="talkList.length < maxlength">
<el-dropdown
slot="reference"
@command="moveGroup"
:disabled="talkList.length > maxlength || talkList.length === maxlength"
>
:disabled="talkList.length > maxlength || talkList.length === maxlength">
<el-button type="primary">+ {{ '新建' + fontType }}</el-button>
<el-dropdown-menu slot="dropdown" trigger="click">
<!-- <el-dropdown-item :command="'4'" v-if="!this.templateType && this.moduleType !== 4">
......@@ -85,23 +65,13 @@
</el-popover>
<el-popover
trigger="hover"
:content="
'最多添加' +
maxlength +
'个' +
fontType +
',如需修改请删除已有' +
fontType +
'后重新尝试'
"
:content="'最多添加' + maxlength + '个' + fontType + ',如需修改请删除已有' + fontType + '后重新尝试'"
placement="top-start"
:disabled="talkList.length < maxlength"
>
:disabled="talkList.length < maxlength">
<div slot="reference" class="ml20">
<el-button
@click="choseCenter"
:disabled="talkList.length > maxlength || talkList.length === maxlength"
>
:disabled="talkList.length > maxlength || talkList.length === maxlength">
从素材中心选择
</el-button>
</div>
......@@ -112,12 +82,7 @@
</el-form-item>
<div style="margin-top: 10px; margin-left: 150px" v-show="talkList.length">
<DragTable
:tableData2="talkList"
@setData="setData"
@getEdit="getEdit"
:dargAble="[2].includes(moduleType)"
/>
<DragTable :tableData2="talkList" @setData="setData" @getEdit="getEdit" :dargAble="[2].includes(moduleType)" />
</div>
<!-- <el-col :span="8" class="g-card" style="margin-top: 20px; padding: 20px;" v-if="showPhone">
<PreviewInPhone :list="talkList" :templateInfo="talkForm.templateInfo" :liveUrl="liveUrl" />
......@@ -131,8 +96,7 @@
@dialogClose="dialogClose"
:materialTalkList="talkList"
:moduleType="moduleType"
:maxlength="maxlength"
/>
:maxlength="maxlength" />
<!-- 模板库 -->
<el-dialog
:title="otherType === 2 ? '选择群发模板' : '选择欢迎语模板'"
......@@ -140,8 +104,7 @@
width="60%"
append-to-body
:close-on-click-modal="false"
v-if="welcomVisible"
>
v-if="welcomVisible">
<TemplateLibrary @changeObj="changeObj" :isGroup="otherType === 2" />
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="selectModle" :loading="libraryLoading">确 定</el-button>
......@@ -156,14 +119,12 @@
:tplType="tplType"
:moduleType="moduleType"
:maxlength="maxlength"
:noApplets="otherType === 3"
/>
:noApplets="otherType === 3" />
<SelectUser
:defaultValues="selectedUserList"
:visible.sync="dialogVisibleSelectUser"
title="选择使用员工"
@success="selectedUser"
></SelectUser>
@success="selectedUser"></SelectUser>
</div>
</template>
......@@ -175,7 +136,6 @@ import { templateAdd, templateDetail } from '@/api/contentCenter/modleCenter'
import DragTable from '@/components/DragTable'
import MaterialCenter from '@/components/ContentCenter/MaterialCenter'
import { string } from 'clipboard'
import UploadToCos from '@/components/UploadToCos'
import { getPosterInfo } from '@/api/material/poster'
import TemplateLibrary from '@/components/ContentCenter/TemplateLibrary'
import MessageContentForm from '@/components/MessageContentForm'
......@@ -185,7 +145,6 @@ export default {
PreviewInPhone,
DragTable,
MaterialCenter,
UploadToCos,
getPosterInfo,
TemplateLibrary,
MessageContentForm,
......
......@@ -4,11 +4,11 @@
<div class="g-card">
<div class="my-title">企业配置</div>
<el-form-item label="企业ID:" prop="corpId">
<el-input style="width: 40%;" v-model="form.corpId" placeholder=""></el-input>
<el-input style="width: 40%" v-model="form.corpId" placeholder=""></el-input>
<div class="tips">企业ID即CorpID,在企微后台->我的企业中获取</div>
</el-form-item>
<el-form-item label="企业名称:" prop="companyName" required>
<el-input style="width: 40%;" v-model="form.companyName" placeholder="企业名称"></el-input>
<el-input style="width: 40%" v-model="form.companyName" placeholder="企业名称"></el-input>
<div class="tips">根据企业 ID 配置后回显</div>
</el-form-item>
<el-form-item label="企业logo" required prop="logoUrl">
......@@ -22,22 +22,20 @@
<div>
<el-input
:disabled="!corpSecretEditState"
style="width: 40%;"
style="width: 40%"
:type="corpSecretEditState ? 'text' : 'password'"
v-model="form.corpSecret"
placeholder="请输入通讯录Secret"
></el-input>
<el-button style="margin-left: 20px;" plain v-if="corpSecretEditState" @click="cancelEditCorpSecret">
placeholder="请输入通讯录Secret"></el-input>
<el-button style="margin-left: 20px" plain v-if="corpSecretEditState" @click="cancelEditCorpSecret">
取消
</el-button>
<el-button type="primary" plain v-if="corpSecretEditState" @click="submitEditCorpSecret">保存</el-button>
<el-button
type="primary"
style="margin-left: 20px;"
style="margin-left: 20px"
plain
v-if="!corpSecretEditState"
@click="editCorpSecret"
>
@click="editCorpSecret">
修改
</el-button>
</div>
......@@ -50,12 +48,11 @@
<div>
<el-input
:disabled="!contactSecretEditState"
style="width: 40%;"
style="width: 40%"
:type="contactSecretEditState ? 'text' : 'password'"
v-model="form.contactSecret"
placeholder="请输入客户联系Secret"
></el-input>
<el-button style="margin-left: 20px;" plain v-if="contactSecretEditState" @click="cancelEditContactSecret">
placeholder="请输入客户联系Secret"></el-input>
<el-button style="margin-left: 20px" plain v-if="contactSecretEditState" @click="cancelEditContactSecret">
取消
</el-button>
<el-button type="primary" plain v-if="contactSecretEditState" @click="submitEditContactSecret">
......@@ -63,11 +60,10 @@
</el-button>
<el-button
type="primary"
style="margin-left: 20px;"
style="margin-left: 20px"
plain
v-if="!contactSecretEditState"
@click="editContactSecret"
>
@click="editContactSecret">
修改
</el-button>
</div>
......@@ -77,10 +73,10 @@
<div class="g-card">
<div class="my-title">回调配置</div>
<el-form-item label="Token:" prop="token">
<el-input style="width: 40%;" v-model="form.token" placeholder="请输入Token"></el-input>
<el-input style="width: 40%" v-model="form.token" placeholder="请输入Token"></el-input>
</el-form-item>
<el-form-item label="EncodingAESKey:" prop="encodingAesKey">
<el-input style="width: 40%;" v-model="form.encodingAesKey" placeholder="请输入EncodingAESKey"></el-input>
<el-input style="width: 40%" v-model="form.encodingAesKey" placeholder="请输入EncodingAESKey"></el-input>
</el-form-item>
</div>
<el-form-item label="" class="ar">
......@@ -90,91 +86,90 @@
</div>
</template>
<script>
import UploadToCos from '../../components/UploadToCos.vue'
export default {
components: { UploadToCos },
name: 'enterprise-wechat-part1',
data() {
return {
corpSecretCopy: '',
corpSecretEditState: false,
contactSecretCopey: '',
contactSecretEditState: false,
form: {},
rules: {
corpId: [{ required: true, message: '必填项', trigger: 'blur' }],
corpSecret: [{ required: true, message: '必填项', trigger: 'blur' }],
companyName: [{ required: true, message: '必填项', trigger: 'blur' }],
contactSecret: [{ required: true, message: '必填项', trigger: 'blur' }],
logoUrl: [{ required: true, message: '必填项', trigger: 'blur' }],
token: [{ required: true, message: '必填项', trigger: 'blur' }],
encodingAesKey: [{ required: true, message: '必填项', trigger: 'blur' }]
}
}
export default {
components: {},
name: 'enterprise-wechat-part1',
data() {
return {
corpSecretCopy: '',
corpSecretEditState: false,
contactSecretCopey: '',
contactSecretEditState: false,
form: {},
rules: {
corpId: [{ required: true, message: '必填项', trigger: 'blur' }],
corpSecret: [{ required: true, message: '必填项', trigger: 'blur' }],
companyName: [{ required: true, message: '必填项', trigger: 'blur' }],
contactSecret: [{ required: true, message: '必填项', trigger: 'blur' }],
logoUrl: [{ required: true, message: '必填项', trigger: 'blur' }],
token: [{ required: true, message: '必填项', trigger: 'blur' }],
encodingAesKey: [{ required: true, message: '必填项', trigger: 'blur' }],
},
}
},
watch: {
data: 'setData',
},
props: {
data: {
type: Object,
default: {},
},
watch: {
data: 'setData'
},
methods: {
editContactSecret() {
this.contactSecretEditState = true
this.contactSecretCopy = JSON.parse(JSON.stringify(this.form.contactSecret))
this.form.contactSecret = ''
},
props: {
data: {
type: Object,
default: {}
}
cancelEditContactSecret() {
this.contactSecretEditState = false
this.form.contactSecret = JSON.parse(JSON.stringify(this.contactSecretCopy))
},
methods: {
editContactSecret() {
this.contactSecretEditState = true
this.contactSecretCopy = JSON.parse(JSON.stringify(this.form.contactSecret))
this.form.contactSecret = ''
},
cancelEditContactSecret() {
submitEditContactSecret() {
if (this.form.contactSecret) {
this.$emit('submit', this.form)
this.contactSecretEditState = false
this.form.contactSecret = JSON.parse(JSON.stringify(this.contactSecretCopy))
},
submitEditContactSecret() {
if (this.form.contactSecret) {
this.$emit('submit', this.form)
this.contactSecretEditState = false
}
},
}
},
editCorpSecret() {
this.corpSecretEditState = true
this.corpSecretCopy = JSON.parse(JSON.stringify(this.form.corpSecret))
this.form.corpSecret = ''
},
cancelEditCorpSecret() {
editCorpSecret() {
this.corpSecretEditState = true
this.corpSecretCopy = JSON.parse(JSON.stringify(this.form.corpSecret))
this.form.corpSecret = ''
},
cancelEditCorpSecret() {
this.corpSecretEditState = false
this.form.corpSecret = JSON.parse(JSON.stringify(this.corpSecretCopy))
},
submitEditCorpSecret() {
if (this.form.corpSecret) {
this.$emit('submit', this.form)
this.corpSecretEditState = false
this.form.corpSecret = JSON.parse(JSON.stringify(this.corpSecretCopy))
},
submitEditCorpSecret() {
if (this.form.corpSecret) {
}
},
submit() {
this.$refs['form'].validate((validate) => {
if (validate) {
this.$emit('submit', this.form)
this.corpSecretEditState = false
}
},
submit() {
this.$refs['form'].validate((validate) => {
if (validate) {
this.$emit('submit', this.form)
}
})
},
setData() {
if (Object.keys(this.data).length) {
this.form = this.data
}
})
},
setData() {
if (Object.keys(this.data).length) {
this.form = this.data
}
},
mounted() {},
created() {}
}
},
mounted() {},
created() {},
}
</script>
<style lang="scss" scoped>
.my-title {
}
.tips {
color: #aaa;
font-size: 12px;
}
.my-title {
}
.tips {
color: #aaa;
font-size: 12px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!