|
@@ -48,7 +48,7 @@
|
|
|
<div v-loading="historyLoading">
|
|
<div v-loading="historyLoading">
|
|
|
<AlarmSummary v-if="historyAlarm" :alarm="historyAlarm" :level-tone="levelTone(historyAlarm.alarmLevel)" />
|
|
<AlarmSummary v-if="historyAlarm" :alarm="historyAlarm" :level-tone="levelTone(historyAlarm.alarmLevel)" />
|
|
|
<el-alert v-if="historyError" :title="historyError" type="error" :closable="false" />
|
|
<el-alert v-if="historyError" :title="historyError" type="error" :closable="false" />
|
|
|
- <AlarmHistory :records="logs" :loading="historyLoading" :error="historyError" :base-url="baseUrl" />
|
|
|
|
|
|
|
+ <AlarmHistory :records="logs" :loading="historyLoading" :error="historyError" />
|
|
|
</div>
|
|
</div>
|
|
|
<template #footer><el-button @click="historyVisible = false">关闭</el-button></template>
|
|
<template #footer><el-button @click="historyVisible = false">关闭</el-button></template>
|
|
|
</el-drawer>
|
|
</el-drawer>
|
|
@@ -60,7 +60,7 @@ import { computed, onBeforeUnmount, reactive, ref, watch } from 'vue'
|
|
|
import { useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router'
|
|
import { useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from 'vue-router'
|
|
|
import { ElMessage } from 'element-plus'
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { Refresh, Search, Upload } from '@element-plus/icons-vue'
|
|
import { Refresh, Search, Upload } from '@element-plus/icons-vue'
|
|
|
-import { getAlarmReviewOptions, getAlarmReviewPage, getAlarmReviewStatistics, getAlarmReviewDetail, getAlarmLogs, submitAlarmReview, uploadAlarmReviewAttachment } from '@/api/alarmReview'
|
|
|
|
|
|
|
+import { getAlarmReviewOptions, getAlarmReviewPage, getAlarmReviewStatistics, getAlarmReviewDetail, getAlarmLogs, submitAlarmReview, uploadAlarmReviewAttachments } from '@/api/alarmReview'
|
|
|
import { alarmAuditText } from '@/utils/alarmLabels'
|
|
import { alarmAuditText } from '@/utils/alarmLabels'
|
|
|
import AlarmSummary from '../AlarmSummary.vue'
|
|
import AlarmSummary from '../AlarmSummary.vue'
|
|
|
import AlarmHistory from '../AlarmHistory.vue'
|
|
import AlarmHistory from '../AlarmHistory.vue'
|
|
@@ -68,7 +68,6 @@ import { useDict } from '@/utils/dict'
|
|
|
const { alarm_level: alarmLevels } = useDict('alarm_level')
|
|
const { alarm_level: alarmLevels } = useDict('alarm_level')
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
|
-const baseUrl = import.meta.env.VITE_APP_BASE_API
|
|
|
|
|
const options = reactive({ auditStatuses: [], alarmLevels: [] })
|
|
const options = reactive({ auditStatuses: [], alarmLevels: [] })
|
|
|
const filters = reactive({ keyword: '', alarmLevel: undefined, auditStatus: undefined })
|
|
const filters = reactive({ keyword: '', alarmLevel: undefined, auditStatus: undefined })
|
|
|
const dateRange = ref([]), rows = ref([]), logs = ref([]), total = ref(0), pageNum = ref(1), pageSize = ref(10)
|
|
const dateRange = ref([]), rows = ref([]), logs = ref([]), total = ref(0), pageNum = ref(1), pageSize = ref(10)
|
|
@@ -134,14 +133,49 @@ function beforeUpload(file) {
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|
|
|
function exceedFiles() { ElMessage.warning('最多上传5张图片') }
|
|
function exceedFiles() { ElMessage.warning('最多上传5张图片') }
|
|
|
-function uploadFile({ file }) { return uploadAlarmReviewAttachment(current.value.id, { ...scope.value }, file).then(response => response.data) }
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * el-upload 的 multiple 选择会为每个文件各调一次 http-request,
|
|
|
|
|
+ * 这里把同一批次的请求收集起来,setTimeout 后一次性调用 /minio/uploads,
|
|
|
|
|
+ * 避免逐张调用单文件接口。结果按收集顺序回写,保证 file.response.token 可用。
|
|
|
|
|
+ */
|
|
|
|
|
+let uploadBatch = []
|
|
|
|
|
+let uploadBatchTimer = null
|
|
|
|
|
+function uploadFile(options) {
|
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
|
+ uploadBatch.push({ options, resolve, reject })
|
|
|
|
|
+ if (uploadBatchTimer) clearTimeout(uploadBatchTimer)
|
|
|
|
|
+ uploadBatchTimer = setTimeout(flushUploadBatch, 0)
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+function flushUploadBatch() {
|
|
|
|
|
+ uploadBatchTimer = null
|
|
|
|
|
+ const group = uploadBatch.splice(0)
|
|
|
|
|
+ const form = new FormData()
|
|
|
|
|
+ group.forEach(({ options }) => form.append('files', options.file))
|
|
|
|
|
+ uploadAlarmReviewAttachments(current.value.id, { ...scope.value }, form)
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ const infos = res.files || []
|
|
|
|
|
+ group.forEach(({ options, resolve }, i) => {
|
|
|
|
|
+ const info = infos[i] || {}
|
|
|
|
|
+ const result = { token: info.relativePath || info.url, url: info.url, name: options.file.name }
|
|
|
|
|
+ options.onSuccess(result)
|
|
|
|
|
+ resolve(result)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(err => {
|
|
|
|
|
+ group.forEach(({ options, reject }) => {
|
|
|
|
|
+ options.onError(err)
|
|
|
|
|
+ reject(err)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
async function submit() {
|
|
async function submit() {
|
|
|
if (submitting.value || uploading.value || !current.value) return
|
|
if (submitting.value || uploading.value || !current.value) return
|
|
|
if (!await formRef.value.validate().catch(() => false)) return
|
|
if (!await formRef.value.validate().catch(() => false)) return
|
|
|
if (files.value.some(file => !file.response?.token)) { formError.value = '存在未上传成功的附件,请移除后重新上传'; return }
|
|
if (files.value.some(file => !file.response?.token)) { formError.value = '存在未上传成功的附件,请移除后重新上传'; return }
|
|
|
submitting.value = true; formError.value = ''
|
|
submitting.value = true; formError.value = ''
|
|
|
try {
|
|
try {
|
|
|
- await submitAlarmReview(current.value.id, { ...scope.value }, { auditStatus: form.auditStatus, opinion: form.opinion.trim(), attachmentTokens: files.value.map(file => file.response.token) })
|
|
|
|
|
|
|
+ await submitAlarmReview(current.value.id, { ...scope.value }, { auditStatus: form.auditStatus, opinion: form.opinion.trim(), attachments: files.value.map(file => file.response.token) })
|
|
|
reviewVisible.value = false; files.value = []; Object.assign(form, { auditStatus: undefined, opinion: '' })
|
|
reviewVisible.value = false; files.value = []; Object.assign(form, { auditStatus: undefined, opinion: '' })
|
|
|
ElMessage.success('核实已提交'); await load()
|
|
ElMessage.success('核实已提交'); await load()
|
|
|
} catch (e) { formError.value = message(e) }
|
|
} catch (e) { formError.value = message(e) }
|