Commit 4a8d5c4d by 杨明

fixed

1 parent b2f6ad32
import { getCustomersList, exportLabelList } from '@/api/modules/tagsManage'
export default {
data() {
return {
tagHeight: 0,
tagCheckItem: [],
allListParams: [],
crowdForm: {
crowdName: '',
crowdDesc: ''
}
}
},
mounted() {
this.getCustomersListData()
},
watch: {
tagCheckItem: {
handler() {
if (this.tagCheckItem.length == 0) {
setTimeout(() => {
this.tagHeight = 0
}, 300)
}
this.allListParams = []
const tagNode = this.$common.utils.deepClone(this.tagCheckItem)
tagNode.forEach(group_item => {
group_item.children.forEach(label_item => {
if (label_item) {
this.allListParams.push({
groupId: group_item.id,
groupName: group_item.name,
groupType: group_item.labelType,
labelId: label_item.id,
labelName: label_item.name
})
}
})
})
this.getCustomersListData()
},
deep: true
}
},
methods: {
//删除标签组
removeItem(index) {
this.tagCheckItem.splice(index, 1)
this.$refs.tagTree.getTreeNode(this.tagCheckItem)
},
//获取选中的标签并排序
getCheckItem(item) {
const tree_id = []
const labelTree = this.$refs.tagTree.labelTree
labelTree.forEach(tree_node => {
tree_node.children.forEach(t_node => {
tree_id.push(t_node.id)
})
})
this.tagCheckItem = []
let group_all = item.getCheckedNodes().filter(item => item.labelType)
let group_Label = item.getCheckedNodes().filter(item => !item.children)
let label_id = []
group_Label.forEach(item => {
label_id.push(item.id)
})
let group_half = item.getHalfCheckedNodes().filter(item => item.labelType)
let group = [...group_half, ...group_all].sort((a, b) => {
return tree_id.indexOf(a.id) - tree_id.indexOf(b.id)
})
this.tagCheckItem = this.$common.utils.deepClone(group)
group.forEach((tag, idx) => {
tag.children.forEach((item, index) => {
if (!label_id.includes(item.id)) {
this.tagCheckItem[idx].children[index] = null
}
})
})
},
//导出
handleExport() {
const params = {
...JSON.parse(JSON.stringify({ tagLists: this.allListParams }))
}
exportLabelList(params).then(res => {
this.$Utils.exportFn(res)
})
},
//客户列表
getCustomersListData() {
const tagLists = this.$common.utils.deepClone(this.allListParams)
this.userLoading = true
const params = {
...JSON.parse(JSON.stringify({ tagLists })),
pageSize: this.$refs.viewCustomers.page.pageSize,
pageNum: this.$refs.viewCustomers.page.pageNum
}
getCustomersList(params).then(res => {
this.userLoading = false
this.tableData = res.data
this.tableTotal = res.count
})
},
//创建人群
groupConfirmDialog() {
console.log(this.allListParams)
if (this.tagCheckItem.length == 0) {
this.$message.error('必须选择一个标签')
return
}
if (!this.crowdForm.crowdName) {
this.$message.error('请输入人群名称')
return
}
const tagCombine = this.allListParams.reduce((prev, cur) => {
const index = prev.findIndex(group => cur.groupId == group.groupId)
if (index == -1) {
return prev.concat({ groupId: cur.groupId, labelIdList: [cur.labelId] })
} else {
prev[index].labelIdList.push(cur.labelId)
return prev
}
}, [])
const params = {
'req.merchantId': this.merchantId,
'req.crowdType': 2, //类型 1-推荐 2-自定义
'req.crowdName': this.crowdForm.crowdName,
'req.crowdDesc': this.crowdForm.crowdDesc,
'req.tagCombine': JSON.stringify(tagCombine)
}
this.$apis.crowdManage
.addCrowd(params)
.then(res => {
if (res) {
this.$message({
type: 'success',
message: '操作成功!'
})
this.groupVisible = false
} else {
this.$message({
type: 'error',
message: '操作失败'
})
}
})
.catch(err => {
this.$message({
type: 'error',
message: err.message
})
})
}
}
}
<template>
<div class="content-wrap">
<div class="content-wrap" v-loading="loading">
<div class="tree-input">
<el-input placeholder="请输入标签组或标签关键字" v-model="filterText" size="small"><i slot="suffix" class="el-input__icon el-icon-search"></i></el-input>
<span @click="resetTree">重置</span>
......@@ -76,6 +76,7 @@ export default {
edition: this.$globalState.session.merchantModel
}
}
this.loading = true
getTableList(params).then(res => {
const labelTreeRets = res.labelTreeRets.map(item => {
return {
......@@ -92,13 +93,15 @@ export default {
this.labelTree.push({
id: item.id + '000',
name: item.labelType,
children: [item]
children: [item],
sort: item.labelType == '系统标签' ? 1 : item.labelType == '企业标签' ? 2 : 3
})
} else {
this.labelTree[index].children.push(item)
}
})
// console.log(this.labelTree)
this.labelTree = this.labelTree.sort((a, b) => a.sort - b.sort)
this.loading = false
})
}
},
......@@ -127,7 +130,7 @@ export default {
}
.tag-tree {
margin-top: 20px;
height: calc(100% - 100px);
height: calc(100% - 80px);
overflow-y: auto;
/deep/ {
.el-tree-node {
......
......@@ -148,7 +148,7 @@
</template>
<script>
import { getTableList, getTableTagNum, newAddTag, updateTag, queryLabelListByGroupId } from '@/api/modules/tagsManage'
import { getTableList, getTableTagNum, newAddTag, updateTag, exportLabelList } from '@/api/modules/tagsManage'
import { getLoginCount } from '@/api/modules/loginCount'
import url from '@/assets/clientDataOverview/nodata.png'
// import { debounce } from '@/utils/index'
......@@ -585,6 +585,15 @@ export default {
this.tagVisible = !this.tagVisible
},
//导出
handleExport() {
const params = {
...JSON.parse(JSON.stringify(this.exportParams))
}
exportLabelList(params).then(res => {
this.$Utils.exportFn(res)
})
},
newAddTagFun() {
//满足条件进行提交
let params = {}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!