Commit 54beea8f by 王志慧

feat

1 parent e404c667
......@@ -6,7 +6,7 @@
* @param {*} params
* @returns
*/
import { http2,http3 } from '@/main'
import { http,http3 } from '@/main'
export function getTableList (params){
params.method='entmicro.api.customer.base.page'
......@@ -159,4 +159,26 @@ export function potentialClientExportApi(params){
data: params,
sign: true
})
}
// 群标签列表
export function getCustomerTag(params){
params.method='entmicro.api.customer.base.tag'
return http3({
url: '/rop-scrm-entmicro/router',
method: 'POST',
data: params,
sign: true,
returnAll:true
})
}
//编辑客户群标签(包含标签新增列表和删除列表)
export function addSingleClientTag(params) {
params.method = 'entmicro.api.customer.base.tag.edit'
return http3({
url: '/rop-scrm-entmicro/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
\ No newline at end of file
/**
* 新增参数sign 判断接口是否需要sign签名(默认有,不必写)
*/
/**
* 用法 : this.$apis.demo.GETLISTDEVICEFILEUNSTOCK(...)
* @param {*} params
* @returns
*/
import { http, http3 } from '@/main'
// const url = 'http://192.168.3.181:9636/rop-scrm-datahub/router'
export function getTableList(params) {
// params.method='scrm.api.datahub.label.querylabeltree'
params.method = 'scrm.api.datahub.labelgroup.queryLabelTree'
return http({
url: '/rop-scrm-datahub/router',
method: 'POST',
data: params,
sign: true
})
}
//计算表格上面的数量
export function getTableTagNum(params) {
// params.method='scrm.api.datahub.label.queryLabelCount'
params.method = 'scrm.api.datahub.labelgroup.queryLabelCount'
return http({
url: '/rop-scrm-datahub/router',
method: 'POST',
data: params,
sign: true
})
}
export function newAddTag(params) {
// params.method='scrm.api.datahub.label.addlabel'
params.method = 'scrm.api.datahub.labelgroup.addLabel'
return http({
url: '/rop-scrm-datahub/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
//修改标签
export function updateTag(params) {
// params.method='scrm.api.datahub.label.updatelabel'
params.method = 'scrm.api.datahub.labelgroup.updateLabel'
return http({
url: '/rop-scrm-datahub/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
//获取单条数据labelList数组
export function queryLabelListByGroupId(params) {
// params.method='scrm.api.datahub.label.queryLabelListByGroupId'
params.method = 'scrm.api.datahub.labelgroup.queryLabelListByGroupId'
return http({
url: '/rop-scrm-datahub/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
// 根据标签获取客户群列表
export function getCustomersList(params) {
params.method = 'entmicro.api.customer.base.getCustomerBasePageByTag'
return http3({
url: '/rop-scrm-entmicro/router',
method: 'POST',
data: params,
sign: true
})
}
//根据groupId查询标签列表
export function getLabelList(params) {
params.method = 'scrm.api.datahub.labelgroup.queryLabelDetailByGroupId'
return http({
url: '/rop-scrm-datahub/router',
method: 'POST',
data: params,
sign: true
})
}
// 根据标签获取客户列表导出
export function exportLabelList(params) {
params.method = 'entmicro.api.customer.customerPageByTagExport'
return http3({
url: '/rop-scrm-entmicro/router',
method: 'POST',
data: params,
sign: true
})
}
import {
getCustomersList,
exportLabelList
} from '@/api/modules/groupTag'
import {
getStaffList
} from '@/api/modules/clientManage'
export default {
data() {
return {
tagHeight: 0,
tagHeightStatus: false,
tagCheckItem: [],
allListParams: [],
crowdForm: {
crowdName: '',
crowdDesc: ''
}
}
},
mounted() {
this.getStaffList()
this.getCustomersListData()
},
watch: {
tagCheckItem: {
handler() {
if (this.tagCheckItem.length == 0) {
this.tagHeight = 0
}
this.allListParams = []
this.sopListParams = []
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.sopListParams.push({
labelGroupName: group_item.name,
labelName: label_item.name
})
}
})
})
this.getCustomersListData()
},
deep: true
},
tagHeight: {
handler(val) {
if (val == 0) {
setTimeout(() => {
this.tagHeightStatus = false
}, 300)
} else {
this.tagHeightStatus = true
}
},
deep: true
}
},
methods: {
//获取跟进员工
getStaffList() {
getStaffList({}).then(res => {
if (res.length == 0) {
return ''
}
const id = this.tagsPartFormList.findIndex(item => {
return item.name == 'followStaff'
})
const staff = res.map(item => {
return {
label: item.staffName,
value: item.staffName
}
})
staff.unshift({
label: '全部',
value: ''
})
this.$nextTick(() => {
this.tagsPartFormList[id].optionList = staff
})
})
},
tagLength(children) {
return children.filter(item => item).length
},
goDetail(scope) {
this.$router.push('/clientManage/clientDetail?id=' + scope.oneId)
},
goGroupDetail(scope) {
this.$router.push('/clientGroupManage/clientGroupDetail?id=' + scope.oneId)
},
jumpGroup() {
this.$router.push({
path: '/crowdManage/index',
query: {
selectTab: 1
}
})
},
//删除标签组
removeItem(index) {
this.tagCheckItem.splice(index, 1)
this.$refs.tagTree.getTreeNode(this.tagCheckItem)
},
treeScroll(id) {
const h = document.querySelector('.node_' + id).offsetTop
this.$refs.tagTree.handleScroll(h)
},
//获取选中的标签并排序
getCheckItem(item) {
const tree_id = []
const labelTree = this.$common.utils.deepClone(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
}
})
})
this.tagCheckItem.forEach(tag => {
tag.children = tag.children.filter(item => item)
})
},
//导出
handleExport() {
const params = {
...JSON.parse(JSON.stringify({
tagLists: this.allListParams
})),
...this.searchForm,
combineType: 2
}
exportLabelList(params).then(res => {
this.$Utils.exportFn(res)
})
},
//客户列表
getCustomersListData() {
if (this.searchForm.createTime) {
this.searchForm.beginCarBuyDate = new Date(this.searchForm.createTime[0]).toLocaleDateString().replace(/-/g, '/')
this.searchForm.endCarBuyDate = new Date(this.searchForm.createTime[1]).toLocaleDateString().replace(/-/g, '/')
}
delete this.searchForm.createTime
const tagLists = this.$common.utils.deepClone(this.allListParams)
this.userLoading = true
const params = {
...JSON.parse(JSON.stringify({
tagLists
})),
...JSON.parse(JSON.stringify(this.searchForm)),
combineType: 2,
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
this.$nextTick(() => {
if (tagLists.length == 0) {
document.querySelector('.noDataText').innerText = '当前未选择标签,快去选择标签查看客户吧!'
} else {
document.querySelector('.noDataText') ? (document.querySelector('.noDataText').innerText = '暂无数据') : ''
}
})
if (this.tableData == 0) {
this.$refs.viewCustomers.setTableHeightFun()
} else {
this.$refs.viewCustomers.tableHeightValues = ''
}
})
.catch(err => {
this.userLoading = false
})
},
//创建人群
groupConfirmDialog() {
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.data.code == 0) {
this.groupVisible = false
this.successVisible = true
} else {
this.$message({
type: 'error',
message: res.data.message
})
}
})
.catch(err => {
this.$message({
type: 'error',
message: err.message
})
})
}
}
}
\ No newline at end of file
......@@ -97,6 +97,9 @@ export default {
goDetail(scope) {
this.$router.push('/clientManage/clientDetail?id=' + scope.oneId)
},
goGroupDetail(scope) {
this.$router.push('/clientGroupManage/clientGroupDetail?id=' + scope.oneId)
},
jumpGroup() {
this.$router.push({
path: '/crowdManage/index',
......
......@@ -72,6 +72,12 @@ const staticRoutes = Object.freeze([
meta: {}
},
{
name: 'groupTagsManage',
path: '/groupTagsManage/index',
component: resolve => require([`@/views/groupTagsManage/index.vue`], resolve),
meta: {}
},
{
name: 'viewCustomers',
path: '/tagsManage/viewCustomers/:info/:type',
component: resolve => require([`@/views/tagsManage/viewCustomers.vue`], resolve),
......
......@@ -67,6 +67,9 @@
<template v-if="currentIndex == 3">
<potential-client ref="childCompPotential" :url="url"></potential-client>
</template>
<template v-if="currentIndex == 4">
<group-tag ref="childCompPotential" :url="url"></group-tag>
</template>
<GLDialog mode="small" :visible.sync="dialogVisible">
<div class="content-body">
<p>该客户暂无员工跟进,无法查看该客户详情,</p>
......@@ -87,6 +90,7 @@ import client from '@/views/clientGroupManage/components/client.vue'
import followEmployee from '@/views/clientGroupManage/components/followEmployee.vue'
import leaveGroupClient from '@/views/clientGroupManage/components/leaveGroupClient.vue'
import potentialClient from '@/views/clientGroupManage/components/potentialClient.vue'
import groupTag from '@/views/clientGroupManage/components/groupTag.vue'
import url from '@/assets/clientDataOverview/nodata.png'
export default {
name: 'clientGroupDetail',
......@@ -94,7 +98,8 @@ export default {
client,
followEmployee,
leaveGroupClient,
potentialClient
potentialClient,
groupTag
},
data() {
return {
......@@ -116,6 +121,10 @@ export default {
{
name: '潜在客户',
personNum: 0
},
{
name: '群标签',
personNum: 0
}
],
currentIndex: 0,
......@@ -136,9 +145,9 @@ export default {
// deep: true,
// // immediate:true,
// handler(val) {
//
//
// if(val){
//
//
// this.searchTable()
// }
// }
......@@ -167,7 +176,7 @@ export default {
},
async getTableDetail(id = this.$route.query.id) {
const res = await getTableDetail({ id: id, pageNum: 1, pageSize: 10 })
if (!res) {
return false
}
......@@ -351,14 +360,14 @@ export default {
}
}
}
.content-body {
font-size: 18px;
text-align: center;
font-weight: 400;
color: #333333;
.bottomText {
margin-top: 10px;
}
.content-body {
font-size: 18px;
text-align: center;
font-weight: 400;
color: #333333;
.bottomText {
margin-top: 10px;
}
}
}
</style>
<template>
<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>
</div>
<el-tree @node-expand="nodeExpand" accordion @check="checkChange" class="tag-tree" ref="tagTree" :data="labelTree" :props="defaultProps" @node-click="nodeClick" show-checkbox node-key="id" :default-expanded-keys="expandId" :expand-on-click-node="false" :filter-node-method="filterNode">
<div class="custom-tree-node" slot-scope="{ node, data }">
<el-tooltip placement="top" v-if="hoverId == data.id && hoverStatus">
<span :class="['tree-node', `node_${data.id}`]" slot="content">
{{ node.label }}
</span>
<span :class="['tree-node', `node_${data.id}`]">
{{ node.label }}
</span>
</el-tooltip>
<span :class="['tree-node', `node_${data.id}`]" v-else @mouseenter="hoverFun(data)">
{{ node.label }}
</span>
<span v-if="data.labelType && data.labelType != '系统标签' && isShowEditBtn(data.labelDTO)" @click.stop="editTree(data)">
<i class="el-icon-edit-outline"></i>
</span>
</div>
</el-tree>
</div>
</template>
<script>
import { getTableList } from '@/api/modules/tagsManage'
export default {
name: 'tagGroup',
data() {
return {
hoverId: '',
hoverStatus: false,
expandId: [],
loading: false,
heightBox: 200,
dialogVisible: false,
filterText: '',
selectNum: 0,
searchStatus: false,
labelTree: [],
defaultProps: {
children: 'children',
label: 'name'
}
}
},
watch: {
filterText(val) {
this.$refs.tagTree.filter(val)
}
},
methods: {
hoverFun(data) {
this.hoverId = data.id
this.hoverStatus = document.querySelector(`.node_${data.id}`).scrollWidth > 140
},
isShowEditBtn(row) {
const { userType, accountLevel, merchantModel } = this.$globalState.session
//集团模式下,只有集团能可以编辑企业,自店,其他只能编辑自店
//单店模式下,仅门店和员工可以编辑
if (row.labelType == '自店标签' && !(merchantModel == 1 && (accountLevel == 2 || accountLevel == 3 || accountLevel == 4))) {
return false
}
if (merchantModel == 1) {
if (accountLevel == 1 && userType == 1) {
return true
}
if (accountLevel !== 1) {
//如果是企业标签不显示
if (row.labelType == '企业标签' || row.labelType == '集团标签') {
return false
}
return true
}
}
return true //门店版都显示编辑按钮
},
nodeClick(data) {
!data.sort && document.querySelector(`.node_${data.id}`).parentElement.previousElementSibling.click()
},
handleScroll(height) {
document.querySelector('.tag-tree').scrollTop = height
},
resetTree() {
this.filterText = ''
this.$parent.searchForm = {}
this.$refs.tagTree.setCheckedKeys([])
this.$nextTick(() => {
this.$emit('getCheckItem', this.$refs.tagTree)
})
},
filterNode(value, data, node) {
if (!value) return true
return data.name.indexOf(value) !== -1
// let val = value.toLowerCase()
// this.$nextTick(() => {
// this.setTreeHeight()
// })
// return this.chooseNode(val, data, node) // 调用过滤二层方法
},
chooseNode(value, data, node) {
if (data.name.indexOf(value) !== -1) {
return true
}
const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了
if (level === 1) {
return false
}
// 先取当前节点的父节点
let parentData = node.parent
// 遍历当前节点的父节点
let index = 0
while (index < level - 1) {
// 如果匹配到直接返回,此处name值是中文字符,enName是英文字符。判断匹配中英文过滤
if (parentData.data.name.indexOf(value) !== -1) {
return true
}
// 否则的话再往上一层做匹配
parentData = parentData.parent
index++
}
// 没匹配到返回false
return false
},
//勾选
checkChange() {
this.$emit('getCheckItem', this.$refs.tagTree)
},
getTreeNode(item) {
let tree_id = []
item.forEach(group_item => {
group_item.children.forEach(label_item => {
label_item && tree_id.push(label_item.id)
})
})
this.$refs.tagTree.setCheckedKeys(tree_id)
},
editTree(data) {
this.$emit('editTag', 'edit', data.labelDTO)
},
updateTreeNode() {
this.getTreeNode(this.$parent.tagCheckItem)
this.$emit('getCheckItem', this.$refs.tagTree)
},
// 获取标签树
getTableList(status) {
this.labelTree = []
let params = {
belongType: 2,
labelTreeReq: {
pageNum: 1,
pageSize: 10000,
shopId: this.$globalState.session.merchantId,
labelGroupName: this.filterText,
edition: this.$globalState.session.merchantModel
}
}
this.loading = true
getTableList(params).then(res => {
const labelTreeRets = res.labelTreeRets.map(item => {
return {
id: item.labelGroup.id,
name: item.labelGroup.name,
children: item.labelList,
labelType: item.labelType == '企业标签' && this.$globalState.session.merchantModel == 1 ? '集团标签' : item.labelType,
labelDTO: item
}
})
const labelType = this.$globalState.session.merchantModel == 1 ? '集团标签' : '企业标签'
labelTreeRets.forEach(item => {
const index = this.labelTree.findIndex(ret => ret.name == item.labelType)
if (index == -1) {
this.labelTree.push({
id: item.labelType == '系统标签' ? 1 : item.labelType == labelType ? 2 : 3,
name: item.labelType,
children: [item],
sort: item.labelType == '系统标签' ? 1 : item.labelType == labelType ? 2 : 3
})
} else {
this.labelTree[index].children.push(item)
}
})
this.labelTree = this.labelTree.sort((a, b) => a.sort - b.sort)
this.expandId = []
if (this.labelTree && this.labelTree.length) {
this.labelTree[0].children.forEach(item => {
this.expandId.push(item.id)
})
}
this.$nextTick(() => {
status && this.updateTreeNode()
this.setTreeHeight()
})
this.loading = false
})
},
setTreeHeight(domNode) {
const nodeHeight = document.querySelectorAll('.el-tree>.el-tree-node').length * 30
if (domNode) {
domNode.style.maxHeight = this.$parent.heightBox - 80 - nodeHeight + 'px'
domNode.style.overflow = 'auto'
} else {
document.querySelector('.el-tree>.el-tree-node.is-expanded .el-tree-node__children').style.maxHeight = this.$parent.heightBox - 80 - nodeHeight + 'px'
document.querySelector('.el-tree>.el-tree-node.is-expanded .el-tree-node__children').style.overflow = 'auto'
}
},
nodeExpand(data, node, target) {
if (data.sort) {
this.$nextTick(() => {
const domNode = target.$refs.node.lastElementChild
this.setTreeHeight(domNode)
})
}
}
},
mounted() {
this.getTableList()
}
}
</script>
<style lang="scss" scoped>
.content-wrap {
padding: 16px 3px 0px 16px;
box-sizing: border-box;
height: 100%;
.tree-input {
display: flex;
align-items: center;
span {
display: inline-block;
color: #5850ff;
font-size: 14px;
width: 40px;
margin-left: 6px;
cursor: pointer;
}
}
.tag-tree {
margin-top: 20px;
overflow-y: auto;
/deep/ {
.el-tree-node {
.el-tree-node__content {
height: 30px;
> .el-checkbox {
display: none;
}
}
}
.el-tree-node__children {
.el-tree-node__content {
.el-checkbox {
display: block;
}
}
}
.custom-tree-node {
font-size: 14px;
color: #333;
}
.tree-node {
width: 140px;
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.el-tree-node__expand-icon {
font-size: 15px;
margin-top: -2px;
color: #000000;
}
.el-tree-node__expand-icon.is-leaf {
color: transparent;
}
.el-checkbox__inner {
margin-right: 10px;
}
.el-icon-edit-outline {
color: #999;
font-size: 15px;
cursor: pointer;
&:hover {
color: #5850ff;
}
}
}
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!