Commit 50fe322d by 匡雅琴

Merge branch 'kyq_dev' into 'v2.12.0'

Kyq dev

See merge request !10
2 parents 50cc9bd4 1a6439ca
This diff could not be displayed because it is too large.
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
"axios": "^0.18.0", "axios": "^0.18.0",
"dayjs": "^1.11.4", "dayjs": "^1.11.4",
"element-ui": "^2.15.1", "element-ui": "^2.15.1",
"glsx-common": "^2.0.1",
"glsx-vue-common": "^2.0.5", "glsx-vue-common": "^2.0.5",
"lodash": "^4.17.10", "lodash": "^4.17.10",
"sass-loader": "^7.1.0", "node-sass": "4.14.1",
"sass-loader": "7.3.1",
"sha1": "^1.1.1", "sha1": "^1.1.1",
"vue": "^2.5.17" "vue": "^2.6.11"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^3.0.1", "@vue/cli-plugin-babel": "^3.0.1",
...@@ -27,6 +29,6 @@ ...@@ -27,6 +29,6 @@
"eslint-plugin-html": "^4.0.5", "eslint-plugin-html": "^4.0.5",
"less": "^3.0.4", "less": "^3.0.4",
"less-loader": "^4.1.0", "less-loader": "^4.1.0",
"vue-template-compiler": "^2.5.17" "vue-template-compiler": "^2.6.11"
} }
} }
// import request from './request'
// const path = 'scrm.api.renewal.insurance.customer.name.list.'
// const defaultPath = 'scrm.api.renewal.order.'
const taskApi = {
// searchCustomerList(data = {}) {
// data.method = `${path}get`
// return request(data)
// },
}
export { taskApi }
<template>
<div class="ly-emotion">
<slot></slot>
</div>
</template>
<script>
import emoji from '../../utils/emo'
export default {
name: 'ly-emotion',
mounted() {
const name = this.$el.innerHTML
const list = emoji.flat(Infinity)
let index = parseInt(list.indexOf(name)) + 1
if (index < 10) {
index = '00' + index
} else if (index >= 10 && index < 100) {
index = '0' + index
}
let imgHTML = `<img src="https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png">`
this.$nextTick(() => {
this.$el.innerHTML = imgHTML
})
}
}
</script>
<style scoped>
.ly-emotion {
display: inline-block;
}
.ly-static-emotion {
width: 24px;
height: 24px;
display: inline-block;
}
</style>
<template>
<div>
<div class="emotion-box" :style="{ height: height + 'px' }">
<div class="emotion-box-line" v-for="(line, i) in list" :key="i">
<Emotion class="emotion-item" v-for="(item, i) in line" :key="i" @click.native="clickHandler(item)">{{ item }}</Emotion>
</div>
</div>
</div>
</template>
<script>
import emoji from '../../utils/emo'
import Emotion from './Emotion'
export default {
props: {
height: {
type: Number,
default: 200
}
},
name: 'emotionWords',
data() {
return {
list: emoji
}
},
methods: {
clickHandler(i) {
let emotion = `${i}`
this.$emit('emotion', emotion)
}
},
components: {
Emotion
}
}
</script>
<style scoped lang="scss">
.emotion-box {
z-index: 2004;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.15);
width: 300px;
box-sizing: border-box;
padding: 5px;
overflow: hidden;
overflow-y: auto;
}
.emotion-box-line {
display: flex;
}
.emotion-item {
flex: 1;
text-align: center;
cursor: pointer;
line-height: 23px;
/deep/ {
img {
width: 24px;
// -webkit-user-select: none;
cursor: default;
pointer-events: none;
}
}
}
</style>
<template>
<div class="welcome-box">
<div class="content">
<div class="content-bg">
<wTextarea ref="textContent" v-model="textValue" @updateText="updateText" :style="{ 'min-height': boxHeight + 'px' }"></wTextarea>
<!-- <vuedraggable animation="300" v-model="previewList" v-if="isPreview(previewList, ATT_TYPE.IMAGE) && Isdraggable">
<transition-group class="welcome-file">
<template v-for="(itm, index) in previewList">
<div class="welcome-img-box" v-if="itm.attType == ATT_TYPE.IMAGE" :style="`background-image: url('${itm.attContent}')`" :key="itm">
<div class="welcome-img-checked">
<i class="el-icon-zoom-in" @click="handleEnlarge(itm.attContent)"></i>
<i class="el-icon-delete" @click="close(index)"></i>
,
</div>
</div>
</template>
</transition-group>
</vuedraggable> -->
<div class="welcome-file" v-if="isPreview(previewList, ATT_TYPE.VEDIO) && Isdraggable">
<template v-for="(itm, index) in previewList">
<template v-if="itm.attType == ATT_TYPE.VEDIO">
<div class="video-panel" :key="itm">
<video id="video" width="100%" height="100%" preload loop muted>
<source :src="itm.attContent" type="video/mp4" />
</video>
<i class="el-icon-video-play" @click="handleEnlarge(itm.attContent, 'video')"></i>
<div class="video-pane-close" @click="close(index)"><img src="../../assets/welcomeWord/close-video.png" alt="" /></div>
</div>
</template>
</template>
</div>
<div class="welcome-file" v-if="isPreview(previewList) && !Isdraggable">
<template v-for="(itm, index) in previewList">
<div v-if="itm.attType != ATT_TYPE.TEXT" :key="index">
<template v-if="itm.attType == ATT_TYPE.IMAGE">
<!-- <i v-show="index == previewList.length - 1 && loading" class="el-icon-loading"></i>
<img v-show="!loading" src="../../../assets/welcomeWord/icon-img.png" alt />
<span :title="itm.attContent">{{ itm.attContent }}</span> -->
<div class="welcome-img-box" :style="`background-image: url('${itm.attContent}')`">
<div class="welcome-img-checked">
<i class="el-icon-zoom-in" @click="handleEnlarge(itm.attContent)"></i>
<i class="el-icon-delete" @click="close(index)"></i>
</div>
</div>
</template>
<template v-else-if="itm.attType == ATT_TYPE.VEDIO">
<div class="video-panel">
<video id="video" width="100%" height="100%" preload loop muted>
<source :src="itm.attContent" type="video/mp4" />
</video>
<i class="el-icon-video-play" @click="handleEnlarge(itm.attContent, 'video')"></i>
<div class="video-pane-close" @click="close(index)"><img src="../../assets/welcomeWord/close-video.png" alt="" /></div>
</div>
</template>
<template v-else-if="itm.attType == ATT_TYPE.ACTIVITY">
<div class="welcome-activity-panel">
<div class="welcome-activity-box">
<div class="welcome-activity-icon">
<img src="../../assets/welcomeWord/coupon.png" alt="" v-if="marketingContent(itm).selectType == 'coupon'" />
<img src="../../assets/welcomeWord/gift.png" alt="" v-else />
</div>
<div class="delete-solid">
<i class="el-icon-delete-solid" @click="close(index)"></i>
</div>
<div class="welcome-activity-desc">
<template v-if="marketingContent(itm).selectType == 'card'">
<div class="model-item-title" :title="marketingContent(itm).equityName">{{ marketingContent(itm).equityName }}</div>
<div class="model-item-content model-item-contents">
试用天数:
<span>{{ marketingContent(itm).freeDay }}天</span>
</div>
</template>
<template v-else-if="marketingContent(itm).selectType == 'package'">
<div class="model-item-title" :title="marketingContent(itm).packageName">{{ marketingContent(itm).packageName }}</div>
<div class="model-item-content model-item-contents">
销售价格:
<span>{{ marketingContent(itm).packagePrice }}元</span>
</div>
</template>
<template v-else-if="marketingContent(itm).selectType == 'coupon'">
<div class="model-item-title" :title="marketingContent(itm).couponName">{{ marketingContent(itm).couponName }}</div>
<div class="model-item-content model-item-contents">
数量:
<span>{{ marketingContent(itm).residueAmount }}</span>
</div>
</template>
<template v-else-if="marketingContent(itm).selectType == 'activity'">
<div class="model-item-title" :title="marketingContent(itm).activityName">{{ marketingContent(itm).activityName }}</div>
<div class="model-item-content"></div>
<div class="model-item-content">
开始时间:
{{ marketingContent(itm).startTime }}
</div>
<div class="model-item-content">
结束时间:
{{ marketingContent(itm).endTime }}
</div>
</template>
<template v-else>
<div class="model-item-title" :title="marketingContent(itm).couponName">{{ marketingContent(itm).equityName }}</div>
<div class="model-item-content model-item-weight">
赠送天数:
<span>{{ marketingContent(itm).effectiveType == 2 ? marketingContent(itm).effectivedDay + '天' : '永久有效' }}</span>
</div>
</template>
</div>
</div>
</div>
<!-- <img src="../../../assets/welcomeWord/icon-applet.png" alt />
<span :title="JSON.parse(itm.attContent).marketingName">{{ JSON.parse(itm.attContent).marketingName }}</span> -->
</template>
<template v-else-if="itm.attType == ATT_TYPE.MINIPROGRAM">
<img src="../../assets/welcomeWord/icon-applet.png" alt />
<span :title="itm.attContent.title">{{ itm.attContent.title }}</span>
</template>
<template v-else-if="itm.attType == ATT_TYPE.FILE">
<div class="welcome-activity-panel">
<div class="welcome-activity-box">
<div class="welcome-activity-icon">
<img src="../../assets/welcomeWord/pdf_r.png" v-if="itm.attContent" />
</div>
<div class="welcome-activity-desc">
<div class="model-item-title">{{ JSON.parse(itm.attContent).fileName }}</div>
</div>
<div class="delete-solid">
<i class="el-icon-delete-solid" @click="close(index)"></i>
</div>
</div>
</div>
</template>
<!-- <i class="el-icon-circle-close" @click="close(index)"></i> -->
</div>
</template>
</div>
<div class="btn-group-panel">
<div class="btn-group">
<div class="add-btn" v-for="item in btnList" :key="item.type">
<!-- <i class="el-icon-circle-plus-outline"></i> -->
<img class="emotion-item" :src="require(`../../assets/welcomeWord/add-${checkedType(item.type)}.png`)" alt v-if="item.type == 'expression'" @click="selectEmotion" />
<img :src="require(`../../assets/welcomeWord/add-${checkedType(item.type)}.png`)" v-else alt />
<span class="emotion-item" v-if="item.type == 'expression'" @click.stop="selectEmotion">{{ item.name }}</span>
<span v-else>{{ item.name }}</span>
<input v-if="item.type == 'img'" type="file" style="opacity: 0" :id="item.type + 'file'" ref="file" class="welcome-input upload-img" :accept="item.accept || 'image/png, image/jpeg, image/jpg'" @change="e => handleImgChange(e)" />
<input v-else-if="item.type == 'video'" type="file" style="opacity: 0" :id="item.type + 'file'" ref="file" class="welcome-input" :accept="item.accept || 'video/*'" @change="e => handleVideoChange(e)" />
<el-link v-else-if="item.type != 'video' && item.type != 'img' && item.type != 'expression'" style="opacity: 0" @click="handleFun(item)">{{ item.name }}</el-link>
</div>
</div>
<div class="text-num">{{ textNum }}/{{ maxNum }}</div>
</div>
</div>
<div v-show="emotionStatus" class="emotion-panel">
<emotion class="emotion-panel-box" @emotion="handleEmotion" :height="280"></emotion>
</div>
</div>
<el-dialog class="image-dialog" :visible.sync="dialogVisibleImg" width="50%">
<img :src="dialogSrc" width="100%" v-if="dialogType == 'img'" />
<video width="100%" autoplay controls :src="dialogSrc" v-else></video>
</el-dialog>
</div>
</template>
<script>
//1朋友圈模板-单图文,2朋友圈模板-多图文,3朋友圈模板-文字+视频,4朋友圈模板-文字,5优惠券-商城券,6活动-权益卡使用,7活动-权益套餐,8活动-秒杀活动,10-素材
const ATT_TYPE = {
TEXT: 1,
IMAGE: 2,
VEDIO: 3,
URL: 4,
MINIPROGRAM: 5,
FILE: 6,
ACTIVITY: 7,
MATERIAL: 10
}
const wordType = [
'expression',
'img',
'video',
'nickname',
'activity',
'material',
'message',
'link',
'code'
]
import emoji from '../../utils/emo'
import Emotion from './Emotion.vue'
import wTextarea from './tag-textarea.vue'
// import vuedraggable from 'vuedraggable'
import { utils } from 'glsx-common'
export default {
name: 'GLEditor',
components: {
Emotion,
wTextarea
// vuedraggable
},
props: {
btnList: Array,
form: String,
boxHeight: {
type: Number,
default: 400
},
ATT_TYPE: {
type: Object,
default: () => ATT_TYPE
}
},
data() {
return {
textNum: 0,
maxNum: 1000,
myArr: [{ name: 888 }, { name: 888 }],
dialogVisibleImg: false,
dialogSrc: '',
dialogType: 'img',
loading: false,
emotionStatus: false,
guestForm: {},
previewList: [],
sendType: '',
sendTime: '',
sendDate: '',
editor: {},
textValue: '',
text: ''
}
},
mounted() {
console.log('渲染了')
document.addEventListener('click', e => {
console.log(e.target.className, '===')
if (e.target.className != 'emotion-item') {
this.emotionStatus = false
}
})
},
computed: {
// activityList() {
// return this.btnList.find(item => item.type == 'activity')
// ? this.btnList.find(item => item.type == 'activity').funParams
// : {}
// },
// messageList() {
// return this.btnList.find(item => item.type == 'message') || {}
// },
imageList() {
return this.btnList.find(item => item.type == 'img') || {}
},
Isdraggable() {
return (this.btnList.find(item => item.type == 'img') || {}).Isdraggable
},
videoList() {
return this.btnList.find(item => item.type == 'video') || {}
},
// materialList() {
// return this.btnList.find(item => item.type == 'material') || {}
// },
linkList() {
return this.btnList.find(item => item.type == 'link') || {}
}
// materialItem() {
// let attContent
// this.previewList.forEach(item => {
// if (item.attType == ATT_TYPE.FILE) {
// }
// })
// return attContent
// }
},
watch: {
previewList: {
handler(val) {
this.$emit('previewWord', val)
},
deep: true
}
},
methods: {
isPreview(preview, type) {
return type
? preview.filter(item => item.attType == type).length
: preview.filter(item => item.attType != ATT_TYPE.TEXT).length
},
handleEnlarge(src, type) {
this.dialogVisibleImg = true
this.dialogSrc = src
this.dialogType = type ? type : 'img'
},
marketingContent(val) {
return val.attContent.marketingContent
},
checkedType(type) {
return wordType.indexOf(type) !== -1 ? type : 'img'
},
//展开表情
selectEmotion() {
this.emotionStatus = !this.emotionStatus
},
//选择表情
handleEmotion(i) {
this.emotionStatus = false
const list = emoji.flat(Infinity)
let index = list.indexOf(i) + 1
if (index < 10) {
index = '00' + index
} else if (index >= 10 && index < 100) {
index = '0' + index
}
this.$refs.textContent.addImg(
`https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png`
)
},
updateText(val) {
this.textInput(val)
},
previewFilter(togetherItem, attType) {
return this.previewList.filter(item => {
return togetherItem.includes(item.attType) || item.attType == attType
})
},
// 上传图片
handleImgChange(e) {
var reader = new FileReader()
var file = e.srcElement.files[0]
// 默认1MB
const limitSize = this.imageList.limitSize || 10
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
this.$message.error('上传图片大小不能超过' + limitSize + 'MB!')
return true
}
const limitNum = this.imageList.limitNum || 0
if (
limitNum &&
this.previewList.filter(item => item.attType == ATT_TYPE.IMAGE)
.length >= limitNum
) {
this.$message.error(`最多上传${limitNum}张图片`)
return
}
this.loading = true
reader.readAsDataURL(file)
this.previewList.push({
attType: this.ATT_TYPE.IMAGE,
attContent: ''
})
if (this.imageList.togetherItem) {
this.previewList = this.previewFilter(
this.imageList.togetherItem,
ATT_TYPE.IMAGE
)
}
reader.onload = e => {
var image = new Image()
image.src = e.target.result
image.onload = () => {
const { limitWidth, limitHeight } = this.imageList
if (
limitWidth &&
limitHeight &&
(image.width > limitWidth || image.height > limitHeight)
) {
this.$message.error(`图片长宽不超过${limitWidth}x${limitHeight}`)
this.previewList.pop()
return
}
const imgFile = e.target.result
const arrBase64 = imgFile.split(',')
const splitStr = file.name.split('.')
const fileUrl = splitStr[splitStr.length - 1] + '@' + arrBase64[1]
// const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
this.imageList.uploadApi({ file: fileUrl }).then(res => {
if (res) {
let len = this.previewList.length - 1
this.previewList[len].attContent = res
document.querySelector('.upload-img').value = ''
} else {
this.previewList.pop()
}
this.loading = false
})
}
}
},
// 上传视频
async handleVideoChange(e) {
var file
try {
file = await this.uploadFileVideo(e)
if (this.videoList.togetherItem) {
this.previewList = this.previewFilter(
this.videoList.togetherItem,
ATT_TYPE.VEDIO
)
}
var reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const arrBase64 = imgFile.split(',')
const splitStr = file.name.split('.')
const fileUrl = splitStr[splitStr.length - 1] + '@' + arrBase64[1]
// const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
this.videoList.uploadApi({ file: fileUrl }).then(res => {
if (res) {
this.previewList.push({
attType: this.ATT_TYPE.VEDIO,
attContent: res
})
}
})
}
} catch (err) {
console.log(err)
}
},
uploadFileVideo(e) {
const _this = this
return new Promise((resolve, reject) => {
let file = e.srcElement.files[0]
// 默认10MB
const limitSize = this.videoList.limitSize || 10
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
_this.$message.error('上传视频大小不能超过' + limitSize + 'MB!')
return reject()
}
const limitNum = this.videoList.limitNum || 0
if (
limitNum &&
this.previewList.filter(item => item.attType == ATT_TYPE.VEDIO)
.length >= limitNum
) {
this.$message.error(`最多上传${limitNum}条视频`)
return
}
let videoUrl = URL.createObjectURL(file)
let videoObj = document.createElement('video')
videoObj.src = videoUrl
videoObj.load()
videoObj.onloadedmetadata = function(evt) {
URL.revokeObjectURL(videoUrl)
const { limitWidth, limitHeight, limitTime } = _this.videoList
if (
limitWidth &&
limitHeight &&
(videoObj.videoWidth > limitWidth ||
videoObj.videoHeight > limitHeight)
) {
_this.$message.error(`上传视频不超过${limitWidth}x${limitHeight}`)
reject()
}
if (limitTime && videoObj.duration > limitTime) {
_this.$message.error(`上传视频不超过${limitTime}s`)
reject()
}
resolve(file)
}
})
},
handleFun(type) {
const name = type.type
if (name == 'nickname') {
this.$refs.textContent.addTag('@昵称')
} else if (name == 'code') {
this.$refs.textContent.addTag('#兑换码')
} else if (name == 'activity') {
this.$refs.activity.init()
} else if (name == 'message') {
this.$refs.message.init()
} else if (name == 'material') {
this.$refs.material.init()
} else if (name == 'link') {
this.$refs.textContent.addCardLink(this.linkList)
}
},
close(index) {
this.previewList.splice(index, 1)
},
textInput(val) {
val = val
.replace(/&nbsp;/g, '')
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
this.textNum = val.replace(/(\n|\s)/g, '').length
if (this.textNum > this.maxNum) {
this.textNum = this.maxNum
this.updateList(this.previewList, 1)
return
}
const hasText = this.previewList.some(
item => item.attType == this.ATT_TYPE.TEXT
)
if (hasText) {
this.$set(this.previewList, 0, {
attContent: val,
attType: this.ATT_TYPE.TEXT
})
} else {
this.previewList.unshift({
attContent: val,
attType: this.ATT_TYPE.TEXT
})
}
},
// selectActivity(val) {
// this.previewAddValue(val, 'ACTIVITY')
// },
// previewAddValue(val, type) {
// let idx = this.previewList.findIndex(
// item => item.attType == this.ATT_TYPE[type]
// )
// if (idx !== -1) {
// this.$set(this.previewList, idx, {
// attContent: val,
// attType: this.ATT_TYPE[type]
// })
// } else {
// this.previewList.push({
// attContent: val,
// attType: this.ATT_TYPE[type]
// })
// }
// },
// 素材
// handleMaterialConfirm(val) {
// const { materialContent, objectName } = val
// const imgSrc = materialContent.imgSrc
// const videoSrc = materialContent.videoSrc
// const pdfSrc = materialContent.pdfSrc
// let html = materialContent.html ? materialContent.html : ''
// if (pdfSrc && !this.materialList.pdfNo) {
// this.previewList.push({
// attContent: JSON.stringify({ fileName: objectName, url: pdfSrc }),
// attType: this.ATT_TYPE.FILE
// })
// return
// }
// if (
// (pdfSrc && this.materialList.pdfNo) ||
// (videoSrc && videoSrc.length && this.materialList.videoNo)
// ) {
// this.$message.error(pdfSrc ? '不支持此类型' : '不支持视频')
// return
// }
// if (imgSrc && imgSrc.length) {
// imgSrc.forEach(item => {
// this.previewList.push({
// attContent: item,
// attType: this.ATT_TYPE.IMAGE
// })
// })
// }
// if (videoSrc && videoSrc.length && !this.materialList.videoNo) {
// videoSrc.forEach(item => {
// this.previewList.push({
// attContent: item,
// attType: this.ATT_TYPE.VEDIO
// })
// })
// }
// const idx = this.previewList.findIndex(
// item => item.attType == this.ATT_TYPE.TEXT
// )
// if (idx !== -1) {
// if (!this.previewList[idx].attContent) {
// html = html.replace('\n', '').replace(/<br\/>/g, '')
// }
// html = html
// .replace(/&amp;/g, '&')
// .replace(/&lt;/g, '<')
// .replace(/&gt;/g, '>')
// let textLen = this.previewList[idx].attContent + html
// if (textLen.replace(/(\n|\s)/g, '').length > this.maxNum) {
// textLen = this.previewList[idx].attContent
// } else {
// this.textNum = textLen.replace(/(\n|\s)/g, '').length
// }
// this.$set(this.previewList, 0, {
// attContent: textLen,
// attType: this.ATT_TYPE.TEXT
// })
// } else {
// html = html
// .replace('\n', '')
// .replace(/<br\/>/g, '')
// .replace(/&amp;/g, '&')
// .replace(/&lt;/g, '<')
// .replace(/&gt;/g, '>')
// let textLen = html
// if (textLen.replace(/(\n|\s)/g, '').length > this.maxNum) {
// textLen = ''
// } else {
// this.textNum = textLen.replace(/(\n|\s)/g, '').length
// }
// this.previewList.unshift({
// attContent: textLen,
// attType: this.ATT_TYPE.TEXT
// })
// }
// this.updateList(this.previewList, 1)
// },
// selectMessage(val) {
// const content = val.content
// this.updateText(content)
// this.textValue = content
// },
changeInput: utils.debounce(function() {
var allNodes = document.getElementById('editor').childNodes
var str = ''
allNodes.forEach(item => {
if (item.className == 'nickname') {
str += item.innerText
} else if (item.data) {
str += item.data
}
})
this.textInput(str)
}, 300)
// updateList(val, status) {
// this.previewList = utils.deepClone(val)
// const obj = val.find(item => item.attType == this.ATT_TYPE.TEXT)
// if (obj) {
// let attContent
// if (status) {
// attContent = obj.attContent.replace(
// /(@昵称|#兑换码)/g,
// '<wise id="1" contenteditable="false">$1</wise>'
// )
// } else {
// this.textNum = obj.attContent
// .replace(/(\n|\s)/g, '')
// .replace(/\[(@昵称|#兑换码)\]/g, '$1')
// .replace(/\[[\u4E00-\u9FA56]{1,4}]/g, '').length
// attContent = obj.attContent.replace(
// /\[(@昵称|#兑换码)\]/g,
// '<wise id="1" contenteditable="false">$1</wise>'
// )
// }
// let htm = attContent.replace(/\[[\u4E00-\u9FA56]{1,4}]/gi, function(
// res
// ) {
// let word = res.replace(/\[|\]/gi, '')
// const list = emoji.flat(Infinity)
// let index = parseInt(list.indexOf(word)) + 1
// if (index < 10) {
// index = '00' + index
// } else if (index >= 10 && index < 100) {
// index = '0' + index
// }
// return `<img src="https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png">`
// })
// if (
// htm.substr(-1, 1) == '>' &&
// navigator.userAgent.indexOf('Firefox') > 0
// ) {
// htm += '&nbsp;'
// }
// setTimeout(() => {
// document.querySelector('.w-textarea_input').innerHTML = htm
// }, 100)
// } else {
// this.textValue = ''
// }
// }
}
}
</script>
<style lang="scss" scoped>
.image-dialog {
/deep/ {
.el-dialog__header {
border-bottom: 0px;
padding: 0px;
}
}
}
.video-panel {
margin-right: 10px;
width: 56px;
height: 56px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
.video-pane-close {
position: absolute;
right: 0px;
top: 0px;
width: 14px;
height: 14px;
cursor: pointer;
}
video {
position: absolute;
object-fit: fill;
}
.el-icon-video-play {
z-index: 10;
font-size: 20px;
color: #fff;
cursor: pointer;
}
}
.welcome-img-box {
width: 56px;
height: 56px;
border-radius: 2px;
background-size: 100% 100%;
position: relative;
margin-right: 10px;
.welcome-img-checked {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s;
&:hover {
opacity: 1;
}
i {
color: rgba(255, 255, 255, 0.8);
font-size: 12px;
&:first-child {
margin-right: 5px;
}
}
}
}
.welcome-activity-panel {
display: flex;
margin-right: 10px;
.welcome-activity-box {
cursor: pointer;
position: relative;
min-width: 180px;
background: #fafbfe;
border-radius: 2px;
border: 1px solid #e8e8ea;
padding: 8px;
box-sizing: border-box;
display: flex;
&:hover {
.delete-solid {
opacity: 1;
}
}
.welcome-activity-icon {
width: 36px;
height: 36px;
margin-right: 8px;
position: relative;
background-size: 100% 100%;
img {
width: 100%;
height: 100%;
}
video {
object-fit: fill;
}
.el-icon-video-play {
position: absolute;
top: 7px;
left: 7px;
font-size: 22px;
color: rgba(255, 255, 255, 0.8);
}
.img-filter-box {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
color: rgba(255, 255, 255, 0.8);
display: flex;
font-size: 13px;
align-items: center;
justify-content: center;
}
}
.delete-solid {
transition: all 0.5s;
opacity: 0;
position: absolute;
top: 0px;
right: 0px;
width: 14px;
height: 14px;
background: rgba(0, 0, 0, 0.5);
display: flex;
font-size: 12px;
align-items: center;
justify-content: center;
}
.el-icon-delete-solid {
color: rgba(255, 255, 255, 0.5);
}
.model-item-title {
font-size: 14px;
font-weight: 600;
color: #333333;
line-height: 20px;
}
.model-item-content {
font-size: 12px;
font-weight: 400;
color: #999999;
line-height: 17px;
span {
color: #5850ff;
}
}
}
}
.emotion-panel {
position: relative;
height: 0px;
&-box {
position: absolute;
bottom: 48px;
left: 2px;
}
}
.content {
display: inline-block;
vertical-align: text-top;
// width: calc(100% - 103px);
width: 100%;
// margin-left: 12px;
.welcome-file {
display: flex;
align-items: center;
color: #999;
line-height: 20px;
padding: 10px;
overflow-x: auto;
border-left: 1px solid #dcdfe6;
border-right: 1px solid #dcdfe6;
border-bottom: 1px solid #e5e5e5;
i {
cursor: pointer;
}
.el-icon-loading {
font-size: 24px;
}
&:last-child {
margin-bottom: 0;
}
}
.btn-group-panel {
display: flex;
justify-content: space-between;
padding: 10px 0 10px 20px;
border: 1px solid #e5e5e5;
border-top: 0;
background: #fafbfe;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
.btn-group {
.add-btn {
display: inline-flex;
position: relative;
align-items: center;
padding-right: 25px;
font-size: 16px;
color: #666;
cursor: pointer;
span {
font-size: 14px;
margin-left: 5px;
cursor: pointer;
}
input {
position: absolute;
width: 100%;
cursor: pointer;
font-size: 0;
height: 40px;
}
img {
width: 16px;
height: 16px;
cursor: pointer;
}
.el-link {
position: absolute;
width: 100%;
}
}
}
.text-num {
padding-right: 10px;
}
}
.date-picker {
margin-top: 10px;
font-size: 14px;
color: #999;
}
}
.required {
display: inline-block;
line-height: 40px;
text-align: right;
width: 90px;
}
.required::before {
content: '*';
color: #f56c6c;
margin-right: 4 px;
}
.form-tips {
font-size: 12px;
color: #999;
}
.form-upload {
position: absolute;
top: 0;
width: 140px;
// width: 100%;
height: 100%;
cursor: pointer;
z-index: 1;
}
/deep/ {
.el-textarea__inner {
background-color: #f7f7f7;
border-radius: 0;
}
.el-textarea__inner:focus {
border-color: #dcdfe6;
}
.el-textarea .el-input__count {
background-color: #f7f7f7;
}
}
.upload {
position: relative;
}
.upload-bg {
position: relative;
width: 140px;
height: 140px;
background-color: #f7f7f7;
color: #999;
border: 1px dashed #dcdfe6;
i {
position: absolute;
top: 40px;
left: 50%;
transform: translateX(-50%);
font-size: 30px;
}
.upload-text {
position: absolute;
bottom: 40px;
left: 50%;
transform: translateX(-50%);
font-size: 12px;
}
}
.tips-text {
display: flex;
align-items: center;
justify-self: center;
color: #000;
font-size: 14px;
padding: 0 16px;
margin-top: 10px;
background-color: rgba(230, 233, 255, 0.49);
border: 1px solid rgba(88, 80, 255, 0.49);
border-radius: 4px;
.tips-icon {
width: 14px;
height: 14px;
margin-right: 8px;
}
}
// 编辑器
.editor-container {
border: 1px solid #dcdfe6;
min-height: 165px;
/deep/ {
.w-e-text {
background-color: #f7f7f7;
}
}
}
.text-editor {
outline: 0;
width: 100%;
min-height: 200px;
max-height: 200px;
border: 1px solid #dcdfe6;
box-sizing: border-box;
padding: 5px;
line-height: 20px;
font-size: 12px;
word-wrap: break-word;
overflow-x: hidden;
overflow-y: auto;
_overflow-y: visible;
}
/deep/.nickname {
display: inline;
// width: 64px;
// height: 20px;
border-radius: 2px;
background-color: #fff;
font-size: 14px;
color: #5850ff;
line-height: 20px;
padding: 2px;
margin: 0 5px;
i {
font-size: 10px;
}
}
</style>
<template>
<div class="w-textarea" ref="wTextarea" v-bind="$attr">
<div contenteditable="true" class="w-textarea_input" ref="wTextareaContent" :id="contentId" @keydown="textareaKeydown($event)" @click="inputClick($event)" @focus="onFocus" @blur="onBlur" @keydown.delete="handleDelete($event)" @input="handleInput($event.target)"></div>
</div>
</template>
<script>
import emoji from '../../utils/emo'
export default {
name: 'wTextarea',
data() {
return {
// 记录currentText以计算长度
currentText: this.value,
// 为input区域生成随机id,当在页面上有多个组件时,用于监听光标的变化
contentId: `content${this.getGuid()}`,
// 输入的时候锁定,禁止更新innerHTML
isLocked: false,
isInsert: false,
// 记录当前选中tag的ID
currentTagId: null,
// 当前光标位置
savedRange: {}
}
},
props: {
value: {
type: String,
default: ''
},
tag: {
// 自定义模版标签的标签名
type: String,
// 默认使用wise作为标签名,并添加了默认样式
// 当使用其他标签名的时候,需要另写标签样式
default: 'wise'
},
tools: {
// 自定义扩展功能:超链接'link',模版标签'tag'
type: Array,
default() {
return [
{ type: 'link', text: '添加超链接' },
{ type: 'tag', text: '添加模版标签' }
]
}
},
maxlength: {
// 最大输入长度
type: [String, Number],
default: ''
}
},
computed: {
count() {
// 字符长度记数
let num = this.maxlength - this.currentText.length
let text =
num < 0 ? `已超出${Math.abs(num)}个字符` : `还可以输入${num}个字符`
return { num, text }
}
},
mounted() {
// 初始化数据
this.currentText &&
(this.$refs.wTextareaContent.innerHTML = this.currentText)
// 创建模版标签的style
this.createStyle()
// 每次光标变化的时候,保存 range
document.addEventListener('selectionchange', this.selectHandler)
},
beforeDestroy() {
// 卸载事件
document.removeEventListener('selectionchange', this.selectHandler)
},
methods: {
updateData(text) {
this.$emit('input', text)
},
createStyle() {
// 为自定义的模版标签添加样式,使之不可编辑
let style = document.createElement('style')
style.innerHTML = `.w-textarea ${this.tag} {
cursor: default;
-webkit-user-modify: read-only !important;
}`
this.$refs.wTextarea.appendChild(style)
},
closeModal() {
this.form.text = ''
this.showModal = false
},
openTagDialog(type) {
// if (addLink)
// 将事件抛给父组件处理
// 处理后需要调用 addTag() 或者 addLink() 将内容传回来
this.$emit('add', type)
},
textareaKeydown(event) {
if (event.keyCode == 13) {
this.insertHtml('<br>')
let nn = document.createElement('br')
document.querySelector('.w-textarea_input').appendChild(nn)
return false
}
},
/*换行*/
insertHtml(html) {
var sel, range
if (window.getSelection) {
// IE9 或 非IE浏览器
sel = window.getSelection()
if (sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0)
range.deleteContents()
// Range.createContextualFragment() would be useful here but is
// non-standard and not supported in all browsers (IE9, for one)
var el = document.createElement('div')
el.innerHTML = html
var frag = document.createDocumentFragment(),
node,
lastNode
while ((node = el.firstChild)) {
lastNode = frag.appendChild(node)
}
range.insertNode(frag)
// Preserve the selection
if (lastNode) {
range = range.cloneRange()
range.setStartAfter(lastNode)
range.collapse(true)
sel.removeAllRanges()
sel.addRange(range)
}
}
} else if (document.selection && document.selection.type != 'Control') {
// IE < 9
document.selection.createRange().pasteHTML(html)
}
const htm = document.querySelector('.w-textarea_input').innerHTML
this.subText(htm)
},
addTag(text) {
// 创建模版标签
let node = document.createElement(this.tag)
if (navigator.userAgent.indexOf('Firefox') > 0) {
node.setAttribute('contenteditable', 'false')
}
node.innerText = text
// 添加id便于删除
node.id = this.getGuid()
this.insertNode(node)
},
addNode() {
let target = this.$refs.wTextareaContent
this.updateData(target.innerHTML)
},
addLink(text, url) {
// 创建a标签
let node = document.createElement('a')
node.innerText = text
node.href = url
node.target = 'blank'
this.insertNode(node)
},
addImg(url) {
// 创建a标签
let node = document.createElement('img')
node.src = url
// node.setAttribute('ondragstart', 'return false;')
this.insertNode(node)
},
onFocus() {
this.isLocked = true
this.isInsert = true
},
onBlur() {
this.isLocked = false
},
insertNode(node) {
// 在内容中插入标签
// 删掉选中的内容(如有)
if (this.savedRange.startContainer) {
this.insertNodeFirst(node)
} else {
document.querySelector('.w-textarea_input').focus()
setTimeout(() => {
this.insertNodeFirst(node)
document.querySelector('.w-textarea_input').blur()
}, 100)
}
},
subText(htm) {
const list = emoji.flat(Infinity)
const cutImg = htm
.replace(/<span>([\s\S]*?)<\/span>/g, '$1')
.replace(
/<img src="https:\/\/img01.glsx.com.cn\/weapp\/resource\/saas\/scrm\/emoji\//g,
''
)
.replace(/<wise.+?>(.+?)(?:<\/wise>)/g, '$1')
.replace(/<br>/g, '\n')
const replaceImg = cutImg.replace(/(\d){3}.png">/g, function(str) {
let s = list[parseInt(str.split('.')[0]) - 1]
return `[${s}]`
})
let Textnode = document.createElement('div')
Textnode.innerHTML = replaceImg
this.currentText = replaceImg
this.$emit('updateText', this.currentText)
},
insertNodeFirst(node) {
this.savedRange.deleteContents()
// 插入链接
if (this.isInsert) {
this.savedRange.insertNode(node)
this.savedRange.insertNode(document.createElement('span'))
} else {
document.querySelector('.w-textarea_input').appendChild(node)
this.savedRange.insertNode(document.createElement('span'))
}
this.isInsert = false
// 更新双向绑定数据
let target = this.$refs.wTextareaContent
this.updateData(target.innerHTML)
let htm = target.innerHTML
this.subText(htm)
},
placeCaretAtEnd(el) {
//传入光标要去的jq节点对象
el.focus()
if (
typeof window.getSelection != 'undefined' &&
typeof document.createRange != 'undefined'
) {
var range = document.createRange()
range.selectNodeContents(el)
range.collapse(false)
var sel = window.getSelection()
sel.removeAllRanges()
sel.addRange(range)
} else if (typeof document.body.createTextRange != 'undefined') {
var textRange = document.body.createTextRange()
textRange.moveToElementText(el)
textRange.collapse(false)
textRange.select()
}
},
handleInput(target) {
// 即时更新数据
this.updateData(target.innerHTML)
let htm = target.innerHTML
this.subText(htm)
},
handleDelete(e) {
// 监听“删除”事件
if (this.currentTagId) {
// 若已选中模版标签,直接删除dom节点
let t = document.getElementById(this.currentTagId)
this.$refs.wTextareaContent.removeChild(t)
this.currentTagId = null
// 阻止浏览器默认的删除事件,并手动更新数据
e.preventDefault()
this.handleInput(e.target)
}
},
inputClick(e) {
// 监听点击事件
this.isLocked = true
const TAG_NAME = e.target.nodeName
if (TAG_NAME === this.tag.toUpperCase()) {
// 点击模版标签时,记录id
this.currentTagId = e.target.id
e.target.className = 'active'
} else if (this.currentTagId) {
// 清空active样式
let target = document.getElementById(this.currentTagId)
target.className = ''
this.currentTagId = null
} else {
this.currentTagId = null
}
},
getGuid() {
// 生成随机ID
return 1
// return `r${new Date().getTime()}d${Math.ceil(Math.random() * 1000)}`
},
selectHandler() {
// 监听选定文本的变动
let sel = window.getSelection()
let range = sel.rangeCount > 0 ? sel.getRangeAt(0) : null
if (
range &&
range.commonAncestorContainer.ownerDocument.activeElement.id ===
this.contentId
) {
this.savedRange = range
}
}
},
watch: {
value(val) {
// 非锁定状态下,实时更新innerHTML
if (!this.isLocked) {
this.$refs.wTextareaContent.innerHTML = val
}
}
}
}
</script>
<style lang="scss">
.w-textarea {
wise {
user-select: none;
border-radius: 2px;
background-color: #fff;
font-size: 14px;
color: #5850ff;
line-height: 20px;
padding: 0px;
margin: 0 2px;
color: #26a2ff;
// padding: 0 1px;
white-space: nowrap;
cursor: default;
-webkit-user-modify: read-only !important;
}
img {
width: 18px;
height: 18px;
// -webkit-user-select: none;
cursor: default;
pointer-events: none;
vertical-align: middle;
}
.active {
background: #dcdfe6;
}
}
</style>
<style lang="scss" scoped>
$borderColor: #e5e5e5;
$bgColor: #f5f7fa;
$textColor: #666;
.w-textarea {
width: 100%;
box-sizing: border-box;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border: 1px solid $borderColor;
position: relative;
overflow-y: auto;
&_input {
width: 100%;
height: 200px;
min-height: 100px;
box-sizing: border-box;
padding: 10px;
line-height: 1.5;
word-break: break-word;
// 允许编辑,禁止富文本
-webkit-user-modify: read-write-plaintext-only !important;
&:focus {
outline: none;
}
}
&_tools {
padding: 0 10px;
height: 40px;
line-height: 40px;
border-top: 1px solid $borderColor;
background-color: $bgColor;
color: $textColor;
font-size: 12px;
&__item {
display: inline-block;
line-height: 1;
padding: 5px 8px;
margin-right: 8px;
color: $textColor;
cursor: pointer;
border: 1px solid $borderColor;
border-radius: 4px;
background: #fff;
transition: all 0.3s;
&:hover {
background: $bgColor;
opacity: 0.7;
}
&:focus {
outline: none;
}
}
&__text {
display: inline-block;
line-height: 40px;
padding: 0 8px;
// float: right;
color: $textColor;
cursor: default;
transition: all 0.3s;
&:hover {
opacity: 1;
}
&.__danger {
color: red;
}
}
}
}
</style>
import Vue from 'vue' import Vue from 'vue'
import GLEditor from './GLEditor/index.vue'
// 注意 有些组件使用异步加载会有影响 // 注意 有些组件使用异步加载会有影响
Vue.component('d2-table', () => import('./d2-table/index.vue')) Vue.component('d2-table', () => import('./d2-table/index.vue'))
Vue.component('GLEditor', GLEditor)
const emoji = [
['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴'],
['睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过'],
['酷', '囧', '抓狂', '吐', '微笑', '愉快', '白眼', '傲慢'],
['饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂'],
['疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见'],
['擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠'],
['鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀'],
['西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰'],
['凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀'],
['足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强'],
['弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你'],
['NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈'],
['磕头', '回头', '跳绳', '投降', '挥手', '激动', '街舞', '左太极'],
['右太极', '嘿哈', '捂脸', '奸笑', '机智', '皱眉', '耶', '社会社会'],
['让我看看', '666', '红包', '蜡烛', '烟花', '福', '庆祝', '爆竹']
]
export default emoji
...@@ -2,141 +2,495 @@ ...@@ -2,141 +2,495 @@
<div> <div>
<div>基础信息</div> <div>基础信息</div>
<!-- 基础信息表单 --> <!-- 基础信息表单 -->
<el-form :model="basicForm" :rules="basicRules" ref="basicForm" label-width="154px"> <el-form
<el-form-item label="业务场景:" prop="scene"> :model="basicForm"
<el-select v-model="basicForm.scene" placeholder="请选择活动区域"> :rules="basicRules"
<el-option label="区域一" value="shanghai"></el-option> ref="basicForm"
<el-option label="区域二" value="beijing"></el-option> label-width="154px"
</el-select> >
</el-form-item> <el-form-item label="业务场景:" prop="scene">
<el-form-item label="商户:" prop="withdrawal"> <el-select v-model="basicForm.scene" placeholder="请选择业务场景">
<el-select v-model="basicForm.withdrawal" placeholder="请选择活动区域"> <el-option label="1.3存量用户众筹" value="0"></el-option>
<el-option label="区域一" value="shanghai"></el-option> </el-select>
<el-option label="区域二" value="beijing"></el-option> </el-form-item>
</el-select> <el-form-item label="商户:" prop="merchant">
</el-form-item> <el-select
<el-form-item label="活动/产品:" prop="activity"> v-model="basicForm.merchant"
<el-select v-model="basicForm.activity" placeholder="请选择活动区域"> filterable
<el-option label="区域一" value="shanghai"></el-option> placeholder="请选择商户"
<el-option label="区域二" value="beijing"></el-option> >
</el-select> <el-option label="区域一" value="shanghai"></el-option>
</el-form-item> <el-option label="区域二" value="beijing"></el-option>
<el-form-item label="任务指定人群:" prop="crowd"> </el-select>
<el-select v-model="basicForm.crowd" placeholder="请选择活动区域"> </el-form-item>
<el-option label="区域一" value="shanghai"></el-option> <el-form-item label="活动/产品:" prop="activity" @focus="selectActivity">
<el-option label="区域二" value="beijing"></el-option> <el-select v-model="basicForm.activity" placeholder="请选择活动/产品">
</el-select> <el-option label="区域一" value="shanghai"></el-option>
</el-form-item> <el-option label="区域二" value="beijing"></el-option>
<el-form-item label="发放渠道:" prop="channel"> </el-select>
<el-radio-group v-model="basicForm.channel"> </el-form-item>
<el-radio label="广联"></el-radio> <el-form-item label="任务指定人群:" prop="crowd">
<el-radio label="门店"></el-radio> <el-select
<el-radio label="服务商"></el-radio> v-model="basicForm.crowd"
</el-radio-group> multiple
</el-form-item> placeholder="请选择任务指定人群"
<el-form-item label="备注:"> >
<el-input type="textarea" v-model="basicForm.tips"></el-input> <el-option label="1.0新车权益销售" value="1"></el-option>
</el-form-item> <el-option label="1.1次新车精品升级" value="2"></el-option>
<el-option label="1.2次新车线上转化" value="3"></el-option>
<el-option label="1.3存量用户众筹" value="4"></el-option>
</el-select>
</el-form-item>
<el-form-item label="发放渠道:" prop="channel">
<el-radio-group v-model="basicForm.channel">
<el-radio label="0">广联</el-radio>
<el-radio label="1">门店</el-radio>
<el-radio label="2">服务商</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注:">
<el-input type="textarea" v-model="basicForm.tips"></el-input>
</el-form-item>
</el-form> </el-form>
<div>任务计划</div> <div>任务计划</div>
<!-- 任务计划tab栏 --> <!-- 任务计划tab栏 -->
<el-tabs v-model="activeName" type="card" @tab-click="handleClick"> <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
<el-tab-pane v-for="(item, index) in taskList" :key="index" :label="`${item.date+'(第'+ (index+1) + '天)'}`" :name="index+''"> <el-tab-pane
<el-button type="primary" @click="addTaskType">添加</el-button> v-for="(item, index) in taskList"
<div> :key="index"
<div v-for="(itm, index) in item.taskData" :key="index"> :label="`${item.date + '(第' + (index + 1) + '天)'}`"
:name="index + ''"
>
<el-button type="primary" size="small" @click="addTaskType(item, index)"
>添加</el-button
>
<div>
<el-form
ref="taskForm"
:model="item"
:rules="taskFormRules"
label-width="154px"
>
<div v-for="(itm, index1) in item.taskData" :key="index1">
<div>{{ itm }}</div>
<el-form-item
label="任务类型:"
:prop="'taskData.' + index1 + '.taskType'"
:rules="taskFormRules.taskType"
>
<el-select
v-model="itm.taskType"
placeholder="请选择任务类型:"
@change="selectTaskType(item, index, itm, index1)"
>
<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-option label="成单指标" value="5"></el-option>
</el-select>
</el-form-item>
<el-form-item
label="任务名称:"
:prop="'taskData.' + index1 + '.taskName'"
:rules="taskFormRules.taskName"
>
<el-input
v-model="itm.taskName"
maxlength="20"
show-word-limit
></el-input>
</el-form-item>
<el-form-item
label="任务说明:"
:prop="'taskData.' + index1 + '.taskDetail'"
:rules="taskFormRules.taskDetail"
>
<el-input
type="textarea"
v-model="itm.taskDetail"
maxlength="50"
show-word-limit
></el-input>
</el-form-item>
<el-form-item
:prop="'taskData.' + index1 + '.shareMaterial'"
:rules="taskFormRules.attachmentList"
v-if="itm.taskType == 2"
>
<label slot="label" class="required">分享素材:</label>
<GLEditor
ref="welcome"
:form="'customer'"
style="line-height: 12px"
:btnList="btnList"
></GLEditor>
<div v-show="attachmentShow" class="el-form-item__error">
{{ attachmentText }}
</div> </div>
</el-form-item>
<el-form-item
v-if="itm.taskType && itm.taskType != 1"
label="奖励模式:"
:prop="'taskData.' + index1 + '.awardModel'"
:rules="taskFormRules.awardModel"
>
<el-radio-group v-model="itm.awardModel">
<el-radio label="0">累计奖励</el-radio>
<el-radio label="1">排名奖励</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="itm.taskType == 2 || itm.taskType == 3"
label="奖励次数:"
:prop="'taskData.' + index1 + '.awardTimes'"
:rules="taskFormRules.awardTimes"
>
<el-radio-group v-model="itm.awardTimes">
<el-radio label="0">单次</el-radio>
<el-radio label="1">重复累计</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="itm.taskType == 4"
label="触发排名:"
:prop="'taskData.' + index1 + '.triggerRank'"
:rules="taskFormRules.triggerRank"
>
<el-radio-group v-model="itm.triggerRank">
<el-radio label="0">第一名</el-radio>
<el-radio label="1">第二名</el-radio>
<el-radio label="2">第三名</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
v-if="itm.taskType == 3"
label="重复次数:"
:prop="'taskData.' + index1 + '.repeteTimes'"
:rules="taskFormRules.repeteTimes"
>
<el-input
v-model="itm.repeteTimes"
oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"
></el-input>
</el-form-item>
<el-form-item
v-if="
itm.taskType == 2 || itm.taskType == 3 || itm.taskType == 5
"
label="触发值:"
:prop="'taskData.' + index1 + '.triggerNum'"
:rules="taskFormRules.triggerNum"
>
<el-input
v-model="itm.triggerNum"
oninput="value=value.replace(/^0+(\d)|[^\d]+/g,'')"
></el-input>
</el-form-item>
<el-form-item
label="奖励积分:"
:prop="'taskData.' + index1 + '.awardIntegral'"
:rules="taskFormRules.awardIntegral"
>
<el-input
v-model="itm.awardIntegral"
oninput="value=value.replace(/[^0-9.]/g,'')"
></el-input>
</el-form-item>
</div> </div>
</el-tab-pane> </el-form>
</el-tabs> </div>
</el-tab-pane>
</el-tabs>
<el-button type="primary" @click="submitTask"> tijiao</el-button>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
// 奖励积分校验规则
const validateAwardIntegral = (rule, value, callback) => {
if (!value) {
callback(new Error('奖励积分不能为空'))
} else if (value.indexOf('.') != -1 && value.split('.').length > 2) {
callback(new Error('仅支持输入大于或等于0的数字,可支持小数点后两位')) // 防止输入多个小数点
} else if (value.indexOf('.') != -1 && value.split('.')[1].length > 2) {
callback(new Error('仅支持输入小数点后两位')) // 小数点后两位
} else {
callback()
}
}
return { return {
// 基础信息表单 // 基础信息表单
basicForm: { basicForm: {
scene: '', scene: '0',
withdrawal: '', merchant: '',
activity: '', activity: '',
crowd: '', crowd: ['4'],
channel: '', channel: '0',
tips: '' tips: '',
}, },
// tab值(默认第一个)
activeName: '0', activeName: '0',
// 分享素材
attachmentShow: false,
attachmentText: '',
btnList: [
{
name: '表情',
funcName: '',
type: 'expression',
limitSize: 10,
},
{
name: '图片',
funcName: '',
type: 'img',
// uploadApi: this.$apis.common.pictureUpload
},
{
name: '视频',
funcName: '',
type: 'video',
limitSize: 10, // 限制视频大小
// togetherItem: [ATT_TYPE.TEXT], // 只允许文本和图片
limitNum: 1, // 限制视频数量
limitWidth: 1280, // 限制视频宽度
limitHeight: 720, // 限制视频高度
limitTime: 30, // 限制视频时长
// uploadApi: this.$apis.common.pictureUpload
},
{
name: '活动专属链接',
funcName: '',
type: 'link',
// uploadApi: this.$apis.common.pictureUpload
},
],
// 任务计划 // 任务计划
taskList: [], taskList: [],
// 公共任务类型 // 公共任务类型
basicObj: { basicObj: {
taskType: '', taskType: '',
taskName: '', taskName: '',
taskDetail: '' taskDetail: '',
}, awardIntegral: '',
// 注册认证任务类型
registerObj: {
integral: ''
}, },
// 分享指标任务类型 // 分享指标任务类型
shareObj: {}, shareObj: {
shareMaterial: '',
awardModel: '0',
awardTimes: '0',
triggerNum: '',
},
// 浏览指标任务类型
browseObj: {
awardModel: '0',
awardTimes: '0',
repeteTimes: '',
triggerNum: '',
},
// 访客指标任务类型
visitorObj: {
awardModel: '0',
triggerRank: '0',
},
// 成单指标任务类型
orderObj: {
awardModel: '0',
triggerNum: '',
},
// 任务计划表
taskPlanList: {},
// 基础信息表单验证 // 基础信息表单验证
basicRules: { basicRules: {
scene: [ scene: [
{ required: true, message: '请选择业务场景', trigger: 'change' } { required: true, message: '请选择业务场景', trigger: 'change' },
], ],
withdrawal: [ withdrawal: [
{ required: true, message: '请选择活动商户', trigger: 'change' } { required: true, message: '请选择活动商户', trigger: 'change' },
], ],
activity: [ activity: [
{ required: true, message: '请选择活动/产品', trigger: 'change' } { required: true, message: '请选择活动/产品', trigger: 'change' },
], ],
crowd: [ crowd: [
{ required: true, message: '请选择任务指定人群', trigger: 'change' } { required: true, message: '请选择任务指定人群', trigger: 'change' },
], ],
channel: [ channel: [
{ required: true, message: '请选择发放渠道', trigger: 'change' } { required: true, message: '请选择发放渠道', trigger: 'change' },
] ],
} },
// 任务计划表单验证
taskFormRules: {
taskType: [
{ required: true, message: '请选择任务类型', trigger: 'change' },
],
taskName: [
{ required: true, message: '请输入任务名称', trigger: 'blur' },
],
taskDetail: [
{ required: true, message: '请输入任务说明', trigger: 'blur' },
],
awardModel: [
{ required: true, message: '请选择奖励模式', trigger: 'change' },
],
awardTimes: [
{ required: true, message: '请选择奖励次数', trigger: 'change' },
],
triggerRank: [
{ required: true, message: '请选择触发排名', trigger: 'change' },
],
repeteTimes: [
{ required: true, message: '请输入重复次数', trigger: 'blur' },
],
triggerNum: [
{ required: true, message: '请输入触发值', trigger: 'blur' },
],
awardIntegral: [
{ required: true, trigger: 'blur', validator: validateAwardIntegral },
],
attachmentList: [
{ required: true, message: '请输入入群欢迎语' },
// { validator: validatorAttachment, trigger: 'change' }
],
},
} }
}, },
mounted() { mounted() {
console.log(this.setHouseRatesColumn('2022-08-20', '2022-08-25')) console.log(this.setHouseRatesColumn('2022-08-20', '2022-08-25'))
}, },
methods: { methods: {
// 点击选择活动/任务
selectActivity() {
if (!this.basicForm.scene) {
this.$message({
message: '请先选择业务场景',
type: 'warning',
})
}
if (!this.basicForm.merchant) {
this.$message({
message: '请先选择商户',
type: 'warning',
})
}
},
// 任务tab切换 // 任务tab切换
handleClick() {}, handleClick() {},
// 遍历日期 // 遍历日期
setHouseRatesColumn(startTime, endTime, week) { setHouseRatesColumn(startTime, endTime, week) {
// 获取时间段内的所有日期/指定星期几的日期 // 获取时间段内的所有日期/指定星期几的日期
week = week == 7 ? 0 : week week = week === 7 ? 0 : week
// let dateList = [] // let dateList = []
startTime = new Date(startTime) startTime = new Date(startTime)
endTime = new Date(endTime) endTime = new Date(endTime)
while (endTime.getTime() - startTime.getTime() >= 0) { while (endTime.getTime() - startTime.getTime() >= 0) {
// let year = startTime.getFullYear() // let year = startTime.getFullYear()
let month = const month =
startTime.getMonth() + 1 < 10 startTime.getMonth() + 1 < 10
? '0' + (startTime.getMonth() + 1) ? '0' + (startTime.getMonth() + 1)
: startTime.getMonth() + 1 : startTime.getMonth() + 1
let day = const day =
startTime.getDate().toString().length == 1 startTime.getDate().toString().length == 1
? '0' + startTime.getDate() ? '0' + startTime.getDate()
: startTime.getDate() : startTime.getDate()
if (isNaN(week) || startTime.getDay() == week) { if (isNaN(week) || startTime.getDay() == week) {
this.taskList.push({ this.taskList.push({
date: `${month}-${day}`, date: `${month}-${day}`,
taskData: [{ ...this.basicObj }] taskData: [],
}) })
} }
startTime.setDate(startTime.getDate() + 1) startTime.setDate(startTime.getDate() + 1)
} }
return this.taskList return this.taskList
} },
} // 添加任务
addTaskType(item, index) {
console.log(this.taskList)
this.taskList[index].taskData.push({
...this.basicObj,
})
console.log(this.taskList)
},
// 任务选择类型切换
selectTaskType(dateTask, dateTaskIndex, task, taskIndex) {
// dateTask -- 具体哪一天的任务对象
// dateTaskIndex -- 具体哪一天的任务对象索引
// task -- 具体哪个任务
// taskIndex -- 具体任务索引
console.log(dateTask, '++++')
// 如果当前选择的是注册认证类型,遍历当天配置的任务类型,判断是否已经选择过了注册认证任务类型,如果是,则弹出错误(注册任务类型一天只允许添加一个)
if (task.taskType == 1) {
var typeIndex = 0
dateTask.taskData.map((taskInfo) => {
if (taskInfo.taskType == 1) {
typeIndex = typeIndex + 1
console.log(typeIndex, 'typeIndex')
}
})
}
if (typeIndex > 1) {
this.$alert('每个时间标签下最多只能有1个该类型任务', '警告', {
confirmButtonText: '知道了',
callback: (action) => {
this.taskList[dateTaskIndex].taskData[taskIndex].taskType = ''
},
})
return
}
console.log(task.taskType)
// 判断任务类型,将任务类型参数push进taskList
var taskItem
switch (task.taskType) {
case '1':
taskItem = { ...this.basicObj }
break
case '2':
taskItem = { ...this.basicObj, ...this.shareObj }
break
case '3':
taskItem = { ...this.basicObj, ...this.browseObj }
break
case '4':
taskItem = { ...this.basicObj, ...this.visitorObj }
break
case '5':
taskItem = { ...this.basicObj, ...this.orderObj }
break
default:
taskItem = { ...this.basicObj }
}
taskItem.taskType = task.taskType
console.log(taskItem, 'taskItem')
this.$set(this.taskList[dateTaskIndex].taskData, taskIndex, taskItem)
console.log(this.taskList)
},
// 提交任务
submitTask() {
console.log(this.taskList)
this.taskList.every((item, index) => {
console.log(index, 'index')
var validFlag = 0
this.$refs['taskForm'][index].validate((valid) => {
if (!valid) validFlag = validFlag + 1
})
console.log(validFlag, 'validFlag')
// 检测到未填写跳转到未填写页面
if (validFlag > 0) {
this.$alert('第' + (index + 1) + '天填写未完成', '警告', {
confirmButtonText: '知道了',
callback: (action) => {
this.activeName = index + ''
},
})
return false
}
return true
})
},
},
} }
</script> </script>
<style> <style></style>
</style>
<template> <template>
<div class="task-contentbox"> <div class="task-contentbox">
<div> <div>
<el-form :inline="true" :model="searchForm"> <el-form :inline="true" :model="searchForm">
<el-form-item label="业务场景:">
<el-select v-model="searchForm.scene" size="small">
<el-option
v-for="(item, index) in sceneOption"
:key="index"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="商户:"> <el-form-item label="商户:">
<el-input v-model="searchForm.name" size="small" placeholder="请输入商户名称"></el-input> <el-input
v-model="searchForm.name"
size="small"
placeholder="请输入商户名称"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="活动/产品:"> <el-form-item label="活动/产品:">
<el-input v-model="searchForm.code" size="small" placeholder="请输入活动/产品名称"></el-input> <el-input
v-model="searchForm.code"
size="small"
placeholder="请输入活动/产品名称"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="状态:"> <el-form-item label="状态:">
<el-select v-model="searchForm.status" size="small"> <el-select v-model="searchForm.status" size="small">
<el-option label="全部" value=""></el-option> <el-option
<el-option label="启用" value="0"></el-option> v-for="(item, index) in taskStatus"
<el-option label="禁用" value="1"></el-option> :key="index"
</el-select> :label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" size="small" @click="handleSearch">查询</el-button> <el-button type="primary" size="small" @click="handleSearch"
>查询</el-button
>
<el-button plain size="small" @click="handleReset">重置</el-button> <el-button plain size="small" @click="handleReset">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<div class="table-top"> <div class="table-top">
<div>订单列表</div> <div>订单列表</div>
<el-button class="output-btn" size="small" style="margin-bottom: 20px" @click="handleEdit">添加任务</el-button> <el-button
<el-button class="output-btn" size="small" style="margin-bottom: 20px" @click="handleObserve">查看</el-button> class="output-btn"
<el-button class="output-btn" size="small" style="margin-bottom: 20px" @click="handleAnalyse">分析</el-button> size="small"
style="margin-bottom: 20px"
@click="handleEdit"
>添加任务</el-button
>
</div> </div>
<div> <div>
<d2-table <d2-table
ref="taskTable" ref="taskTable"
:searchForm="searchForm" :searchForm="searchForm"
:getListApi="getListApi" :getListApi="getListApi"
:tableParams="tableParams" :tableParams="tableParams"
:pageConf="pageConf" :pageConf="pageConf"
> :tableData="tableData"
<template slot="auth-button" slot-scope="scope"> >
<el-button type="text" @click="handleEdit(scope.scope)">编辑</el-button> <div slot="status" slot-scope="scope">
<el-button type="text" @click="handleViewDetail(scope.scope)">任务分析</el-button> <span v-if="scope.scope.status == statusNum.UNPUBLISH">未发布</span>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button> <span v-if="scope.scope.status == statusNum.PUBLISHED">已发布</span>
<el-button type="text" @click="handleActive(scope.scope)">发布</el-button> <span v-if="scope.scope.status == statusNum.FINISHIED">已结束</span>
<el-button type="text" @click="handleInactive(scope.scope)">复制</el-button> </div>
<el-button type="text" @click="handleClone(scope.scope)">克隆</el-button> <template slot="auth-button" slot-scope="scope">
</template> <el-button
</d2-table> type="text"
v-if="scope.scope.status == statusNum.UNPUBLISH"
@click="handleEdit(scope.scope)"
>编辑</el-button
>
<el-button
type="text"
v-if="scope.scope.status != statusNum.UNPUBLISH"
@click="handleAnalyze(scope.scope)"
>任务分析</el-button
>
<el-button
type="text"
v-if="scope.scope.status == statusNum.UNPUBLISH"
@click="handleDelete(scope.scope)"
style="color: red"
>删除</el-button
>
<el-button
type="text"
v-if="scope.scope.status == statusNum.UNPUBLISH"
@click="handleActive(scope.scope)"
>发布</el-button
>
<el-button
type="text"
v-if="scope.scope.status == statusNum.PUBLISHED"
@click="handleInactive(scope.scope)"
>结束</el-button
>
<el-button type="text" @click="handleClone(scope.scope)"
>复制</el-button
>
<el-button
type="text"
v-if="scope.scope.status != statusNum.UNPUBLISH"
@click="handleViewDetail(scope.scope)"
>查看</el-button
>
</template>
</d2-table>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
const sceneOption = [
{
label: '全部',
value: '',
},
{
label: '1.0新车权益销售',
value: '0',
},
{
label: '1.1次新车精品升级',
value: '1',
},
{
label: '1.2次新车线上转化',
value: '2',
},
{
label: '1.3存量用户众筹',
value: '3',
},
]
const statusNum = {
UNPUBLISH: '0',
PUBLISHED: '1',
FINISHIED: '2',
}
const taskStatus = [
{
label: '全部',
value: '',
},
{
label: '未发布',
value: statusNum.UNPUBLISH,
},
{
label: '已发布',
value: statusNum.PUBLISHED,
},
{
label: '已结束',
value: statusNum.FINISHIED,
},
]
import { taskApi } from '../../../api/task'
export default { export default {
data() { data() {
return { return {
// 业务场景选项
sceneOption,
// 状态选项
taskStatus,
statusNum,
searchForm: { searchForm: {
scene: '',
name: '', name: '',
code: '', code: '',
status: '' status: '',
}, },
// 表格参数 // 表格参数
tableParams: { tableParams: {
...@@ -63,51 +182,76 @@ export default { ...@@ -63,51 +182,76 @@ export default {
tableOption: true, tableOption: true,
tableColumns: [ tableColumns: [
{ {
label: '模板名称', label: '业务场景',
prop: 'templateName', prop: 'scene',
width: 200 width: 200,
}, },
{ {
label: '模板编码', label: '商户',
prop: 'templateCode', prop: 'merchant',
width: 250 width: 250,
}, },
{ {
label: '任务数', label: '活动/产品',
prop: 'taskNum' prop: 'activity',
},
{
label: '总收益',
prop: 'income'
},
{
label: '使用门店',
prop: 'withdrawalNumber'
}, },
{ {
label: '使用活动', label: '任务数',
prop: 'activity', prop: 'taskNum',
width: 150
}, },
{ {
label: '创建人', label: '创建人',
prop: 'creatPerson' prop: 'creatPerson',
}, },
{ {
label: '创建时间', label: '创建时间',
prop: 'creatTime' prop: 'creatTime',
width: 150,
}, },
{ {
label: '状态', label: '状态',
prop: 'status' prop: 'status',
} addHtml: 'status',
] },
],
}, },
pageConf: { pageConf: {
pageSize: 'pageSize', pageSize: 'pageSize',
pageNum: 'pageNum', pageNum: 'pageNum',
totalCount: 'data.total' totalCount: 'data.total',
} },
tableData: [
{
id: 11,
scene: '1.3业务场景',
merchant: '我是商户名称',
activity: '氛围灯众筹活动',
taskNum: '10',
creatPerson: '用户名',
creatTime: '2021-10-27 16:00:00',
status: '0',
},
{
id: 22,
scene: '1.3业务场景',
merchant: '我是商户名称',
activity: '360众筹活动',
taskNum: '10',
creatPerson: '用户名',
creatTime: '2021-10-27 16:00:00',
status: '1',
},
{
id: 33,
scene: '1.1业务场景',
merchant: '我是商户名称',
activity: 'AR导航',
taskNum: '10',
creatPerson: '用户名',
creatTime: '2021-10-27 16:00:00',
status: '2',
},
],
// 获取订单列表 // 获取订单列表
// getListApi: customerApi.getOrderList // getListApi: customerApi.getOrderList
} }
...@@ -123,28 +267,28 @@ export default { ...@@ -123,28 +267,28 @@ export default {
this.searchForm = { this.searchForm = {
name: '', name: '',
code: '', code: '',
status: '' status: '',
} }
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.taskTable.refreshTable() this.$refs.taskTable.refreshTable()
}) })
}, },
handleObserve(){ handleObserve() {
this.$root.to([ this.$root.to([
'任务中心', '任务中心',
'任务平台', '任务平台',
'任务管理', '任务管理',
'任务模板管理', '任务模板管理',
'*查看任务' '*查看任务',
]) ])
}, },
handleAnalyse(){ handleAnalyse() {
this.$root.to([ this.$root.to([
'任务中心', '任务中心',
'任务平台', '任务平台',
'任务管理', '任务管理',
'任务模板管理', '任务模板管理',
'*任务分析' '*任务分析',
]) ])
}, },
...@@ -156,29 +300,85 @@ export default { ...@@ -156,29 +300,85 @@ export default {
'任务平台', '任务平台',
'任务管理', '任务管理',
'任务模板管理', '任务模板管理',
'*添加任务模板' '*添加任务模板',
]) ])
} }
// this.$root.close('任务模板管理列表') // this.$root.close('任务模板管理列表')
}, },
// 删除 // 删除
handleDelete() {}, handleDelete(scope) {
// 启用 this.secondConfirm(
handleActive() {}, '提示',
// 禁用 '任务计划删除后,无法恢复。是否确定删除?',
handleInactive() {}, '',
scope.id
)
},
// 发布
handleActive(scope) {
this.secondConfirm(
'提示',
'任务计划发布后,任务会自动下发给对应的员工。是否确定发布?',
'',
scope.id
)
},
// 结束
handleInactive(scope) {
this.secondConfirm(
'提示',
'任务计划结束后,整个任务计划将无法再使用。是否确定结束?',
'',
scope.id
)
},
// 克隆 // 克隆
handleClone() {}, handleClone() {},
// 跳转查看详情 // 跳转查看详情
handleViewDetail(scope) { handleViewDetail(scope) {
console.log(scope) console.log(scope)
// this.$root.to( this.$root.to([
// ['UBI续保', '续保', '保险渠道管理', '订单管理', '*订单管理详情'], '任务中心',
// scope.id '任务平台',
// ) '任务管理',
} '任务模板管理',
} '*查看任务',
])
},
// 任务分析
handleAnalyze(scope) {
console.log(scope)
this.$root.to([
'任务中心',
'任务平台',
'任务管理',
'任务模板管理',
'*任务分析',
])
},
// 二次确认
secondConfirm(title, txt, apiName, apiParams, fn) {
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: (action) => {
if (action == 'confirm') {
taskApi[apiName](apiParams).then((res) => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error',
})
if (res.code == '0') {
fn && fn()
this.handleSearch()
}
})
}
},
})
},
},
} }
</script> </script>
<style scoped> <style scoped></style>
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!