Commit 636c3775 by 前端

更新v3.4.0代码

1 parent 9e5157be
export default {
data() {
return {
groupNumber: 0,
viewLoading: false,
isUpdate: true,
dateOptions: {
disabledDate(time) {
let now = new Date()
now.setTime(now.getTime() - 3600 * 1000 * 24)
return time.getTime() < now
}
},
timeOptions: {
selectableRange: '00:00:00 - 23:59:59'
},
}
},
watch: {
basicForm: {
handler(val) {
if (this.firstFlag) {
this.firstFlag = false
} else {
this.editStatus = true
}
},
deep: true
},
'basicForm.selectType'(newVal, oldVal) {
if (oldVal == 2 || newVal == 2) {
this.basicForm.userList = []
this.selectData = []
this.basicForm.crowdList = []
this.$refs.selectLabel.labelTreeRetSelect = []
}
}
},
methods: {
// 选择客户change事件
radioChange(val) {
this.isSelectCrowd = false
this.isUpdate = true
this.tagging = []
this.taggingList = []
},
// 打开标签筛选
openLabel(merchant) {
if (!this.basicForm[merchant]) {
this.$message({
type: 'error',
message: '请先选择门店'
})
return
}
this.dialogVisible = !this.dialogVisible
this.$refs.selectLabel.init(this.tagging)
},
selectChange(val) {
// 选择门店时,替换欢迎语组件当中的所有merchantId
this.btnList.forEach(item => {
if (item.params && item.params.hasOwnProperty('merchant')) {
item.params.merchant = val
}
if (item.funParams && Object.prototype.toString.call(item.funParams) === '[object Array]') {
item.funParams.forEach(funArr => {
if (funArr.params && funArr.params.hasOwnProperty('merchantId')) {
funArr.params.merchantId = val
}
if (funArr.merchantOpen && funArr.merchantOpen.params && funArr.merchantOpen.params.hasOwnProperty('merchantId')) {
funArr.merchantOpen.params.merchantId = val
}
})
}
})
this.tagging = []
this.taggingList = []
this.basicForm.crowdList = []
this.$refs.selectLabel.labelTreeRetSelect = []
this.isUpdate = true
this.resetMerchantId = val
this.msgMerchantName = val && this.dataItems.find(item => item.msgMerchantId == val).msgMerchantName
},
handleSelect(val) {
this.isUpdate = true
this.tagging = val
let arr = []
this.tagging.forEach(item => {
item.labelList.forEach(tag => {
arr.push({
groupId: item.labelGroup.id,
groupName: item.labelGroup.name,
labelId: tag.id,
labelName: tag.name,
groupType: item.labelType
})
})
})
this.taggingList = arr
},
// 删除标签
removeTag(tag, idx1, idx) {
tag.labelList.splice(idx1, 1)
if (tag.labelList.length == 0) {
this.tagging.splice(idx, 1)
}
let arr = []
this.tagging.forEach(item => {
item.labelList.forEach(tag => {
arr.push({
groupId: item.labelGroup.id,
groupName: item.labelGroup.name,
labelId: tag.id,
labelName: tag.name,
groupType: item.labelType
})
})
})
this.taggingList = arr
this.isUpdate = true
},
// 查看群发人数
viewMembers() {
if (this.basicForm.selectType == '1' && !this.taggingList.length) {
return this.$message({
type: 'error',
message: '请选择标签'
})
}
if (this.basicForm.selectType == 2 && !this.basicForm.crowdList.length) {
return this.$message({
type: 'error',
message: '请选择人群'
})
}
const params = this.getBaseInfo()
this.viewLoading = true
this.$apis.wechatGroup
.batchmessagingCustomercount(params)
.then(res => {
if (res || res == 0) {
this.isUpdate = false
this.groupNumber = res
} else {
this.isUpdate = true
}
this.viewLoading = false
})
.catch(err => {
this.viewLoading = false
this.groupNumber = 0
this.isUpdate = false
})
},
getBaseInfo() {
let params = {
customerType: this.basicForm.selectType,
msgName: this.basicForm.groupName,
msgMerchantId: this.basicForm.selectStore,
msgMerchantName: this.msgMerchantName
}
const combineType = {
label: 2,
crowd: 1
}
if (params.customerType == 1) {
params.combineType = combineType.label
params.labelList = this.taggingList
} else if (params.customerType == 2) {
params.crowdList = this.basicForm.crowdList
params.combineType = combineType.crowd
}
return params
},
// 人群筛选弹窗
selectCrowd(merchant) {
if (!this.basicForm[merchant]) {
this.$message({
type: 'error',
message: '请先选择门店'
})
return
}
this.$refs.selectCrowd.init(this.basicForm.crowdList)
},
// 获取人群数据(根据人群筛选获取群发账号人群数据)
getCrowdData(val) {
this.isUpdate = true
if (val.length) {
this.isSelectCrowd = true
this.basicForm.crowdList = val
} else {
this.basicForm.userList = []
this.basicForm.crowdList = []
this.selectData = []
this.isSelectCrowd = false
this.editStatus = true
this.key = new Date()
}
},
// 删除人群筛选标签
removeCrowd(item, index) {
this.basicForm.crowdList.splice(index, 1)
this.getCrowdData(this.basicForm.crowdList)
if (!this.basicForm.crowdList.length) {
this.basicForm.userList = []
this.selectData = this.basicForm.userList
this.isUpdate = true
this.isSelectCrowd = false
}
this.key = new Date()
},
}
}
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<div class="marketing pro-group"> <div class="marketing pro-group">
<div class="m-b-20 friend-title"> <div class="m-b-20 friend-title">
<div> <div>
<GLButton :size="size" class="el-icon-plus" type="primary" fn="新建朋友圈群发" @click="handleEdit(1)">新建朋友圈群发</GLButton> <!-- <GLButton :size="size" class="el-icon-plus" type="primary" fn="新建朋友圈群发" @click="handleEdit(1)">新建朋友圈群发</GLButton>-->
<!-- <el-button :size="size" type="primary" class="el-icon-plus" fn="新建朋友圈群发" @click="handleEdit(1)">新建朋友圈群发</el-button> --> <el-button :size="size" type="primary" class="el-icon-plus" fn="新建朋友圈群发" @click="handleEdit(1)">新建朋友圈群发</el-button>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
......
<template>
<div>
<GLDialog :bigTitle="'人群筛选'" mode="big" :visible.sync="crowdVisible" v-if="crowdVisible">
<div class="member-wrapper">
<div class="member-left">
<div class="member-title">
人群列表
</div>
<div class="member-content">
<el-form :inline="true" class="member-form" :model="searchForm" @submit.native.prevent>
<el-form-item label="人群名称" style="margin-bottom: 0" size="small">
<el-input :size="size" v-model.trim="searchForm.keyword" @keyup.enter.native="search" clearable
placeholder="请输入关键字搜索"></el-input>
</el-form-item>
<el-form-item label style="margin-bottom: 0;margin-left:10px" size="small">
<el-button type="primary" :size="size" @click="search">搜索</el-button>
</el-form-item>
</el-form>
<div class="table-content">
<GLTable ref="crowdTable" :tableData="tableData" @refreshTable="getCrowdList" :tableTotal="tableTotal"
:layout="layout" :tableParams="crowdTableParams" :hasNum="true" :pageConf="pageConf"
:noDataImg="url" @selectionTable="handleSelectionTable" @row-click="rowClick"></GLTable>
</div>
</div>
</div>
<div class="member-right">
<div class="member-title">已选</div>
<!-- <div class="member-name">人群({{ innerTags.length }}项)</div> -->
<div class="input-tag-wrapper">
<div class="tag-box">
<el-tag v-for="(tag, idx) in innerTags" :key="idx" type="info" closable :disable-transitions="false"
@close="remove(tag, idx)">
{{ tag.crowdName }}
</el-tag>
</div>
</div>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button style="width: 68px;" size="small" @click="crowdVisible = false">取 消</el-button>
<el-button style="width: 68px;" size="small" type="primary" @click.native="handleConfirm">确 定</el-button>
</span>
</GLDialog>
</div>
</template>
<script>
// import url from '@/assets/empty.png'
export default {
name: 'SelectCrowd',
props: {
resetMerchantId: {
type: String,
default: ''
}
},
data() {
return {
url: 0,
crowdVisible: false,
searchForm: {keyword: ''},
innerTags: [],
inner: [],
tableCrowdData: [
{
name: 'asda'
}
],
pageConf: {pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total'},
layout: 'sizes, prev, pager, next, jumper, ->, total',
tableData: [],
tableTotal: 0,
crowdTableParams: {
checkSelectKey: 'id',
checkSelectVal: [],
hasNum: false,
listName: 'crowdUnitList',
// 行数据的key
mutiSelectUniqueKey: 'crowdId',
// 多选ref的名称
mutiSelectName: 'crowdlist',
tableColumns: [
{
label: '人群名称',
prop: 'crowdName'
},
{
label: '人群描述',
prop: 'crowdDesc',
width: '200',
line: 1
},
{
label: '人数',
prop: 'total'
}
]
}
}
},
methods: {
init(val) {
this.inner = this.$common.utils.deepClone(val)
this.innerTags = this.$common.utils.deepClone(val)
this.crowdVisible = true
this.searchForm.keyword = ''
this.$nextTick(() => {
this.$refs.crowdTable.$refs.crowdlistMutiTable.clearSelection()
this.$refs.crowdTable.page.pageNum = 1
this.getCrowdList()
})
},
getCrowdList(page = {pageNum: 1, pageSize: 10}) {
this.$refs.crowdTable.page = page
var params = {
req: {
keyword: this.searchForm.keyword,
merchantId: this.resetMerchantId ? this.resetMerchantId : this.$globalState.session.merchantId,
crowdType: 3,
filterType: 2,
pageSize: page.pageSize,
pageNum: page.pageNum
}
}
this.$apis.wechatGroup.queryCrowdtree(params).then(res => {
this.tableData = res.crowdUnitList
this.tableTotal = res.total
// console.log(this.inner)
// console.log(this.tableData)
// this.tableData.forEach(item => {
// this.inner.forEach((itm, index) => {
// if (itm.crowdId == item.crowdId) {
// this.rowClick(item)
// }
// })
// })
this.recoverySelected()
})
},
// selectionTable(val) {
// this.innerTags = []
// for (let i = 0; i < val.length; i++) {
// const tagArr = this.innerTags.map(item => item.crowdId + '')
// console.log(tagArr)
// if (!tagArr.includes(val[i].crowdId)) {
// this.innerTags.push(val[i])
// }
// console.log(this.innerTags)
// }
// },
// 选择/取消
handleSelectionTable(val) {
var list = JSON.parse(JSON.stringify(this.innerTags))
this.innerTags = []
val.forEach(item => {
if (this.innerTags.findIndex(k => k.crowdId == item.crowdId) == '-1') {
this.innerTags.push(item)
}
})
list.forEach(item => {
if (this.tableData.findIndex(k => k.crowdId == item.crowdId) == '-1' && this.innerTags.findIndex(k => k.crowdId == item.crowdId) == '-1') {
this.innerTags.push(item)
}
})
},
// 恢复选择
addSelected() {
this.$nextTick(() => {
var list = JSON.parse(JSON.stringify(this.innerTags))
if (list && list.length) {
list.forEach(row => {
var idx = this.tableData.findIndex(k => k.crowdId == row.crowdId)
if (idx != -1) {
this.$refs.crowdTable.$refs.crowdlistMutiTable.toggleRowSelection(this.tableData[idx], true)
}
})
}
})
},
recoverySelected() {
// 翻页,去掉已选项
var selectedData = this.$refs.crowdTable.mutiSelectArr.crowdlist
var deleteList = []
this.addSelected()
if (selectedData) {
selectedData.forEach(item => {
if (this.innerTags.findIndex(subItem => subItem.crowdId == item.crowdId) == -1) {
deleteList.push(item)
}
})
this.deleteSelected(deleteList)
}
},
// 删除选中
deleteSelected(deleteList) {
this.$nextTick(() => {
deleteList.forEach(row => {
var idx = this.tableData.findIndex(k => k.crowdId == row.crowdId)
if (idx != -1) {
this.$refs.crowdTable.$refs.crowdlistMutiTable.toggleRowSelection(this.tableData[idx], false)
}
})
})
},
remove(item) {
var idx = this.innerTags.findIndex(k => k.crowdId == item.crowdId)
this.innerTags.splice(idx, 1)
if (this.tableData.map(k => k.crowdId).includes(item.crowdId)) {
var i = this.tableData.findIndex(k => k.crowdId == item.crowdId)
this.$refs.crowdTable.$refs.crowdlistMutiTable.toggleRowSelection(this.tableData[i])
}
},
rowClick(row) {
this.$refs.crowdTable.$refs.crowdlistMutiTable.toggleRowSelection(row)
},
search() {
this.getCrowdList({pageNum: 1, pageSize: 10})
},
handleConfirm() {
// console.log(this.innerTags)
this.$emit('crowdData', this.innerTags)
this.crowdVisible = false
this.searchForm = {keyword: {}}
}
}
}
</script>
<style lang="scss" scoped>
.member-wrapper {
display: flex;
.member-title {
font-size: 16px;
color: #333;
font-weight: 500;
line-height: 22px;
margin-bottom: 6px;
span {
display: inline-block;
padding-left: 5px;
font-size: 12px;
color: #999;
font-weight: 500;
}
}
.member-left {
width: calc(100% - 286px);
.member-content {
border: 1px solid #eee;
padding-bottom: 20px;
/deep/ {
.el-table {
// height: 40vh;
overflow-y: auto;
}
.el-pagination {
margin-top: 0;
}
}
.member-form {
padding: 10px 20px;
}
.table-content {
max-height: 480px;
overflow: auto;
border-top: 1px solid #eee;
}
}
.member-checked {
text-align: right;
margin-top: 10px;
}
}
.member-right {
width: 286px;
margin-left: 14px;
.member-name {
font-size: 14px;
color: #333;
line-height: 20px;
padding: 18px;
border: 1px solid #eee;
}
}
}
.tag-box {
height: 100%;
width: 100%;
}
.input-tag-wrapper {
position: relative;
font-size: 14px;
border: 1px solid #eee;
//border-top: none;
box-sizing: border-box;
color: #606266;
display: inline-block;
padding: 8px 10px;
line-height: 32px;
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
width: 100%;
height: 100%;
display: flex;
align-items: center;
max-height: 557px;
overflow: auto;
// margin-bottom: 10px;
i {
color: #75acff;
margin-right: 3px;
font-size: 14px;
}
/deep/ input {
/* input { */
/* background-color: red!important; 调试用的样式 */
outline: none !important;
border: none !important;
}
/deep/ .el-input {
min-width: 150px;
width: auto;
flex: 1;
}
}
.el-tag {
margin-right: 10px;
line-height: 22px;
margin-bottom: 5px;
height: 24px;
background: #fafbfe !important;
}
/deep/ {
.el-dialog__title {
font-weight: 600;
}
.el-dialog__header {
padding: 20px;
}
.el-dialog__headerbtn {
height: 30px;
.el-dialog__close {
width: 24px;
height: 24px;
font-size: 24px;
}
}
.el-pagination {
padding-left: 20px;
border-top: 1px solid #e8e8ea;
padding-top: 16px;
}
.el-table:before {
display: none;
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!