deviceDetailsList.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <oa-scroll
  3. customClass="scroll-height"
  4. :pageSize="pageSize"
  5. :total="total"
  6. :refresherLoad="true"
  7. :refresherEnabled="true"
  8. :refresherDefaultStyle="'none'"
  9. :refresherThreshold="44"
  10. :refresherBackground="'#f5f6f7'"
  11. @load="load"
  12. @refresh="refresh"
  13. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  14. >
  15. <template #default>
  16. <view class="deviceDetailsList-container">
  17. <view class="flex bg-white p10" style="position: relative">
  18. <u--input
  19. style="width: 100%"
  20. v-model="deviceName"
  21. placeholder="请输入设备名称"
  22. prefixIcon="search"
  23. prefixIconStyle="font-size: 22px;color: #909399"
  24. customStyle="height:30px;background-color:#f5f6fa;"
  25. @confirm="dmpDeviceInfoApi()"
  26. clearable
  27. ></u--input>
  28. <view class="ml10" style="margin-top: auto; margin-bottom: auto; white-space: nowrap" @click="dropdownShow = !dropdownShow">筛选</view>
  29. </view>
  30. <oa-dropdown :dropdownShow="dropdownShow" :closeOnClickOverlay="true" @close="dropdownShow = false">
  31. <template #content>
  32. <u-radio-group v-model="radioValue" placement="column" iconPlacement="right" @change="radioChange">
  33. <u-radio v-for="ra in radioList" :key="ra" :activeColor="proxy.$settingStore.themeColor.color" :label="ra.label" :name="ra.value"></u-radio>
  34. </u-radio-group>
  35. </template>
  36. </oa-dropdown>
  37. <view class="menu-list m0">
  38. <view class="list-cell list-cell-arrow" v-for="(base, index) in dataList" :key="index" @click="handleToDevice(base)">
  39. <view class="menu-item">
  40. <image class="image-bg" style="width: 80rpx; height: 80rpx; margin: auto 10px auto 0" src="@/static/images/deviceManage/1.png"></image>
  41. <view style="width: calc(100% - 51px); display: flex; flex-flow: row wrap; padding-right: 10px">
  42. <view class="deviceHeader">
  43. <view class="deviceName text-ellipsis">设备编号:{{ base.deviceId }}</view>
  44. <view class="deviceStatus" v-if="base.deviceStatus == 1" style="background-color: #16bf00"> 在线 </view>
  45. <view class="deviceStatus" v-if="base.deviceStatus == 2" style="background-color: red"> 离线 </view>
  46. </view>
  47. <view class="deviceContent">设备名称:{{ base.deviceName }}</view>
  48. <view class="deviceContent">安装位置:{{ base.installAddress }}</view>
  49. <!-- <view class="deviceContent">激活状态:{{ base.serviceStatus == 1 ? "未激活" : base.serviceStatus == 2 ? "已激活" : "禁用" }}</view> -->
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. </oa-scroll>
  57. </template>
  58. <script setup>
  59. import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  60. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  61. import { useStores, commonStores } from "@/store/modules/index";
  62. import { dmpDeviceInfo } from "@/api/business/fireIot/deviceManage.js";
  63. const { proxy } = getCurrentInstance();
  64. const commonStore = commonStores();
  65. const dataList = ref([]);
  66. const deviceName = ref("");
  67. const productId = ref("");
  68. const productName = ref("");
  69. const pageSize = ref(20);
  70. const current = ref(1);
  71. const total = ref(0);
  72. const data = reactive({
  73. radioList: [
  74. { label: "全部", value: "" },
  75. { label: "在线", value: "1" },
  76. { label: "离线", value: "2" },
  77. ],
  78. radioValue: "",
  79. dropdownShow: false,
  80. });
  81. const { radioList, radioValue, dropdownShow } = toRefs(data);
  82. /**
  83. * @页面初始化
  84. */
  85. function init() {
  86. dmpDeviceInfoApi();
  87. }
  88. /**
  89. * @列表查询
  90. * @api接口查询
  91. */
  92. function dmpDeviceInfoApi() {
  93. dmpDeviceInfo({ productId: productId.value, deviceName: deviceName.value, current: current.value, size: pageSize.value }).then((requset) => {
  94. if (requset.status === "SUCCESS") {
  95. dataList.value = requset.data.records;
  96. total.value = requset.data.total;
  97. uni.setNavigationBarTitle({
  98. title: `${productName.value}(${total.value})`,
  99. });
  100. }
  101. });
  102. }
  103. /**
  104. * @设备详情跳转点击事件
  105. */
  106. function handleToDevice(array) {
  107. proxy.$tab.navigateTo("/pages/business/fireIot/deviceManage/components/deviceDetails");
  108. commonStore.deviceDetailsArray = array;
  109. commonStore.deviceDetailsArray.productName = productName.value;
  110. }
  111. /**
  112. * @单选change事件
  113. */
  114. function radioChange(e) {
  115. radioValue.value = e;
  116. selectListApi();
  117. }
  118. /**
  119. * @scrollView加载数据
  120. */
  121. function load() {
  122. pageSize.value += 10;
  123. init();
  124. }
  125. /**
  126. * @scrollView刷新数据
  127. */
  128. function refresh() {
  129. deviceName.value = "";
  130. pageSize.value = 20;
  131. init();
  132. }
  133. onReady(() => {});
  134. onShow(() => {
  135. //调用系统主题颜色
  136. proxy.$settingStore.systemThemeColor([1]);
  137. });
  138. onLoad((options) => {
  139. if ("productName" in options) {
  140. productName.value = options.productName;
  141. }
  142. if ("id" in options) {
  143. productId.value = parseInt(options.id);
  144. init();
  145. }
  146. });
  147. </script>
  148. <style lang="scss" scoped>
  149. .deviceDetailsList-container {
  150. .deviceHeader {
  151. min-width: 100%;
  152. font-size: 15px;
  153. display: flex;
  154. white-space: nowrap;
  155. .deviceName {
  156. width: 75%;
  157. color: #000;
  158. }
  159. .deviceStatus {
  160. max-width: 30%;
  161. margin-left: 20px;
  162. font-size: 12px;
  163. color: #ffffff;
  164. padding: 0 5px;
  165. border-radius: 20px;
  166. line-height: 20px;
  167. }
  168. }
  169. .deviceContent {
  170. min-width: 100%;
  171. margin-top: 10px;
  172. font-size: 14px;
  173. color: rgb(102, 102, 102);
  174. }
  175. }
  176. </style>