217 lines
5.0 KiB
Vue
217 lines
5.0 KiB
Vue
<template>
|
|
<div class="add">
|
|
<div class="item">
|
|
<span class="tips">*</span>
|
|
<div class="border not-border">
|
|
<span class="label">推送分类</span>
|
|
<span class="value">
|
|
<AiSelect :list="typeList" v-model="form.type" @data="selectType"></AiSelect>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="item mar-b0">
|
|
<span class="tips">*</span>
|
|
<div class="border not-border">
|
|
<span class="label">消息内容</span>
|
|
</div>
|
|
</div>
|
|
<div class="text-area">
|
|
<textarea placeholder="请输入" maxlength="200" v-model="form.msgContent"></textarea>
|
|
</div>
|
|
<div class="item" v-if="form.type == 15">
|
|
<span class="tips">*</span>
|
|
<div class="border not-border">
|
|
<span class="label">时间</span>
|
|
<span class="value">
|
|
<input type="text" placeholder="请输入" v-model="form.msgTime" maxlength="30">
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="item" v-if="form.type == 15">
|
|
<span class="tips">*</span>
|
|
<div class="border not-border">
|
|
<span class="label">地点</span>
|
|
<span class="value">
|
|
<input type="text" placeholder="请输入" v-model="form.msgPlace" maxlength="100">
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="item" v-if="form.type == 15">
|
|
<span class="tips">*</span>
|
|
<div class="border not-border">
|
|
<span class="label">按钮标题</span>
|
|
<span class="value">
|
|
<input type="text" placeholder="请输入" v-model="form.msgBtnText" maxlength="20">
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="add-btn" @click="submit">
|
|
<div>提交</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapState } from 'vuex'
|
|
export default {
|
|
name: 'add',
|
|
data() {
|
|
return {
|
|
form: {
|
|
type: '10',
|
|
msgContent: '',
|
|
msgTime: '',
|
|
msgPlace: '',
|
|
msgBtnText: '',
|
|
},
|
|
typeList: [{label: '核酸监测通知', value: '15' }, {label: '主动报备提醒', value: '10' }],
|
|
isFlag: true
|
|
}
|
|
},
|
|
onShow() {
|
|
document.title = '新增推送消息'
|
|
},
|
|
computed: {
|
|
...mapState(['user']),
|
|
},
|
|
methods: {
|
|
rules() {
|
|
return {
|
|
type: '请选择推送分类',
|
|
msgContent: '请输入消息内容',
|
|
msgTime: '请选择时间',
|
|
msgPlace: '请输入地点',
|
|
msgBtnText: '请输入按钮标题',
|
|
}
|
|
},
|
|
selectType(selecteds) {
|
|
this.form.type = selecteds?.[0]?.value
|
|
},
|
|
submit() {
|
|
if(this.form.type == 10) {
|
|
this.confirm()
|
|
return
|
|
}
|
|
const rules = this.rules()
|
|
for (let v of Object.keys(rules)) {
|
|
if (!this.form[v]) {
|
|
return this.$u.toast(rules[v])
|
|
}
|
|
}
|
|
this.confirm()
|
|
},
|
|
confirm() {
|
|
if(!this.isFlag) {
|
|
return
|
|
}
|
|
if(!this.form.msgContent) {
|
|
return this.$u.toast('请输入推送消息')
|
|
}
|
|
this.isFlag = false
|
|
this.$http.post('/app/appiptvjpush/addOrUpdate', this.form).then(res => {
|
|
if (res.code === 0) {
|
|
|
|
this.$u.toast('新增成功')
|
|
uni.$emit('getList')
|
|
uni.navigateBack({
|
|
delta: 1
|
|
})
|
|
}
|
|
}).catch((err) => {
|
|
this.$u.toast(err)
|
|
})
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.add {
|
|
.item{
|
|
width: 100%;
|
|
padding-left: 14px;
|
|
background: #FFF;
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
margin-bottom: 16px;
|
|
.tips{
|
|
width: 18px;
|
|
font-size: 32px;
|
|
font-family: PingFangSC-Regular, PingFang SC;
|
|
color: #FF4466;
|
|
line-height: 44px;
|
|
padding: 34px 0 34px 0;
|
|
}
|
|
.border{
|
|
width: calc(100% - 18px);
|
|
padding: 34px 32px 34px 0;
|
|
line-height: 44px;
|
|
border-bottom: 1px solid #D8DDE6;
|
|
line-height: 44px;
|
|
font-size: 32px;
|
|
font-family: PingFangSC-Regular, PingFang SC;
|
|
color: #333;
|
|
display: flex;
|
|
box-sizing: border-box;
|
|
.label{
|
|
width: 170px;
|
|
}
|
|
.value{
|
|
width: calc(100% - 170px);
|
|
text-align: right;
|
|
img{
|
|
width: 32px;
|
|
height: 32px;
|
|
margin-left: 8px;
|
|
vertical-align: middle;
|
|
}
|
|
}
|
|
.color-999{
|
|
color: #999;
|
|
}
|
|
}
|
|
.not-border{
|
|
border-bottom: 0;
|
|
}
|
|
}
|
|
.mar-b0{
|
|
margin-bottom: 0;
|
|
}
|
|
.text-area{
|
|
width: 100%;
|
|
background-color: #fff;
|
|
padding: 0 32px;
|
|
margin-bottom: 16px;
|
|
box-sizing: border-box;
|
|
textarea{
|
|
width: 100%;
|
|
height: 88px;
|
|
padding-bottom: 32px;
|
|
}
|
|
}
|
|
.pad-b152{
|
|
width: 100%;
|
|
padding-bottom: 152px;
|
|
background-color: #f5f5f5;
|
|
}
|
|
.add-btn{
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
z-index: 999;
|
|
width: 100%;
|
|
height: 112px;
|
|
line-height: 112px;
|
|
background: #3975C6;
|
|
font-size: 32px;
|
|
font-family: PingFangSC-Medium, PingFang SC;
|
|
font-weight: 500;
|
|
color: #FFF;
|
|
div{
|
|
text-align: center;
|
|
}
|
|
}
|
|
}
|
|
</style>
|