<!-- 
    filename: dialogForm.vue
    author: liubin
    date: 2023-10-31 15:55:13
    description: 
-->

<template>
	<el-form
		ref="form"
		:model="dataForm"
		label-width="100px"
		v-loading="formLoading">
		<el-row :gutter="20">
			<el-col :span="8">
				<el-form-item label="维修单号" prop="code">
					<span>{{ dataForm.code }}</span>
				</el-form-item>
			</el-col>
			<el-col :span="8">
				<el-form-item label="设备名称" prop="code">
					<span>{{ dataForm.code }}</span>
				</el-form-item>
			</el-col>
			<el-col :span="8">
				<el-form-item label="维修工" prop="code">
					<span>{{ dataForm.code }}</span>
				</el-form-item>
			</el-col>
		</el-row>
		<el-row :gutter="20">
			<el-col :span="8">
				<el-form-item label="故障发生时间" prop="code">
					<span>{{ dataForm.code }}</span>
				</el-form-item>
			</el-col>
			<el-col :span="8">
				<el-form-item label="故障级别" prop="code">
					<span>{{ dataForm.code }}</span>
				</el-form-item>
			</el-col>
			<el-col :span="8">
				<el-form-item label="联系方式" prop="code">
					<span>{{ dataForm.code }}</span>
				</el-form-item>
			</el-col>
		</el-row>
		<el-row :gutter="20">
			<el-col :span="8">
				<el-form-item
					label="维修开始时间"
					prop="alarmCode"
					:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
					<el-date-picker
						v-model="dataForm.startTIme"
						type="datetime"
						:disabled="disabled"
						:placeholder="请选择维修开始时间"
						value-format="timestamp"
						@change="$emit('update', form)"></el-date-picker>
				</el-form-item>
			</el-col>

			<el-col :span="8">
				<el-form-item
					label="维修结束时间"
					prop="alarmCode"
					:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
					<el-date-picker
						v-model="dataForm.startTIme"
						type="datetime"
						:disabled="disabled"
						:placeholder="请选择维修开始时间"
						value-format="timestamp"
						@change="$emit('update', form)"></el-date-picker>
				</el-form-item>
			</el-col>

			<el-col :span="8">
				<el-form-item
					label="维修方式"
					prop="grade"
					:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
					<el-select
						:disabled="disabled"
						v-model="dataForm.grade"
						placeholder="请选择报警级别"
						@change="$emit('update', dataForm)">
						<el-option
							v-for="opt in getDictDatas(DICT_TYPE.EQU_ALARM_LEVEL)"
							:key="opt.value"
							:label="opt.label"
							:value="opt.value" />
					</el-select>
				</el-form-item>
			</el-col>
		</el-row>
		<el-row :gutter="20">
			<el-col :span="8">
				<el-form-item label="故障类型" prop="alarmCode">
					<el-select
						:disabled="disabled"
						v-model="dataForm.grade"
						placeholder="请选择报警级别"
						@change="$emit('update', dataForm)">
						<el-option
							v-for="opt in getDictDatas(DICT_TYPE.EQU_ALARM_LEVEL)"
							:key="opt.value"
							:label="opt.label"
							:value="opt.value" />
					</el-select>
				</el-form-item>
			</el-col>
		</el-row>

		<el-row :gutter="20">
			<el-col>
				<el-form-item
					label="故障明细"
					prop="dsfsdfasd"
					:rules="[{ required: true, message: '不能为空', trigger: 'blur' }]">
					<!-- // 富文本 -->
				</el-form-item>
			</el-col>
		</el-row>

		<el-row :gutter="20">
			<el-col>
				<el-form-item label="维修记录" prop="dsfsdfasd">
					<!-- // 富文本 -->
				</el-form-item>
			</el-col>
		</el-row>

		<el-row :gutter="20">
			<el-col>
				<el-form-item label="维修附件" prop="dsfsdfasd">
					<el-upload></el-upload>
				</el-form-item>
			</el-col>
		</el-row>

		<el-row :gutter="20">
			<el-col>
				<el-form-item label="备注" prop="remark">
					<el-input
						v-model="dataForm.remark"
						@change="$emit('update', form)"
						:placeholder="`请输入备注`"
						:disabled="disabled" />
				</el-form-item>
			</el-col>
		</el-row>
	</el-form>
</template>

<script>
export default {
	name: 'DialogForm',
	model: {
		prop: 'dataForm',
		event: 'update',
	},
	emits: ['update'],
	components: {},
	props: {
		dataForm: {
			type: Object,
			default: () => ({}),
		},
		disabled: {
			type: Boolean,
			default: false,
		},
	},
	data() {
		return {
			formLoading: true,
		};
	},
	mounted() {
		this.getCode('/base/equipment-group-alarm/getCode').then((code) => {
			this.formLoading = false;
			this.$emit('update', {
				...this.dataForm,
				code,
			});
		});
	},
	methods: {
		/** 模拟透传 ref  */
		validate(cb) {
			return this.$refs.form.validate(cb);
		},
		resetFields(args) {
			return this.$refs.form.resetFields(args);
		},
		async handleTypeChange(id) {
			// debugger;
			this.dataForm.alarmCode = '';
			this.$emit('update', this.dataForm);
		},
		async getCode(url) {
			const response = await this.$axios(url);
			return response.data;
		},
	},
};
</script>

<style scoped lang="scss">
.el-date-editor,
.el-select {
	width: 100%;
}
</style>
