fix
This commit is contained in:
210
packages/wxwork/AppMassNotification/components/List.vue
Normal file
210
packages/wxwork/AppMassNotification/components/List.vue
Normal file
@@ -0,0 +1,210 @@
|
||||
<template>
|
||||
<ai-list class="List">
|
||||
<template #title>
|
||||
<ai-title title="群发通知" isShowBottomBorder></ai-title>
|
||||
</template>
|
||||
<template #content>
|
||||
<ai-search-bar>
|
||||
<template #left>
|
||||
<el-button type="primary" icon="iconfont iconAdd" @click="toAdd('')">添加</el-button>
|
||||
</template>
|
||||
</ai-search-bar>
|
||||
<ai-table :tableData="tableData" :total="page.total" :current.sync="page.current" :size.sync="page.size"
|
||||
@getList="getTableData" show-overflow-tooltip :col-configs="colConfigs" :dict="dict">
|
||||
<!-- <el-table-column slot="type" width="240px" label="消息内容" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<el-popover
|
||||
placement="bottom"
|
||||
width="400"
|
||||
:visible-arrow="false"
|
||||
popper-class="wechat-message__container"
|
||||
trigger="hover">
|
||||
<div class="count row-content" slot="reference" v-if="row.content">{{ row.content }}</div>
|
||||
<div class="message-info">
|
||||
<h2 :style="{marginBottom: row.accessUrl ? '16px' : '0'}">{{ row.content }}</h2>
|
||||
<div class="message-info__wrapper" v-if="row.accessUrl">
|
||||
<img v-if="row.contentType == 'image'" :src="row.accessUrl">
|
||||
<video style="width:40px; height: 40px;" v-if="row.contentType == 'video'" :src="row.accessUrl"></video>
|
||||
<img src="../../../../examples/assets/file.png" v-if="row.contentType == 'file'" width="40" height="40"/>
|
||||
<div class="message-info__wrapper--right">
|
||||
<h3 v-if="row.contentType === 'image'">{{ row.media.file.name }}</h3>
|
||||
<h3 v-if="row.contentType === 'video'">{{ row.media.file.name }}</h3>
|
||||
<p v-if="row.contentType === 'image'">{{ row.media.file.fileSizeStr }}</p>
|
||||
<p v-if="row.contentType === 'video'">{{ row.media.file.fileSizeStr }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column slot="options" label="操作" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<el-button type="text" @click="toAdd(row.id)">详情</el-button>
|
||||
<!-- <el-button type="text" @click="handleDelete(row.id)">删除</el-button> -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</ai-table>
|
||||
</template>
|
||||
</ai-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapState} from 'vuex'
|
||||
|
||||
export default {
|
||||
name: "List",
|
||||
props: {
|
||||
dict: Object,
|
||||
instance: Function,
|
||||
params: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableData: [],
|
||||
page: {current: 1, size: 10, total: 0, pages: 0},
|
||||
id: '',
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTableData()
|
||||
},
|
||||
computed: {
|
||||
colConfigs() {
|
||||
let conType = {
|
||||
text: "文本",
|
||||
image: "图片",
|
||||
video: "视频",
|
||||
file: "附件"
|
||||
}
|
||||
return [
|
||||
// { prop: "fileList", label: '消息类型', align: "center", width: "250px", formart: v => v?.map(e=> conType[e.contentType]).toString() },
|
||||
{ prop: "fileList", label: '消息内容', align: "center", width: "250px", formart: v => v?.filter(e=> e.contentType == 'text')[0].content },
|
||||
// { prop: "fileList", label: '消息内容', align: "center", width: "250px", formart: v => v?.filter(e => e.contentType == 'text')[0].content},
|
||||
// { slot: 'type' },
|
||||
{ prop: "messageSource", label: '消息类型', align: "center", formart: v => v==1? '居民': '居民群'},
|
||||
{ prop: "createTime", label: '创建时间', align: "center", width: "250px"},
|
||||
{ prop: "userName", label: '创建人', align: "center", width: "250px", },
|
||||
{ slot: "options" ,},
|
||||
]
|
||||
},
|
||||
...mapState(['user'])
|
||||
},
|
||||
|
||||
methods: {
|
||||
getTableData() {
|
||||
this.instance.post(`/app/pushmessage/list?`, null, {
|
||||
params: {
|
||||
...this.page,
|
||||
}
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
this.tableData = res.data.records
|
||||
this.page.total = res.data.total
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
mapType(type) {
|
||||
return {
|
||||
'image': '图片',
|
||||
'video': '视频',
|
||||
'file': '文件',
|
||||
'text': '文本'
|
||||
}[type]
|
||||
},
|
||||
|
||||
toAdd(id) {
|
||||
this.$emit('change', {
|
||||
type: 'Add',
|
||||
params: {
|
||||
id: id || '',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.List {
|
||||
height: 100%;
|
||||
background: #f3f4f5;
|
||||
|
||||
.count {
|
||||
cursor: pointer;
|
||||
color: #2266FF;
|
||||
font-size: 14px;
|
||||
|
||||
&:hover {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
img, video {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-right: 10px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.message-info {
|
||||
padding: 8px;
|
||||
min-height: 116px;
|
||||
|
||||
h2 {
|
||||
color: #222222;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.message-info__wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 368px;
|
||||
height: 60px;
|
||||
padding: 10px;
|
||||
background: #FFFFFF;
|
||||
border-radius: 2px;
|
||||
border: 1px solid #D0D4DC;
|
||||
|
||||
.message-info__wrapper--right {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
h3 {
|
||||
width: 100%;
|
||||
color: #222222;
|
||||
font-size: 14px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
img, video {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-right: 10px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 6px;
|
||||
font-size: 14px;
|
||||
color: #888888;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.row-content {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,195 @@
|
||||
<template>
|
||||
<section class="SelectDeptUser">
|
||||
<el-input :value="selectText" disabled size="small" @click.native="dialog=true">
|
||||
<el-button type="text" slot="append">开始选择</el-button>
|
||||
</el-input>
|
||||
<ai-dialog :visible.sync="dialog" title="选择部门/人员" width="700px" @onConfirm="handleSubmit" @close="selected=[],getDepts()">
|
||||
<el-breadcrumb separator="/">
|
||||
<el-breadcrumb-item v-for="(item, index) in selectDeptPath" :key="index">
|
||||
<el-button type="text" @click="deptNameClick(item)">{{ item.name }}</el-button>
|
||||
</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<div class="optionsItem" v-for="(row, index) in options" :key="index">
|
||||
<el-row type="flex">
|
||||
<el-checkbox class="fill" :label="row.uid" v-model="row.checked" @change="handleCheck(row,index)">{{ row.name }}</el-checkbox>
|
||||
<el-button type="text" v-if="!row.parentid&&row.kind=='dept'" @click="openDialogTag(row)">添加标签</el-button>
|
||||
<el-button type="text" v-if="row.kind=='dept'" @click="itemClick(row)">更多</el-button>
|
||||
</el-row>
|
||||
<el-tag effect="dark" size="small" v-for="tag in row.selectedTags" :key="tag.id" class="mar-4">{{ tag.name }}</el-tag>
|
||||
</div>
|
||||
<ai-empty v-if="!options.length"/>
|
||||
<ai-dialog :visible.sync="dialogTag" title="选择标签" width="500px" @onConfirm="handleSelectTag" @close="selectedTags=[]" append-to-body>
|
||||
<el-checkbox-group v-model="selectedTags">
|
||||
<div class="optionsItem" v-for="(cls, index) in tagOps" :key="index">
|
||||
<ai-title :title="cls.name"/>
|
||||
<el-checkbox class="fill" v-for="(op, i) in cls.tagList" :key="i" :label="op.id">{{ op.name }}</el-checkbox>
|
||||
</div>
|
||||
</el-checkbox-group>
|
||||
<ai-empty v-if="!tagOps.length"/>
|
||||
</ai-dialog>
|
||||
</ai-dialog>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "SelectDeptUser",
|
||||
model: {
|
||||
event: "change",
|
||||
prop: "value"
|
||||
},
|
||||
props: {
|
||||
value: {default: ""},
|
||||
instance: Function,
|
||||
dict: Object,
|
||||
source: {default: 1}
|
||||
},
|
||||
computed: {
|
||||
selectText: v => v.value?.length > 0 ? "已选择" : "请选择",
|
||||
tagAction: v => v.source == 2 ? '/app/wxcp/wxgroupchattag/listAllByCorp' : '/app/wxcp/wxcorptag/listAllByCorp'
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialog: false,
|
||||
dialogTag: false,
|
||||
currentCorp: {},
|
||||
selected: [],
|
||||
selectDeptPath: [],
|
||||
selectedTags: [],
|
||||
options: [],
|
||||
tagOps: [],
|
||||
allData: [],
|
||||
tags: {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getDepts() {
|
||||
this.instance.post('/app/wxcp/wxdepartment/listAllByCorp').then(res => {
|
||||
if (res?.data) {
|
||||
let parents = res.data.map(e => e.parentid)
|
||||
this.allData = res.data.map(e => ({
|
||||
...e,
|
||||
hasChildren: parents.includes(e.id),
|
||||
uid: [e.corpId, e.id].join("_"),
|
||||
kind: 'dept',
|
||||
checked: false
|
||||
}))
|
||||
this.deptInit()
|
||||
}
|
||||
})
|
||||
},
|
||||
getTagsByCorp(dvcpCorpId) {
|
||||
return this.instance.post(this.tagAction, null, {
|
||||
params: {
|
||||
dvcpCorpId,
|
||||
size: 9999
|
||||
}
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
return this.tagOps = res.data.records || []
|
||||
}
|
||||
})
|
||||
},
|
||||
deptInit() {
|
||||
this.options = this.allData.filter(e => !e.parentid)
|
||||
this.selectDeptPath = [{name: "可选范围", id: ''}]
|
||||
},
|
||||
itemClick(row) {
|
||||
let index = this.selectDeptPath.findIndex(e => e.id == row.id)
|
||||
if (index == -1) {
|
||||
this.selectDeptPath.push(row)
|
||||
this.getDeptsAndUsersByParent(row)
|
||||
}
|
||||
},
|
||||
getDeptsAndUsersByParent(row) {
|
||||
let {id: departmentId, corpId: cid} = row
|
||||
this.options = this.allData.filter(e => e.parentid == departmentId && e.corpId == cid) || []
|
||||
this.instance.post(`/app/wxcp/wxuser/listByDeptId`, null, {
|
||||
params: {departmentId, status: 1, cid}
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
res.data = res.data.map(e => ({
|
||||
...e, kind: "user", checked: this.selected.some(s => {
|
||||
if (e.id == s.id) return true
|
||||
})
|
||||
}))
|
||||
this.options = [this.options, res.data].flat()
|
||||
}
|
||||
})
|
||||
},
|
||||
deptNameClick(row, index) {
|
||||
if (!index) { //第一级别
|
||||
this.deptInit()
|
||||
} else {
|
||||
let length = this.selectDeptPath.length - index
|
||||
this.selectDeptPath.splice(index + 1, length)
|
||||
this.getDeptsAndUsersByParent(row.id)
|
||||
}
|
||||
},
|
||||
openDialogTag(row) {
|
||||
this.getTagsByCorp(row.corpId).then(() => {
|
||||
this.currentCorp = row
|
||||
this.dialogTag = true
|
||||
})
|
||||
},
|
||||
handleSelectTag() {
|
||||
let {corpId} = this.currentCorp
|
||||
this.currentCorp.selectedTags = this.$copy(this.tagOps.map(e => e.tagList).flat().filter(e => this.selectedTags.includes(e.id)))
|
||||
this.tags[corpId] = this.$copy(this.currentCorp.selectedTags)
|
||||
this.dialogTag = false
|
||||
},
|
||||
handleSubmit() {
|
||||
let result = {}
|
||||
this.selected?.map(e => {
|
||||
let {kind, id} = e
|
||||
result[e.corpId] = [result[e.corpId], {kind, id}].flat()
|
||||
})
|
||||
let selected = Object.keys(result).map(corpId => {
|
||||
let res
|
||||
if (result[corpId]) {
|
||||
res = {
|
||||
corpId,
|
||||
objList: result[corpId].filter(e => !!e)
|
||||
}
|
||||
if (this.tags[corpId]?.length > 0) {
|
||||
res.tagId = this.tags[corpId]?.map(e => e.id)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}).filter(e => !!e)
|
||||
this.$emit("change", selected)
|
||||
this.dialog = false
|
||||
},
|
||||
isSelected(uid) {
|
||||
return !!this.selected.find(e => e.uid == uid)
|
||||
},
|
||||
handleCheck(row, i) {
|
||||
if (row.checked) {
|
||||
this.selected.push(row)
|
||||
} else {
|
||||
this.selected.splice(i, 1)
|
||||
}
|
||||
this.$forceUpdate()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getDepts()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.SelectDeptUser {
|
||||
::v-deep.optionsItem {
|
||||
border: 1px solid #eee;
|
||||
margin-bottom: 8px;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
|
||||
.mar-4 {
|
||||
margin-right: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user