detail.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="device-info-wrap info-wrap">
  3. <panel>
  4. <template v-slot:header>
  5. <up-icon size="28rpx" :name="list"></up-icon>
  6. 设备信息
  7. <up-tag
  8. :text="state.deviceInfo.statusName"
  9. plain
  10. size="mini"
  11. :bgColor="valueToConst(DeviceState,state.deviceInfo.status).color"
  12. class="tag-stat"/>
  13. </template>
  14. <template v-slot:content>
  15. <view class="order-info">
  16. <view class="mix-wrap">
  17. <view class="info-column">
  18. <label-text
  19. label="所属产品"
  20. :text="formatTxt(state.deviceInfo.productName)"
  21. />
  22. <label-text
  23. label="设备编码"
  24. :line="2"
  25. :text="formatTxt(state.deviceInfo.name)"
  26. />
  27. <label-text
  28. label="设备类型"
  29. :text="formatTxt(state.deviceInfo.deviceTypeName)"
  30. />
  31. <label-text
  32. label="设备厂家"
  33. :text="formatTxt(state.deviceInfo.manufactor)"
  34. />
  35. </view>
  36. <u--image
  37. :showLoading="true"
  38. :src="getDevImg(state.deviceInfo.devImg)"
  39. width="160rpx"
  40. height="150rpx"
  41. />
  42. </view>
  43. <view class="line-info-wrap">
  44. <label-text
  45. label="第三方设备编码"
  46. :text="formatTxt(state.deviceInfo.thirdDevCode)"
  47. />
  48. <label-text
  49. label="最新在线时间"
  50. :text="formatTxt(state.deviceInfo.lastOnlineTime)"
  51. />
  52. <label-text
  53. label="最后通讯时间"
  54. :text="formatTxt(state.deviceInfo.lastReportTime)"
  55. />
  56. <label-text
  57. label="位置"
  58. line="2"
  59. :text="formatTxt(state.deviceInfo.locationStr)"
  60. />
  61. <label-text
  62. label="描述"
  63. line="3"
  64. :text="formatTxt(state.deviceInfo.description)"
  65. />
  66. </view>
  67. </view>
  68. </template>
  69. </panel>
  70. <panel>
  71. <template v-slot:header>
  72. <up-icon size="28rpx" :name="list"></up-icon>
  73. 运行状态
  74. </template>
  75. <template v-slot:content>
  76. <up-cell-group :border="false">
  77. <up-cell
  78. v-for="item in state.metaInfo.dataMetaRunInfo"
  79. :title="`${item.name}(${item.identifier})`"
  80. size="small"
  81. >
  82. <template v-slot:label>
  83. <view class="meta-data">
  84. <up-text
  85. :lines="1"
  86. :text="`${item.data}${item.data && JSON.parse(item.dataType).specs.unit ? JSON.parse(item.dataType).specs.unit:''}`"
  87. size="30rpx"
  88. :bold="true"
  89. >
  90. </up-text>
  91. <up-text
  92. :lines="1"
  93. :text="formatTxt(item.timeStamp)"
  94. size="20rpx"
  95. >
  96. </up-text>
  97. </view>
  98. </template>
  99. </up-cell>
  100. </up-cell-group>
  101. </template>
  102. </panel>
  103. <up-tabbar
  104. :fixed="true"
  105. :placeholder="false"
  106. :safeAreaInsetBottom="false"
  107. >
  108. <view class="warning-btn">报废</view>
  109. <view class="def-btn">禁用</view>
  110. <view class="def-btn">编辑</view>
  111. </up-tabbar>
  112. </view>
  113. </template>
  114. <script setup lang="ts">
  115. import list from "@/static/aiot/list.svg";
  116. import Panel from "@/components/pannel/index.vue";
  117. import LabelText from "@/components/labeltext/index.vue";
  118. import {onMounted, reactive, ref} from 'vue';
  119. import {getDeviceDetail, getDeviceMeta} from "@/api/device.js";
  120. import {onLoad} from "@dcloudio/uni-app";
  121. import {formatTxt, getDevImg} from "@/util/index.js";
  122. import {valueToConst} from "@/common/consts/CommonConst.js";
  123. import {DeviceState} from "@/common/consts/DeviceConst.js";
  124. const state = reactive({
  125. deviceInfo: {},
  126. metaInfo: {
  127. dataMetaRunInfo: [],
  128. dataOnlineRunInfo: [],
  129. },
  130. });
  131. const metaInfo = reactive({});
  132. const deviceId = ref('')
  133. onLoad((option) => {
  134. deviceId.value = option.id
  135. });
  136. onMounted(() => {
  137. getDeviceDetail(deviceId.value).then((data) => {
  138. state.deviceInfo = data
  139. })
  140. getDeviceMeta(deviceId.value).then((res) => {
  141. if (res.metadataList) {
  142. state.metaInfo.dataMetaRunInfo = res.metadataList.filter((item) => item.disply !== false);
  143. }
  144. if (res.onlineList.type) {
  145. state.metaInfo.dataOnlineRunInfo = res.onlineList
  146. }
  147. })
  148. });
  149. </script>
  150. <style lang="scss">
  151. .device-info-wrap {
  152. padding-bottom: 140rpx;
  153. .panel-wrap {
  154. margin-bottom: $uni-block-gap;
  155. }
  156. .mix-wrap {
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. .info-column {
  161. display: flex;
  162. flex: 1;
  163. align-items: flex-start;
  164. justify-content: flex-start;
  165. flex-direction: column;
  166. }
  167. }
  168. .panel-content {
  169. box-sizing: border-box;
  170. padding: 15px 15px 15px 15px;
  171. }
  172. .label-text-wrap {
  173. margin-top: $uni-text-gap;
  174. }
  175. .stepper-container {
  176. .title-date {
  177. margin-left: auto;
  178. }
  179. }
  180. .u-tabbar__content__item-wrapper {
  181. padding-bottom: 40rpx;
  182. > view {
  183. box-sizing: border-box;
  184. flex: 1;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. color: $uni-bg-color;
  189. &:not(:last-child) {
  190. border-right: 2rpx solid #fefefe47;
  191. }
  192. }
  193. .warning-btn {
  194. background-color: $uni-color-error;
  195. }
  196. .def-btn {
  197. background-color: $uni-color-primary;
  198. }
  199. }
  200. .u-cell-group {
  201. .u-cell {
  202. margin-bottom: $uni-text-gap;
  203. .u-cell__body {
  204. padding: 0;
  205. }
  206. }
  207. }
  208. .meta-data {
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. }
  213. }
  214. </style>