WarningWorkflowActions.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <span class="workflow-actions" @click.stop>
  3. <el-button v-if="allowed('RECEIVE')" v-hasPermi="['warning:warning:handle']" link type="primary" :loading="busy" @click="receive">接收</el-button>
  4. <el-button v-if="allowed('START')" v-hasPermi="['warning:warning:handle']" link type="primary" :loading="busy" @click="start">开始处置</el-button>
  5. <el-button v-if="allowed('HANDLE')" v-hasPermi="['warning:warning:handle']" link type="warning" @click="openProcess">提交处置</el-button>
  6. <WarningReviewAction :row="row" @changed="emit('changed')" />
  7. <el-dialog v-model="visible" title="提交现场处置结果" width="620px" append-to-body :close-on-click-modal="!busy" :before-close="closeProcess">
  8. <el-alert title="提交后进入待核查,由指定核查人解除或退回。" type="info" :closable="false" show-icon />
  9. <WarningItemSummary :warning="row" />
  10. <el-form label-width="90px" style="margin-top: 16px">
  11. <el-form-item v-if="reasons.length" label="处置原因">
  12. <el-select v-model="selectedReasons" multiple clearable filterable placeholder="可选;选择原因会随处置记录保存" style="width: 100%">
  13. <el-option v-for="reason in reasons" :key="reason.reasonId" :label="reason.reasonName" :value="reason.reasonId" />
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="处置结果" required><el-input v-model="content" type="textarea" :rows="5" maxlength="2000" show-word-limit placeholder="填写核查情况、原因、措施和现场恢复情况" /></el-form-item>
  17. <el-form-item label="处置附件">
  18. <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>
  19. </el-form-item>
  20. </el-form>
  21. <template #footer><el-button :disabled="busy" @click="visible = false">取消</el-button><el-button type="primary" :loading="busy" @click="submit">提交核查</el-button></template>
  22. </el-dialog>
  23. </span>
  24. </template>
  25. <script setup>
  26. import WarningItemSummary from './components/WarningItemSummary.vue'
  27. import WarningReviewAction from './components/WarningReviewAction.vue'
  28. import { computed, ref } from 'vue'
  29. import { ElMessage, ElMessageBox } from 'element-plus'
  30. import useUserStore from '@/store/modules/user'
  31. import { confirmWarningData, startWarningProcessData, submitWarningProcessData } from '@/api/pipeNetwork/earlyWarning'
  32. import { getWarningReasonListData } from '@/api/smxyjldczxt/yjxxfb/yjfb'
  33. import { workflowActions } from './warningWorkflow'
  34. const props = defineProps({ row: { type: Object, required: true } })
  35. const emit = defineEmits(['changed'])
  36. const user = useUserStore()
  37. const actions = computed(() => workflowActions(props.row, user.name))
  38. const allowed = action => actions.value.includes(action)
  39. const warningId = () => props.row.warningId || props.row.warning_id
  40. const busy = ref(false)
  41. const visible = ref(false)
  42. const content = ref('')
  43. const files = ref([])
  44. const reasons = ref([])
  45. const selectedReasons = ref([])
  46. function closeProcess(done) { if (!busy.value) done() }
  47. async function run(action, message) {
  48. if (busy.value) return
  49. busy.value = true
  50. try {
  51. const res = await action()
  52. if (res.code !== 200) { ElMessage.error(res.msg || '操作失败'); return }
  53. ElMessage.success(message)
  54. visible.value = false
  55. emit('changed')
  56. } finally { busy.value = false }
  57. }
  58. async function receive() {
  59. try { await ElMessageBox.confirm('确认接收该预警?', '接收预警'); await run(() => confirmWarningData({ warningId: warningId() }), '已接收,请开始处置') } catch (e) { if (!['cancel', 'close'].includes(e)) console.error('接收预警失败', e) }
  60. }
  61. async function start() {
  62. try { await ElMessageBox.confirm('确认开始现场处置?', '开始处置'); await run(() => startWarningProcessData({ warningId: warningId() }), '已开始处置') } catch (e) { if (!['cancel', 'close'].includes(e)) console.error('开始处置失败', e) }
  63. }
  64. async function openProcess() {
  65. content.value = ''; files.value = []; reasons.value = []; selectedReasons.value = []; visible.value = true
  66. try {
  67. const res = await getWarningReasonListData({ warningType: props.row.warningType || props.row.warning_type, warningLevel: props.row.warningLevel || props.row.warning_level })
  68. reasons.value = res.data || []
  69. } catch { ElMessage.warning('参考原因加载失败,可直接填写处置结果') }
  70. }
  71. async function submit() {
  72. if (!content.value.trim()) return ElMessage.warning('请填写现场处置结果')
  73. const rawFiles = files.value.map(file => file.raw).filter(Boolean)
  74. if (rawFiles.some(file => file.size > 10 * 1024 * 1024) || rawFiles.reduce((sum, file) => sum + file.size, 0) > 20 * 1024 * 1024) return ElMessage.warning('附件超过允许大小')
  75. await run(() => submitWarningProcessData({ warningId: warningId(), processContent: content.value.trim(), reasonIds: selectedReasons.value, files: rawFiles }), '处置结果已提交,等待核查')
  76. }
  77. </script>
  78. <style scoped>.workflow-actions { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }</style>