Commit df48df37 by xinla

--no commit message

1 parent 71dbc23b
...@@ -82,12 +82,12 @@ export function getDetail(id) { ...@@ -82,12 +82,12 @@ export function getDetail(id) {
*/ */
export function add(data) { export function add(data) {
data = Object.assign({}, data, { data = Object.assign({}, data, {
emplList: data.users?.map((e) => e.id) + '', emplList: data.users?.map((e) => e.id)?.join(','),
emplNames: data.users?.map((e) => e.name) + '', emplNames: data.users?.map((e) => e.name)?.join(','),
tagList: data.tags?.map((e) => e.id) + '', tagList: data.tags?.map((e) => e.id)?.join(','),
tagNames: data.tags?.map((e) => e.name) + '', tagNames: data.tags?.map((e) => e.name)?.join(','),
chatIdList: data.chatList?.map((e) => e.id) + '', chatIdList: data.groupList?.map((e) => e.id)?.join(','),
chatIdListNames: data.chatList?.map((e) => e.name) + '', chatIdListNames: data.groupList?.map((e) => e.name)?.join(','),
}) })
return request({ return request({
url: service + '/add', url: service + '/add',
......
<template>
<div class="modal">
<el-dialog title="选择客群" v-model="modalVisible" :close-on-click-modal="false">
<div class="fixed-content">
已选择:
<template v-for="(item, index) in groupChildList" :key="index">
<el-tag style="margin-bottom: 5px" v-if="item.groupName" closable @close="handleClose(item)">
{{ item.groupName }}
</el-tag>
</template>
</div>
<el-form
:model="query"
ref="queryForm"
:inline="true"
class="top-search"
label-width="40px"
label-position="left">
<el-form-item label="" prop="groupName">
<el-input style="width: 150px" v-model="query.groupName" placeholder="请输入群名" clearable />
</el-form-item>
<el-form-item label="" prop="groupLeaderName">
<el-input style="width: 150px" v-model="query.groupLeaderName" placeholder="请输入群主" clearable />
</el-form-item>
<el-form-item label="" prop="">
<el-input
style="width: 150px"
:model-value="tagNames"
readonly
@click="showSelectTag = true"
placeholder="请选择客群标签" />
</el-form-item>
<el-form-item label="">
<el-button type="primary" @click="getList(1)">查询</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table
ref="multipleTable"
v-loading="loading"
:data="list"
@select="selectFn"
@select-all="selectAllFn"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="群名" align="center" prop="groupName" />
<el-table-column label="群主" align="center" prop="groupLeaderName" />
<el-table-column label="群标签" width="180">
<template #default="{ row }">
<tag-ellipsis v-if="row.tags" :list="row.tags.split(',')" limit="1"></tag-ellipsis>
</template>
</el-table-column>
<el-table-column label="群总人数 " align="center " prop="memberNum" />
</el-table>
<pagination
v-show="total > 0"
:total="total"
v-model:page="query.pageNum"
v-model:limit="query.pageSize"
@pagination="getList()" />
<template #footer>
<div>
<el-button @click="cancelFn">取 消</el-button>
<el-button type="primary" @click="submit">确 定</el-button>
</div>
</template>
</el-dialog>
<select-tag v-model:visible="showSelectTag" type="2" :selected="tagList" @success="getSelectTag"></select-tag>
</div>
</template>
<script>
import * as api from '@/api/customer/group'
import SelectTag from '@/components/SelectTag.vue'
export default {
name: 'select-group',
props: {
visible: {
type: Boolean,
default: false,
},
limit: {
type: Number,
default: 5,
},
defaults: {
type: Array,
default: () => [],
},
},
components: { SelectTag },
data() {
return {
query: {
pageNum: 1,
pageSize: 10,
groupName: '',
groupLeaderName: '',
tagIds: '',
},
total: 0,
list: [],
loading: false,
groupChildList: [],
tagNames: '',
showSelectTag: false,
tagList: [],
}
},
computed: {
modalVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
},
},
},
watch: {
visible(val) {
val && this.getList(1)
this.groupChildList = JSON.parse(JSON.stringify(this.defaults))
},
},
methods: {
getSelectTag(list) {
this.taglist = list
let arr = []
let arr1 = []
list.forEach((dd) => {
arr.push(dd.name)
arr1.push(dd.tagId)
})
this.tagNames = arr.join(',')
this.query.tagIds = arr1.join(',')
},
handleClose(tag) {
this.groupChildList.splice(this.groupChildList.indexOf(tag), 1)
this.list.forEach((row) => {
if (row.chatId === tag.chatId) {
this.$refs.multipleTable.toggleRowSelection(row, false)
}
})
},
resetQuery() {
;(this.query = {
pageNum: 1,
pageSize: 10,
groupName: '',
groupLeaderName: '',
tagIds: '',
}),
(this.tagList = [])
this.tagNames = ''
this.getList()
},
getList(page) {
this.loading = true
page && (this.query.pageNum = page)
api.getList(this.query).then((res) => {
this.total = Number(res.total)
this.list = res.rows
this.loading = false
setTimeout(() => {
this.toggleSelection()
}, 300)
})
},
toggleSelection() {
if (this.groupChildList) {
this.groupChildList.forEach((row) => {
this.list.forEach((data) => {
if (row.chatId === data.chatId) {
this.$refs.multipleTable.toggleRowSelection(data)
}
})
})
} else {
this.$refs.multipleTable.clearSelection()
}
},
handleSelectionChange(selection) {
let arr = selection
this.groupChildList.forEach((val) => {
arr = arr.filter((item) => {
return item.chatId !== val.chatId
})
})
this.groupChildList.push(...arr)
},
selectFn(data, row) {
if (!data.includes(row)) {
let index = this.groupChildList.findIndex((arr) => arr.chatId === row.chatId)
if (index !== -1) {
this.groupChildList.splice(index, 1)
}
}
},
selectAllFn(data) {
console.log(data)
if (!data.length) {
this.list.forEach((dd) => {
let index = this.groupChildList.findIndex((arr) => arr.chatId === dd.chatId)
if (index !== -1) {
this.groupChildList.splice(index, 1)
}
})
}
},
submit() {
if (!this.groupChildList.length) {
this.msgInfo('请至少选择一个客群!')
return
}
if (this.groupChildList.length > 5) {
this.msgInfo('最多选择五个客群!')
return
}
this.$emit('submit', this.groupChildList)
this.list = []
this.modalVisible = false
},
cancelFn() {
this.list = []
this.modalVisible = false
},
},
created() {},
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
color: var(--font-black-4);
word-break: break-all;
}
.fixed-content {
position: sticky;
top: 0;
left: 0;
z-index: 10;
background: var(--bg-white);
}
</style>
...@@ -10,24 +10,23 @@ export default { ...@@ -10,24 +10,23 @@ export default {
newGroupId: '', newGroupId: '',
dialogVisibleSelectUser: false, // 选择员工会话 dialogVisibleSelectUser: false, // 选择员工会话
dialogVisibleSelectTag: false, // 选择客户标签会话 dialogVisibleSelectTag: false, // 选择客户标签会话
dialogVisibleSelectQrCode: false, // 选择群活码会话 dialogVisibleSelectGroup: false, // 选择群活码会话
loading: false, loading: false,
form: { form: {
codeName: '', // 活码名称 codeName: '', // 活码名称
emplList: [], // 员工 emplList: [], // 员工
welcomeMsg: '', //加群引导语 welcomeMsg: '', //加群引导语
groupCodeId: undefined, // 群活码ID groupCodeId: undefined, // 群活码ID
tagList: [], // 客户标签 skipVerify: false, // 无需确认自动加好友
skipVerify: 0, // 无需确认自动加好友 // users: [],
users: [], // tags: [], // 客户标签
tags: [],
}, },
codes: [], codes: [],
groupQrCode: {}, groupQrCode: {},
rules: Object.freeze({ rules: Object.freeze({
codeName: [{ required: true, message: '该项为必填项', trigger: 'blur' }], codeName: [{ required: true, message: '该项为必填项', trigger: 'blur' }],
users: [{ required: true, message: '该项为必填项', trigger: 'blur' }], users: [{ required: true, message: '该项为必填项', trigger: 'blur' }],
tagList: [{ required: true, message: '该项为必填项', trigger: 'change' }], tags: [{ required: true, message: '该项为必填项', trigger: 'change' }],
groupCodeId: [{ required: true, message: '该项为必填项', trigger: 'blur' }], groupCodeId: [{ required: true, message: '该项为必填项', trigger: 'blur' }],
welcomeMsg: [{ required: true, message: '该项为必填项', trigger: 'blur' }], welcomeMsg: [{ required: true, message: '该项为必填项', trigger: 'blur' }],
}), }),
...@@ -185,7 +184,7 @@ export default { ...@@ -185,7 +184,7 @@ export default {
clearable></TextareaExtend> clearable></TextareaExtend>
</el-form-item> </el-form-item>
<el-form-item label="活码客群:" prop="chatIdList"> <el-form-item label="活码客群:" prop="chatIdList">
<el-button type="primary" @click="selectGroupFn">选择客群</el-button> <el-button type="primary" @click="dialogVisibleSelectGroup = true">选择客群</el-button>
<div class="tip">最多选择五个客群</div> <div class="tip">最多选择五个客群</div>
<TagEllipsis :list="form.groupList" limit="10" defaultProps="groupName"></TagEllipsis> <TagEllipsis :list="form.groupList" limit="10" defaultProps="groupName"></TagEllipsis>
</el-form-item> </el-form-item>
...@@ -255,9 +254,9 @@ export default { ...@@ -255,9 +254,9 @@ export default {
<SelectTag v-model:visible="dialogVisibleSelectTag" :selected="form.tags" @success="submitSelectTag"></SelectTag> <SelectTag v-model:visible="dialogVisibleSelectTag" :selected="form.tags" @success="submitSelectTag"></SelectTag>
<SelectGroup <SelectGroup
v-model:visible="showSelectModal" v-model:visible="dialogVisibleSelectGroup"
:defaults="form.groupList" :defaults="form.groupList"
@submit="(data) => (form.groupList = data)"></SelectGroup> @submit="(data) => (form.groupList = data.map((e) => ({ id: e.chatId, name: e.groupName })))"></SelectGroup>
<!-- 选择二维码弹窗 --> <!-- 选择二维码弹窗 -->
<!-- <SelectQrCode <!-- <SelectQrCode
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!