<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.year" prop="year">
							<el-date-picker v-model="inputForm.year" value-format="YYYY" type="year"
								placeholder="请选择报告年份" />
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="文档存放位置" :rules="rules.specialPlace" prop="specialPlace">
							<el-input v-model="inputForm.specialPlace" 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 ProjectReportArchiveService from '@/api/cw/projectRecords/ProjectReportArchiveService'
import { ElMessageBox } from "element-plus";
export default {
	data() {
		return {
			visible: false,
			title: '',
			inputForm: {
				year: "",
				specialPlace: "",
			},
			// 校验规则，年份必须为数字
			rules: {
				year: [
					{ required: true, message: '请选择报告年份', trigger: 'change' },
				],
				specialPlace: [
					{ required: true, message: '请输入文档存放位置', trigger: 'blur' }
				]
			}
		}
	},
	projectReportArchiveService: null,
	created() {
	},
	components: {
	},
	methods: {
		handleRemove() {
			this.inputForm.file.pop()
		},
		init() {
			this.visible = true
			this.title = '文档转移'
			this.inputForm = {
				year: "",
				specialPlace: "",
			}
			this.projectReportArchiveService = new ProjectReportArchiveService()
			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.projectReportArchiveService.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 = {
				year: "",
				specialPlace: "",
			}
		}

	}
}
</script>

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

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