Files
dvcp_v2_webapp/packages/wxwork/AppMassNotification/components/Add.vue

406 lines
11 KiB
Vue
Raw Normal View History

2022-06-13 17:18:21 +08:00
<template>
<section class="Add">
2022-06-24 20:50:47 +08:00
<ai-detail v-if="!$route.query.id">
2022-06-13 17:18:21 +08:00
<template slot="title">
<ai-title title="群发通知" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template>
<template slot="content">
<ai-card>
<template #title>
<div class="ai-card__title">
2022-06-24 20:45:45 +08:00
<h2>发送条件</h2>
2022-06-13 17:18:21 +08:00
</div>
</template>
<template #content>
2022-06-24 23:12:16 +08:00
<el-form size="small" class="ai-form" :rules="rules" ref="form" :model="form" label-width="100px" label-position="right">
2022-06-13 17:18:21 +08:00
2022-06-24 23:12:16 +08:00
<el-form-item label="发送方式" prop="messageSource" style="width: 50%">
2022-06-24 20:45:45 +08:00
<el-radio v-model="form.messageSource" label="2">居民群</el-radio>
<el-radio v-model="form.messageSource" label="1">居民</el-radio>
2022-06-24 15:08:02 +08:00
</el-form-item>
2022-06-13 17:18:21 +08:00
<el-form-item label="地区选择" style="width: 100%">
2022-06-24 23:12:16 +08:00
<ai-area-get v-model="areaId" :root="areaRootId" :instance="instance" @select="handleAreaSelect" multiple size="small" placeholder="全部地区"/>
2022-06-13 17:18:21 +08:00
</el-form-item>
2022-06-24 23:12:16 +08:00
<el-form-item label="发送范围" style="width: 100%">
<select-dept-user v-model="form.deptList" v-bind="$props" :source="form.messageSource"/>
2022-06-24 15:08:02 +08:00
</el-form-item>
2022-06-13 17:18:21 +08:00
</el-form>
</template>
</ai-card>
<ai-card title="群发消息设置">
<template #content>
<el-form class="ai-form" ref="form" :rules="rules" :model="form" label-width="110px" label-position="right">
<el-form-item class="el-form-item__textarea" label="群发内容" prop="content" style="width: 100%">
<el-input type="textarea" placeholder="请输入…" v-model="form.content" maxlength="1000" :rows="5" show-word-limit></el-input>
</el-form-item>
<!-- 图片 -->
2022-06-24 20:45:45 +08:00
<el-form-item label="图片" style="width: 100%">
2022-06-24 23:12:16 +08:00
<ai-uploader :instance="instance" isWechat v-model="imgList" multiple acceptType=".jpg,.png,.jpeg" :limit="9"
url="/app/wxcp/upload/uploadFile?type=image"></ai-uploader>
2022-06-13 17:18:21 +08:00
</el-form-item>
<!-- 视频 -->
2022-06-24 20:45:45 +08:00
<el-form-item label="视频" style="width: 100%">
2022-06-24 23:12:16 +08:00
<ai-uploader :instance="instance" fileType="file" isWechat multiple acceptType=".mp4" v-model="videoList" :limit="9"
url="/app/wxcp/upload/uploadFile?type=video"></ai-uploader>
2022-06-13 17:18:21 +08:00
</el-form-item>
<!-- 附件 -->
2022-06-24 20:45:45 +08:00
<el-form-item label="附件" style="width: 100%">
2022-06-24 23:12:16 +08:00
<ai-uploader :instance="instance" fileType="file" isWechat multiple v-model="filesList" :limit="9"
url="/app/wxcp/upload/uploadFile?type=file"></ai-uploader>
2022-06-13 17:18:21 +08:00
</el-form-item>
</el-form>
</template>
</ai-card>
</template>
<template #footer>
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="confirm">确认发送</el-button>
</template>
</ai-detail>
2022-06-24 20:50:47 +08:00
<ai-detail class="add" v-if="$route.query.id">
2022-06-13 17:18:21 +08:00
<template slot="title">
<ai-title title="群发通知详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template>
<template slot="content">
<ai-card title="详情">
<template #content>
<ai-wrapper>
<ai-info-item label="创建者" :value="data.userName" isLine></ai-info-item>
2022-06-24 23:21:18 +08:00
<!-- <ai-info-item label="发送类型" :value="data.messageSource" isLine>{{ data.messageSource | format }}</ai-info-item> -->
2022-06-14 14:04:00 +08:00
</ai-wrapper>
<ai-wrapper v-for="item in data.fileList" :key="item.id">
<ai-info-item label="群发内容" :value="item.content" isLine v-if="item.contentType == 'text'"></ai-info-item>
2022-06-14 17:37:10 +08:00
</ai-wrapper>
<ai-wrapper v-for="item in data.fileList" :key="item.id">
2022-06-14 14:04:00 +08:00
<ai-info-item label="图片" isLine v-if="item.contentType == 'image'">
<ai-uploader v-model="images" :instance="instance" :limit="1" disabled/>
</ai-info-item>
2022-06-14 17:37:10 +08:00
</ai-wrapper>
<ai-wrapper v-for="item in data.fileList" :key="item.id">
2022-06-14 14:04:00 +08:00
<ai-info-item label="视频" isLine v-if="item.contentType == 'video'">
<video :src="item.accessUrl" style="width: 100%; height:100%; object-fit: fill;" muted controls="controls"></video>
</ai-info-item>
2022-06-14 17:37:10 +08:00
</ai-wrapper>
<ai-wrapper v-for="item in data.fileList" :key="item.id">
2022-06-14 14:04:00 +08:00
<ai-info-item label="附件" isLine v-if="item.contentType == 'file'">
2022-06-14 17:37:10 +08:00
<ai-file-list :fileList="fileDownLoad"></ai-file-list>
2022-06-14 14:04:00 +08:00
</ai-info-item>
2022-06-13 17:18:21 +08:00
</ai-wrapper>
2022-06-14 17:37:10 +08:00
2022-06-13 17:18:21 +08:00
</template>
</ai-card>
</template>
</ai-detail>
</section>
</template>
<script>
2022-06-14 14:04:00 +08:00
import {mapState} from "vuex";
2022-06-24 23:12:16 +08:00
import SelectDeptUser from "./SelectDeptUser";
2022-06-24 20:50:47 +08:00
2022-06-14 14:04:00 +08:00
export default {
name: 'Add',
2022-06-24 23:12:16 +08:00
components: {SelectDeptUser},
2022-06-14 14:04:00 +08:00
props: {
instance: Function,
2022-06-24 20:50:47 +08:00
dict: Object
2022-06-14 14:04:00 +08:00
},
2022-06-24 20:50:47 +08:00
data() {
2022-06-14 14:04:00 +08:00
return {
isShow: false,
data: {},
form: {
areaId: '',
tag: '',
2022-06-24 20:45:45 +08:00
messageSource: '2',
2022-06-14 14:04:00 +08:00
sendTime: '',
content: '',
contentType: 'text',
2022-06-24 20:45:45 +08:00
fileList: [],
organization: '',
deptList: [{
corpId: "",
objList: [],
tagId: [],
}],
2022-06-13 17:18:21 +08:00
},
2022-06-14 14:04:00 +08:00
tags: [],
subTags: {},
areaId: [],
areaName: [],
imgList: [],
videoList: [],
filesList: [],
2022-06-14 17:37:10 +08:00
fileDownLoad: [],
2022-06-14 14:04:00 +08:00
areaRootId: '',
users: [],
images: [],
2022-06-24 20:45:45 +08:00
imgs: [],
videos: [],
files: [],
2022-06-27 09:03:16 +08:00
// orgIdList: '',
// orgNameList: [],
// orgSelect: '',
// orgAllList: [],
2022-06-14 14:04:00 +08:00
rules: {
2022-06-24 23:12:16 +08:00
content: [{required: true, message: '请输入群发内容'}],
messageSource: [{required: true, message: '请选择群发方式'}],
sendTime: [{required: true, message: '请选择群发时间'}],
2022-06-13 17:18:21 +08:00
},
2022-06-14 14:04:00 +08:00
}
},
2022-06-13 17:18:21 +08:00
2022-06-14 14:04:00 +08:00
computed: {
2022-06-24 20:45:45 +08:00
...mapState(['user']),
2022-06-14 14:04:00 +08:00
tagsChange() {
2022-06-24 23:12:16 +08:00
if (this.tags?.length) {
2022-06-14 14:04:00 +08:00
return this.form.tag = this.tags.toString();
2022-06-13 17:18:21 +08:00
}
},
2022-06-14 14:04:00 +08:00
areaid() {
return this.form.areaId = this.areaId.toString();
},
2022-06-24 20:45:45 +08:00
},
2022-06-27 09:03:16 +08:00
// watch: {
// orgNameList: {
// handler: function (v) {
// this.orgSelect = `已选择${v.length}个组织`
// }
// }
// },
2022-06-14 14:04:00 +08:00
2022-06-24 20:50:47 +08:00
created() {
if (this.$route.query.id) {
2022-06-14 14:04:00 +08:00
this.getInfo()
}
2022-06-24 20:50:47 +08:00
this.areaRootId = [this.user.info.areaId.substr(0, 6), '000000'].join("")
2022-06-14 14:04:00 +08:00
},
2022-06-13 17:18:21 +08:00
2022-06-14 14:04:00 +08:00
methods: {
handleAreaSelect(v) {
this.areaName = v?.[0]?.label
},
2022-06-27 09:03:16 +08:00
2022-06-14 14:04:00 +08:00
// 标签
2022-06-27 09:03:16 +08:00
// getSubTags() {
// this.instance.post(`/app/wxcp/wxgroupchattag/listAllByCorp?dvcpId=${this.orgIdList}`).then(res => {
// if (res?.data) {
// console.log(res);
// this.subTags = res.data.records
// }
// })
// },
2022-06-24 20:50:47 +08:00
getInfo() {
this.instance.post(`/app/pushmessage/detail?id=${this.$route.query.id}`).then(res => {
2022-06-14 14:04:00 +08:00
if (res?.data) {
this.data = res.data
2022-06-24 20:50:47 +08:00
this.images = [{url: res.data.fileList.filter(e => e.contentType == "image")[0]?.accessUrl}]
this.fileDownLoad = [{url: res.data.fileList.filter(e => e.contentType == "file")[0]?.accessUrl}]
2022-06-14 14:04:00 +08:00
}
})
},
2022-06-24 20:50:47 +08:00
confirm() {
2022-06-14 14:04:00 +08:00
this.$refs.form.validate((valid) => {
if (valid) {
this.form.fileList = []
2022-06-24 20:45:45 +08:00
let contentList = [{
2022-06-14 14:04:00 +08:00
content: this.form.content,
contentType: 'text'
2022-06-24 20:45:45 +08:00
}]
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
if (this.imgList.length) {
2022-06-24 20:45:45 +08:00
this.imgs = this.imgList.map(item => {
return {
contentType: 'image',
mediaId: item.media.mediaId,
accessUrl: item.url,
}
})
2022-06-14 14:04:00 +08:00
}
2022-06-13 22:54:51 +08:00
2022-06-24 20:50:47 +08:00
if (this.videoList.length) {
2022-06-24 20:45:45 +08:00
this.videos = this.videoList.map(item => {
return {
contentType: 'video',
mediaId: item.media.mediaId,
accessUrl: item.url,
}
})
2022-06-14 14:04:00 +08:00
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
if (this.filesList.length) {
2022-06-24 20:45:45 +08:00
this.files = this.filesList.map(item => {
return {
contentType: 'file',
mediaId: item.media.mediaId,
accessUrl: item.url,
}
})
2022-06-13 17:18:21 +08:00
}
2022-06-24 20:45:45 +08:00
this.form.fileList = [...contentList, ...this.imgs, ...this.videos, ...this.files]
2022-06-14 14:04:00 +08:00
this.instance.post(`/app/pushmessage/addOrUpdate`, {
...this.form
}).then(res => {
if (res.code == 0) {
this.$message.success('提交成功')
setTimeout(() => {
this.cancel(true)
}, 600)
}
})
}
})
},
2022-06-24 20:50:47 +08:00
cancel(isRefresh) {
2022-06-14 14:04:00 +08:00
this.$emit('change', {
type: 'List',
isRefresh: isRefresh ? true : false
})
2022-06-13 17:18:21 +08:00
}
}
2022-06-14 14:04:00 +08:00
}
2022-06-13 17:18:21 +08:00
</script>
<style scoped lang="scss">
2022-06-24 20:50:47 +08:00
.Add {
height: 100%;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
.ai-card__title {
display: flex;
align-items: center;
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
h2 {
margin-right: 20px;
color: #222222;
font-size: 16px;
font-weight: 700;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
span {
color: #888888;
font-size: 14px;
2022-06-13 17:18:21 +08:00
}
2022-06-24 20:50:47 +08:00
}
.appletss {
display: flex;
flex-wrap: wrap;
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
.applets-item {
2022-06-13 17:18:21 +08:00
display: flex;
2022-06-24 20:50:47 +08:00
align-items: center;
width: 400px;
height: 60px;
margin-right: 8px;
margin-bottom: 8px;
padding: 0 17px;
background: #FFFFFF;
border-radius: 2px;
border: 1px solid #D0D4DC;
cursor: pointer;
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
&:hover {
border-color: #2266FF;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
::v-deep {
.el-radio__label {
display: none;
2022-06-13 17:18:21 +08:00
}
2022-06-24 20:50:47 +08:00
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
img {
width: 40px;
height: 40px;
margin: 0 8px 0 13px;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
span {
color: #222222;
font-size: 12px;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
.el-radio {
margin: 0;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
&.applets-active {
border-color: #2266FF;
2022-06-13 17:18:21 +08:00
}
}
2022-06-24 20:50:47 +08:00
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
.tips {
position: relative;
top: 2px;
padding-left: 8px;
color: #222222;
font-size: 14px;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
.el-form-item-item__textarea {
position: relative;
}
2022-06-13 17:18:21 +08:00
2022-06-24 20:50:47 +08:00
.el-form-item__btn {
position: absolute;
bottom: 12px;
left: 12px;
line-height: 1;
z-index: 1;
color: #2266FF;
font-size: 14px;
user-select: none;
background: #fff;
cursor: pointer;
}
2022-06-24 23:12:16 +08:00
.tags {
// padding: 10px;
.tag_title {
font-weight: 600;
}
.tag_item {
margin: 5px 0;
span {
display: inline-block;
// padding: 5px 10px;
width: 80px;
text-align: center;
height: 30px;
line-height: 30px;
background: #DDD;
color: #333;
border-radius: 4px;
margin-right: 8px;
2022-06-13 17:18:21 +08:00
}
2022-06-24 23:12:16 +08:00
.active {
background: #53bcea;
color: #FFFFFF;
2022-06-13 17:18:21 +08:00
}
}
2022-06-24 23:12:16 +08:00
}
2022-06-24 20:45:45 +08:00
2022-06-13 17:18:21 +08:00
</style>