<!-- Description: 报警管理-处置(设备报警) Author: 李亚光 Date: 2025-04-15 --> <script lang="ts" setup name="DeviceSituationDialog"> import { getDictByCode } from '@/api/system/dict' import { handlerAlarmProcess, getHandlerAlarmRecord } from '@/api/home/alarm/current' import pendingDialog from './pendingDialog.vue' import type { FormRules } from 'element-plus' import { dayjs, ElMessage } from 'element-plus' import useUserStore from '@/store/modules/user' const $route = useRoute() const emits = defineEmits(['refresh']) const userInfo = useUserStore() const dialogFormVisible = ref(false) const loading = ref(false) const info = ref<any>({}) const isFirstFill = ref(true) const alarmCategoryName = ref('') const confirmSituationList = ref<{ id: string; name: string; value: string }[]>([]) const confirmSituationAllList = ref<{ id: string; name: string; value: string }[]>([]) const dataFormRef = ref() const dataForm = ref({ descn: '', // 现场情况备注 }) // 表单 const rules: FormRules = { descn: [{ required: true, message: '现场确认情况不能为空', trigger: ['blur', 'change'] }], } // 前端校验规则 const initDialog = (row: any) => { dataForm.value = { descn: '', // 现场情况备注 } nextTick(() => { dataFormRef.value?.resetFields() }) // console.log(row, 'row') dialogFormVisible.value = true info.value = row alarmCategoryName.value = row.alarmCategory // confirmSituationList.value = confirmSituationAllList.value.filter((item) => item.value.split('-')[1] === '3') } defineExpose({ initDialog }) // 确认 const confirm = () => { dataFormRef.value.validate((valid: any) => { if (valid) { const handler = (data: any[]) => { handlerAlarmProcess(data).then(res => { emits('refresh') ElMessage.success('操作成功') dialogFormVisible.value = false }) } handler([ { alarmId: info.value.id, approvalStatus: "4-3-3", // 其他 -- 字典 confirmValue: "", descn: dataForm.value.descn, approvalPerson: userInfo.name, approvalTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), flowStatus: "5" }, { alarmId: info.value.id, flowStatus: "7", approvalStatus: "4-3-3", // 其他 descn: dataForm.value.descn, approvalPerson: userInfo.name, approvalTime: dayjs().format('YYYY-MM-DD HH:mm:ss') }]) } }) } // 取消 const cancel = () => { dialogFormVisible.value = false } // const fetchDict = () => { // loading.value = true // getDictByCode('confirmSituation').then(res => { // confirmSituationAllList.value = JSON.parse(JSON.stringify(res.data)) // confirmSituationList.value = JSON.parse(JSON.stringify(res.data)) // loading.value = false // }) // } // fetchDict() // const computedDescn = computed(() => { // return confirmSituationAllList.value.filter((item) => item.value === dataForm.value.approvalStatus)[0]?.name || '' // }) </script> <template> <el-dialog v-model="dialogFormVisible" title="报警处置" append-to-body width="500px"> <el-form ref="dataFormRef" v-loading="loading" :rules="rules" :model="dataForm" label-position="right" label-width="120px"> <el-row :gutter="24"> <el-col :span="22"> <el-form-item label="处置情况记录" prop="descn"> <el-input type="textarea" v-model.trim="dataForm.descn" placeholder="现场情况备注" :rows="5" maxlength="100" show-word-limit></el-input> </el-form-item> </el-col> </el-row> </el-form> <template #footer> <div class="dialog-footer"> <el-button type="primary" @click="confirm" :disabled="loading"> 确认 </el-button> <el-button @click="cancel" :disabled="loading"> 取消 </el-button> </div> </template> </el-dialog> </template> <style lang="scss" scoped></style>