<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
	<div>
		<el-dialog :title="title" :close-on-click-modal="false" draggable width="600px" height="500px" @close="close"
			append-to-body v-model="visible">
			<el-form :model="inputForm" ref="inputForm" :class="method === 'view' ? 'readonly' : ''"
				:disabled="status === 'audit' || status === 'taskFormDetail'" label-width="135px"
				@submit.native.prevent>
				<el-row :gutter="0">
				</el-row>
				<el-row :gutter="0">
					<el-col :span="24">
						<el-form-item label="报告年份" :rules="rules.reportNo" prop="reportNo">
							<el-date-picker v-model="inputForm.reportNo" value-format="YYYY" type="year"
								placeholder="请选择报告年份" />
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="文档存放位置" :rules="rules.transferLocation" prop="transferLocation">
							<el-input v-model="inputForm.transferLocation" placeholder="请输入文档存放位置"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>

			<template #footer>
				<span class="dialog-footer">
					<el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
					<el-button v-if="method !== 'view'" type="primary" icon="el-icon-circle-check"
						@click="doSubmit()">确定</el-button>
				</span>
			</template>
		</el-dialog>
	</div>
</template>

<script>
import ReportArchieveService from '@/api/zs/reportArchieve/ReportArchieveService'
import { ElMessageBox } from "element-plus";
export default {
	data() {
		return {
			visible: false,
			title: '',
			inputForm: {
				reportNo: "",
				transferLocation: "",
			},
			// 校验规则，年份必须为数字
			rules: {
				reportNo: [
					{ required: true, message: '请选择报告年份', trigger: 'change' },
				],
				transferLocation: [
					{ required: true, message: '请输入文档存放位置', trigger: 'blur' }
				]
			}
		}
	},
	reportArchieveService: null,
	created() {
	},
	components: {
	},
	methods: {
		handleRemove() {
			this.inputForm.file.pop()
		},
		init() {
			this.visible = true
			this.title = '文档转移'
			this.inputForm = {
				reportNo: "",
				transferLocation: "",
			}
			this.reportArchieveService = new ReportArchieveService()
			this.$forceUpdate()
		},
		doSubmit() {
			// 校验数据
			this.$refs.inputForm.validate((valid) => {
				if (valid) {
					const loading = this.$loading({
						lock: true,
						text: '操作中，请稍后',
						spinner: 'el-icon-loading',
						background: 'rgba(255, 255, 255, 0.3)'
					});
					this.reportArchieveService.updatePlaceByYear(this.inputForm).then((data) => {
						ElMessageBox.alert(data.message, '提示', {
							confirmButtonText: '确定',
							callback: (action) => {
							},
						})
						loading.close();
						this.close()

					}).catch(err => {
						loading.close();
					})
				} else {
					return false;
				}
			});

		},
		close() {
			this.visible = false
			this.$refs.inputForm.resetFields()
			this.inputForm = {
				reportNo: "",
				transferLocation: "",
			}
		}

	}
}
</script>

<style scoped>
/deep/ .el-input-number .el-input__inner {
	text-align: left;
}

.el-row {
	display: flex;
	align-items: center;
	/* 垂直居中 */
}
</style>
