detail.vue 5.2 KB

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