detail.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="container">
  3. <cu-custom ref="Dustom" id="custom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
  5. :isBack="true">
  6. <block slot="backText">返回</block>
  7. <block slot="content">
  8. 设备详情
  9. </block>
  10. </cu-custom>
  11. <My_listbox ref="List" :pullDown="false" @getlist="loadData">
  12. <view class="head">
  13. <view class="name">
  14. <text class="status" :style="{ backgroundColor: detail.bgColor }">{{ detail.status
  15. }}</text>
  16. {{ detail.devicename }}
  17. </view>
  18. <view class="row">
  19. 设备编号:{{ detail.serialnumber || ' --' }}
  20. </view>
  21. <view class="row">
  22. 最近上线时间:{{ detail.lastconnecttime || ' --' }}
  23. </view>
  24. </view>
  25. <preview-image :attinfos="detail.attinfos" />
  26. <view class="ceiling" :style="{ top: tovw(CustomBar) }">
  27. <horizontal-direction ref="hd" />
  28. </view>
  29. <view class="ceiling" :style="{ top: tovw(CustomBar + tabsTop) }">
  30. <tabs :tabs="tabs" @changeTab="changeTab" />
  31. </view>
  32. <control ref="设备控制" :detail="detail" />
  33. <daily-record ref="设备日志" :w_deviceid="w_deviceid" />
  34. <preview ref="详情信息" :detail="detail" />
  35. <alerts ref="告警记录" :w_deviceid="w_deviceid" />
  36. <view style="height: 30px;" />
  37. </My_listbox>
  38. </view>
  39. </template>
  40. <script>
  41. import horizontalDirection from "./modules/horizontalDirection.vue"
  42. import tabs from "./modules/tabs.vue"
  43. import preview from "./modules/preview.vue"
  44. import dailyRecord from "./modules/dailyRecord.vue"
  45. import control from "./modules/control.vue"
  46. import previewImage from "./modules/previewImage.vue"
  47. import alerts from "./modules/alerts.vue"
  48. let page = {};
  49. export default {
  50. components: { horizontalDirection, tabs, preview, dailyRecord, control, previewImage, alerts },
  51. name: "facilityD",
  52. data() {
  53. return {
  54. CustomBar: 0,
  55. tabsTop: 0,
  56. w_deviceid: 0,
  57. detail: {},
  58. showTab: '设备控制',
  59. tabs: [{
  60. name: '设备控制'
  61. }, {
  62. name: '设备日志'
  63. }, {
  64. name: '告警记录'
  65. }, {
  66. name: '详情信息'
  67. }]
  68. }
  69. },
  70. onLoad(options) {
  71. this.w_deviceid = options.id;
  72. this.getDetail(true)
  73. },
  74. mounted() {
  75. this.CustomBar = -10;
  76. this.$refs.List.setHeight();
  77. },
  78. methods: {
  79. getDetail(init = false) {
  80. this.$Http.basic({
  81. "id": 20230615103902,
  82. "content": {
  83. "w_deviceid": this.w_deviceid
  84. }
  85. }).then(res => {
  86. console.log("设备详情", res)
  87. if (this.cutoff(res.msg)) return;
  88. this.setTabs(res.data.prodnum)
  89. switch (res.data.status) {
  90. case '在线':
  91. res.data.bgColor = "#007aff";
  92. break;
  93. case '禁用':
  94. res.data.bgColor = "#F56C6C";
  95. break;
  96. default:
  97. res.data.bgColor = "#F9AE3D";
  98. break;
  99. }
  100. this.detail = res.data;
  101. if (init) {
  102. this.$refs.hd.getList(this.w_deviceid, res.data.prodnum).then(num => this.tabsTop = num)
  103. setTimeout(() => { this.changeTab({ name: this.showTab }, true) }, 100)
  104. }
  105. })
  106. },
  107. setTabs(prodnum) {
  108. if (['FW01', '01'].includes(prodnum)) {
  109. this.showTab = '设备日志';
  110. this.tabs.shift()
  111. }
  112. },
  113. changeTab({ name }, init = false) {
  114. this.showTab = name;
  115. page.show = false;
  116. page = this.$refs[name];
  117. this.loadData(init);
  118. },
  119. loadData(init) {
  120. // show t =加载 f=变化
  121. if ((page.uninitialized && !page.show) || init) {
  122. console.log("首次加载", this.showTab)
  123. page.show = true;
  124. page.initialize(true)
  125. } else if (page.show) {
  126. page.initialize()
  127. } else {
  128. page.show = true;
  129. }
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .ceiling {
  136. position: sticky;
  137. z-index: 9;
  138. }
  139. .head {
  140. width: 355px;
  141. background: #FFFFFF;
  142. border-radius: 4px;
  143. padding: 10px 15px;
  144. box-sizing: border-box;
  145. margin: 10px auto 0;
  146. .name {
  147. line-height: 20px;
  148. font-size: 14px;
  149. font-family: PingFang SC-Medium, PingFang SC;
  150. font-weight: bold;
  151. color: #333333;
  152. margin-bottom: 10px;
  153. .status {
  154. display: inline-block;
  155. padding: 2px 6px;
  156. border-radius: 4px;
  157. color: #FFFFFF;
  158. margin-right: 5px;
  159. font-weight: normal;
  160. font-size: 14px;
  161. }
  162. }
  163. .row {
  164. line-height: 17px;
  165. font-size: 12px;
  166. color: #666666;
  167. margin-bottom: 5px;
  168. }
  169. }
  170. </style>