groutHomeJj.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div class="monitor-container">
  3. <div class="header-box">
  4. <div class="header-container">
  5. <div class="device-detail">
  6. <div class="device-title">&nbsp</div>
  7. <div class="device-val">是否带电</div>
  8. <div class="device-val">是否运行</div>
  9. <div class="device-val">故障</div>
  10. </div>
  11. <div v-for="(device, key) in deviceMonitorList" class="device-detail" :key="key">
  12. <div class="device-title">{{ device.title }}</div>
  13. <div v-for="(detailItem, index) in device.dataList" :key="detailItem.code" class="device-val">
  14. <span v-if="index == 0" :style="{ color: monitorData[detailItem.code] != 1 ? '#BFBFBF' : '#10BC79' }">{{
  15. monitorData[detailItem.code] == 0 ? '不带电' : monitorData[detailItem.code] == 1 ? '带电' : '-'
  16. }}</span>
  17. <span v-if="index == 1" :style="{ color: monitorData[detailItem.code] != 1 ? '#BFBFBF' : '#10BC79' }">{{
  18. monitorData[detailItem.code] == 0 ? '未运行' : monitorData[detailItem.code] == 1 ? '运行' : '-'
  19. }}</span>
  20. <span
  21. v-if="index == 2"
  22. :style="{ color: monitorData[detailItem.code] == 0 ? '#10BC79' : monitorData[detailItem.code] == 1 ? '#F14C4C' : '#BFBFBF' }"
  23. >{{ monitorData[detailItem.code] == 0 ? '正常' : monitorData[detailItem.code] == 1 ? '报警' : '-' }}</span
  24. >
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <component v-if="modalVisible" :is="currentModal" v-model:visible="modalVisible" />
  31. </template>
  32. <script setup lang="ts">
  33. import { onBeforeMount, ref, onMounted, onUnmounted, shallowRef, defineProps, ComponentOptions, reactive } from 'vue';
  34. import { mountedThree, destroy, setModelType } from '../grout.threejs';
  35. import { ScrollBoard as DvScrollBoard } from '@kjgl77/datav-vue3';
  36. import ventBox1 from '/@/components/vent/ventBox1.vue';
  37. import RunParameterModal from './runParameter.modal.vue';
  38. import WarningParameterModal from './warningParameter.modal.vue';
  39. import { deviceMonitorList } from '../grout.data';
  40. import { list } from '../grout.api';
  41. import BarAndLineCustom from '/@/components/chart/BarAndLineCustom.vue';
  42. const props = defineProps({
  43. deviceId: {
  44. type: String,
  45. require: true,
  46. },
  47. deviceType: {
  48. type: String,
  49. require: true,
  50. },
  51. });
  52. const left: string = '0px';
  53. const currentModal = shallowRef<Nullable<ComponentOptions>>(null); //模态框
  54. const modalVisible = ref<Boolean>(false); // 模态框是否可见
  55. const loading = ref(false);
  56. const monitorData = ref({});
  57. // 默认初始是第一行
  58. const dataSource = ref([
  59. {
  60. waterSupply: '-',
  61. beltVla: '-',
  62. density: '-',
  63. pressure: '-',
  64. liquidLevel: '-',
  65. flowRate: '-',
  66. readTime: '',
  67. },
  68. {
  69. waterSupply: '-',
  70. beltVla: '-',
  71. density: '-',
  72. pressure: '-',
  73. liquidLevel: '-',
  74. flowRate: '-',
  75. readTime: '',
  76. },
  77. ]); //dusting
  78. const flvURL1 = () => {
  79. return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  80. // return ''
  81. };
  82. const openModal = (modalName) => {
  83. modalVisible.value = true;
  84. if (modalName == 'RunParameterModal') {
  85. currentModal.value = RunParameterModal;
  86. } else {
  87. currentModal.value = WarningParameterModal;
  88. }
  89. };
  90. // https获取监测数据
  91. let timer: null | NodeJS.Timeout = null;
  92. function getMonitor(flag?) {
  93. if (Object.prototype.toString.call(timer) === '[object Null]') {
  94. timer = setTimeout(
  95. async () => {
  96. await getDataSource();
  97. if (timer) {
  98. timer = null;
  99. }
  100. await getMonitor();
  101. },
  102. flag ? 0 : 1000
  103. );
  104. }
  105. }
  106. async function getDataSource() {
  107. const res = await list({ devicetype: 'pulping_auto', pagetype: 'normal' });
  108. if (res.msgTxt && res.msgTxt[0] && res.msgTxt[0].datalist && res.msgTxt[0].datalist[0]) {
  109. monitorData.value = Object.assign(res.msgTxt[0].datalist[0], res.msgTxt[0].datalist[0]['readData']);
  110. }
  111. // const dataList = res.msgTxt[0].datalist || [];
  112. // dataSource.value = dataList.filter((data) => {
  113. // const item = data.readData;
  114. // Object.assign(data, item);
  115. // return item
  116. // });
  117. // monitorData.value =
  118. }
  119. function handlerDevice(param: string | Object) {}
  120. function controlDevice(flag) {}
  121. onBeforeMount(() => {});
  122. onMounted(() => {
  123. loading.value = true;
  124. mountedThree().then(async () => {
  125. // await setModelType('groutBase');
  126. await setModelType('bertaiBase');
  127. loading.value = false;
  128. timer = null;
  129. await getMonitor(true);
  130. });
  131. });
  132. onUnmounted(() => {
  133. destroy();
  134. if (timer) {
  135. clearTimeout(timer);
  136. timer = undefined;
  137. }
  138. });
  139. </script>
  140. <style lang="less" scoped>
  141. @import '/@/design/vent/modal.less';
  142. @ventSpace: zxm;
  143. .monitor-container {
  144. width: 100%;
  145. height: 100%;
  146. // height: 550px;
  147. // border: 1px solid #fff;
  148. margin-top: 40px;
  149. display: flex;
  150. // justify-content: space-between;
  151. justify-content: center;
  152. padding: 0 5px;
  153. .header-box {
  154. // width: 100%;
  155. margin-top: 50px;
  156. .header-container {
  157. height: auto;
  158. display: flex;
  159. flex-direction: row;
  160. justify-content: center;
  161. color: #fff;
  162. box-shadow: 0 0 30px rgb(0, 153, 184) inset;
  163. }
  164. .device-title {
  165. width: 110px;
  166. text-align: center;
  167. border-top: 1px solid #00baffd4;
  168. border-left: 1px solid #00baffd4;
  169. line-height: 46px;
  170. color: #00e5ff;
  171. background-color: #00bbff21;
  172. }
  173. .device-detail {
  174. text-align: center;
  175. &:first-child {
  176. background-color: #00bbff11;
  177. }
  178. &:last-child {
  179. .device-val,
  180. .device-title {
  181. border-right: 1px solid #00baffd4;
  182. }
  183. }
  184. .device-val {
  185. line-height: 36px;
  186. border-top: 1px solid #00baffd4;
  187. border-left: 1px solid #00baffd4;
  188. &:last-child {
  189. border-bottom: 1px solid #00baffd4;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. :deep(.@{ventSpace}-tabs-tabpane-active) {
  196. overflow: auto;
  197. }
  198. .input-box {
  199. display: flex;
  200. align-items: center;
  201. padding-left: 10px;
  202. .input-title {
  203. color: #73e8fe;
  204. width: auto;
  205. }
  206. .@{ventSpace}-input-number {
  207. border-color: #ffffff88 !important;
  208. }
  209. margin-right: 10px;
  210. }
  211. </style>