detail.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 ref="轮播图" :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" @onUpdate="getDetail" />
  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. },
  73. mounted() {
  74. this.CustomBar = -10;
  75. this.$refs.List.setHeight();
  76. },
  77. onShow() {
  78. this.getDetail(true)
  79. try {
  80. this.$Http.openNetwork = this.$refs.轮播图.openNetwork;
  81. } catch (error) {
  82. setTimeout(() => { this.$Http.openNetwork = this.$refs.轮播图.openNetwork; }, 100)
  83. };
  84. },
  85. methods: {
  86. getDetail(init = false) {
  87. this.$Http.basic({
  88. "id": 20230615103902,
  89. "content": {
  90. nocache: true,
  91. "w_deviceid": this.w_deviceid
  92. }
  93. }).then(res => {
  94. console.log("设备详情", res)
  95. if (this.cutoff(res.msg)) return;
  96. if (!res.data.miniapppath) {
  97. res.data.miniapppath = require("../../control/pages").getPageName(res.data.prodnum);
  98. if (!res.data.miniapppath) {
  99. //未匹配到设备控制页
  100. this.showTab = '设备日志';
  101. this.tabs.shift()
  102. }
  103. }
  104. switch (res.data.status) {
  105. case '在线':
  106. res.data.bgColor = "#007aff";
  107. break;
  108. case '禁用':
  109. res.data.bgColor = "#F56C6C";
  110. break;
  111. default:
  112. res.data.bgColor = "#F9AE3D";
  113. break;
  114. }
  115. this.detail = res.data;
  116. if (init) {
  117. let prodnum = res.data.prodnum;
  118. if (res.data.miniapppath) prodnum = res.data.miniapppath.split("-")[1];
  119. this.$refs.hd.getList(this.w_deviceid, prodnum).then(num => this.tabsTop = num)
  120. setTimeout(() => { this.changeTab({ name: this.showTab }, true) }, 100)
  121. }
  122. })
  123. },
  124. changeTab({ name }, init = false) {
  125. this.showTab = name;
  126. page.show = false;
  127. page = this.$refs[name];
  128. this.loadData(init);
  129. },
  130. loadData(init) {
  131. // show t =加载 f=变化
  132. if ((page.uninitialized && !page.show) || init) {
  133. console.log("首次加载", this.showTab)
  134. page.show = true;
  135. page.initialize(true)
  136. } else if (page.show) {
  137. page.initialize()
  138. } else {
  139. page.show = true;
  140. }
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .ceiling {
  147. position: sticky;
  148. z-index: 9;
  149. }
  150. .head {
  151. width: 355px;
  152. background: #FFFFFF;
  153. border-radius: 4px;
  154. padding: 10px 15px;
  155. box-sizing: border-box;
  156. margin: 10px auto 0;
  157. .name {
  158. line-height: 20px;
  159. font-size: 14px;
  160. font-family: PingFang SC-Medium, PingFang SC;
  161. font-weight: bold;
  162. color: #333333;
  163. margin-bottom: 10px;
  164. .status {
  165. display: inline-block;
  166. padding: 2px 6px;
  167. border-radius: 4px;
  168. color: #FFFFFF;
  169. margin-right: 5px;
  170. font-weight: normal;
  171. font-size: 14px;
  172. }
  173. }
  174. .row {
  175. line-height: 17px;
  176. font-size: 12px;
  177. color: #666666;
  178. margin-bottom: 5px;
  179. }
  180. }
  181. </style>