index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <u-sticky bgColor="#fff" style="border-bottom: 1px #ececec solid">
  3. <u-tabs :list="list" @click="tabsClick" :current="current" :scrollable="list.length >= 5 ? true : false"></u-tabs>
  4. </u-sticky>
  5. <view class="deviceManage" @touchstart="fingerstart" @touchend="fingerend">
  6. <uni-swipe-action>
  7. <uni-swipe-action-item style="background-color: #ffffff">
  8. <view class="content1">
  9. <view style="padding: 10px">
  10. <u-input style="border-radius: 50px" v-model="dataInput" @blur="blur" prefixIcon="search" prefixIconStyle="color: #0c7bf9" placeholder="请输入设备编号"> </u-input>
  11. </view>
  12. <view style="text-align: center; padding: 10px" v-if="!dataRes">暂无数据...</view>
  13. <u-collapse @change="change" @close="close" @open="open" accordion v-else>
  14. <u-collapse-item class="uCollapseItem" v-for="da in dataList" :key="da">
  15. <template v-slot:title>
  16. <view style="display: flex">
  17. <view class="cu-avatar lg" style="margin: 0 10px auto 0;background-color:rgba(0,0,0,0);">
  18. <image class="image-bg" style=" width:80rpx;height:80rpx" src="@/static/images/deviceManage/1.png" ></image>
  19. </view>
  20. <view style="width: 100%">
  21. <view style="display: flex; color: #000000">
  22. <view>设备编号:{{ da.deviceCode }}</view>
  23. <view v-if="da.deviceStatus == 0" style="margin-left: 20px; font-size: 12px; background-color: #aeaeae; color: #ffffff; padding: 0 5px; border-radius: 20px; line-height: 20px">
  24. 离线
  25. </view>
  26. <view v-else-if="da.deviceStatus == 1" style="margin-left: 20px; font-size: 12px; background-color: #12c100; color: #ffffff; padding: 0 5px; border-radius: 20px; line-height: 20px">
  27. 正常
  28. </view>
  29. <view v-else-if="da.deviceStatus == 2" style="margin-left: 20px; font-size: 12px; background-color: #FF1313; color: #ffffff; padding: 0 5px; border-radius: 20px; line-height: 20px">
  30. 故障
  31. </view>
  32. <view v-else style="margin-left: 20px; font-size: 12px; background-color: #0D88F0; color: #ffffff; padding: 0 5px; border-radius: 20px; line-height: 20px"> 告警 </view>
  33. </view>
  34. <view style="display: flex; font-size: 14px; color: #666666; margin: 10px 0">
  35. <view style="width: 50%; word-break: break-all">监测对象:{{ da.installAddress }}</view>
  36. <view style="width: 50%; word-break: break-all; padding-left: 10px">所属单位:{{ da.companyName }}</view>
  37. </view>
  38. <view style="display: flex; font-size: 14px; color: #666666">
  39. <view style="width: 50%; word-break: break-all">负责人:{{ da.linkPerson }}</view>
  40. <view style="width: 50%; word-break: break-all; padding-left: 10px">联系电话:{{ da.linkPhone }}</view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <view class="u-collapse-content">
  46. <!-- <view style="display: flex; flex-wrap: wrap; margin-left: 5%">
  47. <view style="width: 50%; height: 30px; line-height: 30px" v-for="ch in da.dataList" :key="ch">
  48. <span>{{ ch.label }}:</span>
  49. <span :style="ch.value === '正常' ? 'color:#12C100' : 'color:#FF0101'">{{ ch.value }}</span>
  50. </view>
  51. </view> -->
  52. <view style="display: flex; flex-wrap: wrap; margin-left: 5%">
  53. <view style="width: 50%; height: 30px; line-height: 30px" v-for="ch in da.dataList" :key="ch">
  54. <span>{{ ch.portName }}:</span>
  55. <span >{{ ch.portData }}</span>
  56. </view>
  57. </view>
  58. </view>
  59. </u-collapse-item>
  60. </u-collapse>
  61. </view>
  62. </uni-swipe-action-item>
  63. </uni-swipe-action>
  64. </view>
  65. </template>
  66. <script setup>
  67. import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
  68. import { ref, onMounted, inject, shallowRef, reactive, watchEffect } from "vue";
  69. import useXunJianStore from "@/store/modules/xunJian";
  70. const myRequest = inject("$myRequest"); //全局接口请求
  71. const settingsStore = useXunJianStore(); //全局变量值Store
  72. const dataInput = ref("");
  73. const dataRes = ref(0);
  74. const systemTypeNo=ref(5)
  75. const dataList = ref([
  76. ]); //设备管理数据存储
  77. const current = ref(0);
  78. const list = ref([
  79. {
  80. id: 5,
  81. name: "电气火灾",
  82. },
  83. {
  84. id: 4,
  85. name: "烟感",
  86. },
  87. {
  88. id: 3,
  89. name: "水系统",
  90. badge: {
  91. // isDot: true,
  92. // value: 5,
  93. },
  94. },
  95. ]);
  96. const startData = ref({
  97. clientX: "",
  98. clientY: "",
  99. });
  100. const updDistance = ref(100);
  101. const lrDistance = ref(50);
  102. const topMed = ref("");
  103. const bottomMed = ref("");
  104. const leftMed = ref("");
  105. const rightMed = ref("");
  106. /**
  107. * @tabs点击事件
  108. */
  109. function tabsClick(e) {
  110. current.value = e.index;
  111. // alert(current.value)
  112. dataInput.value = ''
  113. }
  114. /**
  115. * @当按下去的时候
  116. */
  117. function fingerstart(e) {
  118. // 记录 距离可视区域左上角 左边距 和 上边距
  119. startData.value.clientX = e.changedTouches[0].clientX;
  120. startData.value.clientY = e.changedTouches[0].clientY;
  121. }
  122. /**
  123. * @当抬起来的时候
  124. */
  125. function fingerend(e) {
  126. // 当前位置 减去 按下位置 计算 距离
  127. const subX = e.changedTouches[0].clientX - startData.value.clientX;
  128. const subY = e.changedTouches[0].clientY - startData.value.clientY;
  129. if (subY > updDistance.value || subY < -updDistance.value) {
  130. if (subY > updDistance.value) {
  131. bottomscroll(subY);
  132. } else if (subY < -updDistance.value) {
  133. topscroll(subY);
  134. }
  135. } else {
  136. if (subX > lrDistance.value) {
  137. rightscroll(subX);
  138. } else if (subX < -lrDistance.value) {
  139. leftscroll(subX);
  140. } else {
  141. console.log("无效操作");
  142. }
  143. }
  144. }
  145. /**
  146. * @上滑触发
  147. */
  148. function topscroll(dista) {
  149. topMed.value ? (topMed.value = dista) : (topMed.value = null);
  150. console.log("触发了上滑方法!");
  151. }
  152. /**
  153. * @下滑触发
  154. */
  155. function bottomscroll(dista) {
  156. bottomMed.value ? (bottomMed.value = dista) : (bottomMed.value = null);
  157. console.log("触发了下滑方法!");
  158. }
  159. /**
  160. * @右滑触发
  161. */
  162. function rightscroll(dista) {
  163. rightMed.value ? (rightMed.value = dista) : (rightMed.value = null);
  164. console.log("触发了右滑方法!");
  165. if (current.value >= 1) {
  166. current.value--;
  167. } else {
  168. current.value = 0;
  169. }
  170. }
  171. /**
  172. * @左滑触发
  173. */
  174. function leftscroll(dista) {
  175. leftMed.value ? (leftMed.value = dista) : (leftMed.value = null);
  176. console.log("触发了左滑方法!");
  177. if (current.value < list.value.length - 1) {
  178. current.value++;
  179. } else {
  180. current.value = 0;
  181. }
  182. }
  183. function blur(e) {
  184. if(dataInput.value ){
  185. classifySearch({systemType:5,deviceCode:dataInput.value})
  186. }
  187. }
  188. //分类信息查询 start
  189. async function classifySearch(params) {
  190. // classifyData.value = []
  191. const res = await myRequest({
  192. url: '/service-fire/dataRt/dataRtList',
  193. data: params
  194. })
  195. console.log('------')
  196. console.log(res.data.data.records)
  197. dataList.value=res.data.data.records
  198. }
  199. // end
  200. watchEffect(() => {
  201. if (current.value == 0) {
  202. console.log(current.value);
  203. classifySearch({systemType:5,deviceCode:dataInput.value,pageNum:'',pageSize:''})
  204. } else if (current.value == 1) {
  205. console.log(current.value);
  206. classifySearch({systemType:1,deviceCode:dataInput.value,pageNum:'',pageSize:''})
  207. } else if (current.value == 2) {
  208. console.log(current.value);
  209. classifySearch({systemType:2,deviceCode:dataInput.value,pageNum:'',pageSize:''})
  210. }
  211. });
  212. function open(e) {
  213. // console.log('open', e)
  214. }
  215. function close(e) {
  216. // console.log('close', e)
  217. }
  218. function change(e) {
  219. // console.log('change', e)
  220. }
  221. // 自定义导航事件
  222. onNavigationBarButtonTap((e) => {
  223. if (e.float == "right") {
  224. uni.navigateTo({
  225. url: "/pages/business/mhxf/xunJian/collect/components/collectRecord",
  226. });
  227. } else {
  228. }
  229. });
  230. onLoad((options) => {
  231. // classifySearch({systemType:5,deviceCode:dataInput.value})
  232. });
  233. onReady(() => {});
  234. onMounted(() => {});
  235. </script>
  236. <style lang="scss">
  237. body {
  238. background: #fff;
  239. }
  240. .is-selected {
  241. color: #1989fa;
  242. }
  243. .deviceManage {
  244. height: calc(100% - 45px);
  245. background-color: #ffffff;
  246. .content1 {
  247. .u-row {
  248. .u-col {
  249. border: 1px #e4e3e3 solid;
  250. border-right: 0px;
  251. border-bottom: 0px;
  252. }
  253. .u-col:last-child {
  254. border-right: 1px #e4e3e3 solid;
  255. }
  256. }
  257. .u-row:last-child {
  258. .u-col {
  259. border-bottom: 1px #e4e3e3 solid;
  260. }
  261. }
  262. }
  263. }
  264. </style>
  265. <style scoped>
  266. body,
  267. uni-page-body,
  268. uni-page-refresh,
  269. .grayBackgroundColor {
  270. background: rgb(241, 241, 241);
  271. }
  272. .whiteBackgroundColor {
  273. background-color: #ffffff;
  274. height: 100%;
  275. }
  276. </style>