极光推送

This commit is contained in:
liuye
2022-06-10 11:07:21 +08:00
parent d4534c7dca
commit a407d007be

View File

@@ -0,0 +1,160 @@
<template>
<section class="AppTvMsg">
<ai-list>
<ai-title slot="title" title="极光推送"/>
<template #content>
<ai-search-bar class="mar-t8">
<template #left>
<el-button type="primary" icon="iconfont iconAdd" @click="dialog=true">添加</el-button>
<el-button icon="iconfont iconDelete" :disabled="!search.ids" @click="handleDelete(search.ids)">删除</el-button>
</template>
</ai-search-bar>
<ai-table :tableData="tableData" :total="page.total" :current.sync="page.current" :size.sync="page.size"
@getList="getTableData" :col-configs="colConfigs" :dict="dict"
@selection-change="v=>search.ids=v.map(e=>e.id).toString()">
<el-table-column slot="type" label="推送分类" align="center">
<template slot-scope="{row}">
<span v-if="row.type == 15" style="color:#42D784;">核酸监测</span>
<span v-else style="color:#4E8EEE;">主动报备提醒</span>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" fixed="right" align="center">
<template slot-scope="{row}">
<el-button type="text" @click="handleDelete(row.id)">删除</el-button>
</template>
</el-table-column>
</ai-table>
</template>
</ai-list>
<ai-dialog title="推送信息" :visible.sync="dialog" @closed="formInit" @onConfirm="submit" width="600px">
<el-form :model="form" size="small" ref="DialogForm" :rules="rules" label-width="80px">
<el-form-item label="推送分类" prop="type">
<ai-select v-model="form.type" :selectList="typeList" placeholder="请选择推送分类"/>
</el-form-item>
<el-form-item label="消息内容" prop="msgContent">
<el-input type="text" v-model="form.msgContent" maxlength="200" />
</el-form-item>
<template v-if="form.type == 15">
<el-form-item label="日期" prop="msgTime">
<el-date-picker v-model="form.msgTime" clearable placeholder="日期" value-format="yyyy-MM-dd"/>
</el-form-item>
<el-form-item label="地点" prop="msgPlace">
<el-input type="text" v-model="form.msgPlace" maxlength="100" />
</el-form-item>
<el-form-item label="按钮标题" prop="msgBtnText">
<el-input type="text" v-model="form.msgBtnText" maxlength="20" />
</el-form-item>
</template>
</el-form>
</ai-dialog>
</section>
</template>
<script>
export default {
name: "AppTvMsg",
label: "极光推送",
props: {
instance: Function,
dict: Object,
permissions: Function
},
computed: {
colConfigs() {
return [
{type: 'selection'},
{slot: "type"},
{label: "消息内容", prop: "content"},
{slot: "options"}
]
}
},
data() {
return {
page: {current: 1, size: 10, total: 0},
tableData: [],
dialog: false,
form: {
type: '',
msgContent: '',
msgTime: '',
msgPlace: '',
msgBtnText: '',
},
rules: {
type: {required: true, message: "请选择推送分类"},
msgContent: {required: true, message: "请输入消息内容"},
msgTime: {required: true, message: "请选择日期"},
msgPlace: {required: true, message: "请输入地点"},
msgBtnText: {required: true, message: "请输入按钮标题"},
},
typeList: [{dictName: '核酸监测', dictValue: '15' }, {dictName: '主动报备提醒', dictValue: '10' }],
search: {ids: []}
}
},
methods: {
getTableData() {
this.instance.post("/app/appiptvjpush/list", null, {
params: {...this.page, ...this.search}
}).then(res => {
if (res?.data) {
this.tableData = res.data?.records
this.page.total = res.data.total
}
})
},
handleDelete(ids) {
this.$confirm("是否要删除推送消息?").then(() => {
this.instance.post("/app/appiptvjpush/delete", null, {
params: {ids}
}).then(res => {
if (res?.code == 0) {
this.$message.success("删除成功!")
this.getTableData()
}
})
}).catch(() => 0)
},
submit() {
this.$refs.DialogForm.validate(v => {
if (v) {
let loading = this.$loading({text: "提交中..."})
this.instance.post("/app/appiptvjpush/addOrUpdate", this.form).then(res => {
loading.close()
if (res?.code == 0) {
this.$message.success("提交成功!")
this.dialog = false
this.page.current = 1
this.getTableData()
}
}).catch(() => loading.close())
}
})
},
formInit() {
for(let key in this.form) {
this.form[key] = ''
}
}
},
created() {
this.getTableData()
}
}
</script>
<style lang="scss" scoped>
.AppTvMsg {
height: 100%;
::v-deep.mar-t16 {
margin-top: 16px;
}
::v-deep.mar-t8 {
margin-top: 8px;
}
}
</style>