index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div class="monitoring-page">
  3. <!-- 新增Tabs组件区分实时/历史数据 -->
  4. <Tabs v-model:activeKey="activeTab" type="card" style="margin-bottom: 16px">
  5. <TabPane tab="实时监测" key="realtime">
  6. <div class="board-info">
  7. <MiniBoard
  8. :key="index"
  9. v-for="(item, index) in boardData"
  10. type="A"
  11. :label="item.label"
  12. :value="item.value"
  13. layout="label-top"
  14. class="board-item"
  15. />
  16. </div>
  17. <!-- 实时数据表格 -->
  18. <BasicTable @register="registerRealtimeTable" :scroll="{ x: 'max-content' }">
  19. <template #action="{ record }">
  20. <div class="action-buttons">
  21. <!-- 操作按钮 -->
  22. <button @click="openModal(record, 'detail')" class="action-btn detail-btn" title="操作">
  23. <span class="action-text">详情</span>
  24. </button>
  25. <!-- 已解决按钮 -->
  26. <button @click="openModal(record, 'resolved')" class="action-btn resolved-btn" title="已解决">
  27. <span class="action-text">已解决</span>
  28. </button>
  29. </div>
  30. </template>
  31. </BasicTable>
  32. </TabPane>
  33. <TabPane tab="历史数据" key="history">
  34. <!-- 历史数据表格 -->
  35. <BasicTable @register="registerHistoryTable" :scroll="{ x: 'max-content' }">
  36. <template #action="{ record }">
  37. <div class="action-buttons">
  38. <button @click="openModal(record, 'history')" class="action-btn">
  39. <SvgIcon name="details" />
  40. </button>
  41. </div>
  42. </template>
  43. </BasicTable>
  44. </TabPane>
  45. </Tabs>
  46. <!-- 弹窗组件 -->
  47. <a-modal
  48. style="top: 30%; left: 170px"
  49. v-model:visible="visibleModal"
  50. :width="450"
  51. title="实时监测数据"
  52. @ok="handleOkEdit"
  53. @cancel="handleCancelEdit"
  54. >
  55. <a-table></a-table>
  56. </a-modal>
  57. <!-- 弹窗组件 -->
  58. <a-modal
  59. style="height: 400px"
  60. v-model:visible="visibleresolveModal"
  61. :width="600"
  62. centered
  63. title="密闭漏风处理情况"
  64. @ok="handleOkEdit()"
  65. @cancel="handleCancelEdit"
  66. >
  67. <a-textarea style="width: 90%; margin-left: 20px; margin-right: 20px" v-model:value="resolveValue" placeholder="请输入解决情况" :rows="4" />
  68. </a-modal>
  69. </div>
  70. </template>
  71. <script setup lang="ts">
  72. import { ref } from 'vue';
  73. import { BasicTable, useTable } from '/@/components/Table';
  74. import { Tabs, TabPane } from 'ant-design-vue';
  75. import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  76. import { SvgIcon } from '/@/components/Icon';
  77. // 引入模拟数据
  78. import { boardData, columns, searchFormSchema, minesData, historicalMinesData } from './pressureDiffAnalysis.data';
  79. // 激活的Tab页签
  80. const activeTab = ref('realtime');
  81. const visibleModal = ref(false);
  82. const visibleresolveModal = ref(false);
  83. const resolveValue = ref('');
  84. // 注册实时数据表格
  85. const [registerRealtimeTable] = useTable({
  86. dataSource: minesData,
  87. columns,
  88. formConfig: {
  89. labelWidth: 120,
  90. schemas: searchFormSchema,
  91. showAdvancedButton: false,
  92. },
  93. pagination: false,
  94. striped: false,
  95. useSearchForm: true,
  96. bordered: true,
  97. showIndexColumn: false,
  98. canResize: false,
  99. actionColumn: {
  100. width: 120,
  101. title: '操作',
  102. dataIndex: 'action',
  103. slots: { customRender: 'action' },
  104. fixed: undefined,
  105. },
  106. });
  107. // 注册历史数据表格
  108. const [registerHistoryTable] = useTable({
  109. dataSource: historicalMinesData,
  110. columns,
  111. formConfig: {
  112. labelWidth: 120,
  113. schemas: searchFormSchema,
  114. showAdvancedButton: false,
  115. },
  116. pagination: false,
  117. striped: false,
  118. useSearchForm: true,
  119. bordered: true,
  120. showIndexColumn: false,
  121. canResize: false,
  122. actionColumn: {
  123. width: 120,
  124. title: '操作',
  125. dataIndex: 'action',
  126. slots: { customRender: 'action' },
  127. fixed: undefined,
  128. },
  129. });
  130. // 弹窗引用
  131. const realtimeModalRef = ref(null);
  132. const historyModalRef = ref(null);
  133. // 打开弹窗方法(区分实时/历史)
  134. const openModal = (record, type) => {
  135. if (type === 'realtime') {
  136. // 可向实时弹窗传递当前记录数据
  137. realtimeModalRef.value?.showModal(record);
  138. } else if (type === 'resolved') {
  139. visibleresolveModal.value = true;
  140. record.isResolved = resolveValue.value || '';
  141. } else if (type === 'detail') {
  142. visibleModal.value = true;
  143. } else {
  144. // 可向历史弹窗传递当前记录数据
  145. historyModalRef.value?.showModal(record);
  146. }
  147. };
  148. const handleOkEdit = () => {
  149. visibleresolveModal.value = false;
  150. };
  151. const handleCancelEdit = () => {
  152. visibleresolveModal.value = false;
  153. };
  154. </script>
  155. <style lang="less" scoped>
  156. .monitoring-page {
  157. padding: 16px;
  158. }
  159. .board-info {
  160. display: grid;
  161. grid-template-columns: repeat(5, auto); /* 3列:改5则为5列 */
  162. gap: auto;
  163. justify-content: start;
  164. flex-wrap: wrap;
  165. box-sizing: border-box;
  166. background-color: #fff;
  167. padding: 10px;
  168. margin: 0 10px;
  169. gap: 100px;
  170. }
  171. .board-item {
  172. box-sizing: border-box;
  173. }
  174. .action-btn {
  175. cursor: pointer;
  176. border: none;
  177. padding: 4px;
  178. }
  179. .action-icon {
  180. width: 16px;
  181. height: 16px;
  182. }
  183. .action-text {
  184. font-size: 12px;
  185. color: #6398fc;
  186. }
  187. </style>