rt-sim-training-client/src/views/system/notification/index.vue

175 lines
4.9 KiB
Vue
Raw Normal View History

2020-09-09 11:25:31 +08:00
<template>
<div class="card-box">
<el-steps class="steps" :active="display">
<el-step title="系统通知" icon="el-icon-edit-outline" />
<el-step title="" icon="el-icon-upload" />
</el-steps>
<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">
2020-09-11 16:07:18 +08:00
<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="subject">
<el-input v-model="messageModel.subject" style="width: 450px" /></el-form-item>
2020-09-09 11:25:31 +08:00
<el-form-item label="内容:" prop="content">
2020-09-11 16:07:18 +08:00
<el-input
v-model="messageModel.content"
style="width: 450px"
type="textarea"
maxlength="450"
show-word-limit
:autosize="{ minRows: 4, maxRows: 12}"
/>
2020-09-09 11:25:31 +08:00
</el-form-item>
2020-09-11 16:07:18 +08:00
<el-form-item label="通知选择:" prop="type">
<el-radio-group v-model="messageModel.type">
2020-09-09 11:25:31 +08:00
<el-radio v-for="(item, index) in regionList" :key="index" :label="item.value">{{ item.label }}</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
</div>
</div>
<div class="draft">
2020-09-11 16:07:18 +08:00
<el-button type="primary" @click="pushNotification">发布</el-button>
2020-09-09 11:25:31 +08:00
</div>
</div>
</template>
<script>
2020-09-11 16:07:18 +08:00
import { pushSysNotice } from '@/api/pushMessage';
2020-09-09 11:25:31 +08:00
export default {
name: 'News',
data() {
return {
display: 1,
2020-09-11 16:07:18 +08:00
regionList: [
{label: '邮件通知', value: '01'},
{label: '短信通知', value: '02'}
],
typeList: [],
2020-09-09 11:25:31 +08:00
messageModel: {
2020-09-11 16:07:18 +08:00
notice: '',
subject: '',
2020-09-09 11:25:31 +08:00
content: '',
2020-09-11 16:07:18 +08:00
type: '02'
2020-09-09 11:25:31 +08:00
},
rules: {
2020-09-11 16:07:18 +08:00
notice: [
{ required: true, message: '请选择消息类型', trigger: 'change'}
],
subject: [
2020-09-09 11:25:31 +08:00
{ required: true, message: this.$t('rules.enterTheNewsTitle'), trigger: 'blur'}
],
content:[
{ required: true, message: this.$t('rules.enterTheNewsContent'), trigger: 'blur' }
],
2020-09-11 16:07:18 +08:00
type: [
2020-09-09 11:25:31 +08:00
{ required: true, message: this.$t('rules.chooseNewsCanBeClosed'), trigger: 'change' }
]
}
};
},
mounted() {
2020-09-11 16:07:18 +08:00
this.typeList = [];
this.$Dictionary.noticeList().then(list => {
this.typeList = list.map(elem => { return { value: elem.code, label: elem.name }; });
console.log(this.typeList);
2020-09-09 11:25:31 +08:00
});
},
methods: {
pushNotification() {
this.$refs['form'].validate((valid) => {
if (valid) {
2020-09-11 16:07:18 +08:00
pushSysNotice(this.messageModel).then(resp => {
2020-09-09 11:25:31 +08:00
this.$message.success('推送成功');
}).catch(() => {
this.$messageBox('推送失败');
});
} else {
return false;
}
});
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.card-box {
padding-top: 20px;
height: 100%;
margin: 0 auto;
}
.steps {
width: 980px;
margin: 0 auto;
/deep/ {
.el-step__icon.is-icon {
width: 95px;
}
}
}
.online_box {
position: absolute;
left: 20px;
top: 18px;
}
.forms {
width: 800px;
margin: 0 auto;
margin-top: 10px;
height: calc(100% - 150px);
/deep/ {
.el-select {
float: left;
width: calc(600px);
}
.el-textarea {
float: left;
width: calc(600px);
}
.el-form-item__content>.el-input {
float: left;
width: calc(600px);
}
.el-input-number {
float: left;
width: calc(250px);
}
2020-09-11 16:07:18 +08:00
.el-textarea .el-input__count {
color: #909399;
position: absolute;
font-size: 12px;
bottom: -10px;
right: 7px;
background: transparent;
}
2020-09-09 11:25:31 +08:00
}
}
.draft {
width: 300px;
text-align: center;
margin: 20px auto;
}
</style>