Files
dvcp_v2_webapp/project/sass/apps/Announce/AppAnnounce/components/Add.vue

492 lines
15 KiB
Vue
Raw Normal View History

2022-07-13 09:13:31 +08:00
<template>
2022-07-15 10:40:02 +08:00
<ai-detail class="AppAnnounceAdd">
2022-07-13 09:13:31 +08:00
<template slot="title">
2022-07-13 16:53:59 +08:00
<ai-title :title="id ? '编辑居民群发' : '添加居民群发'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
2022-07-13 09:13:31 +08:00
</ai-title>
</template>
<template slot="content">
2022-07-13 16:53:59 +08:00
<div class="AppAnnounceDetail-container">
<el-form ref="form" class="left" :model="form" label-width="110px" label-position="right">
<ai-card title="基本信息">
<template #content>
<div class="ai-form">
2022-07-13 18:15:26 +08:00
<el-form-item label="任务名称" prop="name" style="width: 100%;" :rules="[{ required: true, message: '请输入任务名称', trigger: 'blur' }]">
2022-07-18 17:14:58 +08:00
<el-input size="small" placeholder="请输入任务名称" v-model="form.taskTitle" :maxlength="15" show-word-limit></el-input>
2022-07-13 16:53:59 +08:00
</el-form-item>
2022-07-18 17:14:58 +08:00
<el-form-item label="发送范围" style="width: 100%;" prop="sendScope">
<el-radio-group v-model="form.sendScope">
<el-radio label="0">全部居民群</el-radio>
<el-radio label="1">按部门选择</el-radio>
<el-radio label="2">按网格选择</el-radio>
2022-07-13 16:53:59 +08:00
</el-radio-group>
</el-form-item>
2022-07-14 14:00:27 +08:00
<el-form-item label="选择群主" prop="departmentName" style="width: 100%;" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
<el-input size="small" :autosize="{ minRows: 2, maxRows: 10}" placeholder="请选择..." disabled v-model="form.departmentName">
<ai-user-get slot="append" isStrictly :instance="instance" isChooseUnit>
<el-button type="info">选择</el-button>
</ai-user-get>
</el-input>
<div class="tips">
<p>消息预计送达居民群数</p>
<span>215</span>
2022-07-18 17:14:58 +08:00
<el-tooltip
placement="top"
content="任务开始后3天内15分钟更新1次3天后访问页面时触发更新1时间最多刷新1次">
<i class="iconfont iconModal_Warning"></i>
</el-tooltip>
2022-07-14 14:00:27 +08:00
</div>
</el-form-item>
<el-form-item label="发送内容" prop="departmentName" style="width: 100%;" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
<el-input size="small" type="textarea" :rows="6" placeholder="请输入文本内容..." v-model="form.departmentName"></el-input>
<div class="add">
2022-07-18 17:14:58 +08:00
<div class="fileList" v-if="fileList.length">
<div class="add-item" v-for="(item, index) in fileList" :key="index">
<div class="left">
<img :src="mapIcon(item.media.type)" />
<span>{{ item.name }}</span>
</div>
<i @click="removeFile(index)">删除</i>
</div>
</div>
2022-07-14 14:00:27 +08:00
<el-popover
placement="top"
width="340"
offset="0"
trigger="hover">
<div class="add-item" slot="reference" style="width: max-content;">
<img src="https://cdn.cunwuyun.cn/dvcp/announce/add.png" />
<span style="color: #2266FF; font-size: 12px;">添加附件类型</span>
</div>
<div class="AppAnnounceDetail-content-wrapper">
2022-07-18 17:14:58 +08:00
<el-upload
ref="upload"
multiple
:file-list="fileList"
:show-file-list="false"
:before-upload="v => handleChange(v, 10, '.jpg,.png,.jpeg')"
:limit="9"
action="/app/wxcp/upload/uploadFile"
accept=".jpg,.png,.jpeg"
:http-request="v => submitUpload(v, 'image')">
<div class="content-item" trigger>
<img src="https://cdn.cunwuyun.cn/dvcp/announce/big-img.png" />
<p>图片</p>
</div>
</el-upload>
<el-upload
ref="upload"
multiple
:file-list="fileList"
:show-file-list="false"
:before-upload="v => handleChange(v, 10, '.mp4')"
:limit="9"
action="/app/wxcp/upload/uploadFile"
accept=".mp4"
:http-request="v => submitUpload(v, 'video')">
<div class="content-item" trigger>
<img src="https://cdn.cunwuyun.cn/dvcp/announce/big-video.png" />
<p>视频</p>
</div>
</el-upload>
2022-07-14 14:00:27 +08:00
<div class="content-item">
<img src="https://cdn.cunwuyun.cn/dvcp/announce/folder.png" />
<p>文件</p>
</div>
<div class="content-item">
<img src="https://cdn.cunwuyun.cn/dvcp/announce/site.png" />
<p>网页</p>
</div>
<div class="content-item">
<img src="https://cdn.cunwuyun.cn/dvcp/announce/miniapp.png" />
<p>小程序</p>
</div>
</div>
</el-popover>
</div>
<div class="tips">
<em>从本地上传图片最大支持10MB支持JPG,PNG格式视频最大支持10MB支持MP4格式文件最大支持20MB</em>
</div>
</el-form-item>
2022-07-18 17:14:58 +08:00
<el-form-item label="宣发审批" prop="enableExamine" style="width: 100%;" :rules="[{ required: true, message: '请输入任务名称', trigger: 'blur' }]">
<el-switch
v-model="form.enableExamine"
active-value="1"
inactive-value="0"
active-text="开启后,创建的群发任务需要审批人进行审批">
</el-switch>
</el-form-item>
<el-form-item v-if="form.enableExamine === '1'" label="审批人员" prop="departmentName" style="width: 100%;" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
<el-input size="small" :autosize="{ minRows: 2, maxRows: 10}" placeholder="请选择..." disabled v-model="form.departmentName">
<ai-user-get slot="append" isStrictly :instance="instance" isChooseUnit>
<el-button type="info">选择</el-button>
</ai-user-get>
</el-input>
</el-form-item>
2022-07-13 16:53:59 +08:00
</div>
</template>
</ai-card>
</el-form>
2022-07-18 17:14:58 +08:00
<div class="right">
<img class="phone" src="https://cdn.cunwuyun.cn/dvcp/announce/phone.png" />
<img class="phone-wrapper" src="https://cdn.cunwuyun.cn/dvcp/announce/phone-wrapper.png" />
<div class="right-content">
</div>
</div>
2022-07-13 16:53:59 +08:00
</div>
2022-07-13 09:13:31 +08:00
</template>
<template #footer>
<el-button @click="cancel">取消</el-button>
2022-07-18 17:14:58 +08:00
<el-button type="primary" @click="confirm" style="width: 120px;">通知成员发送</el-button>
<el-button type="primary" @click="confirm">定时发送</el-button>
2022-07-13 09:13:31 +08:00
</template>
</ai-detail>
</template>
<script>
export default {
name: 'Add',
props: {
instance: Function,
dict: Object,
params: Object
},
data () {
return {
info: {},
department: [],
2022-07-18 17:14:58 +08:00
fileList: [],
2022-07-13 09:13:31 +08:00
form: {
2022-07-18 17:14:58 +08:00
choiceTime: '',
contents: {},
enableExamine: '0',
examines: [],
wxGroups: [],
sendScope: '0',
sendType: 0,
2022-07-13 09:13:31 +08:00
name: '',
2022-07-18 17:14:58 +08:00
taskTitle: ''
2022-07-13 09:13:31 +08:00
},
id: '',
tagsList: []
}
},
created () {
this.getTags()
if (this.params && this.params.departmentId && !this.params.id) {
this.department = [{
id: String(this.params.departmentId),
name: this.params.departmentName
}]
this.form.departmentIds = [this.params.departmentId]
this.form.departmentName = this.params.departmentName
}
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
},
methods: {
getInfo (id) {
this.instance.post(`/app/wxcp/wxuser/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = {
...res.data,
departmentName: res.data.departmentNames,
tagIds: res.data.tags.map(v => v.id),
departmentIds: res.data.departmentIdsStr.split(',')
}
}
})
},
2022-07-18 17:14:58 +08:00
removeFile (index) {
this.fileList.splice(index, 1)
},
mapIcon (type) {
return {
image: 'https://cdn.cunwuyun.cn/dvcp/announce/img.png',
video: 'https://cdn.cunwuyun.cn/dvcp/announce/video.png',
folder: 'https://cdn.cunwuyun.cn/dvcp/announce/folder.png',
site: 'https://cdn.cunwuyun.cn/dvcp/announce/site.png',
miniapp: 'https://cdn.cunwuyun.cn/dvcp/announce/miniapp.png'
}[type]
},
onBeforeUpload(event) {
return this.onOverSize(event)
},
getExtension(name) {
return name.substring(name.lastIndexOf('.'))
},
handleChange (e, size, accept) {
const isLt10M = e.size / 1024 / 1024 < size
const suffixName = this.getExtension(e.name)
const suffixNameList = accept.split(',')
if (suffixNameList.indexOf(`${suffixName.toLowerCase()}`) === -1) {
this.$message.error(`不支持该格式`)
return false
}
if (!isLt10M) {
this.$message.error(`大小不超过${10}MB!`)
return false
}
return true
},
submitUpload (file, type) {
let formData = new FormData()
formData.append('file', file.file)
formData.append('type', type)
this.instance.post(`/app/wxcp/upload/uploadFile`, formData, {
withCredentials: false
}).then(res => {
if (res.code == 0) {
this.fileList.push({
...res.data.file,
media: res.data.media
})
this.$message.success('上传成功')
}
})
},
2022-07-13 09:13:31 +08:00
onChange (e) {
if (e.length) {
this.form.departmentIds = e.map(v => v.id)
this.form.departmentName = e.map(v => v.name).join(',')
} else {
this.form.departmentIds = ''
this.form.departmentName = ''
}
},
getTags () {
this.instance.post(`/app/wxcp/wxtag/listAll`).then(res => {
if (res.code == 0) {
this.tagsList = res.data
}
})
},
onClose () {
this.form.explain = ''
},
confirm () {
this.$refs.form.validate((valid) => {
if (valid) {
const api = this.id ? '/app/wxcp/wxuser/update' : '/app/wxcp/wxuser/add'
this.instance.post(api, {
...this.form
}).then(res => {
if (res.code == 0) {
this.$message.success('提交成功')
setTimeout(() => {
this.cancel(true)
}, 600)
}
})
}
})
},
cancel (isRefresh) {
this.$emit('change', {
type: 'list',
isRefresh: !!isRefresh
})
}
}
}
</script>
2022-07-14 14:00:27 +08:00
<style lang="scss">
.AppAnnounceDetail-content-wrapper {
display: flex;
align-items: center;
.content-item {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
width: 64px;
height: 64px;
line-height: 1;
margin-right: 4px;
text-align: center;
background: #F9F9F9;
border-radius: 2px;
cursor: pointer;
&:hover {
opacity: 0.6;
}
&:last-child {
margin-right: 0;
}
img {
width: 32px;
height: 32px;
margin-bottom: 4px;
}
p {
color: #222;
font-size: 12px;
}
}
}
2022-07-15 10:40:02 +08:00
.AppAnnounceAdd {
2022-07-14 14:00:27 +08:00
.ai-detail__content {
2022-07-13 16:53:59 +08:00
.ai-detail__content--wrapper {
position: relative;
max-width: 100%;
margin: 0;
height: 100%;
overflow: hidden;
}
}
2022-07-14 14:00:27 +08:00
.add {
display: flex;
flex-direction: column;
padding: 14px 16px;
background: #F9F9F9;
border-radius: 0px 0px 2px 2px;
border: 1px solid #D0D4DC;
border-top: none;
.add-item {
display: flex;
align-items: center;
line-height: 1;
cursor: pointer;
&:hover {
opacity: 0.6;
}
img {
width: 20px;
height: 20px;
margin-right: 2px;
}
span {
color: #222;
font-size: 14px;
}
}
2022-07-18 17:14:58 +08:00
.fileList {
margin-bottom: 12px;
.add-item {
justify-content: space-between;
margin-bottom: 8px;
.left {
display: flex;
align-items: center;
}
i {
font-size: 14px;
cursor: pointer;
font-style: normal;
color: red;
&:hover {
opacity: 0.6;
}
}
&:last-child {
margin-bottom: 0;
}
}
}
2022-07-14 14:00:27 +08:00
}
2022-07-13 16:53:59 +08:00
.AppAnnounceDetail-container {
display: flex;
position: relative;
height: 100%;
padding: 0 20px;
overflow-y: overlay;
.left {
flex: 1;
margin-right: 20px;
}
.right {
position: sticky;
top: 0;
2022-07-18 17:14:58 +08:00
width: 338px;
height: 675px;
.phone {
position: absolute;
left: 14px;
top: 14px;
z-index: 1;
width: 310px;
height: 647px;
}
.phone-wrapper {
position: absolute;
left: 0;
top: 0;
z-index: 2;
width: 338px;
height: 675px;
}
2022-07-14 14:00:27 +08:00
}
}
.tips {
display: flex;
align-items: center;
font-size: 14px;
color: #222222;
span {
margin: 0 3px;
color: #2266FF;
}
i {
2022-07-18 17:14:58 +08:00
color: #8899bb;
2022-07-14 14:00:27 +08:00
}
em {
line-height: 20px;
margin-top: 8px;
color: #888888;
font-size: 12px;
font-style: normal;
2022-07-13 16:53:59 +08:00
}
}
}
2022-07-13 09:13:31 +08:00
</style>