RightTop.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="duty-card">
  3. <div class="title gradient-text">指挥动态</div>
  4. <ul class="tabs">
  5. <li v-for="(tab, index) in tabs" :key="index" :class="{ active: tab.id === activeTab }" @click="setActiveTab(tab.id)">
  6. {{ tab.label }}
  7. </li>
  8. </ul>
  9. <div class="card-content">
  10. <RenWuGenZong v-if="activeTab === '任务跟踪'" />
  11. <div v-else-if="activeTab === '预案通知'" class="custom-table">
  12. <div class="table-content">
  13. <div v-for="(notification, index) in notifications" :key="index" class="tr">
  14. <div class="td">
  15. <div class="unit-date">
  16. <span class="unit">{{ notification.unit }}</span>
  17. <span class="date">{{ notification.date }}</span>
  18. <span :class="['status', { error: notification.status === '发送失败', success: notification.status === '已发送' }]">
  19. {{ notification.status === '发送失败' ? '发送失败' : `接收人:${notification.receiver}` }}
  20. </span>
  21. </div>
  22. <div class="content">{{ notification.content }}</div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script lang="ts" setup>
  31. import { onMounted, ref, reactive } from 'vue';
  32. import { taskList } from '@/api/duty/eventing';
  33. import RenWuGenZong from '@/views/emergencyCommandMap/RightSection/RenWuGenZong.vue'; // 确保 eventing.ts 的路径正确
  34. const props = defineProps<{
  35. eventId?: string; // 使用可选属性
  36. }>();
  37. // 输出 eventId 以验证是否正确获取
  38. console.log('Received eventId in RightTop:', props.eventId);
  39. // 定义 tabs
  40. const tabs = reactive([
  41. { id: '任务跟踪', label: '任务跟踪' },
  42. { id: '预案通知', label: '预案通知' },
  43. { id: '资源调度', label: '资源调度' }
  44. ]);
  45. const activeTab = ref('预案通知');
  46. const setActiveTab = (id) => {
  47. activeTab.value = id;
  48. };
  49. // 定义 notifications
  50. const notifications = ref([]);
  51. // 请求数据
  52. const fetchData = async () => {
  53. try {
  54. if (!props.eventId) {
  55. console.error('eventId 未找到');
  56. return;
  57. }
  58. const response = await taskList({ eventId: props.eventId });
  59. if (response.code === 200) {
  60. console.log('查询成功:', response.data);
  61. updateTaskList(response.data);
  62. } else {
  63. console.error('查询失败:', response.msg);
  64. }
  65. } catch (error) {
  66. console.error('请求失败:', error);
  67. }
  68. };
  69. // 更新任务列表
  70. const updateTaskList = (tasks) => {
  71. notifications.value = tasks.map((task) => ({
  72. unit: task.dept_name,
  73. date: task.sent_time,
  74. status: task.sent_status === 0 ? '暂未发送' : '已发送',
  75. content: task.yzy_content,
  76. receiver: task.nick_name // 假设所有的任务都有接收者
  77. }));
  78. };
  79. // 在组件挂载时获取数据
  80. onMounted(() => {
  81. console.log('Mounting RightTop component');
  82. if (props.eventId) {
  83. fetchData();
  84. } else {
  85. console.warn('RightTop did not receive eventId:', props.eventId);
  86. }
  87. });
  88. </script>
  89. <style lang="scss" scoped>
  90. .tabs {
  91. display: flex;
  92. justify-content: flex-start; /* 选项卡靠左对齐 */
  93. padding: 0px 0;
  94. .active {
  95. background: url('@/assets/images/emergencyCommandMap/tabActive.png') no-repeat;
  96. }
  97. li {
  98. cursor: pointer;
  99. padding: 20px;
  100. font-size: 38px;
  101. color: #fff;
  102. width: 349px;
  103. height: 118px;
  104. background: url('@/assets/images/emergencyCommandMap/tab.png') no-repeat;
  105. display: flex;
  106. justify-content: center;
  107. align-items: flex-end;
  108. font-family: YouSheBiaoTiHei;
  109. &:hover {
  110. background: url('@/assets/images/emergencyCommandMap/tabActive.png') no-repeat;
  111. }
  112. }
  113. }
  114. .custom-table {
  115. width: 100%;
  116. .table-content {
  117. height: 600px;
  118. overflow-y: auto;
  119. .tr {
  120. display: flex;
  121. align-items: center;
  122. .td {
  123. flex: 1;
  124. padding: 10px;
  125. font-size: 36px;
  126. .unit-date {
  127. display: flex;
  128. align-items: center; /* 确保垂直居中 */
  129. justify-content: space-between; /* 使 status 靠右对齐 */
  130. span {
  131. white-space: nowrap;
  132. &.unit {
  133. font-size: 36px; /* 调整字体大小 */
  134. margin-right: 5px; /* 减小单位与日期之间的间距 */
  135. }
  136. &.date {
  137. font-size: 36px; /* 调整字体大小 */
  138. margin-right: auto; /* 使用 auto 推动 status 靠右 */
  139. }
  140. &.status {
  141. font-size: 36px; /* 调整字体大小 */
  142. text-align: right; /* 可选:如果需要进一步对齐内部文本 */
  143. }
  144. &.error {
  145. color: #ff4d4f; /* 发送失败时使用红色 */
  146. }
  147. &.success {
  148. color: #fff; /* 发送成功时使用黑色 */
  149. }
  150. }
  151. }
  152. .content {
  153. margin-top: 10px;
  154. font-size: 36px; /* 内容字体大小 */
  155. line-height: 1.5; /* 增加行高以适应较大的字体 */
  156. }
  157. }
  158. }
  159. }
  160. }
  161. .duty-card {
  162. width: 1966px;
  163. height: 879px;
  164. background: url('@/assets/images/commandDynamic/dialog.png') no-repeat;
  165. position: relative;
  166. color: #fff;
  167. .card-content {
  168. display: flex;
  169. flex-wrap: wrap;
  170. padding-top: 10px; /* 减小顶部填充 */
  171. padding-left: 100px;
  172. width: 2500px;
  173. }
  174. }
  175. .title {
  176. position: absolute;
  177. top: 6px;
  178. left: 141px;
  179. font-size: 60px;
  180. }
  181. </style>