index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <z-paging class="page" ref="paging" v-model="dataList" :default-page-size="20" @query="queryList">
  3. <!-- z-paging默认铺满全屏,此时页面所有view都应放在z-paging标签内,否则会被盖住 -->
  4. <!-- 需要固定在页面顶部的view请通过slot="top"插入,包括自定义的导航栏 -->
  5. <template #top>
  6. <uni-row class="search-row flex-row align-center justify-between">
  7. <uni-col :span="18">
  8. <uni-easyinput
  9. v-model="keywords"
  10. :styles="inputStyles"
  11. :placeholderStyle="placeholderStyle"
  12. :placeholder="$t('common.searchHint')" />
  13. </uni-col>
  14. <uni-col :span="6" class="flex-row justify-end">
  15. <button class="mini-btn" type="primary" size="mini" @click="searchList">
  16. {{ $t('operation.search') }}
  17. </button>
  18. </uni-col>
  19. </uni-row>
  20. </template>
  21. <view style="margin-top: 10px">
  22. <template v-for="(item, index) of dataList" :key="index">
  23. <view :class="item.ifInline === 3 ? 'item-online' : 'item-offline'" @click="viewDetail(item)">
  24. <uni-row class="flex-row">
  25. <image v-if="item.ifInline === 3" src="~@/static/realTimeData/online.png" style="width: 32px; height: 32px"/>
  26. <image v-else src="~@/static/realTimeData/offline.png" style="width: 32px; height: 32px"/>
  27. <uni-col style="color: #333333">
  28. <view class="flex-row align-center" style="justify-content: space-between; margin-left: 10px">
  29. <view class="flex-row align-center">
  30. <text style="font-size: 14px">{{ item.deviceName }}</text>
  31. <text class="max-content" style="margin: 0 10px; font-size: 10px">{{ item.lastInlineTime }}</text>
  32. </view>
  33. <view
  34. v-if="item.ifInline === 3"
  35. class="flex-row align-center max-content"
  36. style="font-size: 12px; color: #00AF77"
  37. >
  38. <view class="dot-green" />
  39. {{ $t('realTimeData.status.online') }}
  40. </view>
  41. <view
  42. v-else
  43. class="flex-row align-center max-content"
  44. style="font-size: 12px; color: #FB0000"
  45. >
  46. <view class="dot-red" />
  47. {{ $t('realTimeData.status.offline') }}
  48. </view>
  49. </view>
  50. <uni-row style="margin-left: 10px; margin-top: 4px; font-size: 12px">
  51. <uni-col :span="12">{{ $t('realTimeData.number') }}<span style="margin-left: 10px">{{ item.deviceCode }}</span></uni-col>
  52. <uni-col :span="12">{{ $t('realTimeData.type') }}<span style="margin-left: 10px">{{ item.assetClassName }}</span></uni-col>
  53. </uni-row>
  54. </uni-col>
  55. </uni-row>
  56. </view>
  57. </template>
  58. </view>
  59. </z-paging>
  60. </template>
  61. <script setup>
  62. import {
  63. ref,
  64. reactive
  65. } from 'vue'
  66. import { getDeviceRealTimeDataList } from "@/api/realTimeData";
  67. const keywords = ref('')
  68. const placeholderStyle = ref('color:#797979; font-weight:500; font-size:16px')
  69. const inputStyles = reactive({
  70. backgroundColor: '#FFFFFF',
  71. color: '#797979',
  72. })
  73. const paging = ref(null)
  74. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  75. const dataList = ref([])
  76. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  77. const queryList = (pageNo, pageSize) => {
  78. // 此处请求仅为演示,请替换为自己项目中的请求
  79. getDeviceRealTimeDataList({
  80. pageNo,
  81. pageSize,
  82. commonParam: keywords.value,
  83. }).then(res => {
  84. // console.log('res', res)
  85. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  86. paging.value.complete(res.data.list);
  87. }).catch(() => {
  88. // 如果请求失败写paging.value.complete(false);
  89. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  90. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  91. paging.value.complete(false);
  92. })
  93. }
  94. const searchList = () => {
  95. paging.value.reload()
  96. }
  97. const viewDetail = (row) => {
  98. const { id, deviceCode, deviceName, ifInline, lastInlineTime } = row
  99. const json = JSON.stringify({ id, deviceCode, deviceName, ifInline, lastInlineTime })
  100. uni.navigateTo({ url: '/pages/realTimeData/detail/index?info=' + json })
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .page {
  105. box-sizing: border-box;
  106. padding: 10px !important;
  107. }
  108. .search-row {
  109. height: 35px;
  110. width: 100%;
  111. background: #F3F5F9;
  112. z-index: 10;
  113. .mini-btn {
  114. height: 35px;
  115. line-height: 35px;
  116. width: calc(100% - 10px);
  117. margin-left: 10px;
  118. }
  119. }
  120. .item {
  121. width: 100%;
  122. background: #FFFFFF;
  123. border-radius: 6px;
  124. margin-top: 10px;
  125. padding: 14px 20px;
  126. font-size: 14px;
  127. }
  128. .item-module {
  129. width: 100%;
  130. height: 42px;
  131. box-sizing: border-box;
  132. padding: 10px 15px 10px 10px;
  133. border-radius: 6px 6px 0 0;
  134. background: linear-gradient(270deg, #FFFFFF 0%, #8EBEFF 100%);
  135. &.tobeFilled {
  136. background: linear-gradient(270deg, #FFFFFF 0%, #FFF0F0 100%);
  137. }
  138. .module-status {
  139. // min-width: 60px;
  140. height: 23px;
  141. padding: 0 6px;
  142. background: #FFEBEB;
  143. border-radius: 3px;
  144. border: 1px solid #FFFFFF;
  145. text-align: center;
  146. font-weight: 500;
  147. font-size: 16px;
  148. line-height: 23px;
  149. color: #E7000D;
  150. }
  151. }
  152. .item-content {
  153. width: 100%;
  154. height: calc(100% - 42px - 32px - 15px);
  155. box-sizing: border-box;
  156. padding: 15px 20px 15px 10px;
  157. font-weight: 500;
  158. font-size: 14px;
  159. color: #333333;
  160. line-height: 20px;
  161. }
  162. .item-title {
  163. width: 100%;
  164. margin-bottom: 15px;
  165. }
  166. .item-title-width {
  167. min-width: 70px;
  168. }
  169. .max-content{
  170. min-width: max-content;
  171. }
  172. .item-online {
  173. padding: 10px 10px 10px 14px;
  174. background: linear-gradient( 180deg, #92C0FF 0%, rgba(245,245,245,0) 100%);
  175. border-radius: 6px;
  176. margin-bottom: 10px;
  177. }
  178. .item-offline {
  179. padding: 10px 10px 10px 14px;
  180. background: linear-gradient( 180deg, #FFE8E8 0%, rgba(245,245,245,0) 100%);
  181. border-radius: 6px;
  182. margin-bottom: 10px;
  183. }
  184. .dot-red {
  185. width: 6px;
  186. height: 6px;
  187. background: #FB0000;
  188. border-radius: 3px;
  189. margin-right: 5px;
  190. }
  191. .dot-green {
  192. width: 6px;
  193. height: 6px;
  194. background: #00BD80;
  195. border-radius: 3px;
  196. margin-right: 5px;
  197. }
  198. </style>