groutHome.vue 6.0 KB

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