deviceDetailsList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 margin-0">
  38. <view class="list-cell list-cell-arrow" v-for="(base, index) in dataList" :key="index" @click="handleToDevice(base)">
  39. <view class="menu-item-box">
  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: #12c100"> 在线 </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 { publicStores, useStores } from "@/store/modules/index";
  62. import { dmpDeviceInfo } from "@/api/business/fireIot/deviceManage.js";
  63. const { proxy } = getCurrentInstance();
  64. const publicStore = publicStores();
  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. {
  75. label: "全部",
  76. value: "",
  77. },
  78. {
  79. label: "在线",
  80. value: "1",
  81. },
  82. {
  83. label: "离线",
  84. value: "2",
  85. },
  86. ],
  87. radioValue: "",
  88. dropdownShow: false,
  89. });
  90. const { radioList, radioValue, dropdownShow } = toRefs(data);
  91. /**
  92. * @页面初始化
  93. */
  94. function init() {
  95. dmpDeviceInfoApi();
  96. }
  97. /**
  98. * @列表查询
  99. * @api接口查询
  100. */
  101. function dmpDeviceInfoApi() {
  102. dmpDeviceInfo({ productId: productId.value, deviceName: deviceName.value, current: current.value, size: pageSize.value }).then((requset) => {
  103. if (requset.status === "SUCCESS") {
  104. dataList.value = requset.data.records;
  105. total.value = requset.data.total;
  106. uni.setNavigationBarTitle({
  107. title: `${productName.value}(${total.value})`,
  108. });
  109. }
  110. });
  111. }
  112. /**
  113. * @设备详情跳转点击事件
  114. */
  115. function handleToDevice(array) {
  116. proxy.$tab.navigateTo("/pages/business/fireIot/deviceManage/components/deviceDetails");
  117. publicStore.$state.deviceDetailsArray = array;
  118. publicStore.$state.deviceDetailsArray.productName = productName.value;
  119. }
  120. /**
  121. * @单选change事件
  122. */
  123. function radioChange(e) {
  124. radioValue.value = e;
  125. selectListApi();
  126. }
  127. /**
  128. * @scrollView加载数据
  129. */
  130. function load() {
  131. pageSize.value += 10;
  132. init();
  133. }
  134. /**
  135. * @scrollView刷新数据
  136. */
  137. function refresh() {
  138. deviceName.value = "";
  139. pageSize.value = 20;
  140. total.value = 0;
  141. init();
  142. }
  143. onReady(() => {});
  144. onShow(() => {
  145. //调用系统主题颜色
  146. proxy.$settingStore.systemThemeColor([1]);
  147. });
  148. onLoad((options) => {
  149. if ("productName" in options) {
  150. productName.value = options.productName;
  151. }
  152. if ("id" in options) {
  153. productId.value = parseInt(options.id);
  154. init();
  155. }
  156. });
  157. </script>
  158. <style lang="scss" scoped>
  159. .deviceDetailsList-container {
  160. .menu-item-box {
  161. }
  162. .deviceHeader {
  163. min-width: 100%;
  164. font-size: 15px;
  165. display: flex;
  166. white-space: nowrap;
  167. .deviceName {
  168. width: 75%;
  169. color: #000;
  170. }
  171. .deviceStatus {
  172. max-width: 30%;
  173. margin-left: 20px;
  174. font-size: 12px;
  175. color: #ffffff;
  176. padding: 0 5px;
  177. border-radius: 20px;
  178. line-height: 20px;
  179. }
  180. }
  181. .deviceContent {
  182. min-width: 100%;
  183. margin-top: 10px;
  184. font-size: 14px;
  185. color: rgb(102, 102, 102);
  186. }
  187. }
  188. </style>