RenWuGenZong.vue 5.2 KB

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