<template>
<el-drawer title="技术反馈" v-model="visible" :size="600" append-to-body destroy-on-close :close-on-click-modal="false" @closed="$emit('closed')">
	<el-main>
		<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left" style="padding:0 20px;" v-loading="isSaveing">
			<el-form-item label="反馈标题" prop="title">
				<el-input v-model="form.title" clearable placeholder="反馈标题" />
			</el-form-item>
			<el-form-item label="反馈图片" prop="files">
				<sc-upload-multiple v-model="form.files" draggable :limit="3" tip="最多上传3个文件,单个文件不要超过10M,请上传图像格式文件"></sc-upload-multiple>
			</el-form-item>
			<el-form-item label="反馈内容" prop="content">
				<el-input v-model="form.content" type="textarea" :autosize="{ minRows: 4, maxRows: 6 }" clearable placeholder="反馈标题" />
			</el-form-item>
			<el-form-item><el-button type="primary" @click="onSubmit">确认提交</el-button></el-form-item>
		</el-form>
	</el-main>
</el-drawer>
</template>

<script>
export default {
	data(){
		return {
			form: {},
			rules: {
				title: [{required: true, message: '请输入反馈的标题', trigger: 'blur'}],
				content: [{required: true, message: '请输入反馈的内容', trigger: 'blur'}]
			},
			isSaveing: false,
			visible: false
		}
	},
	methods: {
		//显示
		open(){
			this.visible = true;
			return this;
		},
		async onSubmit(){
			this.$refs.form.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true
					let res = await this.$API.system.feedback.add.post(this.form)
					if(res.code == 1){
						this.$message.success('已反馈请等待回复！')
						this.isSaveing = false
						this.visible = false
						this.$emit('sccuss', res.data)
					}
				}else{
					this.$message.error('请正确填写！')
				}
			})
		}
	}
}
</script>

<style>
</style>
