<!-- 反馈弹框 -->
<template>
	<div class='feedbackDialog'>
		<el-dialog title="" :show-close="false" :append-to-body="true" :close-on-click-modal="false" :close-on-press-escape="false" :lock-scroll="true" :visible.sync="dialogFeedbackVisible">
			<div slot="title" class="header-title">
				<span class="dialogHeader">新增反馈</span>
				<img @click="closeDialog('feedbackForm')" class="dialogHeaderClose" src="../assets/images/dialogClose.png" />
			</div>
			<div class="">
				<div class="elDiv">
					<el-form :model="feedbackForm" :rules="rules" ref="feedbackForm" label-width="100px" class="demo-ruleForm">
						<el-form-item label="反馈内容" prop="des">
							<el-input type="textarea" :rows="18" v-model="feedbackForm.des"></el-input>
						</el-form-item>
					</el-form>
				</div>
				<div class="dialogBtns">
					<el-button class="mrgt" type="primary" @click="submitForm('feedbackForm')" style="margin-right: 30px;">保存</el-button>
				</div>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
	//例如：import 《组件名称》 from '《组件路径》';

	export default {
		name: "feedbackDialog",
//import引入的组件需要注入到对象中才能使用
		props: ['showFeedback'],
		components: {},
		data () {
//这里存放数据
			return {
				dialogFeedbackVisible: false,
				feedbackForm: {
					des: ''
				},
				rules:{
					des: [
						{ required: true, message: '请填写反馈内容', trigger: 'blur' }
					]
				}
			};
		},
//监听属性 类似于data概念
		computed: {},
//监控data中的数据变化
		watch: {
			showFeedback: {
				immediate: true,
				handler(showFeedback) {
					console.log(showFeedback)
					this.dialogFeedbackVisible = showFeedback;
				}
			}
		},
//方法集合
		methods: {
			submitForm(formName) {
				this.$refs[formName].validate((valid) => {
					if (valid) {
						console.log(1111)
						let data = JSON.parse(this.$Base64.decode(localStorage.getItem('login')));
						let obj = {
							"des": this.feedbackForm.des,
							"id": null,
							"userId": data.id
						}
						console.log(obj)
						this.$axios.postFeedback(obj).then((res) => {
							console.log(res)
							if (res.status === 200) {
								this.$message({
									message: '新增反馈成功！',
									type: 'success'
								});
								this.closeDialog('feedbackForm');
							}
						})
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			closeDialog(formName) {
				this.$refs[formName].resetFields();
				this.$emit('close', false);
			}
		},
//生命周期 - 创建完成（可以访问当前this实例）
		created () {

		},
//生命周期 - 挂载完成（可以访问DOM元素）
		mounted () {

		},
		beforeCreate () {
		}, //生命周期 - 创建之前
		beforeMount () {
		}, //生命周期 - 挂载之前
		beforeUpdate () {
		}, //生命周期 - 更新之前
		updated () {
		}, //生命周期 - 更新之后
		beforeDestroy () {
		}, //生命周期 - 销毁之前
		destroyed () {
		}, //生命周期 - 销毁完成
		activated () {
		}, //如果页面有keep-alive缓存功能，这个函数会触发
	}
</script>
<style scoped>
	.elDiv{
		width: 90%;
		margin: 30px auto;
	}

	.dialogBtns{
		position: fixed;
		bottom: 0;
		left: 10%;
		width: 80%;
		margin: 80px auto;
		text-align: center;
		border-top: 2px solid #5059D5;
	}

	.mrgt{
		margin-top: 20px;
	}

	/deep/ .el-form-item__label {
		text-align: center;
		vertical-align: middle;
		float: none;
		font-size: 18px;
		color: #606266;
		line-height: 40px;
		padding: 0 12px 0 0;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
	}

	/deep/ .el-form-item__content {
		line-height: 40px;
		position: relative;
		font-size: 14px;
		margin-left: 0 !important;
	}

	/deep/ .el-textarea__inner {
		display: block;
		resize: vertical;
		padding: 5px 15px;
		line-height: 1.5;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
		width: 100%;
		font-size: inherit;
		color: #606266;
		background-color: #EFF2FA;
		background-image: none;
		border: 1px solid #DCDFE6;
		border-radius: 4px;
		-webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
		transition: border-color .2s cubic-bezier(.645,.045,.355,1);
	}
</style>
