detail.vue 5.1 KB

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