新增系统信息逻辑

This commit is contained in:
zyy 2020-09-11 16:07:18 +08:00
parent e5687c13dd
commit 27a9a7a744
3 changed files with 63 additions and 20 deletions

View File

@ -8,3 +8,12 @@ export function pushMessage(data) {
data: data
});
}
/** 推送通知消息*/
export function pushSysNotice(data) {
return request({
url: `/api/v1/sysNotice`,
method: 'post',
data: data
});
}

View File

@ -86,10 +86,10 @@ function loadDictionary() {
_LimitOperation: [],
_SystemInform: [], // 通知类型
_Notice: [], // 通知类型
systemInform: function () {
return queryData('system_inform', this, '_SystemInform');
noticeList: function () {
return queryData('notice', this, '_Notice');
},
regionTypeList: function () {

View File

@ -7,13 +7,30 @@
<div class="joylink-card forms">
<div style="height: 100%; padding-top: 40px; overflow-y: auto; position: relative;">
<el-form ref="form" :model="messageModel" :rules="rules" label-width="200px">
<el-form-item label="内容主题:" prop="title">
<el-input v-model="messageModel.title" style="width: 450px" /></el-form-item>
<el-form-item label="内容:" prop="content">
<el-input v-model="messageModel.content" style="width: 450px" type="textarea" :autosize="{ minRows: 2, maxRows: 6}" />
<el-form-item label="消息类型:" prop="notice">
<el-select v-model="messageModel.notice" placeholder="请选择" style="width: 220px;">
<el-option
v-for="item in typeList"
:key="item.value"
:label="item.label"
:value="item.label"
/>
</el-select>
</el-form-item>
<el-form-item label="通知选择:" prop="showClose">
<el-radio-group v-model="messageModel.showClose">
<el-form-item label="内容主题:" prop="subject">
<el-input v-model="messageModel.subject" style="width: 450px" /></el-form-item>
<el-form-item label="内容:" prop="content">
<el-input
v-model="messageModel.content"
style="width: 450px"
type="textarea"
maxlength="450"
show-word-limit
:autosize="{ minRows: 4, maxRows: 12}"
/>
</el-form-item>
<el-form-item label="通知选择:" prop="type">
<el-radio-group v-model="messageModel.type">
<el-radio v-for="(item, index) in regionList" :key="index" :label="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
@ -21,49 +38,58 @@
</div>
</div>
<div class="draft">
<el-button type="primary" @click="pushNotification">{{ $t('system.push') }}</el-button>
<el-button type="primary" @click="pushNotification">发布</el-button>
</div>
</div>
</template>
<script>
import { pushMessage } from '@/api/pushMessage';
import { pushSysNotice } from '@/api/pushMessage';
export default {
name: 'News',
data() {
return {
display: 1,
regionList: [],
regionList: [
{label: '邮件通知', value: '01'},
{label: '短信通知', value: '02'}
],
typeList: [],
messageModel: {
title: '',
notice: '',
subject: '',
content: '',
showClose: '02'
type: '02'
},
rules: {
title: [
notice: [
{ required: true, message: '请选择消息类型', trigger: 'change'}
],
subject: [
{ required: true, message: this.$t('rules.enterTheNewsTitle'), trigger: 'blur'}
],
content:[
{ required: true, message: this.$t('rules.enterTheNewsContent'), trigger: 'blur' }
],
showClose: [
type: [
{ required: true, message: this.$t('rules.chooseNewsCanBeClosed'), trigger: 'change' }
]
}
};
},
mounted() {
this.regionList = [];
this.$Dictionary.systemInform().then(list => {
this.regionList = list.map(elem => { return { value: elem.code, label: elem.name }; });
this.typeList = [];
this.$Dictionary.noticeList().then(list => {
this.typeList = list.map(elem => { return { value: elem.code, label: elem.name }; });
console.log(this.typeList);
});
},
methods: {
pushNotification() {
this.$refs['form'].validate((valid) => {
if (valid) {
pushMessage(this.messageModel).then(resp => {
pushSysNotice(this.messageModel).then(resp => {
this.$message.success('推送成功');
}).catch(() => {
this.$messageBox('推送失败');
@ -128,6 +154,14 @@ export default {
float: left;
width: calc(250px);
}
.el-textarea .el-input__count {
color: #909399;
position: absolute;
font-size: 12px;
bottom: -10px;
right: 7px;
background: transparent;
}
}
}