Files

381 lines
9.2 KiB
Vue
Raw Permalink Normal View History

2021-11-22 10:26:08 +08:00
<template>
<div class="add-meeting">
2021-12-31 16:59:05 +08:00
<div>
2021-11-22 10:26:08 +08:00
<div class="card">
<header><em>*</em>公告标题</header>
2022-01-10 13:54:07 +08:00
<input v-model="form.title" :focus="true" placeholder="请输入" :maxlength="30">
2021-11-22 10:26:08 +08:00
</div>
<div class="card">
<header><em>*</em>公告内容</header>
2021-12-31 09:38:08 +08:00
<AiEditor v-model="form.content" placeholder="请输入最多500字" :maxlength="500"/>
2021-11-22 10:26:08 +08:00
</div>
<div class="card">
2021-12-13 11:56:11 +08:00
<AiUploader :multiple="true" type="image" :limit="9" placeholder="上传图片" @list="fileList" :def="form.files"
action="/admin/file/add2"></AiUploader>
2021-11-22 10:26:08 +08:00
</div>
2021-11-30 14:48:18 +08:00
<div class="card item-wrap">
<u-row justify="between" class="item" style="border-bottom: 1px solid #eeeeee" @click="handleSelectUser">
2021-11-22 10:26:08 +08:00
<header><em>*</em>发送对象</header>
<div class="right">
2022-01-19 19:02:02 +08:00
<template v-if="!form.selectCount">
2021-11-22 10:26:08 +08:00
<span>请选择</span>
</template>
<template v-else>
2022-01-19 19:02:02 +08:00
已选择<em>{{ form.selectCount }}</em>
2021-11-22 10:26:08 +08:00
</template>
2021-12-22 09:35:07 +08:00
<div class="right-arrow"/>
2021-11-22 10:26:08 +08:00
</div>
</u-row>
2021-12-31 16:59:05 +08:00
<u-row justify="between" class="item">
2021-11-22 10:26:08 +08:00
<header><em>*</em>发送时间</header>
</u-row>
<u-row justify="between">
<div class="type" :class="[index==0 && 'active']" @click="index=0,form.releaseTime=null">立即发送
<img :src="$cdn + 'notice/jiaobiao.png'" alt="" v-show="index==0">
</div>
2021-12-13 11:56:11 +08:00
<div class="type" :class="[index==1 && 'active']" @click="index=1">定时发送
2021-11-22 10:26:08 +08:00
<img :src="$cdn + 'notice/jiaobiao.png'" alt="" v-show="index==1">
</div>
</u-row>
<u-gap height="38"></u-gap>
<u-row justify="between" class="item" style="box-shadow: none;" @click="show=true" v-show="index==1">
<header><em>*</em>定时发送时间</header>
<div class="right">
<template v-if="!form.releaseTime">
<span>请选择</span>
</template>
<template v-else>
2021-12-13 11:56:11 +08:00
<span>{{ form.releaseTime }}</span>
2021-11-22 10:26:08 +08:00
</template>
<div class="right-arrow"></div>
</div>
</u-row>
</div>
<div class="footer">
<div @click="add(0)">保存草稿</div>
<div @click="add(1)">立即发布</div>
</div>
</div>
2021-11-23 14:07:26 +08:00
<u-picker v-model="show" mode="time" :params="options" @confirm="confirm"></u-picker>
2021-11-22 10:26:08 +08:00
</div>
</template>
<script>
2021-12-13 11:56:11 +08:00
import {mapActions} from "vuex";
export default {
name: "add",
data() {
return {
show: false,
index: 0,
list: [],
form: {
id: null,
title: "",
content: "",
persons: [],
2022-01-19 17:59:57 +08:00
ticket: '',
2022-01-19 19:02:02 +08:00
selectCount: 0,
2021-12-13 11:56:11 +08:00
releaseTime: null,
files: [],
},
2022-01-19 16:16:38 +08:00
selectedUserCount: 0,
2021-12-13 11:56:11 +08:00
flag: null,
options: {
year: true,
month: true,
day: true,
hour: true,
minute: true,
second: true,
timestamp: true,
},
2021-12-21 18:40:25 +08:00
clickedUserSelect: false
2021-12-13 11:56:11 +08:00
}
},
2021-12-13 14:02:07 +08:00
onLoad(opt) {
2021-12-15 14:37:20 +08:00
if (opt.id) {
2021-12-13 14:02:07 +08:00
this.form.id = opt.id;
this.flag = opt.flag;
2021-12-13 11:56:11 +08:00
this.getDetail();
}
},
2021-12-13 14:02:07 +08:00
2021-12-13 11:56:11 +08:00
methods: {
2022-01-19 17:14:37 +08:00
...mapActions(['selectPrivilegedContact', 'wxInvoke']),
2021-12-13 11:56:11 +08:00
handleSelectUser() {
2022-01-19 19:31:51 +08:00
// if (this.clickedUserSelect) return this.$u.toast("正在打开人员选择器")
// this.clickedUserSelect = true
this.$loading()
2022-01-19 17:30:54 +08:00
this.selectPrivilegedContact({
2021-12-13 11:56:11 +08:00
fromDepartmentId: 0,
2022-01-19 16:27:06 +08:00
selectedTickets: this.form.ticket ? [this.form.ticket] : [],
2022-01-19 16:38:16 +08:00
selectedOpenUserIds: this.form.persons ? this.form.persons.map(e => e.id) : []
2022-01-19 17:30:54 +08:00
}).then(res => {
2022-01-19 19:02:02 +08:00
uni.hideLoading()
2022-01-19 17:30:54 +08:00
this.clickedUserSelect = false
this.form.persons = res.userList?.map(e => ({id: e.openUserId})) || []
this.form.ticket = res.selectedTicket
2022-01-19 19:02:02 +08:00
this.form.selectCount = res.selectedUserCount
2022-01-19 17:30:54 +08:00
}).catch(e => {
2022-01-19 19:31:51 +08:00
uni.hideLoading()
2022-01-19 17:30:54 +08:00
})
2021-11-22 11:30:26 +08:00
},
2021-12-13 11:56:11 +08:00
confirm(e) {
if (e.timestamp < (Date.now() / 1000) || 0) {
return this.$u.toast("发送时间不能小于当前时间");
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
this.form.releaseTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
2021-11-22 10:26:08 +08:00
},
2021-12-13 11:56:11 +08:00
fileList(e) {
this.form.files = e
2021-11-22 11:30:26 +08:00
},
2021-12-13 11:56:11 +08:00
change(e) {
this.form.persons = e
2021-11-22 10:26:08 +08:00
},
2021-12-13 11:56:11 +08:00
getDetail() {
this.$http.post("/app/appannouncement/detail", null, {
params: {
id: this.form.id,
detail: this.flag
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
}).then(res => {
if (res && res.data) {
this.form.releaseTime = res.data.releaseTime;
2022-01-19 17:59:57 +08:00
this.form.ticket = res.data.ticket
2022-01-19 19:02:02 +08:00
this.form.selectCount = res.data.selectCount
2021-12-13 11:56:11 +08:00
Object.keys(this.form).map(e => {
this.form[e] = res.data[e];
})
this.index = res.data.releaseTime ? 1 : 0;
}
})
},
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
add(status) {
// if(status==1){
if (!this.form.title) return this.$u.toast("请输入公告标题")
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
if (!this.form.content) return this.$u.toast("请输入公告内容")
2021-11-22 10:26:08 +08:00
2022-01-20 10:15:19 +08:00
if (!this.form.ticket) return this.$u.toast("请选择发送对象")
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
if (this.index == 1 && !this.form.releaseTime) return this.$u.toast("请选择定时发送时间")
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
if (this.form.releaseTime && new Date(this.form.releaseTime).getTime() < Date.now()) return this.$u.toast("发送时间不能小于当前时间");
// }
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
this.$http.post("/app/appannouncement/addOrUpdate", {
...this.form,
status,
}).then(res => {
if (res.code == 0) {
2021-12-14 14:12:27 +08:00
this.$u.toast(status == 1 ? "发布成功" : "保存成功");
2021-12-17 15:19:23 +08:00
uni.navigateBack({})
2021-12-13 11:56:11 +08:00
}
})
2021-11-22 10:26:08 +08:00
},
2021-12-13 11:56:11 +08:00
},
2021-12-14 16:10:49 +08:00
onShow() {
document.title = "新增公告";
},
2021-12-13 11:56:11 +08:00
computed: {
background() {
return `url(${this.$cdn}/notice/jiaobiao.png) no-repeat; background-size: 46px 48px;position: absolute;bottom: 0;right: 0;`
},
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
}
2021-11-22 10:26:08 +08:00
</script>
<style lang="scss" scoped>
2021-12-13 11:56:11 +08:00
.add-meeting {
min-height: 100%;
background: #F5F5F5;
padding-bottom: 140px;
.card {
background-color: #FFFFFF;
box-sizing: border-box;
padding: 32px;
margin-top: 16px;
header {
font-size: 32px;
font-weight: 400;
color: #333333;
em {
font-style: normal;
2021-11-22 10:26:08 +08:00
font-size: 32px;
2021-12-13 11:56:11 +08:00
color: #FF4466;
margin-right: 8px;
vertical-align: middle;
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
}
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
input {
margin: 32px 0 16px;
box-sizing: border-box;
padding: 0 16px;
}
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
textarea {
width: 100%;
height: 160px;
margin: 32px 0 16px;
box-sizing: border-box;
padding: 0 16px;
}
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
.u-row {
margin-top: 34px;
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
.time {
display: flex;
flex-direction: column;
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
& > span:first-child {
font-size: 60px;
font-weight: 600;
color: #333333;
line-height: 84px;
}
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
& > span:last-child {
font-size: 22px;
color: #333333;
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
}
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
.arrow {
width: 28px;
height: 68px;
overflow: hidden;
position: relative;
transform: rotate(180deg);
&:before, &:after {
content: "";
width: 50px;
height: 50px;
position: absolute;
transform: scaleY(1.3) translate(30%, -40px) rotate(45deg);
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
&:before {
top: 59px;
background-color: #CCCCCC;
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
&:after {
left: 7px;
top: 59px;
background-color: #FFFFFF;
2021-11-22 10:26:08 +08:00
}
}
2021-12-13 11:56:11 +08:00
.type {
width: 320px;
2021-11-22 10:26:08 +08:00
height: 112px;
2021-12-13 11:56:11 +08:00
background: #F5F5F5;
color: #333333;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
font-size: 30px;
font-weight: 500;
letter-spacing: 1px;
position: relative;
& > img {
width: 46px;
height: 48px;
position: absolute;
right: 0;
bottom: 0;
2021-11-22 10:26:08 +08:00
}
}
2021-12-13 11:56:11 +08:00
.active {
background-color: #E7F1FE;
color: #1174FE;
}
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
.item {
2021-11-22 10:26:08 +08:00
height: 112px;
2021-12-13 11:56:11 +08:00
box-shadow: 0px -1px 0px 0px #D8DDE6;
margin-top: 0;
2021-11-22 10:26:08 +08:00
2021-12-13 11:56:11 +08:00
.right {
font-size: 28px;
color: #999999;
2021-11-22 10:26:08 +08:00
display: flex;
align-items: center;
2021-12-13 11:56:11 +08:00
em {
font-style: normal;
color: #1365DD;
}
2021-11-22 10:26:08 +08:00
}
2021-12-13 11:56:11 +08:00
.right-arrow {
width: 16px;
height: 16px;
display: inline-block;
border-top: 5px solid #CCCCCC;
border-right: 5px solid #CCCCCC;
transform: rotate(45deg);
2021-11-22 10:26:08 +08:00
}
}
}
2021-12-13 11:56:11 +08:00
.item-wrap {
padding: 0 32px;
}
.footer {
height: 112px;
width: 100%;
position: fixed;
left: 0;
bottom: 0;
2022-01-19 18:33:58 +08:00
z-index: 111;
2021-12-13 11:56:11 +08:00
background-color: #FFFFFF;
display: flex;
align-items: center;
& > div {
font-size: 36px;
color: #333333;
}
& > div:first-child {
width: 270px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
& > div:last-child {
width: calc(100% - 270px);
height: 100%;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
background-color: #1365DD;
}
}
}
2021-11-22 10:26:08 +08:00
</style>