Commit 3303cbb7 by 前端

Merge branch 'v3.24.0' into 'master'

上线合并

See merge request !9
2 parents c5352860 f554cd44
...@@ -239,6 +239,47 @@ const getTypeListApi = params => { ...@@ -239,6 +239,47 @@ const getTypeListApi = params => {
}) })
} }
/**
* 创建积分提醒短信
*/
const createSmsApi = params => {
params.method = 'scrm.api.shopmall.integral.remind.msg.create'
return http({
url: 'rop-scrm-shopmall/router',
data: params
})
}
/**
* 积分提醒短信详情
*/
const getSmsDetailApi = params => {
params.method = 'scrm.api.shopmall.integral.remind.msg.detail'
return http({
url: 'rop-scrm-shopmall/router',
data: params
})
}
/**
* 开关提醒短信
*/
const openSmsApi = params => {
params.method = 'scrm.api.shopmall.integral.remind.msg.onOff'
return http({
url: 'rop-scrm-shopmall/router',
data: params
})
}
/**
* 触达客户
*/
const smsCustomerApi = params => {
params.method = 'scrm.api.shopmall.integral.remind.record.page'
return http({
url: 'rop-scrm-shopmall/router',
data: params
})
}
export default { export default {
getList, getList,
getOrderDetail, getOrderDetail,
...@@ -260,5 +301,9 @@ export default { ...@@ -260,5 +301,9 @@ export default {
getIntegralDetail, getIntegralDetail,
getCustomerIntegralList, getCustomerIntegralList,
auditIntegral, auditIntegral,
getTypeListApi getTypeListApi,
createSmsApi,
getSmsDetailApi,
openSmsApi,
smsCustomerApi
} }
<!-- 搜索 --> <!-- 搜索 -->
<template> <template>
<div :class="['glsx-combi-form', isEdit ? 'gl-form-page' : '']"> <div :class="['glsx-combi-form', isEdit ? 'gl-form-page' : '']">
<el-form :ref="formRef" :inline="true" :model="formObj" :rules="formRules" size="small" class="glsx-combi-form-block"> <el-form :ref="formRef" :inline="isInline" :model="formObj" :rules="formRules" size="small" class="glsx-combi-form-block">
<template v-for="(item, index) in formData"> <template v-for="(item, index) in formData">
<el-form-item v-if="!item.isHide" :key="index" :id="item.name" :labelWidth="isEdit ? '154px' : labelWidth" :class="[{ 'no-label': !item.label, isBlock: isBlock }, { textBox: item.type == 'textBox' }]" :style="{ 'margin-bottom': isEdit ? '24px' : '', 'margin-right': isEdit ? '0px' : '30px', ...item.style }" :label="item.label" :prop="item.name"> <el-form-item v-if="!item.isHide" :key="index" :id="item.name" :labelWidth="isEdit ? '154px' : labelWidth" :class="[{ 'no-label': !item.label, isBlock: isBlock }, { textBox: item.type == 'textBox' }]" :style="{ 'margin-bottom': isEdit ? '24px' : '', 'margin-right': isEdit ? '0px' : '30px', ...item.style }" :label="item.label" :prop="item.name">
<span v-if="!item.isHide && item.tips" class="tips-block" slot="label"> <span v-if="!item.isHide && item.tips" class="tips-block" slot="label">
...@@ -116,6 +116,10 @@ export default { ...@@ -116,6 +116,10 @@ export default {
} }
}, },
props: { props: {
isInline: {
type: Boolean,
default: true
},
isBlock: { isBlock: {
type: Boolean, type: Boolean,
default: false default: false
......
<template>
<div class="sms-container">
<div class="sms-content">
<glsx-combi-form :isInline="false" class="glsx-combi-form" ref="baseInfoRef" labelWidth="154px" defaultWidth="432px" :formObj.sync="formObj" :formData="formData" :formRules="myRule">
<template v-for="(item, index) in form_solt">
<div :key="index" :slot="item.name">
<el-switch @change="openSmsByHttp($event, formObj[item.attr])" v-model="formObj[item.attr].switch" :active-value="true" :inactive-value="false"></el-switch>
<div style="position: relative" class="wrapper">
<div class="topSet flex">
<span>发送时间:积分到账</span>
<div class="set-int">
<el-input @change="onchangeInput" class="intTime" v-model="formObj[item.attr].time" maxlength="4" oninput="if(value){value=value.replace(/[^\d]/g,'')} if(value<=0){value=''} if(value>1000){value=1000}" placeholder="请输入"></el-input>
</div>
<span>小时后,未提现或兑换时发送</span>
</div>
<div class="sms-box">
<div class="left">群发内容:</div>
<div class="right">
<wTextarea maxlength="500" :value="formObj[item.attr].messageContext" :ref="item.attr" class="textarea" @updateText="updateText($event, item.attr)" :style="{ 'min-height': boxHeight + 'px' }"></wTextarea>
<div class="word-limit">
<span :class="[{ redColorText: formObj[item.attr].text.length > 500 }]">{{ formObj[item.attr].text.length || 0 }}</span>
/500
</div>
<div class="select-panel">
<div @click="handleSelectMessage($event, item.attr, '短链')" class="flex marl24">
<img src="@/images/link.png" class="link" />
<span class="">短链</span>
</div>
<div @click="handleSelectMessage($event, item.attr, '客户积分')" class="flex marl24">
<img src="@/images/jifen.png" class="link" />
<span class="">客户积分</span>
</div>
<div @click="handleSelectMessage($event, item.attr, '客户姓名')" class="flex">
<img src="@/images/username.png" class="link" />
<span class="">客户姓名</span>
</div>
</div>
<div class="showSmsModel">
<span>【{{ formObj.miniId }}】</span>
<span v-html="highText(formObj[item.attr].model)" v-if="formObj[item.attr].model"></span>
<span>拒收请回复R</span>
</div>
</div>
</div>
</div>
</div>
</template>
</glsx-combi-form>
</div>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter>
</div>
</template>
<script type='text/ecmascript-6'>
import glsxCombiForm from '@/components/glsx-combi-form'
import wTextarea from './tag-textarea.vue'
const DJ_MINI_APPID = '车生活助手'
const MINI = [
{
confId: DJ_MINI_APPID,
confName: '车生活助手'
}
]
export default {
name: 'add',
props: {},
components: {
glsxCombiForm,
wTextarea
},
data() {
return {
boxHeight: 178,
myRule: {
miniId: [{ required: true, message: '短信签名', trigger: 'change' }]
},
formObj: {
miniId: DJ_MINI_APPID,
message_first: {
messageContext: '',
switch: false,
time: null,
model: null,
text: '',
name: '短信一',
msgNo: 1
},
message_second: {
messageContext: '',
switch: false,
time: null,
model: null,
text: '',
name: '短信二',
msgNo: 2
},
message_three: {
messageContext: '',
switch: false,
time: null,
model: null,
text: '',
name: '短信三',
msgNo: 3
}
},
formData: [
{
label: '短信签名',
name: 'miniId',
type: 'select',
isDisabled: false,
optionList: MINI,
optionId: 'confId',
optionLabel: 'confName',
changeAttr: val => {}
},
{
label: '短信一',
name: 'smsFirst',
addHtml: 'smsSlot1'
},
{
label: '短信二',
name: 'smsFirst',
addHtml: 'smsSlot2'
},
{
label: '短信三',
name: 'smsFirst',
addHtml: 'smsSlot3'
}
],
form_solt: [
{
name: 'smsSlot1',
attr: 'message_first'
},
{
name: 'smsSlot2',
attr: 'message_second'
},
{
name: 'smsSlot3',
attr: 'message_three'
}
]
}
},
mounted() {
this.getSMSDetail()
},
methods: {
// 信息文案处理高亮和字数限制
highText(title) {
const shortLink = '#短链#',
customerJf = '#客户积分#',
customerName = '#客户姓名#'
// 如果标题中包含,关键字就替换一下
if (title.length > 500) {
title = title.substring(0, 500)
}
if (title.includes(shortLink)) {
title = title.replaceAll(shortLink, '<font style="color:#5092FF !important;">' + shortLink + '</font>')
}
if (title.includes(customerJf)) {
title = title.replaceAll(customerJf, '<font style="color:#5850ff !important;">' + customerJf + '</font>')
}
if (title.includes(customerName)) {
title = title.replaceAll(customerName, '<font style="color:#5850ff !important;">' + customerName + '</font>')
}
return title
},
// 获取标签文案
subText(htm) {
const cutImg = htm
.replace(/<wise.+?>(.+?)(?:<\/wise>)/g, '$1')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&amp;/g, '&')
.replace(/(\n|\s|&nbsp;)/g, '')
.replace(/<br>/g, '\n')
.replace(/<span>([\s\S]*?)<\/span>/g, '$1')
.replace(/<div>([\s\S]*?)<\/div>/g, '$1')
return cutImg
},
// 编辑器文案获取
updateText(html, type) {
const text = JSON.stringify(html)
const linkText = JSON.parse(this.subText(text))
if (html) {
this.formObj[type].model = linkText
} else {
this.formObj[type].model = null
}
this.formObj[type].messageContext = html
this.formObj[type].text = linkText
this.editStatus = true
},
// 点击标签
handleSelectMessage(e, type, textName) {
const _refs = this.$refs[type][0]
// if (_refs.currentText.indexOf(`#${textName}#`) != -1) {
// return
// }
_refs.addTag(`#${textName}#`)
this.editStatus = true
},
// 提交
handleSave() {
const params = this.handlerParams()
if (Array.isArray(params)) {
if(!params.length)return this.$message({ message: '请选择需要提交的短信',type: 'error'})
this.$apis.points.createSmsApi({ msgList: params }).then(res => {
if (res) {
this.editStatus = false
this.$message({
message: '提交成功',
type: 'success'
})
this.getSMSDetail()
} else {
this.$message({
message: res.message,
type: 'error'
})
}
})
}
},
handleCancel() {
if (this.editStatus) {
this.$confirm('当前有内容信息未保存,是否继续返回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.$router.back()
})
.catch(() => {})
} else {
this.$router.back()
}
},
//处理提交参数
handlerParams() {
const _temp = this.$common.utils.deepClone(this.formObj)
delete _temp.miniId
let isHaveOpen = false,
needCheckList = [],
params = []
// 筛选已打开的短信模块
for (let k in _temp) {
const target = _temp[k]
if (target.switch || target.id) {
isHaveOpen = true
needCheckList.push(target)
}
}
// 检查已打开的短信模块内容
if (isHaveOpen) {
let isHaveBlack = false,
errName = '',
errTitle = '发送时间'
needCheckList.forEach(el => {
if (!el.time) {
isHaveBlack = true
errName = el.name
errTitle = '发送时间'
} else if (!el.text) {
isHaveBlack = true
errName = el.name
errTitle = '群发内容'
}
})
if (isHaveBlack) return this.$message.error(`请填写${errName}${errTitle}`)
// 比较发送时间是否填写正确短信1<短信2<短信3
let isHaveTimeErr = false,
errName2 = ''
for (let i = 0; i < needCheckList.length; i++) {
let start = needCheckList[i],
end = needCheckList[i + 1]
if (end && (Number(start.time) > Number(end.time) || Number(start.time) == Number(end.time))) {
isHaveTimeErr = true
errName = start.name
errName2 = end.name
}
}
if (isHaveTimeErr) return this.$message.error(`${errName2}发送时间需大于${errName}发送时间`)
needCheckList.forEach(el => {
let obj = {
msgType: 1,
msgNo: el.msgNo,
msgSign: this.formObj.miniId,
delayTime: el.time,
msgContent: el.text,
openType: el.switch ? 1 : 2
}
if (el.id) obj.id = el.id
params.push(obj)
})
}
return params
},
// 处理详情回显标签内容
handlerDetailTagContent(tagContent) {
const shortLink = '#短链#',
customerJf = '#客户积分#',
customerName = '#客户姓名#'
if (tagContent.includes(shortLink)) {
const rid = `r${new Date().getTime()}d${Math.ceil(Math.random() * 1000)}`
tagContent = tagContent.replaceAll(shortLink, `<span></span><wise id="${rid}">${shortLink}</wise>`)
}
if (tagContent.includes(customerJf)) {
const rid = `r${new Date().getTime()}d${Math.ceil(Math.random() * 1000)}`
tagContent = tagContent.replaceAll(customerJf, `<span></span><wise id="${rid}">${customerJf}</wise>`)
}
if (tagContent.includes(customerName)) {
const rid = `r${new Date().getTime()}d${Math.ceil(Math.random() * 1000)}`
tagContent = tagContent.replaceAll(customerName, `<span></span><wise id="${rid}">${customerName}</wise>`)
}
return tagContent
},
// 获取短信详情
getSMSDetail() {
this.$apis.points.getSmsDetailApi({ msgType: 1 }).then(res => {
if (res && Array.isArray(res)) {
res.forEach(el => {
if (el.msgNo == 1) {
this.formObj.message_first.messageContext = this.handlerDetailTagContent(el.msgContent)
this.formObj.message_first.switch = el.openType == 1 ? true : false
this.formObj.message_first.time = el.delayTime
this.formObj.message_first.model = el.msgContent
this.formObj.message_first.text = el.msgContent
this.formObj.message_first.id = el.id
} else if (el.msgNo == 2) {
this.formObj.message_second.messageContext = this.handlerDetailTagContent(el.msgContent)
this.formObj.message_second.switch = el.openType == 1 ? true : false
this.formObj.message_second.time = el.delayTime
this.formObj.message_second.model = el.msgContent
this.formObj.message_second.text = el.msgContent
this.formObj.message_second.id = el.id
} else if (el.msgNo == 3) {
this.formObj.message_three.messageContext = this.handlerDetailTagContent(el.msgContent)
this.formObj.message_three.switch = el.openType == 1 ? true : false
this.formObj.message_three.time = el.delayTime
this.formObj.message_three.model = el.msgContent
this.formObj.message_three.text = el.msgContent
this.formObj.message_three.id = el.id
}
})
}
})
},
// 短信开关触发接口
openSmsByHttp(e, item) {
if (item && item.id) {
const { id, msgNo, name } = item
const str = e ? `${name}已打开` : `${name}已关闭`
this.$apis.points.openSmsApi({ id, msgType: 1, msgNo, openType: e ? 1 : 2 }).then(res => {
if (res) {
this.editStatus = false
this.$message({
message: str,
type: 'success'
})
}
})
}
},
onchangeInput() {
this.editStatus = true
}
}
}
</script>
<style scoped lang='scss'>
.sms-content {
background: white;
padding: 38px 20px;
margin-bottom: 16px;
.textarea {
width: 592px !important;
background: white;
border-bottom: none;
}
.wrapper {
width: 778px;
box-sizing: border-box;
padding: 22px 20px 16px;
background: #f9f9f9;
.topSet {
font-weight: 400;
font-size: 14px;
color: #333333;
margin-bottom: 20px;
.set-int {
margin: 0 8px;
.intTime {
width: 80px;
height: 32px;
background: #ffffff;
font-weight: 400;
font-size: 14px;
color: #666666;
}
}
}
}
.sms-box {
display: flex;
.left {
font-weight: 400;
font-size: 14px;
color: #333333;
}
.right {
.word-limit {
background: white;
text-align: right;
font-weight: 400;
font-size: 14px;
color: #999999;
border: 1px solid #e5e5e5;
width: 592px !important;
box-sizing: border-box;
padding-right: 8px;
border-top: none;
height: 28px;
line-height: 28px;
}
.redColorText {
color: red !important;
}
.showSmsModel {
font-size: 14px;
font-weight: 400;
color: #333333;
width: 592px !important;
box-sizing: border-box;
margin-top: 8px;
line-height: 22px;
}
}
}
.select-panel {
padding-left: 20px;
background: #fafbfe;
display: flex;
font-size: 14px;
font-weight: 400;
color: #666666;
line-height: 40px;
border: 1px solid #e5e5e5;
width: 592px !important;
border-top: 0px;
box-sizing: border-box;
border-radius: 0 0 4px 4px;
cursor: pointer;
.flex {
display: flex;
align-items: center;
}
.marl24 {
margin-right: 24px;
}
.link {
width: 18px;
height: 18px;
margin-right: 4px;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="sms-customer">
<div class="filter-wrap">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
</div>
<div class="table-wrap">
<div class="out_wrap">
<div class="choseRow flex_scb">
<div class="wrap">
<div class="choseItem" :class="{ active: currentIndex == index }" v-for="(item, index) in choseList" :key="index" @click="tabClick(index)">
{{ item }}
</div>
</div>
</div>
</div>
<div class="table-box">
<GLTable ref="listRef" :beforeSearchFn="beforeSearchFn" :getListApi="getListApi" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf">>
<div class="sendTypeSlot" slot="sendTypeSlot" slot-scope="scope">
<div :class="[{colorSuccess:scope.scope.sendType==1,colorFail:scope.scope.sendType==2,colorWait:scope.scope.sendType==0}]"></div>
<span v-if="scope.scope.sendType!=2">{{scope.scope.sendType==1?'已发送':'待发送'}}</span>
<span v-if="scope.scope.sendType==2">发送失败</span>
</div>
</GLTable>
</div>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'customer',
props: {},
data() {
return {
searchForm: {
userPhone: '',
sendType: '',
merchantName: ''
},
searchFormData: [
{
label: '手机号',
name: 'userPhone',
type: 'input',
maxlength: 11
},
{
label: '状态',
name: 'sendType',
type: 'select',
maxlength: 100,
optionList: [
{ text: '全部', id: '' },
{ text: '待发送 ', id: '0' },
{ text: '已发送', id: '1' }
],
optionId: 'id',
optionLabel: 'text'
},
{
label: '所属门店',
name: 'merchantName',
type: 'input',
maxlength: 100
}
],
choseList: ['短信一', '短信二', '短信三'],
currentIndex: 0,
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
tableSearchForm: {},
getListApi: this.$apis.points.smsCustomerApi,
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '用户姓名',
prop: 'userName',
},
{
label: '用户手机号',
prop: 'userPhone',
},
{
label: '当前积分',
prop: 'currentIntegral'
},
{
label: '所属门店',
prop: 'merchantName'
},
{
label: '发送状态',
minWidth: 120,
addHtml:'sendTypeSlot'
},
{
label: '发送时间',
prop:'sendTime'
}
]
}
}
},
mounted() {},
methods: {
handleSearch() {
this.$refs.listRef.refreshTable()
},
handleReset() {
this.searchForm = this.$options.data.call(this).searchForm
this.$refs.listRef.refreshTable()
},
tabClick(index) {
this.currentIndex = index
this.$refs.listRef.refreshTable()
},
beforeSearchFn(){
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
getParams(){
let params = JSON.parse(JSON.stringify(this.searchForm))
params.msgType = 1
params.msgNo = +this.currentIndex+1
return params
}
}
}
</script>
<style scoped lang='scss'>
.filter-wrap {
padding: 20px 20px 0;
background: white;
}
.table-wrap {
margin-top: 16px;
}
.out_wrap {
position: relative;
z-index: 100;
margin-bottom: -1px;
}
.choseRow {
display: flex;
.choseItem {
display: inline-block;
box-sizing: border-box;
padding: 0 20px;
height: 40px;
line-height: 40px;
cursor: pointer;
margin-right: 1px;
border-radius: 4px 4px 0 0;
background: #fafafa;
font-weight: 400;
font-size: 14px;
color: #666666;
}
.active {
color: #5850ff;
background-color: white;
font-weight: 600;
border-bottom: none;
}
}
.flex_scb {
display: flex;
align-items: center;
justify-content: space-between;
}
.table-box {
box-sizing: border-box;
padding: 16px 20px;
border-radius: 0 4px 4px 4px;
background: white;
}
.sendTypeSlot{
display: flex;
align-items: center;
}
.colorWait,.colorFail,.colorSuccess{
background: #FDB757;
width: 6px;
height: 6px;
border-radius: 50%;
margin-right: 4px;
}
.colorSuccess{
background: #2CCA74;
}
.colorFail{
background: #EB4E4E;
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="sms-container">
<el-tabs v-model="curTabIndex" @tab-click="changeTab">
<el-tab-pane v-for="(item, index) in tabList" :key="index" :label="item.name" :name="item.conId">
<template v-if="item.conId == 'sms'">
<addCom></addCom>
</template>
<template v-if="item.conId == 'customer'">
<customerCom></customerCom>
</template>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import addCom from './add.vue'
import customerCom from './customer.vue'
export default {
name: 'index',
components: {
addCom,
customerCom
},
data() {
return {
tabList: [
{
name: '短信内容',
conId: 'sms'
},
{
name: '触达客户',
conId: 'customer'
}
],
curTabIndex: 'sms'
}
},
created() {},
mounted() {},
methods: {
changeTab() {}
}
}
</script>
<style lang="scss" scoped>
.sms-container {
/deep/ .el-tabs__item {
font-size: 16px !important;
}
}
</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>
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(`#${this.contentId}`).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(`#${this.contentId}`).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(`#${this.contentId}`).focus()
setTimeout(() => {
this.insertNodeFirst(node)
document.querySelector(`#${this.contentId}`).blur()
}, 100)
}
},
subText(htm) {
const cutImg = htm
// .replace(/<wise.+?>(.+?)(?:<\/wise>)/g, '$1')
// .replace(/&lt;/g, '<')
// .replace(/&gt;/g, '>')
// .replace(/&amp;/g, '&')
// .replace(/(\n|\s|&nbsp;)/g, '')
// .replace(/<br>/g, '\n')
// .replace(/<span>([\s\S]*?)<\/span>/g, '$1')
// .replace(/<div>([\s\S]*?)<\/div>/g, '$1')
this.currentText = cutImg
this.$emit('updateText', this.currentText)
},
insertNodeFirst(node) {
this.savedRange.deleteContents()
// 插入链接
if (this.isInsert) {
this.savedRange.insertNode(node)
} else {
document.querySelector(`#${this.contentId}`).appendChild(node)
}
if (navigator.userAgent.indexOf('Chrome') != -1) {
this.savedRange.insertNode(document.createElement('span'))
}
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
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>
...@@ -249,6 +249,7 @@ ...@@ -249,6 +249,7 @@
size="medium" size="medium"
>取消</el-button> >取消</el-button>
<el-button <el-button
v-if="!isWatchPage"
type="primary" type="primary"
@click="handleConfirm" @click="handleConfirm"
size="medium" size="medium"
...@@ -459,12 +460,14 @@ export default { ...@@ -459,12 +460,14 @@ export default {
gasCardServiceCharge: 0, gasCardServiceCharge: 0,
passageServiceCharge: 0 passageServiceCharge: 0
}, },
pageNum: 1 pageNum: 1,
isWatchPage:false
} }
}, },
mounted () { mounted () {
const { id, type } = this.$route.query const { id, type } = this.$route.query
if (id) this.getDetail(id, type) if (id) this.getDetail(id, type)
this.isWatchPage = !type
}, },
methods: { methods: {
refreshTable ({ pageNum }) { refreshTable ({ pageNum }) {
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
@click="jump" @click="jump"
size="small" size="small"
>门店客户积分充值</el-button> >门店客户积分充值</el-button>
<el-button @click="toSMS" size="small">提醒短信
</el-button>
<el-button @click="handleExport" size="small">导出 <el-button @click="handleExport" size="small">导出
</el-button> </el-button>
</div> </div>
...@@ -187,7 +189,7 @@ export default { ...@@ -187,7 +189,7 @@ export default {
{ {
label: '创建时间', label: '创建时间',
minWidth: 150, minWidth: 150,
formatter: cell => dayjs(cell.createdDate).format('YYYY/MM/DD hh:mm:ss') formatter: cell => dayjs(cell.createdDate).format('YYYY/MM/DD HH:mm:ss')
}, },
{ {
label: '审核人', label: '审核人',
...@@ -197,7 +199,7 @@ export default { ...@@ -197,7 +199,7 @@ export default {
{ {
label: '审核时间', label: '审核时间',
minWidth: 150, minWidth: 150,
formatter: cell => cell.auditDate ? dayjs(cell.auditDate).format('YYYY/MM/DD hh:mm:ss') : '' formatter: cell => cell.auditDate ? dayjs(cell.auditDate).format('YYYY/MM/DD HH:mm:ss') : ''
}, },
] ]
}, },
...@@ -280,6 +282,7 @@ export default { ...@@ -280,6 +282,7 @@ export default {
path: '/storeCredit/add', path: '/storeCredit/add',
query: { query: {
$title: '门店客户积分充值', $title: '门店客户积分充值',
type:'addRecharge'
} }
}) })
}, },
...@@ -298,6 +301,14 @@ export default { ...@@ -298,6 +301,14 @@ export default {
type type
} }
}) })
},
toSMS(){
this.$router.push({
path: '/sms/index',
query: {
$title: '提醒短信',
}
})
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!