<template>
	<div class="container">
		<el-input type="text" placeholder="请输入套餐标题" style="width: 100%;" v-model="model.title" maxlength="15" ref="title"></el-input>
		<textarea v-model="model.meal" placeholder="请输入套餐内容"
			style="width: 100%;height: 100px;margin-top: 10px;border: 1px solid #EEEEEE;" ref="meal"></textarea>
		<el-button type="primary" @click="BtnClick" style=" margin:10px 0px 10px 10px">发布介绍</el-button>
	</div>
</template>

<script>
	import {
		AddOrUpdRichTextmeal,
		DelRichTextmeal,
		GetListRichTextmeal
	} from '../../api/meal.js'
	export default {
		data() {
			return {

				model: {
					"id": 0,
					"title": "",
					"meal": "",
					"add_time": "2022-01-05T10:45:05.324Z",
					"update_time": "2022-01-05T10:45:05.324Z",
					"status": 0
				}
			}
		},
		created() {

		},
		methods: {
			BtnClick() {
				if (this.model.title == '') {
					this.$message.error('请输入套餐标题')
					this.$refs.title.focus()
				} else if(this.model.meal==''){
					this.$message.error('请输入套餐内容')
					this.$refs.meal.focus()
				} else{
					AddOrUpdRichTextmeal(this.model).then(res => {
						console.log('res', res)
						if (res.data.code == 200) {
							this.$message.success('发布成功')
							this.model.meal=this.model.title=''
						} else {
							this.$message.error('发布失败')
						}
					})
				}
			}

		}
	}
</script>

<style>
</style>
