<template>
	<div>
		<div class="content-head">
			<dataBreadcrumb :breads="breads"></dataBreadcrumb>
			<h3>提出问题</h3>
			<h5>投标方向招标方提出澄清问题</h5>
		</div>
		<div class="content">
			<div class="form">
				<el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm">
					<el-form-item label="澄清问题标题" prop="title">
						<el-input v-model="ruleForm.title" placeholder="请输入"></el-input>
					</el-form-item>
					<el-form-item label="澄清问题内容" prop="content">
						<el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="ruleForm.content">
						</el-input>
					</el-form-item>
					<el-form-item label="澄清问题附件" prop="file">
						<singleUpload :limit="5" tip="最多上传5个文件，每个文件不超过100M。" @input="getfile"></singleUpload>
					</el-form-item>
				</el-form>
				<div class="button">
					<el-button @click="cancle">取消</el-button>
					<el-button type="primary" @click="submit">提交</el-button>
				</div>
			</div>
		</div>
	</div>
</template>
<script>
	import {
		interrogate
	} from '@api/supply/bid'
	import dataBreadcrumb from '@components/dataBreadcrumb.vue'
	import singleUpload from '@components/Upload/Upload.vue'
	export default {
		components: {
			dataBreadcrumb,
			singleUpload,
		},
		data() {
			return {
				editorOption: {},
				breads: ['投标管理', '我参与的项目', '工作台'],
				ruleForm: {
					title: '',
					content:"",
					accessoryPOList: [],
				},
				rules: {
					title: [{
						required: true,
						message: '请输入',
						trigger: 'blue'
					}],
					release: [{
						required: true,
						message: '请输入',
						trigger: 'blue'
					}],
					// file: [{
					//   required: true,
					//   message: '请输入',
					//   trigger: 'blue'
					// }],
					content: [{
						required: true,
						message: '请输入',
						trigger: 'blue'
					}]
				}
			}
		},

		methods: {
			getfile(val) {
				for(let item of val){
					item.accessoryUrl=item.fileUrl
				}
				this.ruleForm.accessoryList = val
			},
			cancle() {
				this.$router.go(-1)
			},
			//提交表单
			async submit() {
				try {
					const valid = await this.$refs['ruleForm'].validate()
					if (valid) {
						let ruleForm = this.ruleForm
						ruleForm.projectId = localStorage.getItem("projectId")
						ruleForm.companyId = localStorage.getItem("companyId")
						const {
							code,
							msg
						} = await interrogate(ruleForm)
						if (code === 200) {
							this.$message({
								message: msg,
								type: 'success',
								duration: 1500
							})
							setTimeout(() => {
								this.$router.go(-1)
							}, 1500)
						}else{
							this.$message.error(msg)
						}
					}
				} catch (err) {
					console.log(err)
				}
			}
		}
	}
</script>


<style scoped>
	.content {
		padding: 0;
		padding-bottom: 100px;
		padding-top: 50px;
	}

	.button {
		width: 200px;
		margin: 50px auto 0
	}

	.form {
		width: 60%;
		margin: 0px auto;
	}
</style>
