| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <span class="workflow-actions" @click.stop>
- <el-button v-if="allowed('RECEIVE')" v-hasPermi="['warning:warning:handle']" link type="primary" :loading="busy" @click="receive">接收</el-button>
- <el-button v-if="allowed('START')" v-hasPermi="['warning:warning:handle']" link type="primary" :loading="busy" @click="start">开始处置</el-button>
- <el-button v-if="allowed('HANDLE')" v-hasPermi="['warning:warning:handle']" link type="warning" @click="openProcess">提交处置</el-button>
- <WarningReviewAction :row="row" @changed="emit('changed')" />
- <el-dialog v-model="visible" title="提交现场处置结果" width="620px" append-to-body :close-on-click-modal="!busy" :before-close="closeProcess">
- <el-alert title="提交后进入待核查,由指定核查人解除或退回。" type="info" :closable="false" show-icon />
- <WarningItemSummary :warning="row" />
- <el-form label-width="90px" style="margin-top: 16px">
- <el-form-item v-if="reasons.length" label="处置原因">
- <el-select v-model="selectedReasons" multiple clearable filterable placeholder="可选;选择原因会随处置记录保存" style="width: 100%">
- <el-option v-for="reason in reasons" :key="reason.reasonId" :label="reason.reasonName" :value="reason.reasonId" />
- </el-select>
- </el-form-item>
- <el-form-item label="处置结果" required><el-input v-model="content" type="textarea" :rows="5" maxlength="2000" show-word-limit placeholder="填写核查情况、原因、措施和现场恢复情况" /></el-form-item>
- <el-form-item label="处置附件">
- <el-upload v-model:file-list="files" :auto-upload="false" action="#" multiple :limit="9" accept=".pdf,.doc,.docx,.xls,.xlsx,.zip,.jpg,.jpeg,.png"><el-button>选择附件</el-button><template #tip><div class="el-upload__tip">单个文件不超过 10MB,总计不超过 20MB。</div></template></el-upload>
- </el-form-item>
- </el-form>
- <template #footer><el-button :disabled="busy" @click="visible = false">取消</el-button><el-button type="primary" :loading="busy" @click="submit">提交核查</el-button></template>
- </el-dialog>
- </span>
- </template>
- <script setup>
- import WarningItemSummary from './components/WarningItemSummary.vue'
- import WarningReviewAction from './components/WarningReviewAction.vue'
- import { computed, ref } from 'vue'
- import { ElMessage, ElMessageBox } from 'element-plus'
- import useUserStore from '@/store/modules/user'
- import { confirmWarningData, startWarningProcessData, submitWarningProcessData } from '@/api/pipeNetwork/earlyWarning'
- import { getWarningReasonListData } from '@/api/smxyjldczxt/yjxxfb/yjfb'
- import { workflowActions } from './warningWorkflow'
- const props = defineProps({ row: { type: Object, required: true } })
- const emit = defineEmits(['changed'])
- const user = useUserStore()
- const actions = computed(() => workflowActions(props.row, user.name))
- const allowed = action => actions.value.includes(action)
- const warningId = () => props.row.warningId || props.row.warning_id
- const busy = ref(false)
- const visible = ref(false)
- const content = ref('')
- const files = ref([])
- const reasons = ref([])
- const selectedReasons = ref([])
- function closeProcess(done) { if (!busy.value) done() }
- async function run(action, message) {
- if (busy.value) return
- busy.value = true
- try {
- const res = await action()
- if (res.code !== 200) { ElMessage.error(res.msg || '操作失败'); return }
- ElMessage.success(message)
- visible.value = false
- emit('changed')
- } finally { busy.value = false }
- }
- async function receive() {
- try { await ElMessageBox.confirm('确认接收该预警?', '接收预警'); await run(() => confirmWarningData({ warningId: warningId() }), '已接收,请开始处置') } catch (e) { if (!['cancel', 'close'].includes(e)) console.error('接收预警失败', e) }
- }
- async function start() {
- try { await ElMessageBox.confirm('确认开始现场处置?', '开始处置'); await run(() => startWarningProcessData({ warningId: warningId() }), '已开始处置') } catch (e) { if (!['cancel', 'close'].includes(e)) console.error('开始处置失败', e) }
- }
- async function openProcess() {
- content.value = ''; files.value = []; reasons.value = []; selectedReasons.value = []; visible.value = true
- try {
- const res = await getWarningReasonListData({ warningType: props.row.warningType || props.row.warning_type, warningLevel: props.row.warningLevel || props.row.warning_level })
- reasons.value = res.data || []
- } catch { ElMessage.warning('参考原因加载失败,可直接填写处置结果') }
- }
- async function submit() {
- if (!content.value.trim()) return ElMessage.warning('请填写现场处置结果')
- const rawFiles = files.value.map(file => file.raw).filter(Boolean)
- if (rawFiles.some(file => file.size > 10 * 1024 * 1024) || rawFiles.reduce((sum, file) => sum + file.size, 0) > 20 * 1024 * 1024) return ElMessage.warning('附件超过允许大小')
- await run(() => submitWarningProcessData({ warningId: warningId(), processContent: content.value.trim(), reasonIds: selectedReasons.value, files: rawFiles }), '处置结果已提交,等待核查')
- }
- </script>
- <style scoped>.workflow-actions { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }</style>
|