Commit fe4f0511 by 匡雅琴

素材类型优化

1 parent fab7e516
...@@ -286,9 +286,26 @@ export default { ...@@ -286,9 +286,26 @@ export default {
if (this.materialAddForm.isNotifySender) { if (this.materialAddForm.isNotifySender) {
params.isNotifySender = 0 params.isNotifySender = 0
} }
if (params.materialType == 1) { if (this.materialAddForm.materialType == 1) {
params.materialUrl = this.pdfUrl params.materialUrl = this.pdfUrl
} else if (params.materialType == 3) { } else if (this.materialAddForm.materialType == 3) {
let html = this.textBoxContent
let imgHtml = html.match(/<img.*?(?:>|\/>)/g)
let videoHtml = html.match(/<video.*?(?:>|\/>)/g)
if (imgHtml) {
for (let i = 0; i < imgHtml.length; i++) {
html = html.replace(imgHtml[i], '')
}
}
if (videoHtml) {
for (let i = 0; i < videoHtml.length; i++) {
html = html.replace(videoHtml[i], '')
}
}
html = html.replace(/<[^>]+>/g, '')
if (videoHtml && videoHtml.length && !imgHtml && !html.length) params.materialType = 4
if (!imgHtml && !videoHtml) params.materialType = 5
if (imgHtml && imgHtml.length && !videoHtml && !html.length) params.materialType = 6
this.textBoxContent = encodeURIComponent(this.textBoxContent) this.textBoxContent = encodeURIComponent(this.textBoxContent)
params.materialUrl = this.textBoxContent params.materialUrl = this.textBoxContent
} }
...@@ -303,19 +320,20 @@ export default { ...@@ -303,19 +320,20 @@ export default {
} }
this.$apis.material.materialDetail(params).then(res => { this.$apis.material.materialDetail(params).then(res => {
this.materialAddForm = res this.materialAddForm = res
if (this.materialAddForm.businessType) { if (res.businessType) {
const businessTypeArr = this.materialAddForm.businessType.split(',') const businessTypeArr = this.materialAddForm.businessType.split(',')
this.materialAddForm.businessType = businessTypeArr.map(item => parseInt(item)) this.materialAddForm.businessType = businessTypeArr.map(item => parseInt(item))
} else { } else {
this.materialAddForm.businessType = [] this.materialAddForm.businessType = []
} }
if (this.materialAddForm.materialType == 3) { if (res.materialType == 3 || res.materialType == 4 || res.materialType == 5 || res.materialType == 6) {
this.materialAddForm.materialType = 3
this.materialAddForm.materialUrl = decodeURIComponent(this.materialAddForm.materialUrl) this.materialAddForm.materialUrl = decodeURIComponent(this.materialAddForm.materialUrl)
this.$refs.textBox.setEdit(this.materialAddForm.materialUrl) this.$refs.textBox.setEdit(this.materialAddForm.materialUrl)
} else if (this.materialAddForm.materialType == 1) { } else if (res.materialType == 1) {
this.pdfUrl = this.materialAddForm.materialUrl this.pdfUrl = this.materialAddForm.materialUrl
} }
if (this.materialAddForm.tagJson) { if (res.tagJson) {
const tagging = eval(this.materialAddForm.tagJson) const tagging = eval(this.materialAddForm.tagJson)
// let arr = [] // let arr = []
this.tagging = tagging.map(item => { this.tagging = tagging.map(item => {
...@@ -479,20 +497,6 @@ export default { ...@@ -479,20 +497,6 @@ export default {
handleSubmit() { handleSubmit() {
this.$refs.materialAddForm.validate(valid => { this.$refs.materialAddForm.validate(valid => {
if (valid) { if (valid) {
// let tagging = this.tagging.map(item => {
// let tagIds = item.labelList.map(tag => {
// return tag.id
// })
// let name = item.labelList.map(tag => {
// return tag.name
// })
// return {
// groupId: item.labelGroup.id,
// tagIds: tagIds.join(','),
// name: name.join(','),
// labelType: item.labelGroup.name
// }
// })
var params = this.getParams() var params = this.getParams()
if (!params.materialUrl) { if (!params.materialUrl) {
this.$message({ this.$message({
...@@ -503,23 +507,13 @@ export default { ...@@ -503,23 +507,13 @@ export default {
} }
// status 状态 0 启用 -1 禁用 1 存草稿 // status 状态 0 启用 -1 禁用 1 存草稿
params.status = 0 params.status = 0
// params.isNotifySender = -1
// params.tagJson = JSON.stringify(tagging)
// if (this.materialAddForm.isNotifySender) {
// params.isNotifySender = 0
// }
// if (params.materialType == 1) {
// params.materialUrl = this.pdfUrl
// } else if (params.materialType == 3) {
// this.textBoxContent = encodeURIComponent(this.textBoxContent)
// params.materialUrl = this.textBoxContent
// }
let material let material
if (params.id) { if (params.id) {
material = 'materialEdit' material = 'materialEdit'
} else { } else {
material = 'materialInsert' material = 'materialInsert'
} }
console.log(params, '====')
this.$apis.material[material](params).then(res => { this.$apis.material[material](params).then(res => {
if (res) { if (res) {
this.$message({ this.$message({
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</span> </span>
<div class="container"> <div class="container">
<div class="search-form"> <div class="search-form">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="materialFormData" @handleOk="getListApi" @handleRest="handleReset"></GLCombiForm> <GLCombiForm ref="showSearch" :rowNumber="2" :formObj="searchForm" :formData="materialFormData" @handleOk="getListApi" @handleRest="handleReset"></GLCombiForm>
</div> </div>
<div class="tabelList"> <div class="tabelList">
<el-row> <el-row>
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<!-- 素材为自定义链接 --> <!-- 素材为自定义链接 -->
<span v-if="scope.scope.materialType == 2"></span> <span v-if="scope.scope.materialType == 2"></span>
<!-- 素材为图文 --> <!-- 素材为图文 -->
<span v-if="scope.scope.materialType == 3" class="material-content"> <span v-if="scope.scope.materialType == 3 || scope.scope.materialType == 4 || scope.scope.materialType == 5 || scope.scope.materialType == 6" class="material-content">
<!-- 图片 --> <!-- 图片 -->
<el-popover placement="top" trigger="hover" v-if="scope.scope.urlType == 'img'"> <el-popover placement="top" trigger="hover" v-if="scope.scope.urlType == 'img'">
<div> <div>
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<!-- 视频 --> <!-- 视频 -->
<el-popover placement="right" trigger="hover" v-if="scope.scope.urlType == 'video'"> <el-popover placement="right" trigger="hover" v-if="scope.scope.urlType == 'video'">
<div> <div>
<video controls autoplay width="300" height="300"> <video controls width="300" height="300">
<source :src="scope.scope.materialContentRpcResponse.materialUrl" type="video/mp4" /> <source :src="scope.scope.materialContentRpcResponse.materialUrl" type="video/mp4" />
</video> </video>
</div> </div>
...@@ -84,9 +84,10 @@ ...@@ -84,9 +84,10 @@
<div slot="materialType" slot-scope="scope"> <div slot="materialType" slot-scope="scope">
<span v-if="scope.scope.materialType == 1">pdf文件</span> <span v-if="scope.scope.materialType == 1">pdf文件</span>
<span v-if="scope.scope.materialType == 2">自定义链接</span> <span v-if="scope.scope.materialType == 2">自定义链接</span>
<span v-if="scope.scope.urlType == 'video'">视频</span> <span v-if="scope.scope.materialType == 3">图文</span>
<span v-if="scope.scope.urlType == 'img'">图文</span> <span v-if="scope.scope.materialType == 4">视频</span>
<span v-if="!scope.scope.urlType && scope.scope.materialType == 3">纯文字</span> <span v-if="scope.scope.materialType == 5">纯文字</span>
<span v-if="scope.scope.materialType == 6">纯图片</span>
</div> </div>
<span slot="auth-button" slot-scope="scope"> <span slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton> <GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
...@@ -175,6 +176,18 @@ export default { ...@@ -175,6 +176,18 @@ export default {
{ {
optionId: 3, optionId: 3,
optionLabel: '图文' optionLabel: '图文'
},
{
optionId: 4,
optionLabel: '视频'
},
{
optionId: 5,
optionLabel: '纯文字'
},
{
optionId: 6,
optionLabel: '纯图片'
} }
], ],
optionId: 'optionId', optionId: 'optionId',
...@@ -513,11 +526,8 @@ export default { ...@@ -513,11 +526,8 @@ export default {
let data = res let data = res
let tableData = [] let tableData = []
data.forEach(item => { data.forEach(item => {
// 根据素材类型是图文还是pdf处理数据 // 根据素材类型是图文处理数据
if (item.materialType != 3) { if (item.materialType == 3 || item.materialType == 4 || item.materialType == 5 || item.materialType == 6) {
item.materialContentRpcResponse.materialUrl = ''
}
if (item.materialType == 3) {
let html = decodeURIComponent(item.materialContentRpcResponse.materialUrl) let html = decodeURIComponent(item.materialContentRpcResponse.materialUrl)
let imgHtml = html.match(/<img.*?(?:>|\/>)/g) let imgHtml = html.match(/<img.*?(?:>|\/>)/g)
let videoHtml = html.match(/<video.*?(?:>|\/>)/g) let videoHtml = html.match(/<video.*?(?:>|\/>)/g)
......
...@@ -216,12 +216,13 @@ export default { ...@@ -216,12 +216,13 @@ export default {
params.flag = 0 params.flag = 0
this.$apis.material.materialDetail(params).then(res => { this.$apis.material.materialDetail(params).then(res => {
this.detailInfo = res this.detailInfo = res
if (this.detailInfo.tagJson) { if (res.tagJson) {
this.detailInfo.tagJson = eval(this.detailInfo.tagJson) this.detailInfo.tagJson = eval(this.detailInfo.tagJson)
} else { } else {
this.detailInfo.tagJson = [] this.detailInfo.tagJson = []
} }
if (this.detailInfo.materialType == 3) { if (res.materialType == 3 || res.materialType == 4 || res.materialType == 5 || res.materialType == 6) {
this.detailInfo.materialType = 3
this.detailInfo.materialUrl = decodeURIComponent(this.detailInfo.materialUrl) this.detailInfo.materialUrl = decodeURIComponent(this.detailInfo.materialUrl)
let html = this.detailInfo.materialUrl let html = this.detailInfo.materialUrl
let imgHtml = html.match(/<img.*?(?:>|\/>)/g) let imgHtml = html.match(/<img.*?(?:>|\/>)/g)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!