2026-04-07 17:01:46 +08:00
|
|
|
|
<template>
|
2026-04-08 16:01:04 +08:00
|
|
|
|
<PageContainer :title="title" @click-back="handleClickBack" class="page-container">
|
2026-04-07 17:01:46 +08:00
|
|
|
|
<!-- 当前站点信息 -->
|
|
|
|
|
|
<CurrentSite />
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 事件类型 -->
|
2026-04-10 13:39:36 +08:00
|
|
|
|
<PanelItem title="事件类型" style="margin-bottom: 10px" v-if="!isContinue">
|
2026-04-07 17:01:46 +08:00
|
|
|
|
<van-radio-group v-model="eventType" direction="horizontal" class="event-type-group">
|
|
|
|
|
|
<van-radio name="water">水毁灾害</van-radio>
|
|
|
|
|
|
<van-radio name="ice">冰雪灾害</van-radio>
|
|
|
|
|
|
</van-radio-group>
|
|
|
|
|
|
</PanelItem>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 根据事件类型渲染不同表单 -->
|
2026-04-10 13:39:36 +08:00
|
|
|
|
<WaterDisaster v-if="eventType === 'water'" ref="waterDisasterRef" />
|
|
|
|
|
|
|
2026-04-07 17:01:46 +08:00
|
|
|
|
<!-- 冰雪灾害表单(待实现) -->
|
|
|
|
|
|
<div v-else class="coming-soon">
|
|
|
|
|
|
<van-empty description="冰雪灾害表单开发中..." />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 提交按钮 -->
|
2026-04-10 13:39:36 +08:00
|
|
|
|
<van-button type="primary" class="footer-btn" @click="handleSubmit" :loading="submitting"> 提交 </van-button>
|
2026-04-07 17:01:46 +08:00
|
|
|
|
</PageContainer>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-04-08 16:01:04 +08:00
|
|
|
|
import { ref, onMounted, computed } from 'vue'
|
|
|
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
2026-04-07 17:01:46 +08:00
|
|
|
|
import { showToast, showSuccessToast, showFailToast } from 'vant'
|
|
|
|
|
|
import PageContainer from '@/components/PageContainer.vue'
|
|
|
|
|
|
import CurrentSite from '@/components/CurrentSite.vue'
|
|
|
|
|
|
import PanelItem from '@/components/PanelItem.vue'
|
2026-04-08 09:21:47 +08:00
|
|
|
|
import WaterDisaster from './WaterDisaster/WaterDisaster.vue'
|
2026-04-10 13:39:36 +08:00
|
|
|
|
import { request } from '@shared/utils/request'
|
2026-04-08 11:12:41 +08:00
|
|
|
|
import mockFormData from './waterDisasterFormData.json'
|
2026-04-07 17:01:46 +08:00
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
2026-04-08 16:01:04 +08:00
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
|
|
|
|
// 是否为续报
|
|
|
|
|
|
const isContinue = computed(() => route.query.isContinue)
|
|
|
|
|
|
|
|
|
|
|
|
const title = ref(!isContinue ? '灾毁填报' : '灾毁续报')
|
2026-04-07 17:01:46 +08:00
|
|
|
|
|
|
|
|
|
|
// 事件类型
|
|
|
|
|
|
const eventType = ref('water')
|
|
|
|
|
|
|
|
|
|
|
|
// 表单数据
|
2026-04-10 13:39:36 +08:00
|
|
|
|
const formData = ref(route.query.mock ? mockFormData : {})
|
2026-04-07 17:01:46 +08:00
|
|
|
|
const waterDisasterRef = ref(null)
|
|
|
|
|
|
const submitting = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
// 返回上一页
|
|
|
|
|
|
const handleClickBack = () => {
|
|
|
|
|
|
router.replace('/disasterManagement')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 提交表单
|
|
|
|
|
|
const handleSubmit = async () => {
|
|
|
|
|
|
// 验证表单
|
|
|
|
|
|
if (eventType.value === 'water') {
|
|
|
|
|
|
if (!waterDisasterRef.value.validate()) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-10 13:39:36 +08:00
|
|
|
|
|
2026-04-07 17:01:46 +08:00
|
|
|
|
submitting.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 获取表单数据
|
|
|
|
|
|
let formData = {}
|
|
|
|
|
|
if (eventType.value === 'water') {
|
|
|
|
|
|
formData = waterDisasterRef.value.getFormData()
|
|
|
|
|
|
}
|
2026-04-10 13:39:36 +08:00
|
|
|
|
|
2026-04-07 17:01:46 +08:00
|
|
|
|
// 添加事件类型和站点信息
|
|
|
|
|
|
const submitData = {
|
2026-04-10 13:39:36 +08:00
|
|
|
|
...formData
|
2026-04-07 17:01:46 +08:00
|
|
|
|
// 可以在这里添加站点信息等其他数据
|
|
|
|
|
|
}
|
2026-04-08 11:12:41 +08:00
|
|
|
|
|
|
|
|
|
|
const res = await request({
|
|
|
|
|
|
url: '/snow-ops-platform/water-damage/addOrUpdate',
|
|
|
|
|
|
method: 'post',
|
|
|
|
|
|
data: submitData
|
|
|
|
|
|
})
|
2026-04-08 16:01:04 +08:00
|
|
|
|
|
2026-04-10 13:39:36 +08:00
|
|
|
|
if (res?.code === '00000') {
|
2026-04-08 16:01:04 +08:00
|
|
|
|
showSuccessToast('提交成功')
|
2026-04-10 13:39:36 +08:00
|
|
|
|
// 提交成功后返回列表页
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
router.replace('/disasterManagement')
|
|
|
|
|
|
}, 1000)
|
2026-04-08 16:01:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
showFailToast(res.message)
|
|
|
|
|
|
}
|
2026-04-07 17:01:46 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showFailToast('提交失败,请重试')
|
|
|
|
|
|
console.error('提交失败:', error)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
submitting.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-08 11:12:41 +08:00
|
|
|
|
|
2026-04-08 16:01:04 +08:00
|
|
|
|
// 获取灾毁详情
|
|
|
|
|
|
const getDisasterDetail = async () => {
|
|
|
|
|
|
const id = route.query.id
|
|
|
|
|
|
if (!id) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const result = await request({
|
|
|
|
|
|
url: `/snow-ops-platform/water-damage/getById`,
|
|
|
|
|
|
method: 'get',
|
|
|
|
|
|
params: { id }
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (result?.data) {
|
|
|
|
|
|
// 接口返回 Data 结构
|
|
|
|
|
|
const data = result.data
|
|
|
|
|
|
const newFormData = {
|
2026-04-10 13:39:36 +08:00
|
|
|
|
...data,
|
|
|
|
|
|
lossList: null,
|
|
|
|
|
|
report: formData.value.report,
|
|
|
|
|
|
fileList: null
|
2026-04-08 16:01:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
waterDisasterRef.value.initFormData(newFormData)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showToast(result.message || '获取详情失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取灾毁详情失败:', error)
|
|
|
|
|
|
showToast('获取详情失败,请稍后重试')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 11:12:41 +08:00
|
|
|
|
onMounted(() => {
|
2026-04-10 13:39:36 +08:00
|
|
|
|
if (route.query?.id) {
|
2026-04-08 16:01:04 +08:00
|
|
|
|
getDisasterDetail()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
waterDisasterRef.value.initFormData(formData.value)
|
|
|
|
|
|
}
|
2026-04-08 11:12:41 +08:00
|
|
|
|
})
|
2026-04-07 17:01:46 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.page-container {
|
|
|
|
|
|
padding-bottom: 80px;
|
|
|
|
|
|
background-color: #f5f7fa;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.event-type-group {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 24px;
|
|
|
|
|
|
:deep(.van-radio) {
|
|
|
|
|
|
margin-right: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.coming-soon {
|
|
|
|
|
|
padding: 40px 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.footer-btn {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
bottom: 15px;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
width: calc(100% - 32px);
|
|
|
|
|
|
max-width: 340px;
|
|
|
|
|
|
border-radius: 48px;
|
|
|
|
|
|
height: 48px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
z-index: 10;
|
|
|
|
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
|
|
opacity: 0.9;
|
|
|
|
|
|
transform: translateX(-50%) scale(0.98);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-10 13:39:36 +08:00
|
|
|
|
</style>
|