index.vue 8.6 KB

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