detail.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div class="form-page">
  3. <div class="page-header">
  4. <h2 class="page-title">{{ pageTitle }}</h2>
  5. </div>
  6. <!-- 发布单位信息 -->
  7. <PublishUnitInformation class="mb20" />
  8. <!-- 涉事主体基本信息 -->
  9. <QuestionInformation />
  10. <!-- 水上交通安全通报信息 -->
  11. <WaterSafetyInformation ref="noticeChildRef" />
  12. <!-- 接收单位处置意见 -->
  13. <ReceivingUnitOpinion />
  14. <div class="flex">
  15. <div>水上交通安全相关通报文书:</div>
  16. <div>《水上交通安全信息通报函》</div>
  17. </div>
  18. <!-- 底部按钮区 -->
  19. <div class="form-actions">
  20. <slot name="btn">
  21. <el-button type="primary" @click="handleSubmit">附件材料一键下载</el-button>
  22. <el-button type="primary" @click="router.back">返回</el-button>
  23. </slot>
  24. </div>
  25. </div>
  26. </template>
  27. <script setup lang="ts" name="CommonForm">
  28. import { ref, onMounted, onBeforeUnmount } from 'vue';
  29. import { useRoute, useRouter } from 'vue-router';
  30. import PublishUnitInformation from '@/components/notificationDetailsParts/publishUnitInformation.vue';
  31. import QuestionInformation from '@/components/notificationDetailsParts/questionInformation.vue';
  32. import WaterSafetyInformation from '@/components/notificationDetailsParts/waterSafetyInformation.vue';
  33. import ReceivingUnitOpinion from './receivingUnitOpinion.vue';
  34. const route = useRoute();
  35. const router = useRouter();
  36. const pageTitle = ref(''); // 页面标题
  37. const isDetail = ref(false); // 是否为详情模式
  38. const isEdit = ref(false); // 是否为编辑模式
  39. const noticeChildRef = ref<any>();
  40. onMounted(async () => {
  41. const { type, id } = route.query;
  42. try {
  43. switch (type as string) {
  44. case 'add':
  45. pageTitle.value = '水上交通安全信息发布与处置完成管理 新增发布';
  46. isEdit.value = false;
  47. break;
  48. case 'edit':
  49. pageTitle.value = '水上交通安全信息发布与处置完成管理 编辑发布';
  50. isEdit.value = true;
  51. break;
  52. case 'detail':
  53. pageTitle.value = '水上交通安全信息发布与处置完成管理 查看发布';
  54. isDetail.value = true;
  55. break;
  56. default:
  57. throw new Error(`无效操作类型: ${type}`);
  58. }
  59. } catch (error) {
  60. handleBack();
  61. } finally {}
  62. });
  63. const handleBack = () => {
  64. router.go(-1);
  65. };
  66. onBeforeUnmount(() => {
  67. isDetail.value = false;
  68. isEdit.value = false;
  69. });
  70. const handleSubmit = async () => {
  71. // 调用子组件的校验方法
  72. const isValid = await noticeChildRef.value.validateForm();
  73. if (isValid) {
  74. console.log('校验通过,执行提交逻辑');
  75. } else {
  76. console.log('校验失败,请检查表单');
  77. }
  78. };
  79. </script>
  80. <style scoped lang="scss">
  81. .form-page {
  82. padding: 20px;
  83. background-color: #fff;
  84. }
  85. .page-header {
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 100%;
  90. margin-bottom: 30px;
  91. .page-title {
  92. font-size: 22px;
  93. font-weight: 500;
  94. color: #5070ae;
  95. }
  96. }
  97. .form-actions {
  98. display: flex;
  99. justify-content: center;
  100. margin-top: 40px;
  101. gap: 16px;
  102. .el-button {
  103. padding: 8px 24px;
  104. }
  105. }
  106. // 响应式调整
  107. @media (max-width: 768px) {
  108. .form-container {
  109. padding: 15px;
  110. }
  111. .page-header {
  112. flex-direction: column;
  113. align-items: flex-start;
  114. gap: 10px;
  115. }
  116. }
  117. </style>