消息发送

This commit is contained in:
liuye
2022-06-24 21:47:52 +08:00
parent 8e807e785f
commit ac3f5d2eff
5 changed files with 55 additions and 55 deletions

View File

@@ -20,6 +20,7 @@
</div> </div>
<u-icon name="arrow-right" color="#ddd" size="32"></u-icon> <u-icon name="arrow-right" color="#ddd" size="32"></u-icon>
</div> </div>
<AiEmpty description="暂无数据" v-if="!orgInfo.Organizational"/>
<!-- <p class="total">组织内共72人</p> --> <!-- <p class="total">组织内共72人</p> -->
</div> </div>
</div> </div>

View File

@@ -23,6 +23,7 @@
</div> </div>
</div> </div>
</div> </div>
<AiEmpty description="暂无数据" v-if="!list.length"/>
</div> </div>
</template> </template>

View File

@@ -137,25 +137,32 @@ export default {
} }
}, },
confirm() { confirm() {
// if(!this.areaIdList.length) {
// return this.$u.toast('请选择用户')
// }
this.$loading() this.$loading()
if(this.form.sendType == 1 && !this.form.sendTime) { if(!this.deptUserTagList.length) {
return this.$u.toast('请选择群发时间') return this.$u.toast('请选择部门')
} }
if(!this.form.content) { if(!this.form.content) {
return this.$u.toast('请输入文本内容') return this.$u.toast('请输入文本内容')
} }
if(this.form.contentType == 'image' && !this.formData.fileList.length) {
return this.$u.toast('请上传图片') let result = {}, tags = {}
} this.deptUserTagList.map(e => {
if(this.form.contentType == 'video' && !this.formData.fileList.length) { let {kind, id, tagIdList} = e
return this.$u.toast('请上传视频') result[e.corpId] = [result[e.corpId], {kind, id}].flat()
} if (tagIdList) {
if(this.form.contentType == 'file' && !this.formData.fileList.length) { tags[e.corpId] = [tags[e.corpId], {tagIdList}].flat()
return this.$u.toast('请上传文件')
} }
})
console.log(result, tags)
var deptList = Object.keys(result).map(corpId => ({
corpId,
objList: result[corpId],
tagId: tags[corpId]?.tagIdList
}))
console.log(deptList)
this.formData.fileList = [] this.formData.fileList = []
var contentFile = { var contentFile = {
content: this.form.content, content: this.form.content,
@@ -195,20 +202,15 @@ export default {
...this.form, ...this.form,
...this.formData, ...this.formData,
areaId: this.areaIdList.join(','), areaId: this.areaIdList.join(','),
tag: this.tagIdList.join(','), deptList: deptList,
messageSource: this.sendType == 1 ? '1' : '2'
} }
this.$http.post("/app/pushmessage/addOrUpdate", params).then(res => { this.$http.post("/app/pushmessage/addOrUpdate", params).then(res => {
if (res?.code == 0) { if (res?.code == 0) {
this.$u.toast('发送成功') this.$u.toast('发送成功')
this.form = { setTimeout(() => {
content: '', uni.navigateBack()
contentType: 'text', }, 500)
sendType: '0',
sendTime: ''
}
this.areaIdList = []
this.tagIdList = []
this.formDataInit()
}else { }else {
this.$u.toast(res.msg) this.$u.toast(res.msg)
} }
@@ -216,14 +218,6 @@ export default {
this.$u.toast(err) this.$u.toast(err)
}) })
}, },
formDataInit() {
for(let key in this.formData) {
this.formData[key] = ''
}
this.formData.fileListImg = []
this.formData.fileListVideo = []
this.formData.fileListFile = []
},
back() { back() {
uni.navigateBack() uni.navigateBack()
} }

View File

@@ -75,18 +75,18 @@ export default {
this.treeList = this.allData.filter(e => !e.parentid) this.treeList = this.allData.filter(e => !e.parentid)
this.selectDeptPath = [{name: "可选范围", id: ''}] this.selectDeptPath = [{name: "可选范围", id: ''}]
}, },
itemClick({id, name}) { itemClick({id, name, corpId}) {
let index = this.selectDeptPath.findIndex(e => e.id == id) let index = this.selectDeptPath.findIndex(e => e.id == id && e.corpId == corpId)
if (index == -1) { if (index == -1) {
this.selectDeptPath.push({name, id}) this.selectDeptPath.push({name, id, corpId})
this.getDeptsAndUsersByParent(id) this.getDeptsAndUsersByParent(id, corpId)
} }
}, },
getDeptsAndUsersByParent(departmentId) { getDeptsAndUsersByParent(departmentId, corpId) {
this.treeList = this.allData.filter(e => e.parentid == departmentId) this.treeList = this.allData.filter(e => e.parentid == departmentId && e.corpId == corpId)
this.userList = [] this.userList = []
this.$http.post(`/app/wxcp/wxuser/listByDeptId`, null, { this.$http.post(`/app/wxcp/wxuser/listByDeptId`, null, {
params: {departmentId, status: 1} params: {departmentId, status: 1, cid: corpId}
}).then(res => { }).then(res => {
if (res?.data) { if (res?.data) {
this.userList = res.data.map(e => ({...e, isChecked: this.isSelected(e.id)})) this.userList = res.data.map(e => ({...e, isChecked: this.isSelected(e.id)}))

View File

@@ -1,8 +1,8 @@
<template> <template>
<section class="selectTag"> <section class="selectTag">
<p class="title">已选择部门</p> <p class="title">已选择组织</p>
<div class="list"> <div class="list">
<div class="item" v-for="(item, index) in deptList" :key="index"> <div class="item" v-for="(item, index) in deptList" :key="index" v-if="!item.parentid">
<div class="name-flex"> <div class="name-flex">
<div class="name">{{ item.name }}</div> <div class="name">{{ item.name }}</div>
<div class="btn" @click="chooseTag(index)">添加标签</div> <div class="btn" @click="chooseTag(index)">添加标签</div>
@@ -32,6 +32,7 @@
</div> </div>
</div> </div>
</div> </div>
<AiEmpty description="暂无数据" v-if="!tagList.length"/>
</div> </div>
</u-popup> </u-popup>
</section> </section>
@@ -46,7 +47,7 @@ export default {
deptList: [], deptList: [],
userList: [], userList: [],
showTagList: false, showTagList: false,
sendType: '', //0居民 1居民 sendType: '', //0居民 1居民
tagList: [], tagList: [],
deptIndex: 0 deptIndex: 0
} }
@@ -55,17 +56,7 @@ export default {
methods: { methods: {
chooseTag(index) { chooseTag(index) {
this.deptIndex = index this.deptIndex = index
this.getTagList(this.deptList[index].id) this.getTagList(this.deptList[index].corpId)
// if(this.deptList[index].tagIdList) {
// this.tagList.map((item) => {
// item.tagList.map((items) => {
// if(this.deptList[index].tagIdList.includes(items.id)) {
// items.isCheck = true
// }
// })
// })
// }
// this.showTagList = true
}, },
typeClick(index, indexs) { typeClick(index, indexs) {
this.tagList[index].tagList[indexs].isCheck = !this.tagList[index].tagList[indexs].isCheck this.tagList[index].tagList[indexs].isCheck = !this.tagList[index].tagList[indexs].isCheck
@@ -92,7 +83,7 @@ export default {
this.showTagList=false this.showTagList=false
}, },
getTagList(id) { getTagList(id) {
var url = this.sendType == 1 ? `/app/wxcp/wxgroupchattag/listAllByCorp?dvcpId=${id}` : '/wxcp/wxgroupchattag/listAllTag?size=100' var url = this.sendType == 1 ? `/app/wxcp/wxcorptag/listAllByCorp?dvcpCorpId=${id}` : `/app/wxcp/wxgroupchattag/listAllByCorp?dvcpCorpId=${id}`
this.$http.post(url).then(res => { this.$http.post(url).then(res => {
if (res?.code == 0) { if (res?.code == 0) {
res.data.records.map((item) => { res.data.records.map((item) => {
@@ -101,11 +92,23 @@ export default {
}) })
}) })
this.tagList = res.data.records this.tagList = res.data.records
if(this.deptList[this.deptIndex].tagIdList) {
this.tagList.map((item) => {
item.tagList.map((items) => {
if(this.deptList[this.deptIndex].tagIdList.includes(items.id)) {
items.isCheck = true
}
})
})
}
this.showTagList = true
} }
}) })
}, },
confirm() { confirm() {
uni.setStorageSync('selectDeptUser', [this.deptList, ...this.userList]) console.log([...this.deptList, ...this.userList])
uni.setStorageSync('selectDeptUser', [...this.deptList, ...this.userList])
uni.navigateBack({ delta: 2 }) uni.navigateBack({ delta: 2 })
}, },
back() { back() {
@@ -119,6 +122,7 @@ export default {
onLoad() { onLoad() {
var list = uni.getStorageSync('selectDeptUser') var list = uni.getStorageSync('selectDeptUser')
this.sendType = uni.getStorageSync('sendType') this.sendType = uni.getStorageSync('sendType')
console.log(list)
list.map((item) => { list.map((item) => {
if(item.kind == 'dept') { if(item.kind == 'dept') {
this.deptList.push(item) this.deptList.push(item)