<template>
    <el-dialog draggable width="500px" v-model="dialogVisible" title="人工维护">
        <el-scrollbar>
            <el-form :inline="false" :model="form" label-width="140px" :rules="rules" ref="formRef">

                <el-form-item label="暂降核实原因:" prop="verifyReason">
                  
                    <el-select v-model="form.verifyReason" placeholder="请选择暂降核实原因" filterable>
                        <el-option v-for="item in verifyReasonList" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </el-form-item>
                <el-form-item label="暂降核实原因详情:" prop="verifyReasonDetail">
             
                    <el-input v-model="form.verifyReasonDetail" :rows="3" type="textarea" placeholder="请输入暂降核实原因详情" />
                </el-form-item>
            </el-form>
        </el-scrollbar>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" @click="submit">确认</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script lang="ts" setup>
import { ref, inject } from 'vue'
import { reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { updateEventReason } from '@/api/event-boot/highAndLowPressure'
import { useDictData } from '@/stores/dictData'
const  emit=defineEmits(['onSubmit'])
const dictData = useDictData()
const dialogVisible = ref(false)
const verifyReasonList: any = dictData.getBasicData('verifyReason')
const formRef = ref()
const form: any = reactive({
    eventId: '',
    verifyReason: '',
    verifyReasonDetail: ''
})
const rules = {
    verifyReasonDetail: [{ required: true, message: '请输入暂降核实原因详情', trigger: 'blur' },],
    verifyReason: [{ required: true, message: '请输入暂降核实原因', trigger: 'blur' },],
}

const open = (row: any) => {
    dialogVisible.value = true
    form.eventId = row.eventId
    form.verifyReason = row.verifyReason
    form.verifyReasonDetail = row.verifyReasonDetail
}
const submit = () => {
    formRef.value.validate(async (valid: boolean) => {
        if (valid) {
            updateEventReason(form).then(res => {

                ElMessage.success('录入成功！')
                dialogVisible.value = false
                emit('onSubmit')
            })
        }
    })
}

defineExpose({ open })
</script>
