Commit 2eb4b02a by 杨明

欢迎语 底部

1 parent 01abf26f
Showing 47 changed files with 2887 additions and 85 deletions
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"element-ui": "^2.15.6", "element-ui": "^2.15.6",
"glsx-common": "^1.3.2", "glsx-common": "^1.3.2",
"vuedraggable": "^2.24.3",
"vue": "^2.6.11" "vue": "^2.6.11"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
<el-button plain class="btn-three" size="mini" disabled>超小</el-button> <el-button plain class="btn-three" size="mini" disabled>超小</el-button>
</div> </div>
<hr /> <hr />
<h3>el-dialog调整</h3> <h3>el-dialog调整</h3>
<!-- <GLDialog :visible.sync="visible" title="aaaaaaaaa"> <!-- <GLDialog :visible.sync="visible" title="aaaaaaaaa">
...@@ -132,16 +131,9 @@ ...@@ -132,16 +131,9 @@
<el-button plain @click="showDialog">dialog(小)</el-button> <el-button plain @click="showDialog">dialog(小)</el-button>
<el-button plain @click="testDialog3">dialog(中)无按钮</el-button> <el-button plain @click="testDialog3">dialog(中)无按钮</el-button>
<el-button plain @click="testBeforeDialog">之前小弹窗</el-button> <el-button plain @click="testBeforeDialog">之前小弹窗</el-button>
<GLFull>SDK发就算冷冻机房乐山大佛</GLFull>
<!-- :content="'hello HelloWorld'" --> <!-- :content="'hello HelloWorld'" -->
<GLDialog <GLDialog :mode="mode" bigTitle="大标题" :hasFooter="hasFooter" :type="'error'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow">
:mode="mode"
bigTitle="大标题"
:hasFooter="hasFooter"
:type="'error'"
@onOk="handleOk"
@onCancel="handleCancel"
:visible.sync="dialogShow">
<div> <div>
<div>这是一段信息</div> <div>这是一段信息</div>
<div>这是一段信息</div> <div>这是一段信息</div>
...@@ -210,28 +202,9 @@ ...@@ -210,28 +202,9 @@
<el-button type="primary" size="small" @click="dialogShow = false">确定123</el-button> <el-button type="primary" size="small" @click="dialogShow = false">确定123</el-button>
</span> --> </span> -->
</GLDialog> </GLDialog>
<GLDialog <GLDialog :mode="mode" title="提示" :hasFooter="hasFooter" :type="'error'" :content="'hello HelloWorld'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow2"></GLDialog>
:mode="mode" <GLDialog title="提示123" :mode="mode" :hasFooter="hasFooter" :type="'error'" :content="'hello HelloWorld'" @onOk="handleOk" @onCancel="handleCancel" :visible.sync="dialogShow1"></GLDialog>
title="提示"
:hasFooter="hasFooter"
:type="'error'"
:content="'hello HelloWorld'"
@onOk="handleOk"
@onCancel="handleCancel"
:visible.sync="dialogShow2">
</GLDialog>
<GLDialog
title="提示123"
:mode="mode"
:hasFooter="hasFooter"
:type="'error'"
:content="'hello HelloWorld'"
@onOk="handleOk"
@onCancel="handleCancel"
:visible.sync="dialogShow1">
</GLDialog>
<hr /> <hr />
</div> </div>
</template> </template>
<script> <script>
...@@ -703,7 +676,7 @@ export default { ...@@ -703,7 +676,7 @@ export default {
}, },
condition: row => { condition: row => {
const h = this.$createElement const h = this.$createElement
const vNode = h('span','','11323') const vNode = h('span', '', '11323')
return true return true
}, },
attrs: { attrs: {
...@@ -711,7 +684,7 @@ export default { ...@@ -711,7 +684,7 @@ export default {
//boolean或者函数 //boolean或者函数
disabled: (row, condition) => { disabled: (row, condition) => {
// console.log(123456) // console.log(123456)
return 1==1 return 1 == 1
} }
// disabled: false // disabled: false
}, },
...@@ -762,7 +735,7 @@ export default { ...@@ -762,7 +735,7 @@ export default {
// condition: row => { // condition: row => {
// return true // return true
// }, // },
condition: (row) => { condition: row => {
// return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
// setTimeout(resolve(true),2000) // setTimeout(resolve(true),2000)
// }) // })
...@@ -771,7 +744,7 @@ export default { ...@@ -771,7 +744,7 @@ export default {
}, },
// 属性 // 属性
attrs: { attrs: {
type: 'text', type: 'text'
//boolean或者函数, 参数 row ,config //boolean或者函数, 参数 row ,config
// disabled: (row, condition) => { // disabled: (row, condition) => {
// // console.log('disabled') // // console.log('disabled')
...@@ -804,10 +777,10 @@ export default { ...@@ -804,10 +777,10 @@ export default {
// 测试省市组件 // 测试省市组件
subdistrict: 3, subdistrict: 3,
//测试弹框 //测试弹框
dialogShow:false, dialogShow: false,
dialogShow1:false, dialogShow1: false,
dialogShow2:false, dialogShow2: false,
mode:"mid", mode: 'mid',
hasFooter: true hasFooter: true
} }
}, },
...@@ -1059,51 +1032,51 @@ export default { ...@@ -1059,51 +1032,51 @@ export default {
console.log(val) console.log(val)
}, },
//测试弹框 //测试弹框
testDialog(number){ testDialog(number) {
this.dialogShow = !this.dialogShow this.dialogShow = !this.dialogShow
this.hasFooter = true this.hasFooter = true
switch (number) { switch (number) {
case 1: case 1:
this.mode = 'big' this.mode = 'big'
break; break
case 2: case 2:
this.mode = 'mid' this.mode = 'mid'
break; break
case 3: case 3:
this.mode = 'small' this.mode = 'small'
break; break
case 4: case 4:
this.mode = 'mid' this.mode = 'mid'
this.hasFooter = false this.hasFooter = false
break; break
} }
}, },
testDialog2(){ testDialog2() {
this. mode = 'mid' this.mode = 'mid'
this.dialogShow2 = !this.dialogShow2 this.dialogShow2 = !this.dialogShow2
this.hasFooter = true this.hasFooter = true
}, },
testDialog3(){ testDialog3() {
this. mode = 'mid' this.mode = 'mid'
this.dialogShow2 = !this.dialogShow2 this.dialogShow2 = !this.dialogShow2
this.hasFooter = false this.hasFooter = false
}, },
showDialog(){ showDialog() {
this.dialogShow1 = !this.dialogShow1 this.dialogShow1 = !this.dialogShow1
this.mode = 'small' this.mode = 'small'
this.hasFooter = true this.hasFooter = true
}, },
handleOk(){ handleOk() {
console.log('点击确定') console.log('点击确定')
this.dialogShow = false this.dialogShow = false
this.dialogShow1 = false this.dialogShow1 = false
}, },
handleCancel(){ handleCancel() {
console.log('点击取消') console.log('点击取消')
this.dialogShow = false this.dialogShow = false
this.dialogShow1 = false this.dialogShow1 = false
}, },
testBeforeDialog(){ testBeforeDialog() {
this.$confirm('检测到未保存的内容,是否在离开页面前保存修改?', '确认信息', { this.$confirm('检测到未保存的内容,是否在离开页面前保存修改?', '确认信息', {
// distinguishCancelAndClose: true, // distinguishCancelAndClose: true,
confirmButtonText: '是', confirmButtonText: '是',
...@@ -1112,7 +1085,6 @@ export default { ...@@ -1112,7 +1085,6 @@ export default {
}) })
} }
} }
} }
</script> </script>
<style lang="scss"> <style lang="scss">
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* 启动项目工程即可 * 启动项目工程即可
*/ */
//创建的组件 //创建的组件
import Vue from 'vue' import Vue from 'vue'
import { import {
// 基础 // 基础
GLExternal, GLExternal,
GLButton, GLButton,
...@@ -18,25 +18,29 @@ ...@@ -18,25 +18,29 @@
GLTableButton, GLTableButton,
// 业务 // 业务
GLProvince, GLProvince,
GLBcTest GLBcTest,
GLEditor,
GLFull
} from '../../dist/glsx-components.umd.min.js' } from '../../dist/glsx-components.umd.min.js'
import '../../dist/glsx-components.css' import '../../dist/glsx-components.css'
const permissions = { const permissions = {
routes: [ routes: [
{ path: '/', meta: { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'] } }, { path: '/', meta: { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'] } },
{ path: '/a', meta: {} } { path: '/a', meta: {} }
], ],
routerBase: '' routerBase: ''
} }
Vue.use(GLButton, permissions) Vue.use(GLButton, permissions)
Vue.use(GLExternal) Vue.use(GLExternal)
Vue.use(GLDialog) Vue.use(GLDialog)
Vue.use(GLTable) Vue.use(GLTable)
Vue.use(GLFooter) Vue.use(GLFooter)
Vue.use(GLSearch) Vue.use(GLSearch)
Vue.use(GLSearchItem) Vue.use(GLSearchItem)
Vue.use(GLCombiForm) Vue.use(GLCombiForm)
Vue.use(GLTableButton) Vue.use(GLTableButton)
Vue.use(GLProvince) Vue.use(GLProvince)
Vue.use(GLBcTest) Vue.use(GLBcTest)
Vue.use(GLEditor)
Vue.use(GLFull)
import GLEditor from './src/index.vue'
console.log(GLEditor)
// 为组件提供 install 安装方法,供按需引入
GLEditor.install = function (Vue) {
Vue.component(GLEditor.name, GLEditor)
}
// 默认导出组件
export default GLEditor
<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 class="square-main">
<el-dialog title="选择活动" :visible.sync="dialogVisible" width="1088px" :before-close="handleClose">
<div class="model-panel" v-loading="loading">
<div class="model-panel-tab">
<label>活动类型:</label>
<el-tabs v-model="activeName" @tab-click="handleClick" type="card">
<template v-for="(item, index) in activityList">
<el-tab-pane :label="item.itemName" :name="item.itemValue" v-if="itemType != 'merchant'" :key="index"></el-tab-pane>
<el-tab-pane :label="item.itemName" v-if="openFlag && itemType == 'itemType'" :key="index"></el-tab-pane>
</template>
</el-tabs>
</div>
<div class="model-item-panel" v-if="modelList.length > 0">
<div class="model-item" :class="{ checked: selectItem == item }" v-for="(item, index) in modelList" :key="index" @click="handleSelectItem(item)">
<template v-if="selectType == 'card'">
<div class="model-item-title" :title="item.equityName">{{ item.equityName }}</div>
<div class="model-item-content">领取方式:免费领用</div>
<div class="model-item-content"></div>
<div class="model-item-content model-item-contents">
试用天数:
<span>{{ item.freeDay }}天</span>
</div>
</template>
<template v-else-if="selectType == 'package'">
<div class="model-item-title" :title="item.packageName">{{ item.packageName }}</div>
<div class="model-item-content">领取方式:付费购买</div>
<div class="model-item-content"></div>
<div class="model-item-content model-item-contents">
销售价格:
<span>{{ item.packagePrice }}元</span>
</div>
</template>
<template v-else-if="selectType == 'coupon'">
<div class="model-item-title" :title="item.couponName">{{ item.couponName }}</div>
<div class="model-item-content" v-if="item.effectiveType == 3">有效期:无限制</div>
<div class="model-item-content" v-if="item.effectiveType == 6">有效期:{{ item.effectiveDays }}天</div>
<div class="model-item-content" v-if="item.effectiveType == 2">有效期:{{ item.effectiveStartTime ? item.effectiveStartTime.split(' ')[0] : '' }}~{{ item.effectiveEndTime ? item.effectiveEndTime.split(' ')[0] : '' }}</div>
<div class="model-item-content">
使用途径:
{{ item.useChannel == 1 ? '线上商品' : '到店核销' }}
</div>
<div class="model-item-content model-item-contents">
数量:
<span>{{ item.residueAmount }}</span>
</div>
</template>
<template v-else-if="selectType == 'activity'">
<div class="model-item-title" :title="item.activityName">{{ item.activityName }}</div>
<div class="model-item-content"></div>
<div class="model-item-content">
开始时间:
{{ item.startTime }}
</div>
<div class="model-item-content">
结束时间:
{{ item.endTime }}
</div>
</template>
<template v-else>
<div class="model-item-title" :title="item.couponName">{{ item.equityName }}</div>
<div class="model-item-content">获取方式:需先购买无忧服务套餐</div>
<div class="model-item-content">获取限制:每个服务套餐限领一次</div>
<div class="model-item-content model-item-weight">
赠送天数:
<span>{{ item.effectiveType == 2 ? item.effectivedDay + '天' : '永久有效' }}</span>
</div>
</template>
</div>
</div>
<div class="model-item-empty" v-else v-loading="loading">
<img src="../../../assets/empty.png" />
<div class="empty-item">暂无数据</div>
</div>
<el-pagination v-if="selectType != 'card' && selectType != 'merchant'" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[12, 24, 36, 48]" :page-size="pageSize" :total="tableTotal" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogVisible = false">取 消</el-button>
<el-button size="small" type="primary" @click="handleSelect" v-show="modelList.length">确 定</el-button>
<el-button size="small" type="primary" @click="handleOpen" v-show="modelList.length == 0 && selectType == 'coupon' && memberMenu">立即添加</el-button>
<el-button size="small" type="primary" @click="handleOpen" v-show="modelList.length == 0 && selectType == 'package' && couponMenu">立即添加</el-button>
<el-button size="small" type="primary" @click="handleOpen" v-show="modelList.length == 0 && selectType == 'activity' && activityMenu">立即添加</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
const openUrl = function (url) {
const link = document.createElement('a')
link.href = url
link.target = '_blank'
link.rel = 'opener'
link.click()
}
export default {
name: 'ActivityModel',
data() {
return {
dialogVisible: false,
couponMenu: false,
loading: false,
activeName: 3,
modelList: [],
pageNum: 1,
pageSize: 12,
tableTotal: 0,
openFlag: 0,
selectItem: {
id: ''
}
}
},
props: {
activityList: Array
},
computed: {
selectType() {
return this.activityList.find(act => act.itemValue == this.activeName).itemType
}
},
methods: {
handleSelectItem(item) {
this.selectItem = item
if (item.equityClassId) {
this.selectItem.id = item.equityClassId
}
console.log(this.selectItem)
},
handleSelect() {
if (!this.selectItem.id) {
this.$message({
type: 'error',
message: '请选择活动'
})
return
}
this.dialogVisible = false
const marketingId = this.selectItem.id ? this.selectItem.id : this.selectItem.equityClassId
const marketingName = this.selectType == 'card' ? this.selectItem.equityName : this.selectType == 'package' ? this.selectItem.packageName : this.selectType == 'activity' ? this.selectItem.activityName : this.selectType == 'coupon' ? this.selectItem.couponName : this.selectItem.equityName
const marketingContent = { ...this.selectItem, selectType: this.selectType }
this.$emit('selectActivity', { marketingId, marketingType: this.activeName, marketingName, marketingContent })
},
handleSizeChange(val) {
this.pageSize = val
this.getModelList()
},
handleCurrentChange(val) {
this.pageNum = val
this.getModelList()
},
handleOpen() {
let url
switch (this.activeName) {
case '2':
url = '/marketing/couponManage/index'
break
case '4':
url = '/marketing/memberCenter/setmealAddUpdate?%24title=%25E5%2588%259B%25E5%25BB%25BA%25E5%25A5%2597%25E9%25A4%2590'
break
case '5':
url = '/marketing/seckillActivity/editActivity/1'
break
}
openUrl(location.origin + url)
this.dialogVisible = false
},
getModelList() {
this.modelList = []
this.loading = true
let params = {
pageSize: this.pageSize,
pageNum: this.pageNum
}
const activityChecked = this.activityList.find(act => act.itemValue == this.activeName)
Object.assign(params, activityChecked.params)
activityChecked
.getInterfaceApi(params)
.then(res => {
this.modelList = res.list ? res.list : res.data ? res.data : res
this.tableTotal = res.total ? res.total : 0
this.loading = false
})
.catch(() => {
this.loading = false
})
},
merchantOpen() {
let channel = null
if (location.host == 'scrm.cgacar.com') {
channel = 2
}
const activityMerchant = this.activityList.find(act => act.itemType == 'merchant')
let params = { channel, ...activityMerchant.merchantOpen.params }
activityMerchant.merchantOpen.merchantOpenApi(params).then(res => {
this.openFlag = res.openFlag
})
},
init() {
this.merchantOpen()
this.couponMenu = false
this.activityMenu = false
this.memberMenu = false
const menu = JSON.parse(sessionStorage['SCRM_BASE_MENULIST'])
menu.forEach(item => {
if (item.name == 'marketing') {
if (!item.children) {
return
}
item.children.forEach(itm => {
console.log(itm.path)
if (itm.path == '/couponManage/index') {
this.couponMenu = true
}
if (itm.path == '/seckillActivity/index') {
this.activityMenu = true
}
if (itm.path == '^') {
this.memberMenu = true
}
})
}
})
this.dialogVisible = true
this.getModelList()
this.selectItem = {}
},
handleClick() {
this.getModelList()
}
}
}
</script>
<style lang="scss" scoped>
.square-main {
/deep/ {
.el-dialog__footer {
text-align: center;
}
}
}
.model-panel {
.model-panel-tab {
display: flex;
align-items: center;
margin-bottom: 18px;
label {
font-size: 16px;
font-weight: 400;
color: #000000;
line-height: 24px;
}
/deep/ {
.el-checkbox:last-of-type {
margin-right: 8px;
}
.el-tabs__nav {
border: 0;
}
.el-tabs__header {
border: 0;
background-color: #f4f6fc;
margin: 0px;
}
.el-tabs__item {
border: none;
width: 180px;
height: 32px;
line-height: 32px;
margin: 2px;
text-align: center;
}
.el-tabs__item.is-active {
background-color: #fff;
border-radius: 4px;
font-weight: 600;
}
}
}
.model-item-empty {
> img {
display: block;
margin: 50px auto 0px;
width: 60px;
height: auto;
}
.empty-item {
text-align: center;
font-size: 14px;
font-weight: 400;
color: #000000;
line-height: 22px;
margin-bottom: 30px;
}
}
.model-item-panel {
// display: grid;
// grid-template-columns: repeat(4, 25%);
// grid-row-gap: 10px;
max-height: 38vh;
overflow: auto;
display: flex;
flex-wrap: wrap;
align-items: stretch;
flex-direction: row;
.model-item {
width: 240px;
margin-right: 24px;
margin-bottom: 24px;
padding: 12px 16px;
position: relative;
height: 128px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #e6e6e6;
padding: 14px 24px;
box-sizing: border-box;
&:nth-child(4n) {
margin-right: 0px;
}
&.checked {
background: rgba(88, 80, 255, 0.1);
border: 1px solid #5850ff;
}
&-qrcode {
position: absolute;
right: 10px;
bottom: 10px;
width: 60px;
height: 60px;
border: 1px solid #979797;
}
&-title {
font-size: 18px;
font-weight: 600;
color: #333333;
line-height: 25px;
margin-bottom: 5px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
&-content {
font-size: 12px;
font-weight: 400;
color: #666666;
line-height: 16px;
height: 16px;
margin-top: 6px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
&.model-item-weight {
line-height: 20px;
height: 20px;
}
span {
color: #5850ff;
font-size: 20px;
}
}
&-contents {
line-height: 22px;
height: 22px;
}
}
}
}
</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) && 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 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>
</transition-group>
</vuedraggable>
<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="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">
<div class="add-btn" v-for="item in btnList" :key="item.type">
<!-- <i class="el-icon-circle-plus-outline"></i> -->
<img :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 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 == 'nickname' || item.type == 'message' || item.type == 'activity' || item.type == 'material'" style="opacity: 0" @click="handleFun(item.type)">{{ item.name }}</el-link>
</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>
<activity-model ref="activity" @selectActivity="selectActivity" :activityList="activityList"></activity-model>
<message-model ref="message" @selectItem="selectMessage" :messageList="messageList"></message-model>
<material-model ref="material" :materialList="materialList" @handleMaterialConfirm="handleMaterialConfirm"></material-model>
</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']
import emoji from '../../../utils/emo'
import ActivityModel from './activityModel'
import MessageModel from './messageModel'
import materialModel from './materialModel'
import Emotion from './emotionWords'
import wTextarea from './tag-textarea'
import vuedraggable from 'vuedraggable'
import { utils } from 'glsx-common'
export default {
name: 'GLEditor',
components: {
ActivityModel,
Emotion,
wTextarea,
MessageModel,
materialModel,
vuedraggable
},
props: {
btnList: Array,
form: String,
boxHeight: {
type: Number,
default: 400
},
ATT_TYPE: {
type: Array,
default: ATT_TYPE
}
},
data() {
return {
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(vuedraggable)
},
computed: {
activityList() {
return 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') || {}
},
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) {
return 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 JSON.parse(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 base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
this.imageList.uploadApi({ file: base64 }).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 base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
this.videoList.uploadApi({ file: base64 }).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(name) {
if (name == 'nickname') {
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()
}
},
close(index) {
this.previewList.splice(index, 1)
},
textInput(val) {
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: JSON.stringify(val),
attType: this.ATT_TYPE[type]
})
} else {
this.previewList.push({
attContent: JSON.stringify(val),
attType: this.ATT_TYPE[type]
})
}
},
// 素材
handleMaterialConfirm(val) {
console.log(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: pdfSrc,
attType: this.ATT_TYPE.FILE
})
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) {
this.textValue = this.previewList[idx].attContent + html
this.$set(this.previewList, 0, {
attContent: this.previewList[idx].attContent + html,
attType: this.ATT_TYPE.TEXT
})
} else {
html = html.replace('\n', '')
this.previewList.unshift({
attContent: html,
attType: this.ATT_TYPE.TEXT
})
this.textValue = html
}
},
selectMessage(val) {
const content = val.content
this.updateText(content)
this.textValue = content
},
insertHtmlAtCaret(html) {
var sel, range, frag
if (window.getSelection) {
sel = window.getSelection()
if (sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0)
range.deleteContents()
var el = document.createElement('span')
el.innerHTML = '<span contenteditable="false" class="nickname">@昵称<i class="el-icon-error"></i></span>'
// var el = document.createElement('div')
// el.innerHTML = html
frag = document.createDocumentFragment()
var node
var lastNode
while ((node = el.firstChild)) {
lastNode = frag.appendChild(node)
}
range.insertNode(frag)
if (lastNode) {
range = range.cloneRange()
range.setEndAfter(lastNode)
range.collapse(true)
sel.removeAllRanges()
sel.addRange(range)
}
}
}
},
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) {
this.previewList = this.$common.utils.deepClone(val)
// this.eventBus.$emit('update', this.previewList)
const obj = val.find(item => item.attType == this.ATT_TYPE.TEXT)
if (obj) {
let attContent = obj.attContent.replaceAll('[@昵称]', '<wise id="1">@昵称</wise>')
const 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">`
})
setTimeout(() => {
document.querySelector('.w-textarea_input').innerHTML = htm
}, 100)
} else {
this.textValue = ''
}
}
}
}
</script>
<style lang="scss" scoped>
.welcome-box {
}
.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-bg {
// background-color: #f7f7f7;
}
.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 {
padding: 10px 0 10px 20px;
border: 1px solid #e5e5e5;
border-top: 0;
background: #fafbfe;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
.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%;
}
}
}
.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>
<el-dialog title="选择素材" :visible.sync="isMaterialVisible" width="70%" class="relateStore">
<GLCombiForm :rowNumber="1" ref="showSearch" :formObj="searchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<div class="model-panel">
<div class="model-item-panel" v-if="modelList.length > 0" v-loading="loading">
<div class="model-item" :class="{ checked: selectItem.id == item.id }" v-for="(item, index) in modelList" :key="index" @click="handleSelectItem(item)">
<el-tooltip effect="dark" placement="top" :content="item.materialContentRpcResponse.materialName" :disabled="item.materialContentRpcResponse.materialName.length < 16">
<!-- <span class="hide-content">{{ item.materialContentRpcResponse.materialName }}</span> -->
<div class="model-item-title" :title="item.materialContentRpcResponse.materialName">{{ item.materialContentRpcResponse ? item.materialContentRpcResponse.materialName : '-' }}</div>
</el-tooltip>
<!-- <img :src="item.materialContentRpcResponse.materialUrl" /> -->
<!-- 素材内容 -->
<!-- <div slot="materialContentRpcResponse" slot-scope="scope" style="text-align: center"> -->
<!-- 素材为PDF -->
<span v-if="item.materialType == 1" class="material-content">
<!-- <el-tooltip effect="dark" placement="top" :content="item.materialContentRpcResponse.materialName" :disabled="item.materialContentRpcResponse.materialName.length < 16">
<span class="hide-content">{{ item.materialContentRpcResponse.materialName }}</span>
</el-tooltip> -->
<img class="img-pdf" src="../../../assets/welcomeWord/pdf.png" alt="" />
<p class="model-item-content">{{ item.materialContentRpcResponse.materialName }}.png</p>
</span>
<!-- 素材为自定义链接 -->
<!-- <span v-if="item.materialType == 2"></span> -->
<!-- 图文 -->
<span v-if="item.materialType == 3" class="material-content">
<!-- <el-tooltip effect="dark" placement="top" :content="item.materialContentRpcResponse.materialName" :disabled="item.materialContentRpcResponse.materialName.length < 16">
<span>{{ item.materialContentRpcResponse.materialName }}</span>
</el-tooltip> -->
<!-- <el-popover placement="top" trigger="click">
<div>
<img style="width: 72px; height: 72px;" v-if="item.materialContentRpcResponse.materialUrl" :src="item.materialContentRpcResponse.materialUrl" alt="" />
<img class="img-material" v-else src="@/assets/material/car.png" alt="" />
</div>
<span slot="reference">
<img v-if="item.materialContentRpcResponse.materialUrl" class="img-material" :src="item.materialContentRpcResponse.materialUrl" />
<img v-else class="img-material" src="@/assets/material/car.png" alt="" />
</span>
</el-popover> -->
<img v-if="item.materialContent && item.materialContent.urlType == 'img'" class="img-material" :src="item.materialContent.materialUrl" />
<video v-if="item.materialContent && item.materialContent.urlType == 'video'" class="img-material" width="100%" height="100%" preload loop muted>
<source :src="item.materialContent.materialUrl" type="video/mp4" />
</video>
</span>
</div>
<!-- </div> -->
</div>
<div class="model-item-empty" v-else v-loading="loading">
<img src="../../../assets/empty.png" />
<div class="empty-item">暂无数据</div>
</div>
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[12, 24, 36, 48]" :page-size="pageSize" :total="tableTotal" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="isMaterialVisible = false">取 消</el-button>
<el-button size="small" type="primary" @click="handleMaterialConfirm">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import GLCombiForm from '../../GlCombiForm/src/index'
export default {
name: 'materialModel',
components: {
GLCombiForm
},
data() {
return {
isMaterialVisible: false,
searchForm: {
groupId: '',
materialType: ''
},
searchFormData: [
{
label: '素材分组',
name: 'groupId',
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'materialGroupName',
optionsName: 'groupList'
},
{
label: '素材类型',
name: 'materialType',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confName',
optionsName: 'materialTypeList'
}
],
// selectedData: [],
// selectingData: [],
// needTip: ['editProduct'],
modelList: [],
selectItem: {
id: ''
},
// 分页
pageNum: 1,
pageSize: 12,
tableTotal: 0,
baseData: {
groupList: [],
materialTypeList: [
{
confId: 1,
confName: 'PDF'
},
// {
// confId: 2,
// confName: '自定义链接'
// },
{
confId: 3,
confName: '图文'
}
]
}
}
},
props: {
materialList: Object
},
methods: {
init() {
this.getBaseData()
this.getModelList()
this.isMaterialVisible = true
},
getBaseData() {
this.materialList.groupListApi({}).then(res => {
this.baseData.groupList = res
this.getOptionsList('searchFormData')
})
},
handleSelectItem(item) {
this.selectItem = item
},
getimgsrc(htmlstr) {
var reg = /<img.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim
var arr = []
var tem
while ((tem = reg.exec(htmlstr))) {
arr.push(tem[2])
}
return arr
},
getvideosrc(htmlstr) {
var reg = /<video.+?src=('|")?([^'"]+)('|")?(?:\s+|>)/gim
var arr = []
var tem
while ((tem = reg.exec(htmlstr))) {
arr.push(tem[2])
}
return arr
},
getModelList() {
var params = {
...this.searchForm,
status: 0,
pageNum: this.pageNum,
pageSize: this.pageSize
}
this.materialList.materialListApi(params).then(res => {
this.modelList = res.data
this.tableTotal = res.count
let tableData = []
this.modelList.forEach(item => {
if (item.materialType == 1) {
this.$set(item, 'materialContent', { pdfSrc: decodeURIComponent(item.materialContentRpcResponse.materialUrl) })
return
}
let html = decodeURIComponent(item.materialContentRpcResponse.materialUrl)
let imgSrc = this.getimgsrc(html)
let videoSrc = this.getvideosrc(html)
let imgHtml = html.match(/<img.*?(?:>|\/>)/g)
let videoHtml = html.match(/<video.*<\/video>/g)
let materialUrl, urlType, imgCount
if (imgSrc.length) {
materialUrl = imgSrc[0]
urlType = 'img'
imgCount = imgSrc.length
for (let i = 0; i < imgHtml.length; i++) {
html = html.replace(imgHtml[i], '')
}
}
if (videoSrc.length) {
materialUrl = videoSrc[0]
urlType = 'video'
for (let i = 0; i < videoHtml.length; i++) {
html = html.replace(videoHtml[i], '')
}
}
html = html.replace(/<p><\/p>/g, '').replace(/<p>([\s\S]+)<\/p>/, '\n$1')
if (materialUrl) {
this.$set(item, 'materialContent', { materialUrl, imgCount, urlType, imgSrc, videoSrc, html })
} else {
this.$set(item, 'materialContent', { html })
}
})
})
},
handleReset() {
this.searchForm = {
groupId: '',
materialType: ''
}
this.handleSearch()
},
handleSearch() {
this.pageNum = 1
this.getModelList()
},
handleSizeChange(val) {
this.pageSize = val
this.getModelList()
},
handleCurrentChange(val) {
this.pageNum = val
this.getModelList()
},
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find(k => k.name == refreshSigle)
var index = this[formName].findIndex(k => k.name == refreshSigle)
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
} else {
this[formName].forEach((item, index) => {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
}
})
}
},
handleMaterialConfirm() {
console.log(this.selectItem)
this.isMaterialVisible = false
this.$emit('handleMaterialConfirm', {
objectId: this.selectItem.id,
objectName: this.selectItem.materialContentRpcResponse.materialName,
materialContent: this.selectItem.materialContent
})
}
}
}
</script>
<style lang="scss" scoped>
.relateStore {
/deep/ {
.gl-operate {
margin-left: 10px;
}
}
}
.model-panel {
.model-panel-tab {
display: flex;
align-items: center;
margin-bottom: 18px;
label {
font-size: 16px;
font-weight: 400;
color: #000000;
line-height: 24px;
}
/deep/ {
.el-checkbox:last-of-type {
margin-right: 8px;
}
.el-tabs__nav {
border: 0;
}
.el-tabs__header {
border: 0;
background-color: #f4f6fc;
margin: 0px;
}
.el-tabs__item {
border: none;
width: 180px;
height: 32px;
line-height: 32px;
margin: 2px;
text-align: center;
}
.el-tabs__item.is-active {
background-color: #fff;
border-radius: 4px;
font-weight: 600;
}
.el-pagination {
padding: 5px;
}
}
}
.model-item-empty {
> img {
display: block;
margin: 50px auto 0px;
width: 60px;
height: auto;
}
.empty-item {
text-align: center;
font-size: 14px;
font-weight: 400;
color: #000000;
line-height: 22px;
margin-bottom: 30px;
}
}
.model-item-panel {
// display: grid;
// grid-template-columns: repeat(4, 25%);
// grid-row-gap: 10px;
max-height: 38vh;
overflow: auto;
display: flex;
flex-wrap: wrap;
align-items: stretch;
flex-direction: row;
.model-item {
width: 240px;
margin-right: 24px;
margin-bottom: 24px;
padding: 12px 16px;
position: relative;
text-align: center;
// height: 128px;
background: #ffffff;
border-radius: 4px;
border: 1px solid #e6e6e6;
padding: 14px 24px;
box-sizing: border-box;
&:nth-child(4n) {
margin-right: 0px;
}
&.checked {
background: rgba(88, 80, 255, 0.1);
border: 1px solid #5850ff;
}
&-qrcode {
position: absolute;
right: 10px;
bottom: 10px;
width: 60px;
height: 60px;
border: 1px solid #979797;
}
&-title {
font-size: 18px;
font-weight: 600;
color: #333333;
line-height: 25px;
margin-bottom: 5px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.img-pdf {
width: 40px;
height: 40px;
margin-top: 10px;
}
.img-material {
width: 72px;
height: 72px;
object-fit: fill;
}
&-content {
font-size: 12px;
font-weight: 400;
color: #666666;
line-height: 16px;
height: 16px;
margin-top: 6px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
&.model-item-weight {
line-height: 20px;
height: 20px;
}
span {
color: #5850ff;
font-size: 20px;
}
}
&-contents {
line-height: 22px;
height: 22px;
}
}
}
}
</style>
<template>
<div class="square-main">
<el-dialog title="选择模板" :visible.sync="dialogVisible" width="1142px" :before-close="handleClose" :close-on-click-modal="false">
<div class="model-panel" v-loading="messageLoading">
<el-form :inline="true" class="message-form" :model="searchForm" ref="searchForm">
<el-form-item label="模板标题" size="small">
<el-input v-model="searchForm.title" :size="size" placeholder="请输入模板名称搜索"></el-input>
</el-form-item>
<el-form-item label="创建者" size="small" style="margin-left: 10px">
<el-select v-model="searchForm.createdBy" :size="size" placeholder="全部">
<el-option v-for="item in createdList" :key="item.id" :label="item.createdName" :value="item.createdBy"></el-option>
</el-select>
</el-form-item>
<el-form-item size="small" style="margin-left: 10px">
<el-button type="primary" :size="size" @click="search">查询</el-button>
</el-form-item>
<el-form-item style="float: right; margin-right: 0">
<el-button :size="size" icon="el-icon-plus" @click="createModel">新增模板</el-button>
</el-form-item>
</el-form>
<!-- <div class="model-panel-tab">
<label>模板类型:</label>
<el-tabs v-model="activeName" @tab-click="handleClick" type="card">
<el-tab-pane label="售前" name="1"></el-tab-pane>
<el-tab-pane label="售中" name="2"></el-tab-pane>
<el-tab-pane label="售后" name="3"></el-tab-pane>
</el-tabs>
</div>-->
<div class="model-item-panel" v-if="!loading && modelList.length > 0" v-loading="loading">
<div class="model-item" v-for="item in modelList" :key="item.id">
<div class="model-item-radio">
<el-radio v-model="messageRadio" :label="item"></el-radio>
</div>
<div class="model-item-title">
<div class="model-title-h1">{{ item.title }}</div>
<div class="model-title-h2">{{ item.content }}</div>
</div>
<div class="model-item-content">
<div class="model-content">创建人:{{ item.createdName }}</div>
<div class="model-content">创建日期:{{ item.createdTime }}</div>
</div>
<div class="model-item-btn">
<el-button v-if="item.createdBy == userId" type="text" :size="size" @click="editModel(item.id)">编辑</el-button>
</div>
</div>
</div>
<div class="model-item-panel" v-else>
<img src="../../../assets/empty.png" />
<div class="empty-item">暂无数据</div>
</div>
<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize" :total="tableTotal" :layout="layout"></el-pagination>
</div>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="handleClose">取 消</el-button>
<el-button size="small" type="primary" @click="selectModelItem">复制文本</el-button>
</span>
</el-dialog>
<el-dialog :title="modelTitle" :visible.sync="createVisible" width="547px" :before-close="handleCreateClose" :close-on-click-modal="false">
<el-form :model="templateForm" :rules="templateRules" ref="templateForm" label-width="100px" class="templateForm">
<el-form-item label="标题" prop="title">
<el-input v-model="templateForm.title" maxlength="10" show-word-limit placeholder="输入10个字以内的标题,如活动促销"></el-input>
</el-form-item>
<el-form-item label="内容说明" prop="content">
<el-input type="textarea" v-model="templateForm.content" maxlength="600" :rows="7" show-word-limit placeholder="输入不超过600字内的文字说明"></el-input>
</el-form-item>
</el-form>
<div class="template-footer">
<el-button size="small" @click="createModel">取 消</el-button>
<el-button size="small" type="primary" :loading="createLoading" @click="handleCreate">立即创建</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'MessageModel',
data() {
return {
dialogVisible: false,
createVisible: false,
loading: false,
activeName: '1',
messageRadio: {},
messageLoading: false,
modelList: [
// {
// title: '121',
// content: 'jlkjl就离开家离开家离开jlkjl就离开家离开家离开jlkjl就离开家离开家离开jlkjl就离开家离开家离开jlkjl就离开家离开家离开jlkjl就离开家离开家离开jlkjl就离开家离开家离开',
// createdTime: '2022-01-04'
// }
],
pageNum: 1,
pageSize: 10,
tableTotal: 0,
layout: '',
searchForm: {},
templateForm: {},
templateRules: {
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
content: [{ required: true, message: '请输入标题', trigger: 'blur' }]
},
createLoading: false,
createdList: [],
modelTitle: '创建群发模板',
userId: ''
}
},
mounted() {
console.log(this.$globalState, '222323')
if (this.$globalState) {
this.userId = this.$globalState.session.id
}
},
props: {
messageList: Object
},
methods: {
init() {
this.messageLoading = true
this.pageNum = 1
this.messageRadio = {}
this.dialogVisible = true
this.dracImMessage()
this.getCreatedList()
},
selectModelItem() {
this.dialogVisible = false
this.$emit('selectItem', this.messageRadio)
},
handleClick() {
this.dracImMessage()
},
search() {
this.dracImMessage(this.searchForm)
},
handleClose() {
this.dialogVisible = false
this.modelList = []
this.tableTotal = 0
},
dracImMessage(searcher) {
this.modelList = []
this.loading = true
let params = {
pageSize: this.pageSize,
pageNum: this.pageNum
}
if (searcher) {
params.title = searcher.title
params.createdBy = searcher.createdBy
}
const { templateApi } = this.messageList
templateApi(params).then(res => {
if (res) {
this.modelList = res.data
this.tableTotal = res.count
if (res.count > 10) {
this.layout = 'pager'
}
}
this.loading = false
})
},
handleSizeChange(val) {
console.log(`每页 ${val} 条`)
},
handleCurrentChange(val) {
this.pageNum = val
this.dracImMessage()
console.log(`当前页: ${val}`)
},
createModel() {
this.createVisible = !this.createVisible
if (!this.createVisible) {
this.templateForm = {}
}
},
handleCreate() {
this.$refs.templateForm.validate(valid => {
if (valid) {
console.log(this.templateForm)
this.createLoading = true
const params = {
title: this.templateForm.title,
content: this.templateForm.content
}
const { templateSaveApi, templateUpdateApi } = this.messageList
let api = templateSaveApi
if (this.templateForm.id) {
api = templateUpdateApi
params.id = this.templateForm.id
}
api(params).then(res => {
console.log(res)
this.createLoading = false
if (res) {
this.$message({
type: 'success',
message: '操作成功!'
})
this.pageNum = 1
this.createModel()
this.dracImMessage()
}
})
}
})
},
editModel(id) {
this.createModel()
this.modelTitle = '编辑群发模板'
this.getTemplateDetail(id)
},
getCreatedList() {
const { getSearchApi } = this.messageList
getSearchApi({}).then(res => {
this.createdList = res
this.$nextTick(() => {
this.messageLoading = false
})
})
},
getTemplateDetail(id) {
const { templateDetailApi } = this.messageList
templateDetailApi({ id }).then(res => {
console.log(res)
if (res) {
this.templateForm = res
}
})
}
}
}
</script>
<style lang="scss" scoped>
.model-panel {
padding: 0 20px;
.model-panel-tab {
display: flex;
align-items: center;
margin-bottom: 18px;
label {
font-size: 16px;
font-weight: 400;
color: #000000;
line-height: 24px;
}
/deep/ {
.el-checkbox:last-of-type {
margin-right: 8px;
}
.el-tabs__nav {
border: 0;
}
.el-tabs__header {
border: 0;
background-color: #f4f6fc;
margin: 0px;
}
.el-tabs__item {
border: none;
width: 180px;
height: 32px;
line-height: 32px;
margin: 2px;
text-align: center;
}
.el-tabs__item.is-active {
background-color: #fff;
border-radius: 4px;
}
}
}
.model-item-panel {
max-height: 400px;
overflow: auto;
> img {
display: block;
margin: 50px auto 0px;
width: 60px;
height: auto;
}
.empty-item {
text-align: center;
font-size: 14px;
font-weight: 400;
color: #000000;
line-height: 22px;
margin-bottom: 30px;
}
.model-item {
display: flex;
padding: 20px;
border-bottom: 1px solid #e9e9e9;
&:last-child {
border-bottom: none;
}
&-radio {
width: 60px;
/deep/ {
.el-radio__input {
margin-top: 10px;
}
.el-radio__label {
display: none;
}
}
}
&-content {
min-width: 210px;
margin-right: 50px;
.model-content {
font-size: 14px;
font-weight: 400;
color: #999999;
line-height: 20px;
}
}
&-title {
flex: 1;
.model-title-h1 {
font-size: 14px;
font-weight: 400;
max-width: 658px;
color: #333333;
line-height: 20px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.model-title-h2 {
font-size: 14px;
font-weight: 400;
color: #999999;
line-height: 20px;
max-width: 658px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
&-btn {
width: 30px;
height: 40px;
}
}
}
}
.message-form .el-form-item {
margin-bottom: 0 !important;
}
/deep/ .el-pager {
height: 30px;
}
.el-pagination {
margin-top: 21px;
}
.templateForm {
padding: 0 20px;
/deep/ {
.el-textarea__inner {
background-color: #fff;
}
.el-textarea .el-input__count {
background-color: #fff;
}
}
}
.template-footer {
text-align: center;
border-top: 1px solid #e6e6e6;
padding-top: 16px;
margin-bottom: -14px;
}
/deep/ {
.el-dialog__body {
padding: 30px 0;
}
}
</style>
<template>
<div class="w-textarea" ref="wTextarea" v-bind="$attr">
<div contenteditable="true" class="w-textarea_input" ref="wTextareaContent" :id="contentId" @click="inputClick($event)" @focus="onFocus" @blur="onBlur" @keydown.delete="handleDelete($event)" @input="handleInput($event.target)"></div>
<!-- <div class="w-textarea_tools" v-if="tools.length > 0 || maxlength">
<button
class="w-textarea_tools__item"
v-for="item in tools"
:key="item.type"
@click="openTagDialog(item.type)"
>{{item.text}}</button>
<span
:class="['w-textarea_tools__text',
count.num < 0 ? '__danger' : '']"
v-if="maxlength"
>{{count.text}}</span>
</div>-->
<!-- <div class="w-textarea_dialog">
<slot></slot>
</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)
},
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)
},
promiseAdd(item, num) {
return new Promise((resolve, reject) => {
setTimeout(() => {
document.querySelector('.w-textarea_input').innerHTML += item
document.querySelector('.w-textarea_input').focus()
resolve()
}, num * 100)
})
},
promiseAddNode(item, num) {
return new Promise((resolve, reject) => {
setTimeout(() => {
document.querySelector('.w-textarea_input').innerHTML += item
document.querySelector('.w-textarea_input').focus()
resolve()
}, num * 100)
})
},
addContent(attContent) {
attContent.forEach(async (item, index) => {
await this.promiseAdd(item, index)
this.addTag('@昵称')
// await this.promiseAddNode(item, index)
// this.addNode()
// t2(item)
})
// for (let i = 0; i < attContent.length; i++) {
// if (attContent[i] || (i == 0 && !attContent[i])) {
// document.querySelector('.w-textarea_input').innerHTML += attContent[i]
// document.querySelector('.w-textarea_input').focus()
// document.querySelector('.w-textarea_input').click()
// this.$nextTick(()=>{
// this.addTag('@昵称')
// })
// }
// // 代码格式
// // (function(a) {})(b)
// }
},
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)
}
},
insertNodeFirst(node) {
this.savedRange.deleteContents()
// 插入链接
if (this.isInsert) {
this.savedRange.insertNode(node)
} else {
document.querySelector('.w-textarea_input').appendChild(node)
}
this.isInsert = false
// 更新双向绑定数据
let target = this.$refs.wTextareaContent
if (navigator.userAgent.indexOf('Firefox') > 0 || navigator.userAgent.indexOf('QQBrowser') > 0) {
this.updateData(target.innerHTML + '&nbsp;')
} else {
this.updateData(target.innerHTML)
}
let htm = target.innerHTML
const list = emoji.flat(Infinity)
const cutImg = htm
.replace(/<img src="https:\/\/img01.glsx.com.cn\/weapp\/resource\/saas\/scrm\/emoji/g, '')
.replaceAll('<wise id="1">@昵称</wise>', '@昵称')
.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.substring(0, 600)
console.log(this.currentText)
this.$emit('updateText', this.currentText)
},
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
console.log(htm)
const list = emoji.flat(Infinity)
const cutImg = htm.replaceAll('<img src="https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/', '')
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 = Textnode.innerText.substring(0, 600)
this.$emit('updateText', this.currentText)
},
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 {
border-radius: 2px;
background-color: #fff;
font-size: 14px;
color: #5850ff;
line-height: 20px;
padding: 2px;
margin: 0 5px;
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>
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
</div> </div>
</template> </template>
<script> <script>
import { utils } from 'glsx-common'
export default { export default {
name: 'GLFooter', name: 'GLFooter',
props: { props: {
...@@ -21,20 +22,24 @@ export default { ...@@ -21,20 +22,24 @@ export default {
data() { data() {
return { return {
footerLeft: 0, footerLeft: 0,
footerWidth: 0 footerWidth: 0,
aside: ''
} }
}, },
methods: { methods: {
resize() { resize: utils.debounce(function () {
this.footerLeft = document.querySelector(this.className)?document.querySelector(this.className).offsetLeft : 0 this.footerLeft = document.querySelector(this.className) ? document.querySelector(this.className).offsetLeft : 0
this.footerWidth = document.documentElement.clientWidth - this.footerLeft this.footerWidth = document.documentElement.clientWidth - this.footerLeft
} }, 100)
}, },
destroyed() { destroyed() {
window.removeEventListener('resize', this.resize) window.removeEventListener('resize', this.resize)
this.aside && this.aside.removeEventListener('DOMSubtreeModified', this.resize)
}, },
mounted() { mounted() {
this.resize() this.resize()
this.aside = document.querySelector('.base-container-aside')
this.aside && this.aside.addEventListener('DOMSubtreeModified', this.resize)
window.addEventListener('resize', this.resize) window.addEventListener('resize', this.resize)
} }
} }
...@@ -45,10 +50,10 @@ export default { ...@@ -45,10 +50,10 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: fixed; position: static !important;
bottom: 0px; bottom: 0px;
height: 64px; height: 64px;
background: #ffffff; background: #ffffff;
box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1); box-shadow: none !important;
} }
</style> </style>
import GLFull from './src/index.vue'
// 为组件提供 install 安装方法,供按需引入
GLFull.install = function (Vue) {
Vue.component(GLFull.name, GLFull)
}
// 默认导出组件
export default GLFull
<template>
<div class="full-container">
<el-tooltip placement="top" v-if="hoverStatus">
<div slot="content">
<template v-if="$slots.default"><slot></slot></template>
<template v-else>
{{ label }}
</template>
</div>
<div :class="['full-text', identification]" :style="{ width: labelWidth + 'px' }" @mouseenter="hoverFun" v-if="textType != 'text' && !haveClose">
<el-tag type="info" class="full-text" :disable-transitions="false">
<i class="el-icon-user-solid" v-if="textType == 'user'"></i>
{{ label }}
</el-tag>
</div>
<div v-if="textType != 'text' && haveClose" @mouseenter="hoverFun">
<el-tag class="tag-user-closable" :style="{ 'max-width': labelWidth + 'px' }" type="info" :disable-transitions="false" closable @close="handleRemove">
<i class="el-icon-user-solid" v-if="textType == 'user'"></i>
<span :class="['full-text-user', { 'user-icon-checked': textType == 'user' && haveClose }, identification]">{{ label }}</span>
</el-tag>
</div>
<div :class="[line ? 'full-text-line' : 'full-text', identification]" @mouseenter="hoverFun" :style="{ width: labelWidth + 'px', '-webkit-line-clamp': line }" v-if="textType == 'text'">
<template v-if="$slots.default"><slot></slot></template>
<template v-else>
{{ label }}
</template>
</div>
</el-tooltip>
<template v-else>
<div :class="['full-text', identification]" @mouseenter="hoverFun" :style="{ width: labelWidth + 'px' }" v-if="textType != 'text' && !haveClose">
<el-tag type="info" class="full-text" :disable-transitions="false">
<i class="el-icon-user-solid" v-if="textType == 'user'"></i>
{{ label }}
</el-tag>
</div>
<div @mouseenter="hoverFun" v-if="textType != 'text' && haveClose">
<el-tag class="tag-user-closable" type="info" :style="{ 'max-width': labelWidth + 'px' }" :disable-transitions="false" closable @close="handleRemove">
<i class="el-icon-user-solid" v-if="textType == 'user'"></i>
<span :class="['full-text-user', identification]">{{ label }}</span>
</el-tag>
</div>
<div :class="[line ? 'full-text-line' : 'full-text', identification]" @mouseenter="hoverFun" :style="{ width: labelWidth + 'px', '-webkit-line-clamp': line }" v-if="textType == 'text'">
<template v-if="$slots.default"><slot></slot></template>
<template v-else>
{{ label }}
</template>
</div>
</template>
</div>
</template>
<script>
export default {
name: 'GLFull',
data() {
return {
hoverStatus: false
}
},
props: {
//唯一标识
identi: {
type: String,
default: 'identi'
},
//文本
label: {
type: String,
default: ''
},
//文本宽度
labelWidth: {
type: Number,
default: 100
},
//行数
line: {
type: Number,
default: 0
},
textType: {
type: String,
default: 'text', // text 文本 user 跟进员工 tag 标签
validator: function (value) {
return ['text', 'user', 'tag'].indexOf(value) !== -1
}
},
//是否包含关闭按钮
haveClose: {
type: Boolean,
default: false
}
},
computed: {
identification() {
return 'text_' + this.identi
}
},
methods: {
hoverFun() {
if (this.haveClose) {
//this.hoverStatus = this.identi ? document.querySelector(`.${this.identification}`).scrollWidth > document.querySelector(`.${this.identification}`).offsetWidth : document.querySelector(`.full-text`).scrollWidth > this.labelWidth - 30
this.hoverStatus = document.querySelector(`.${this.identification}`).scrollWidth > document.querySelector(`.${this.identification}`).offsetWidth
} else {
let widthMuti = this.textType == 'user' ? 17 : this.textType == 'tag' ? 20 : 0
// this.hoverStatus = this.identi ? document.querySelector(`.${this.identification}`).scrollWidth - widthMuti > this.labelWidth : document.querySelector(`.full-text`).scrollWidth > this.labelWidth
this.hoverStatus = document.querySelector(`.${this.identification}`).scrollWidth - widthMuti > this.labelWidth
}
},
handleRemove() {
this.$emit('handleRemove')
}
}
}
</script>
<style scoped lang="scss">
.full-container {
display: inline-block;
/deep/ {
.el-tag {
height: 26px;
line-height: 26px;
}
}
}
.full-text {
max-width: 100%;
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.full-text-user {
max-width: calc(100% - 14px);
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
&.user-icon-checked {
max-width: calc(100% - 30px);
}
}
.tag-user-closable {
display: flex;
align-items: center;
/deep/ {
.el-icon-close {
margin-top: 2px;
}
}
}
.full-text-line {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
word-break: break-all;
}
.el-icon-user-solid {
color: #75acff;
margin-right: 3px;
font-size: 14px;
}
</style>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
// 导入颜色选择器组件 // 导入颜色选择器组件
// import '@/plugins/element.js' // import '@/plugins/element.js'
import { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu ,Dialog,MessageBox} from '@/plugins/element.js' import { Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox } from '@/plugins/element.js'
import '@/theme/theme.scss' import '@/theme/theme.scss'
// 一次性注册所有的过滤器 本地测试 // 一次性注册所有的过滤器 本地测试
...@@ -24,16 +24,19 @@ import GLTableButton from './GlTableButton' ...@@ -24,16 +24,19 @@ import GLTableButton from './GlTableButton'
// 导入业务组件 // 导入业务组件
import GLProvince from './GLProvince' import GLProvince from './GLProvince'
import GLFull from './GLFull'
import GLEditor from './Editor'
import GLBcTest from '@/bcPackages/GLBcTest' import GLBcTest from '@/bcPackages/GLBcTest'
//el原始组件 //el原始组件
const ElComponent = [Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu,Dialog,MessageBox] const ElComponent = [Table, TableColumn, Popover, Button, ButtonGroup, Loading, Input, Form, FormItem, Pagination, Tooltip, Icon, Select, Option, DatePicker, Dropdown, DropdownItem, DropdownMenu, Dialog, MessageBox]
// 业务组件导入列表 // 业务组件导入列表
const BcComponent = [GLBcTest] const BcComponent = [GLBcTest]
// 存储组件列表 // 存储组件列表
const components = [TestComp, GLExternal, GLButton, GLDialog, GLTable, GLFooter, GLSearch, GLSearchItem, GLCombiForm, GLTableButton, GLProvince].concat(ElComponent).concat(BcComponent) const components = [TestComp, GLExternal, GLButton, GLDialog, GLTable, GLFooter, GLSearch, GLSearchItem, GLCombiForm, GLTableButton, GLProvince, GLFull, GLEditor].concat(ElComponent).concat(BcComponent)
// console.log('components: ', components); // console.log('components: ', components);
// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册 // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
...@@ -46,7 +49,7 @@ const install = function (Vue) { ...@@ -46,7 +49,7 @@ const install = function (Vue) {
if (install.installed) return if (install.installed) return
// 遍历注册全局组件 // 遍历注册全局组件
components.map(component => { components.map(component => {
if(!component.name) return if (!component.name) return
Vue.component(component.name, component) Vue.component(component.name, component)
}) })
} }
...@@ -60,10 +63,10 @@ if (typeof window !== 'undefined' && window.Vue) { ...@@ -60,10 +63,10 @@ if (typeof window !== 'undefined' && window.Vue) {
* @param {*} compArr 组件数组,将他们转化为obj导出 * @param {*} compArr 组件数组,将他们转化为obj导出
* @returns compObj {} * @returns compObj {}
*/ */
const getNameComp = (compArr)=>{ const getNameComp = compArr => {
if (compArr.length === 0) return if (compArr.length === 0) return
let compObj = {} let compObj = {}
compArr.forEach((item)=>{ compArr.forEach(item => {
compObj[item.name] = item compObj[item.name] = item
}) })
return compObj return compObj
...@@ -87,6 +90,7 @@ export default { ...@@ -87,6 +90,7 @@ export default {
GLTableButton, GLTableButton,
//业务组件 //业务组件
GLProvince, GLProvince,
GLBcTest GLBcTest,
GLFull,
GLEditor
} }
const emoji = [
['微笑', '撇嘴', '色', '发呆', '得意', '流泪', '害羞', '闭嘴'],
['睡', '大哭', '尴尬', '发怒', '调皮', '呲牙', '惊讶', '难过'],
['酷', '囧', '抓狂', '吐', '微笑', '愉快', '白眼', '傲慢'],
['饥饿', '困', '惊恐', '流汗', '憨笑', '大兵', '奋斗', '咒骂'],
['疑问', '嘘', '晕', '折磨', '衰', '骷髅', '敲打', '再见'],
['擦汗', '抠鼻', '鼓掌', '糗大了', '坏笑', '左哼哼', '右哼哼', '哈欠'],
['鄙视', '委屈', '快哭了', '阴险', '亲亲', '吓', '可怜', '菜刀'],
['西瓜', '啤酒', '篮球', '乒乓', '咖啡', '饭', '猪头', '玫瑰'],
['凋谢', '示爱', '爱心', '心碎', '蛋糕', '闪电', '炸弹', '刀'],
['足球', '瓢虫', '便便', '月亮', '太阳', '礼物', '拥抱', '强'],
['弱', '握手', '胜利', '抱拳', '勾引', '拳头', '差劲', '爱你'],
['NO', 'OK', '爱情', '飞吻', '跳跳', '发抖', '怄火', '转圈'],
['磕头', '回头', '跳绳', '投降', '挥手', '激动', '街舞', '左太极'],
['右太极', '嘿哈', '捂脸', '奸笑', '机智', '皱眉', '耶', '社会社会'],
['让我看看', '666', '红包', '蜡烛', '烟花', '福', '庆祝', '爆竹']
]
export default emoji
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!