detail.vue 6.2 KB

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