<template>
	<div>
		<common @asynCallBack="asynCallBack"></common>
		<top-header :pageTitle="pageTitle"></top-header>

		<div class="mui-content margin60">
			<form class="mui-input-group vongi-send">
				<div class="mui-input-row">
					<label>通知标题</label>
					<input type="text" v-model="addForm.title" placeholder="请输入标题">
				</div>

				<textarea-check v-model="addForm.content" :max="1000" :placeholder="'请填写内容，最多可输入1000字'"></textarea-check>

			</form>
		</div>
		<div class="fyy-footer">
			<div class="bindfyy-btn">
				<button type="submit" class="mui-btn mui-btn-primary " @click="submit">发送</button></div>
		</div>
		<loading :visible="isLoading"></loading>

	</div>
</template>


<script>
	import * as API_Notice from '@/apis/Common/notice'

	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import TextareaCheck from '$project/components/TextareaCheck.vue'

	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'CommonNoticeSend',
		components: {
			Common,
			Loading,
			TopHeader,
			TextareaCheck
		},
		data() {
			return {
				pageTitle: '发送通知',

				isLoading: false,

				addForm: {
					title: '',
					content: '',
				},
				detail: {},
			}
		},
		created() {

		},
		methods: {

			//表单校验
			checkForm() {
				if (!this.addForm.title) {
					mui.toast('请输入通知标题');
					return false;
				} else if (!this.addForm.content) {
					mui.toast('请输入通知内容');
					return false;
				} else {
					return true;
				}
			},
			//提交
			submit() {
				if (this.checkForm()) {
					this.isLoading = true;
					API_Notice.sendMessage(this.addForm).then(response => {
						this.isLoading = false;
						mui.toast("发送成功");
						//跳转首页
						this.$router.push({
							name: 'Master',
							query: {}
						})

					}).catch(error => {
						this.isLoading = false;
						mui.toast(error);
					})
				}
			},
			asynCallBack() {

			},
		},
		mounted() {

		},
		destroyed() {},
		computed: {

		}
	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style scoped>
</style>
