index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div class="bg" style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; overflow: hidden">
  3. <a-spin :spinning="loading" />
  4. <!-- <div
  5. id="fiber3DCSS"
  6. class="threejs-Object-CSS"
  7. v-show="!loading"
  8. style="width: 100%; height: 100%; position: absolute; pointer-events: none; overflow: hidden; z-index: 1; top: 0"
  9. >
  10. <div v-for="i in fiberListNum">
  11. <div v-for="item in 10" :id="'fiberMeg' + i + item" :key="item" class="monitor-msg-box">
  12. <div class="monitor-msg-container" :class="{ errorColor: errorNum.includes(item), warningColor: warningNum.includes(item) }">
  13. <div class="monitor-item">
  14. <p class="item-title">{{ (item - 1) * 100 }}~{{ item * 100 }}m区域:</p>
  15. <p><span class="data-title">平均温度(℃):</span><span class="num">30</span></p>
  16. <p><span class="data-title">最高温度(℃):</span><span class="num">40</span></p>
  17. <p><span class="data-title">最低温度(℃):</span><span class="num">10</span></p>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div> -->
  23. <div id="fiberBox" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
  24. </div>
  25. <div class="scene-box">
  26. <div class="top-box">
  27. <div class="top-center">
  28. <div class="input-box">
  29. <span class="input-title">模型展示范围:</span>
  30. <a-select class="title-select" ref="select" v-model:value="currentLen" @change="handleLenChange">
  31. <a-select-option value="1">0m~1000m</a-select-option>
  32. <a-select-option value="2">1000m~2000m</a-select-option>
  33. <a-select-option value="3">2000m~3000m</a-select-option>
  34. </a-select>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="title-text">
  39. {{ selectData.strinstallpos || selectData.strname }}
  40. </div>
  41. <div class="bottom-tabs-box">
  42. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  43. <a-tab-pane key="1" tab="实时监测">
  44. <MonitorTable
  45. columnsType="fiber_monitor"
  46. :dataSource="dataSource"
  47. @selectRow="getSelectRow"
  48. design-scope="fiber-monitor"
  49. title="皮带机监测"
  50. >
  51. <template #filterCell="{ column, record }">
  52. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == 0 ? 'green' : 'red'">{{
  53. record.warnFlag == 0 ? '正常' : '报警'
  54. }}</a-tag>
  55. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == '0' ? '#f00' : 'green'">{{
  56. record.netStatus == '0' ? '断开' : '连接'
  57. }}</a-tag>
  58. <div v-if="record.nwindownum == 1 && column.dataIndex === 'rearArea'">/</div>
  59. </template>
  60. </MonitorTable>
  61. </a-tab-pane>
  62. <a-tab-pane key="2" tab="实时曲线图" force-render>
  63. <div class="tab-item" v-if="activeKey === '2'">
  64. <DeviceEcharts
  65. chartsColumnsType="fiber_chart"
  66. xAxisPropType="strname"
  67. :dataSource="dataSource"
  68. height="100%"
  69. :chartsColumns="chartsColumns"
  70. :device-list-api="baseList"
  71. device-type="fiber"
  72. />
  73. </div>
  74. </a-tab-pane>
  75. <a-tab-pane key="3" tab="历史数据">
  76. <div class="tab-item">
  77. <HistoryTable columns-type="fibre" device-type="fiber" designScope="fiber-history" />
  78. </div>
  79. </a-tab-pane>
  80. <a-tab-pane key="4" tab="报警历史">
  81. <div class="tab-item">
  82. <AlarmHistoryTable columns-type="alarm" device-type="fiber" :device-list-api="baseList" designScope="alarm-history" />
  83. </div>
  84. </a-tab-pane>
  85. <a-tab-pane key="5" tab="操作历史">
  86. <div class="tab-item">
  87. <HandlerHistoryTable columns-type="operator_history" device-type="fiber" :device-list-api="baseList" designScope="alarm-history" />
  88. </div>
  89. </a-tab-pane>
  90. </a-tabs>
  91. </div>
  92. </div>
  93. </template>
  94. <script setup lang="ts">
  95. import DeviceEcharts from '../comment/DeviceEcharts.vue';
  96. import { onBeforeMount, ref, onMounted, onUnmounted, reactive, toRaw, watch } from 'vue';
  97. import MonitorTable from '../comment/MonitorTable.vue';
  98. import HistoryTable from '../comment/HistoryTable.vue';
  99. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  100. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  101. import { mountedThree, destroy, setModelType } from './fiber.threejs';
  102. import { list, getTableList } from './fiber.api';
  103. import { list as baseList } from '../../deviceManager/windWindowTabel/ventanalyWindow.api';
  104. import { chartsColumns } from './fiber.data';
  105. import lodash from 'lodash';
  106. const fiberListNum = ref(3);
  107. const deviceBaseList = ref([]);
  108. const activeKey = ref('1');
  109. const loading = ref(false);
  110. const warningNum = ref<number[]>([]);
  111. const errorNum = ref<number[]>([]);
  112. // 默认初始是第一行
  113. const selectRowIndex = ref(0);
  114. const dataSource = ref([]);
  115. const currentLen = ref('1'); // 选择光纤距离
  116. // 设备数据
  117. const controlType = ref(1);
  118. const tabChange = (activeKeyVal) => {
  119. activeKey.value = activeKeyVal;
  120. };
  121. const initData = {
  122. deviceID: '',
  123. deviceType: '',
  124. strname: '',
  125. dataDh: '-', //压差
  126. dataDtestq: '-', //测试风量
  127. sourcePressure: '-', //气源压力
  128. dataDequivalarea: '-',
  129. netStatus: '0', //通信状态
  130. fault: '气源压力超限',
  131. forntArea: '0',
  132. rearArea: '0',
  133. frontRearDifference: '-',
  134. rearPresentValue: '-',
  135. maxarea: '',
  136. nwindownum: 0,
  137. };
  138. // 监测数据
  139. const selectData = reactive(lodash.cloneDeep(initData));
  140. function handleLenChange() {
  141. //
  142. }
  143. // https获取监测数据
  144. let timer: null | NodeJS.Timeout = null;
  145. function getMonitor() {
  146. if (Object.prototype.toString.call(timer) === '[object Null]') {
  147. timer = setTimeout(async () => {
  148. const data = await getDataSource();
  149. Object.assign(selectData, data);
  150. // addFiberText(selectData)
  151. if (timer) {
  152. timer = null;
  153. }
  154. getMonitor();
  155. }, 1000);
  156. }
  157. }
  158. async function getDataSource() {
  159. console.log(11111);
  160. const res = await list({ devicetype: 'fiber', pagetype: 'normal' });
  161. console.log(2222, res);
  162. dataSource.value = res.msgTxt[0].datalist || [];
  163. dataSource.value.forEach((data: any) => {
  164. const readData = data.readData;
  165. data = Object.assign(data, readData);
  166. });
  167. const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  168. return data;
  169. }
  170. // 获取设备基本信息列表
  171. function getDeviceBaseList() {
  172. getTableList({ pageSize: 1000 }).then((res) => {
  173. deviceBaseList.value = res.records;
  174. });
  175. }
  176. // 切换检测数据
  177. function getSelectRow(selectRow, index) {
  178. if (!selectRow) return;
  179. selectRowIndex.value = index;
  180. const baseData: any = deviceBaseList.value.find((baseData: any) => baseData.id === selectRow.deviceID);
  181. Object.assign(selectData, initData, selectRow, baseData);
  182. setModelType('beltFiber');
  183. }
  184. onBeforeMount(() => {
  185. getDeviceBaseList();
  186. });
  187. onMounted(() => {
  188. loading.value = true;
  189. mountedThree().then(async () => {
  190. loading.value = false;
  191. // getMonitor();
  192. setTimeout(() => {
  193. warningNum.value = [3, 6];
  194. errorNum.value = [9];
  195. }, 3000);
  196. });
  197. getMonitor();
  198. });
  199. onUnmounted(() => {
  200. destroy();
  201. if (timer) {
  202. clearTimeout(timer);
  203. timer = undefined;
  204. }
  205. });
  206. </script>
  207. <style lang="less" scoped>
  208. @import '/@/design/vent/modal.less';
  209. @ventSpace: zxm;
  210. :deep(.@{ventSpace}-tabs-tabpane-active) {
  211. overflow: auto;
  212. }
  213. .input-box {
  214. display: flex;
  215. align-items: center;
  216. padding-left: 10px;
  217. .input-title {
  218. color: #73e8fe;
  219. width: auto;
  220. }
  221. .@{ventSpace}-input-number {
  222. border-color: #ffffff88 !important;
  223. }
  224. margin-right: 10px;
  225. }
  226. .monitor-msg-box {
  227. width: 170px;
  228. margin-top: 100px;
  229. .monitor-msg-container {
  230. width: 170px;
  231. height: 150px;
  232. box-shadow: rgba(128, 128, 128, 0.3) 0px 0px 40px inset;
  233. border: 1px solid rgba(128, 128, 128, 0.3);
  234. background-color: transparent;
  235. }
  236. .errorColor {
  237. box-shadow: #f73b2440 0px 0px 40px inset;
  238. border: 1px solid #f73b2440;
  239. }
  240. .warningColor {
  241. box-shadow: #ff9b1740 0px 0px 40px inset;
  242. border: 1px solid #ff9b1740;
  243. }
  244. .monitor-item {
  245. padding: 10px 10px 0px 10px;
  246. color: #fff;
  247. letter-spacing: 2px;
  248. .item-title {
  249. color: #73e8fe;
  250. }
  251. .num {
  252. color: #ffa500;
  253. }
  254. }
  255. }
  256. </style>