Commit f83e75a2 by 杨明

fixed

1 parent 5cda1645
<template>
<div class="ly-emotion">
<slot></slot>
</div>
</template>
<script>
import emoji from '@/utils/emo'
export default {
name: 'ly-emotion',
mounted() {
const name = this.$el.innerHTML
const list = emoji.flat(Infinity)
let index = parseInt(list.indexOf(name)) + 1
if (index < 10) {
index = '00' + index
} else if (index >= 10 && index < 100) {
index = '0' + index
}
let imgHTML = `<img src="https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png">`
this.$nextTick(() => {
this.$el.innerHTML = imgHTML
})
}
}
</script>
<style scoped>
.ly-emotion {
display: inline-block;
}
.ly-static-emotion {
width: 24px;
height: 24px;
display: inline-block;
}
</style>
<template>
<div>
<div class="emotion-box" :style="{ height: height + 'px' }">
<div class="emotion-box-line" v-for="(line, i) in list" :key="i">
<emotion class="emotion-item" v-for="(item, i) in line" :key="i" @click.native="clickHandler(item)">{{ item }}</emotion>
</div>
</div>
</div>
</template>
<script>
import emoji from '@/utils/emo'
import Emotion from './Emotion'
export default {
props: {
height: {
type: Number,
default: 200
}
},
name: 'emotionWords',
data() {
return {
list: emoji
}
},
methods: {
clickHandler(i) {
let emotion = `${i}`
this.$emit('emotion', emotion)
}
},
components: {
Emotion
}
}
</script>
<style scoped lang="scss">
.emotion-box {
z-index: 2004;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.15);
width: 300px;
box-sizing: border-box;
padding: 5px;
overflow: hidden;
overflow-y: auto;
}
.emotion-box-line {
display: flex;
}
.emotion-item {
flex: 1;
text-align: center;
cursor: pointer;
line-height: 23px;
/deep/ {
img {
width: 24px;
-webkit-user-select: none;
cursor: default;
pointer-events: none;
}
}
}
</style>
<template>
<div class="w-textarea" ref="wTextarea">
<div contenteditable="true" class="w-textarea_input" ref="wTextareaContent" :id="contentId" @keydown="textareaKeydown($event)" @click="inputClick($event)" @focus="onFocus" @blur="onBlur" @keydown.delete="handleDelete($event)" @input="handleInput($event.target)"></div>
</div>
</template>
<script>
import emoji from '@/utils/emo'
export default {
name: 'wTextarea',
data() {
return {
// 记录currentText以计算长度
currentText: this.value,
// 为input区域生成随机id,当在页面上有多个组件时,用于监听光标的变化
contentId: `content${this.getGuid()}`,
// 输入的时候锁定,禁止更新innerHTML
isLocked: false,
isInsert: false,
// 记录当前选中tag的ID
currentTagId: null,
// 当前光标位置
savedRange: {}
}
},
props: {
value: {
type: String,
default: ''
},
tag: {
// 自定义模版标签的标签名
type: String,
// 默认使用wise作为标签名,并添加了默认样式
// 当使用其他标签名的时候,需要另写标签样式
default: 'wise'
},
tools: {
// 自定义扩展功能:超链接'link',模版标签'tag'
type: Array,
default() {
return [
{ type: 'link', text: '添加超链接' },
{ type: 'tag', text: '添加模版标签' }
]
}
},
maxlength: {
// 最大输入长度
type: [String, Number],
default: ''
}
},
computed: {
count() {
// 字符长度记数
let num = this.maxlength - this.currentText.length
let text = num < 0 ? `已超出${Math.abs(num)}个字符` : `还可以输入${num}个字符`
return { num, text }
}
},
mounted() {
// 初始化数据
this.currentText && (this.$refs.wTextareaContent.innerHTML = this.currentText)
// 创建模版标签的style
this.createStyle()
// 每次光标变化的时候,保存 range
document.addEventListener('selectionchange', this.selectHandler)
},
beforeDestroy() {
// 卸载事件
document.removeEventListener('selectionchange', this.selectHandler)
},
methods: {
updateData(text) {
this.$emit('input', text)
},
createStyle() {
// 为自定义的模版标签添加样式,使之不可编辑
let style = document.createElement('style')
style.innerHTML = `.w-textarea ${this.tag} {
cursor: default;
-webkit-user-modify: read-only !important;
}`
this.$refs.wTextarea.appendChild(style)
},
closeModal() {
this.form.text = ''
this.showModal = false
},
openTagDialog(type) {
// if (addLink)
// 将事件抛给父组件处理
// 处理后需要调用 addTag() 或者 addLink() 将内容传回来
this.$emit('add', type)
},
textareaKeydown(event) {
if (event.keyCode == 13) {
this.insertHtml('<br>')
let nn = document.createElement('br')
document.querySelector('.w-textarea_input').appendChild(nn)
return false
}
},
/*换行*/
insertHtml(html) {
var sel, range
if (window.getSelection) {
// IE9 或 非IE浏览器
sel = window.getSelection()
if (sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0)
range.deleteContents()
// Range.createContextualFragment() would be useful here but is
// non-standard and not supported in all browsers (IE9, for one)
var el = document.createElement('div')
el.innerHTML = html
var frag = document.createDocumentFragment(),
node,
lastNode
while ((node = el.firstChild)) {
lastNode = frag.appendChild(node)
}
range.insertNode(frag)
// Preserve the selection
if (lastNode) {
range = range.cloneRange()
range.setStartAfter(lastNode)
range.collapse(true)
sel.removeAllRanges()
sel.addRange(range)
}
}
} else if (document.selection && document.selection.type != 'Control') {
// IE < 9
document.selection.createRange().pasteHTML(html)
}
const htm = document.querySelector('.w-textarea_input').innerHTML
this.subText(htm)
},
addTag(text) {
// 创建模版标签
let node = document.createElement(this.tag)
if (navigator.userAgent.indexOf('Firefox') > 0) {
node.setAttribute('contenteditable', 'false')
}
node.innerText = text
// 添加id便于删除
node.id = this.getGuid()
this.insertNode(node)
},
addNode() {
let target = this.$refs.wTextareaContent
this.updateData(target.innerHTML)
},
addLink(text, url) {
// 创建a标签
let node = document.createElement('a')
node.innerText = text
node.href = url
node.target = 'blank'
this.insertNode(node)
},
addImg(url) {
// 创建a标签
let node = document.createElement('img')
node.src = url
// node.setAttribute('ondragstart', 'return false;')
this.insertNode(node)
},
onFocus() {
this.isLocked = true
this.isInsert = true
},
onBlur() {
this.isLocked = false
},
insertNode(node) {
// 在内容中插入标签
// 删掉选中的内容(如有)
if (this.savedRange.startContainer) {
this.insertNodeFirst(node)
} else {
document.querySelector('.w-textarea_input').focus()
setTimeout(() => {
this.insertNodeFirst(node)
document.querySelector('.w-textarea_input').blur()
}, 100)
}
},
subText(htm) {
const list = emoji.flat(Infinity)
const cutImg = htm
.replace(/<span>([\s\S]*?)<\/span>/g, '$1')
.replace(/<img src="https:\/\/img01.glsx.com.cn\/weapp\/resource\/saas\/scrm\/emoji\//g, '')
.replace(/<wise.+?>(.+?)(?:<\/wise>)/g, '$1')
.replace(/<br>/g, '\n')
const replaceImg = cutImg.replace(/(\d){3}.png">/g, function(str) {
let s = list[parseInt(str.split('.')[0]) - 1]
return `[${s}]`
})
let Textnode = document.createElement('div')
Textnode.innerHTML = replaceImg
this.currentText = replaceImg
this.$emit('updateText', this.currentText)
},
insertNodeFirst(node) {
this.savedRange.deleteContents()
// 插入链接
if (this.isInsert) {
this.savedRange.insertNode(node)
} else {
document.querySelector('.w-textarea_input').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: transparent;
font-size: 14px;
color: #5850ff;
line-height: 20px;
padding: 0px;
margin: 0 2px;
color: #26a2ff;
// padding: 0 1px;
white-space: nowrap;
user-select: none;
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>
<!--
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-04-20 15:15:08
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-06-10 15:19:23
* @FilePath: \scrm-micro-battles\src\views\battle\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%
im
-->
<!--
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-04-20 15:15:08
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-06-10 14:48:12
* @FilePath: \scrm-micro-battles\src\views\battle\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="activity">
<GLTabs v-model="activeName" :tabPaneList="tabPaneList" @tab-click="handleClick"></GLTabs>
<!-- 表格区域 开始 -->
<div class="container">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<div class="flex-between title">
<div class="title-text">专员列表</div>
<template v-if="activeName == 'first'">
<el-button :size="size" type="primary" class="battle-set-btn" @click="battleSetHandle">批量配置专员</el-button>
</template>
</div>
<GLTable ref="battleRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun" @selectionTable="selectionTable">
<div slot="activityTime" slot-scope="scope">{{ dateFormatFun(scope.scope.startTime) }}-{{ dateFormatFun(scope.scope.endTime) }}</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleClose(scope.scope, 'close')" v-if="scope.scope.actionReportSendFlag == 1">关闭</el-button>
<el-button type="text" @click="handleClose(scope.scope, 'open')" v-else>打开</el-button>
<el-button type="text" v-if="scope.scope.reportStaffs.length == 0" @click="handlebattleOn(scope.scope)">配置</el-button>
<el-button type="text" v-else @click="handlebattleOn(scope.scope, 'edit')">编辑</el-button>
<div class="text-area">
<w-textarea ref="textContent" v-model="textValue" @updateText="updateText"></w-textarea>
<div class="btn-group-panel">
<div class="btn-group">
<div class="add-btn" v-for="(item, k) in btnList" :key="k" @click="selectItem(item)">
<template v-if="item.type == 1">
<img class="emotion-item" src="@/assets/textarea/expression.png" />
<span class="emotion-item">{{ item.name }}</span>
</template>
<template v-else>
<img class="emotion-item" src="@/assets/textarea/add.png" />
<span class="emotion-item">{{ item.name }}</span>
</template>
</div>
</GLTable>
</div>
<GLDialog mode="big" :before-close="handlebattleClose" class="battle-dialog" bigTitle="配置专员" @onOk="handlebattleConfirm" @onCancel="handlebattleClose" :visible.sync="battleVisible" :beforeSearchFn="beforeSearchFn">
<div class="gl-form-page gl-form-min">
<el-form ref="form" label-width="154px">
<el-form-item label="发送人员:">
<el-radio-group v-model="config.staffType" @change="changeType">
<el-radio v-model="radio" label="1">全部人员</el-radio>
<el-radio v-model="radio" label="2">指定人员</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="所属企业:">
<el-radio-group v-model="config.merchantId" @change="changeRadio">
<template v-for="(item, index) in merchantList">
<el-radio :key="index" :label="item.merchantId">{{ item.merchantName }}</el-radio>
</template>
</el-radio-group>
</el-form-item>
<el-form-item label="人员选择:" v-show="config.staffType == 2">
<el-button size="small" @click="openMembers">
<i class="el-icon-plus"></i>
选择成员
</el-button>
<div class="el-input-tag input-tag-wrapper" v-show="userList.length">
<GLFull :label="tag.staffName" :identi="`${tag.id}`" labelWidth="110" textType="user" :haveClose="true" v-for="(tag, idx) in userList" :key="idx" @handleRemove="removeStaff(idx)"></GLFull>
</div>
</el-form-item>
<!-- 战报自动发送 -->
<el-form-item class="select-wrap" label="战报自动发送:">
<div class="common el-form-item__content">
<div class="el-input" ref="automaticRef">
<div class="el-input__inner" @click="openMenu(1)">
<span v-if="!wechat.battleStaffName" class="placeholder">选择成员</span>
{{ wechat.battleStaffName }}
</div>
<span class="el-input__suffix" @click="openMenu(1)">
<span class="el-input__suffix-inner"><i :class="['el-select__caret', 'el-input__icon', 'el-icon-arrow-up', menuIndex != 1 ? 'is-reverse' : '']"></i></span>
</span>
</div>
<div class="empty-btn" @click="clearWechat(1)">清空</div>
</div>
<transition name="el-zoom-in-top" v-if="menuIndex == 1">
<gl-select-menu :domEl="automaticEl" @changeStatu="hideSelect">
<el-form-item class="search-groomname">
<el-input placeholder="请输入搜索关键词" v-model="filterText"></el-input>
</el-form-item>
<div class="el-select-dropdown__wrap el-scrollbar__wrap">
<template v-if="automaticData.length > 0">
<el-tree class="filter-tree" :data="automaticData" node-key="id" :default-expanded-keys="expandedKeys" :props="defaultProps" default-expand-all :filter-node-method="filterNode" ref="tree" @node-click="handleNodeClick"></el-tree>
</template>
<div class="empty" v-else>暂无数据</div>
</div>
</gl-select-menu>
</transition>
</el-form-item>
<!-- 喜报自动发送 -->
<el-form-item class="select-wrap" label="喜报自动发送:">
<div class="common el-form-item__content">
<div class="el-input" ref="happyRef">
<div class="el-input__inner" @click="openMenu(2)">
<span v-if="!wechat.goodStaffName" class="placeholder">选择成员</span>
{{ wechat.goodStaffName }}
</div>
<span class="el-input__suffix" @click="openMenu(2)">
<span class="el-input__suffix-inner"><i :class="['el-select__caret', 'el-input__icon', 'el-icon-arrow-up', menuIndex != 2 ? 'is-reverse' : '']"></i></span>
</span>
</div>
<div class="empty-btn" @click="clearWechat(2)">清空</div>
</div>
<transition name="el-zoom-in-top" v-if="menuIndex == 2">
<gl-select-menu :domEl="happyEl" @changeStatu="hideSelect">
<el-form-item class="search-groomname">
<el-input placeholder="请输入搜索关键词" v-model="filterTextH"></el-input>
</el-form-item>
<div class="el-select-dropdown__wrap el-scrollbar__wrap">
<template v-if="automaticData.length > 0">
<el-tree class="filter-tree" :data="automaticData" node-key="id" :default-expanded-keys="expandedKeys" :props="defaultProps" default-expand-all :filter-node-method="filterNode" ref="treeH" @node-click="handleNodeClick"></el-tree>
</template>
<div class="empty" v-else>暂无数据</div>
</div>
</gl-select-menu>
</transition>
</el-form-item>
<!-- 关联群 -->
<el-form-item class="select-wrap" label="关联群:">
<div class="common el-form-item__content">
<div class="el-input" ref="groupRef">
<div class="el-input__inner" @click="openMenu(3)">
<span class="placeholder" v-if="wechat.roomName == ''">选择选择群</span>
{{ wechat.roomName }}
</div>
<span class="el-input__suffix" @click="openMenu(3)">
<span class="el-input__suffix-inner"><i :class="['el-select__caret', 'el-input__icon', 'el-icon-arrow-up', menuIndex != 3 ? 'is-reverse' : '']"></i></span>
</span>
</div>
</div>
<transition name="el-zoom-in-top" v-if="menuIndex == 3">
<gl-select-menu :domEl="domEl" @changeStatu="hideSelect">
<el-form-item class="search-groomname">
<el-input placeholder="请输入搜索关键词" prefix-icon="el-icon-search" v-model="roomName"></el-input>
</el-form-item>
<div class="el-select-dropdown__wrap el-scrollbar__wrap">
<ul class="el-scrollbar__view el-select-dropdown__list">
<template v-if="groupList.length > 0">
<li v-for="i in roomName == '' ? groupList : stageList" class="el-select-dropdown__item" :key="i" @click="selectGroup(i)">
<span>{{ i.roomName }}</span>
</li>
</template>
<div class="empty" v-else>暂无数据</div>
</ul>
</div>
</gl-select-menu>
</transition>
</el-form-item>
<el-form-item class="select-wrap" label="群名:">
<el-input v-model="groupName" placeholder="请输入群名" @blur="importGroup"></el-input>
</el-form-item>
</el-form>
</div>
</GLDialog>
<GLDialog :mode="mode" title="选择员工" @onOk="handlestaffbattleConfirm" @onCancel="handlestaffbattleClose" :visible.sync="battlestaffVisible">
<SelectMember ref="selectMember" :selectlist="userList" v-if="battlestaffVisible" :merchantId="config.merchantId"></SelectMember>
</GLDialog>
</div>
<div v-show="emotionStatus" class="emotion-panel">
<emotion-words class="emotion-panel-box" @emotion="handleEmotion" :height="280"></emotion-words>
</div>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import { dateFormat } from '../../utils/index'
import SelectMember from '../battle/components/SelectMember.vue'
import GlSelectMenu from '../battle/components/select-dropdown.vue'
import emoji from '@/utils/emo'
import WTextarea from './components/WTextarea'
import EmotionWords from './components/EmotionWords'
export default {
components: {
SelectMember,
GlSelectMenu
},
data() {
return {
groupName: '',
isgroup: true,
isAutomatic: true,
menuIndex: 0,
merchantId: '',
merchantName: '',
activeName: 'first',
size: 'small',
mode: 'mid',
battleVisible: false,
battlestaffVisible: false,
url: url,
setectList: [],
setectEditList: [],
merchantList: [],
groupList: [],
tabPaneList: [
btnList: [
{
label: '进行中',
name: 'first'
type: 1,
name: '表情'
},
{
label: '已结束',
name: 'second'
}
],
searchFormData: [
type: 2,
name: '销售顾问'
},
{
type: 2,
name: '客户姓名'
},
{
label: '活动门店',
name: 'merchantName',
type: 'input'
type: 2,
name: '车型'
},
{
label: '活动名称',
name: 'activityNames',
type: 'select',
width: '215px',
multiple: true,
attrs: {
multipleLimit: 10
},
noFilter: false,
optionList: [],
optionId: 'confId',
optionLabel: 'confName'
type: 2,
name: '订单总金额'
},
{
label: '活动类型',
name: 'marketingType',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confName',
optionsName: 'activityTypeList'
type: 2,
name: '阳光激励费'
},
{
type: 2,
name: '商品名称'
}
],
tableSearchForm: {
merchantName: '',
activityName: '',
activityType: ''
},
// 表格
userList: [],
selectArray: [],
getListApi: this.$apis.battle.getActivitylist,
tableParams: {
// btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: true,
// // 行数据的key
mutiSelectUniqueKey: 'activityId',
// 多选ref的名称
mutiSelectName: 'activity',
tableColumns: [
{
label: '活动名称',
prop: 'activityName'
},
{
label: '活动门店',
prop: 'merchantName'
},
{
label: '活动类型',
prop: 'marketingType',
formatter: cellValue => {
const data = this.baseData.activityTypeList.filter(item => item.confId == cellValue.marketingType)
return data.length > 0 ? data[0].confName : '--'
}
},
{
label: '活动时间',
addHtml: 'activityTime'
},
{
label: '负责人',
formatter: val => {
return val.reportStaffs.length > 0 ? val.reportStaffs.map(item => item.staffName).join('、') : '--'
},
prop: 'reportStaffs',
line: 1,
width: 300
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'currentPage', totalCount: 'total' },
defaultProps: {
children: 'children',
label: 'name'
},
expandedKeys: [],
filterText: '',
filterTextH: '',
automaticData: [],
stageList: [],
roomName: '',
config: {
merchantId: '',
staffType: '2'
},
wechat: {
battleStaffName: '',
goodStaffName: '',
roomName: ''
},
idBefEncryptionBattle: '',
idBefEncryptionGood: '',
baseData: {
activityTypeList: [
{ confId: '3', confName: '众筹' },
{ confId: '5', confName: '膨胀金' }
]
}
emotionStatus: false
}
},
mounted() {
this.getOptionsList('searchFormData')
this.getCrowdfundingParams()
this.getMerchantList()
},
computed: {
domEl() {
return this.$refs.groupRef
},
automaticEl() {
return this.$refs.automaticRef
},
happyEl() {
return this.$refs.happyRef
}
},
watch: {
activeName: {
handler(val) {
if (val == 'first') {
this.tableParams.tableOption = true
this.$nextTick(() => {
this.tableParams.mutiSelectUniqueKey = 'activityId'
this.tableParams.mutiSelectName = 'activityId'
})
} else {
this.tableParams.tableOption = false
this.$nextTick(() => {
this.tableParams.mutiSelectUniqueKey = ''
this.tableParams.mutiSelectName = ''
})
}
},
immediate: true
},
idBefEncryptionBattle(val) {
this.importGroup()
},
idBefEncryptionGood(val) {
this.importGroup()
},
filterText(val) {
this.$refs.tree.filter(val)
},
filterTextH(val) {
this.$refs.treeH.filter(val)
},
roomName(val) {
this.filterRoomName(val)
}
components: {
WTextarea,
EmotionWords
},
methods: {
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)
}
}
})
}
},
async getCrowdfundingParams() {
/**参数类型 1:众筹活动名称(返回类型String),2:众筹活动门店 */
const funding = await this.$apis.seckillActivity.getCrowdfundingParams({
parameterType: 1
})
const gold = await this.$apis.seckillActivity.getCrowdGoldParams({
parameterType: 1
})
const activity = [...funding?.parameters, ...gold?.parameters]
let activityNameList = []
activity.map(e => {
activityNameList.push({
confId: e,
confName: e
})
})
this.$set(this.searchFormData[1], 'optionList', this.$common.utils.deepClone(activityNameList))
},
clearData() {
// this.setectList = []
this.config.merchantId = this.merchantId
this.config.staffType = '2'
this.wechat = {
battleStaffName: '',
goodStaffName: '',
roomName: ''
}
this.groupName = ''
this.hideSelect()
},
filterNode(value, data) {
if (!value) return true
return data.name.indexOf(value) !== -1
},
filterRoomName(value) {
this.stageList = this.groupList.filter(item => {
if (item.roomName.indexOf(value) !== -1) {
return item
}
})
},
handleNodeClick(data) {
this.setSendName(data.name, data.staffId)
// this.wechat.roomName = ''
if (this.menuIndex == 1) {
this.idBefEncryptionBattle = data.idBefEncryption
}
if (this.menuIndex == 2) {
this.idBefEncryptionGood = data.idBefEncryption
}
this.hideSelect()
},
setSendName(name, staffId, isClear, i) {
console.log(staffId, this.wechat.battleStaffId, i)
if (this.menuIndex == 1 || i == 1) {
if (staffId == this.wechat.battleStaffId && staffId) return
Object.assign(this.wechat, { battleStaffName: name, battleStaffId: staffId })
}
if (this.menuIndex == 2 || i == 2) {
if (staffId == this.wechat.goodStaffId && staffId) return
Object.assign(this.wechat, { goodStaffName: name, goodStaffId: staffId })
}
console.log(this.wechat)
if (isClear && !this.wechat.battleStaffName && !this.wechat.goodStaffName) {
this.wechat.roomName = ''
this.groupList = []
return
}
if (isClear && (this.wechat.battleStaffName || this.wechat.goodStaffName)) return
this.wechat.roomName = ''
this.getGroupList()
},
hideSelect() {
this.menuIndex = 0
},
selectGroup(data) {
this.hideSelect()
this.wechat.roomName = data.roomName
const { goodStaffId, battleStaffId } = this.wechat
if (this.wechat.battleStaffName) {
const staffCloudId = data.staffInfoList.find(i => i.staffId == battleStaffId)?.staffCloudId
this.wechat.battleGroupId = staffCloudId + '_R:' + data.roomIdOnly
}
if (this.wechat.goodStaffName) {
const staffCloudId = data.staffInfoList.find(i => i.staffId == goodStaffId)?.staffCloudId
this.wechat.goodGroupId = staffCloudId + '_R:' + data.roomIdOnly
}
// this.wechat.groupId = data.roomChatId
},
importGroup() {
if (this.wechat.roomName) return
if (this.wechat.battleStaffName) {
this.wechat.battleGroupId = this.idBefEncryptionBattle + '_R:' + this.groupName
}
if (this.wechat.goodStaffName) {
this.wechat.goodGroupId = this.idBefEncryptionGood + '_R:' + this.groupName
}
},
openMenu(e) {
if (e == this.menuIndex) return (this.menuIndex = 0)
this.menuIndex = e
},
removeStaff(index) {
this.userList.splice(index, 1)
},
//所属企业
changeRadio(val) {
if (this.config.staffType == 1) this.getDepartmentTree()
this.merchantList.forEach(item => {
item.merchantId == val ? (this.merchantName = item.merchantName) : ''
})
this.userList = []
},
getMerchantList() {
this.$apis.battle.getMerchantList({}).then(res => {
this.merchantList = res
this.config.merchantId = this.merchantList && this.merchantList[0].merchantId
this.merchantId = this.merchantList && this.merchantList[0].merchantId
this.merchantName = this.merchantList && this.merchantList[0].merchantName
})
},
changeType(val) {
if (val == 1) {
this.getDepartmentTree()
selectItem(item) {
if (item.type == 1) {
this.selectEmotion()
} else {
this.userList = []
this.selectTag(item.name)
}
},
handleClose(scope, status) {
const info = status == 'close' ? '关闭' : '打开'
const infoN = status == 'close' ? '取消' : '恢复'
this.$confirm(`${info}则${infoN}战报发送功能,是否确认${info}?`, info, {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
})
.then(() => {
this.activityOpen(scope)
})
.catch(() => {
// this.$message({
// type: 'info',
// message: '已取消'
// })
})
},
activityOpen(scope) {
const { activityId, actionReportSendFlag } = scope
this.$apis.battle
.activityOpen({
activityId,
actionReportSendFlag: actionReportSendFlag == 1 ? 2 : 1
})
.then(res => {
if (res) {
this.handleSearch()
this.$message.success('操作成功')
}
})
},
battleSetHandle() {
if (this.setectList.length == 0) {
this.$message({
message: '请选择活动',
type: 'error'
})
return
}
this.getDepartmentTree()
this.userList = []
// this.editStatus = false
this.battleVisible = true
},
dateFormatFun(date) {
return dateFormat(date)
},
selectionTable(val) {
this.setectList = val
},
handlestaffbattleConfirm() {
this.battlestaffVisible = false
this.userList = this.$refs.selectMember.userList
},
handlestaffbattleClose() {
this.battlestaffVisible = false
},
openMembers() {
this.battlestaffVisible = true
// if (this.ids.length > 0) {
// this.$refs.selectMember.$refs.tree.setCheckedKeys(this.ids)
// }
},
handlebattleConfirm() {
if (this.userList.length == 0) {
this.$message({
message: '请选择专员',
type: 'error'
})
return
}
if (this.wechat.battleStaffName !== '' && this.wechat.roomName == '' && !this.groupName) {
this.$message({
message: '请选择关联群',
type: 'error'
})
return
}
let staffRequestList = []
let batchstaffRequestList = []
this.userList.forEach(item => {
staffRequestList.push({
staffId: item.staffId,
staffName: item.staffName,
merchantId: this.config.merchantId,
merchantName: this.merchantName,
userId: item.userId
})
})
const setectList = this.setectEditList.length ? this.setectEditList : this.setectList
setectList.forEach(item => {
let autoStaff = {}
if (Object.keys(this.wechat).length) {
const { battleStaffId, battleStaffName, battleGroupId, goodStaffName, roomName, goodGroupId, goodStaffId } = this.wechat
autoStaff = {
battleStaffId,
battleStaffName,
battleGroupId,
goodGroupId,
goodStaffName,
goodStaffId,
autoGroupName: roomName ? roomName : this.groupName,
autoGroupMerchantId: this.$merchantId
}
}
batchstaffRequestList.push({
activityId: item.activityId,
...autoStaff,
staffRequestList
})
})
this.$apis.battle.insertStaff({ batchstaffRequestList, staffType: this.config.staffType }).then(res => {
this.$message({
message: res.code == '0' ? '配置成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.data) {
this.battleVisible = false
this.handleSearch()
this.activeName = 'first'
this.clearData()
}
})
//选择标签
selectTag(name) {
this.$refs.textContent.addTag(name)
},
handlebattleClose() {
this.clearData()
this.setectEditList = []
this.battleVisible = false
//展开表情
selectEmotion() {
this.emotionStatus = !this.emotionStatus
},
handleDetails() {},
handlebattleOn(data, sign) {
this.setectEditList = []
this.userList = []
this.wechat = {
battleStaffName: '',
roomName: '',
goodStaffName: ''
//选择表情
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.setectEditList.push(data)
this.battleVisible = true
if (sign) {
this.getStaffList(data)
}
this.getDepartmentTree()
},
clearWechat(i) {
this.setSendName('', '', true, i)
},
//获取编辑
getStaffList(data) {
this.$apis.battle.getStaffList({ id: data.activityId }).then(res => {
this.config.merchantId = res.staffs[0].merchantId
this.merchantId = res.staffs[0].merchantId
this.merchantName = res.staffs[0].merchantName
this.userList = res.staffs
this.config.staffType = res.staffType + ''
// this.wechat.staffId = res.autoStaffId
// this.wechat.battleStaffName = res.autoStaffName
// this.wechat.groupId = res.autoGroupId
// this.wechat.roomName = res.autoGroupName
const { goodStaffId, goodStaffName, battleStaffId, battleStaffName, goodGroupId, battleGroupId, autoGroupName, autoGroupMerchantId } = res
this.wechat = {
goodStaffId,
goodStaffName,
battleStaffId,
battleStaffName,
goodGroupId,
battleGroupId,
roomName: '',
autoGroupMerchantId
}
const groupId = battleGroupId || goodGroupId
if (groupId.split('_R:')[1] == autoGroupName) {
this.groupName = autoGroupName
this.idBefEncryptionBattle = battleGroupId.split('_R:')[0]
this.idBefEncryptionGood = goodGroupId.split('_R:')[0]
} else {
this.wechat.roomName = autoGroupName
}
this.getGroupList(this.wechat.staffId)
})
},
getGroupList(id) {
const { battleStaffId, goodStaffId } = this.wechat
const msgStaffIdList = [battleStaffId, goodStaffId]
this.$apis.battle.getGroupList({ msgStaffIdList, unionRoom: true }).then(res => {
if (res.code == 0) {
this.groupList = res.data
}
})
},
handleSetting() {
this.drawer = true
},
handleClick() {
this.handleSearch()
},
handleReset() {
this.tableSearchForm = {}
this.handleSearch()
},
getParams() {
let params = {
...this.tableSearchForm
}
this.activeName == 'first' ? (params.activityStatus = 2) : (params.activityStatus = 3)
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.battleRef.data.length ? (this.$refs.battleRef.tableHeightValues = '') : this.$refs.battleRef.setTableHeightFun()
},
handleSearch() {
this.$refs.battleRef.refreshTable()
},
async getDepartmentTree() {
// let params = { addChildrensFlag: true, queryMerchantId: this.config.merchantId,loginStatus:1 }
let params = { addChildrensFlag: true, queryMerchantId: this.$merchantId, loginStatus: 1 }
let data = await this.$apis.battle.getlistDepartmentTree(params)
this.ids = []
this.automaticData = data
await this.initData(this.automaticData)
this.expandedKeys = [this.automaticData[0]?.id]
},
initData(data) {
data.forEach((item, index) => {
this.$set(item, 'name', item.staffName ? item.staffName : item.departmentName)
let entmicroStaffResponses = this.$common.utils.deepClone(item.entmicroStaffResponses) || []
entmicroStaffResponses = entmicroStaffResponses.filter((staff, idx) => {
if (staff.staffName) {
this.$set(staff, 'name', staff.staffName)
} else {
this.$set(staff, 'name', staff.departmentName)
}
if (staff.staffId && !this.ids.includes(staff.staffId)) {
this.ids.push(staff.staffId)
return true
} else if (staff.staffId && this.ids.includes(staff.staffId)) {
return false
}
})
let child = this.$common.utils.deepClone(item.children) || []
child = child.filter((staff, idx) => {
if (staff.staffName) {
this.$set(staff, 'name', staff.staffName)
} else {
this.$set(staff, 'name', staff.departmentName)
}
if (staff.staffId && !this.ids.includes(staff.staffId)) {
this.ids.push(staff.staffId)
return true
} else if (staff.staffId && this.ids.includes(staff.staffId)) {
return false
} else if (staff.entmicroStaffResponses) {
staff.staffId = staff.id
return true
}
})
const children = [...child, ...entmicroStaffResponses]
item.children = children
//清除没有员工的部门
if (!item.staffName && item.entmicroStaffResponses === null) {
// data.splice(index, 1)
}
children.length && this.initData(children)
})
this.$refs.textContent.addImg(`https://img01.glsx.com.cn/weapp/resource/saas/scrm/emoji/${index}.png`)
}
}
}
</script>
<style scoped lang="scss">
.activity {
/deep/ {
.el-select .el-tag {
max-width: 60% !important;
}
.el-form-item__content {
overflow: inherit !important;
}
}
.container {
margin-top: 16px;
.title {
height: 32px;
line-height: 32px;
margin-bottom: 10px;
.title-text {
font-weight: 600;
font-size: 16px;
color: #333333;
margin-left: 4px;
}
}
}
.empty-btn {
position: absolute;
right: -40px;
top: 0px;
font-size: 14px;
color: #5850ff;
}
.config-pannel {
background: #f9f9f9;
width: 520px;
height: 168px;
<style lang="scss" scoped>
.text-area {
background: #fff;
// width: 448px;
}
.btn-group-panel {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
padding: 10px 0 10px 20px;
border: 1px solid #e5e5e5;
border-top: 0;
background: #fafbfe;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
.btn-group {
display: flex;
.config-item {
padding: 26px 20px;
}
.clear-btn {
justify-content: space-around;
gap: 20px;
.add-btn {
display: inline-flex;
position: relative;
align-items: center;
font-size: 16px;
color: #666;
cursor: pointer;
background: #f1f1f1;
width: 40px;
height: 100%;
line-height: 20px;
font-size: 14px;
color: #666666;
padding: 60px 13px;
box-sizing: border-box;
}
}
.input-tag-wrapper {
position: relative;
font-size: 14px;
background-color: #fff;
background-image: none;
border-radius: 4px;
border: 1px solid #dcdfe6;
box-sizing: border-box;
color: #666;
display: inline-block;
outline: none;
padding: 5px;
max-height: 68px;
overflow: auto;
flex-wrap: wrap;
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
width: 450px;
display: flex;
align-items: center;
margin-top: 6px;
font-size: 14px;
i {
color: #75acff;
margin-right: 3px;
font-size: 14px;
}
/deep/ .el-tag {
background-color: #fff !important;
margin-bottom: 4px;
}
}
.select-wrap {
.common {
margin: 4px 0;
height: 40px !important;
overflow: hidden;
/deep/ .el-input {
height: 40px !important;
line-height: 40px !important;
}
/deep/ .el-input__suffix {
height: 40px !important;
margin-top: -4px;
.is-reverse {
transform: rotate(180deg);
}
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%;
}
}
}
}
.search-groomname {
width: 252px;
margin: 12px 16px 0;
/deep/.el-input {
width: 252px;
.text-num {
padding-right: 10px;
}
}
.filter-tree {
padding: 0 16px;
}
.empty {
padding: 10px 0;
margin: 0;
text-align: center;
color: #999;
font-size: 13px;
}
.placeholder {
.date-picker {
margin-top: 10px;
font-size: 14px;
color: #c0c6ce;
line-height: 20px;
color: #999;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!