Commit 5a6097fdfa8431bc1b72c0d0c98bf67bfab61e21

Authored by sqy
1 parent 3da8e52f

fix:[DEFECT-360] 修复首页调整查询问题

@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 </view> 25 </view>
26 </view> 26 </view>
27 </u-sticky> 27 </u-sticky>
28 - <mescroll-body ref="mescrollRef" @init="mescrollInit" :upOption="upOption" :down="downOption" @down="downCallback" @up="upCallback"> 28 + <mescroll-body ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" @up="upCallback">
29 <view class="device-list"> 29 <view class="device-list">
30 <view @click="openDeviceDetail(item.id, item.alarmStatus, item.lastOnlineTime, item.tbDeviceId)" class="list-item" v-for="item in list" :key="item.id"> 30 <view @click="openDeviceDetail(item.id, item.alarmStatus, item.lastOnlineTime, item.tbDeviceId)" class="list-item" v-for="item in list" :key="item.id">
31 <view 31 <view
@@ -101,7 +101,6 @@ @@ -101,7 +101,6 @@
101 101
102 <script> 102 <script>
103 import fTabbar from '@/components/module/f-tabbar/f-tabbar'; 103 import fTabbar from '@/components/module/f-tabbar/f-tabbar';
104 -import fNavbar from '@/components/module/f-navbar/f-navbar';  
105 import FilterItem from './FilterItem.vue'; 104 import FilterItem from './FilterItem.vue';
106 import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js'; 105 import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
107 import { debounce } from '@/plugins/throttle.js'; 106 import { debounce } from '@/plugins/throttle.js';
@@ -109,7 +108,6 @@ export default { @@ -109,7 +108,6 @@ export default {
109 mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件) 108 mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
110 components: { 109 components: {
111 fTabbar, 110 fTabbar,
112 - fNavbar,  
113 FilterItem 111 FilterItem
114 }, 112 },
115 data() { 113 data() {
@@ -188,19 +186,27 @@ export default { @@ -188,19 +186,27 @@ export default {
188 page: { 186 page: {
189 num: 0, 187 num: 0,
190 size: 10 188 size: 10
191 - } 189 + },
  190 + deviceState: ''
192 }; 191 };
193 }, 192 },
194 - onLoad(e) { 193 + async onLoad(options) {
195 // 隐藏原生的tabbar 194 // 隐藏原生的tabbar
196 uni.hideTabBar(); 195 uni.hideTabBar();
197 - console.log('e', e);  
198 - if (e.type !== undefined) {  
199 - console.log(123)  
200 - const statusT = JSON.parse(e.type);  
201 - this.loadData(1, {  
202 - deviceState: statusT 196 + const { deviceState } = options;
  197 + this.deviceState = deviceState;
  198 + if (deviceState) {
  199 + this.deviceStatus.forEach(item => {
  200 + item.type === deviceState ? (item.checked = true) : (item.checked = false);
203 }); 201 });
  202 + await this.loadData(1, {
  203 + deviceState
  204 + });
  205 + } else {
  206 + await this.loadData(1);
  207 + }
  208 + if (!this.list.length) {
  209 + this.mescroll.showEmpty();
204 } 210 }
205 }, 211 },
206 onShow() { 212 onShow() {
@@ -217,6 +223,7 @@ export default { @@ -217,6 +223,7 @@ export default {
217 this.list = []; 223 this.list = [];
218 this.page.num = 1; 224 this.page.num = 1;
219 //联网加载数据 225 //联网加载数据
  226 + this.resetFilter();
220 this.loadData(this.page.num); 227 this.loadData(this.page.num);
221 }, 228 },
222 229
@@ -224,39 +231,41 @@ export default { @@ -224,39 +231,41 @@ export default {
224 upCallback() { 231 upCallback() {
225 //联网加载数据 232 //联网加载数据
226 this.page.num += 1; 233 this.page.num += 1;
227 - this.loadData(this.page.num); 234 + const deviceState = this.deviceStatus.find(item => item.checked);
  235 + const alarmStatus = this.alarmStatus.find(item => item.checked);
  236 + const deviceType = this.typeStatus.find(item => item.checked);
  237 + this.loadData(this.page.num, {
  238 + deviceState: deviceState.type ? deviceState.type : undefined,
  239 + deviceType: deviceType.type ? deviceType.type : undefined,
  240 + alarmStatus: alarmStatus.type === '0' || alarmStatus.type === '1' ? alarmStatus.type : undefined
  241 + });
228 }, 242 },
229 243
230 //获取设备 244 //获取设备
231 - loadData(pageNo, params = {}) {  
232 - let httpData = {  
233 - page: pageNo,  
234 - pageSize: 10,  
235 - ...params  
236 - };  
237 - uni.$u.http  
238 - .get('/yt/device', { 245 + async loadData(pageNo, params = {}) {
  246 + try {
  247 + let httpData = {
  248 + page: pageNo,
  249 + pageSize: 10,
  250 + ...params
  251 + };
  252 + const { total, items } = await uni.$u.http.get('/yt/device', {
239 params: httpData, 253 params: httpData,
240 custom: { 254 custom: {
241 load: false 255 load: false
242 } 256 }
243 - })  
244 - .then(res => {  
245 - this.total = res.total;  
246 - uni.stopPullDownRefresh();  
247 - console.log('获取后端数据', res);  
248 - //方法一(推荐): 后台接口有返回列表的总页数 totalPage  
249 - this.mescroll.endByPage(res.items.length, res.total); //必传参数(当前页的数据个数, 总页数)  
250 - if (pageNo == 1) {  
251 - this.list = res.items;  
252 - } else {  
253 - this.list = this.list.concat(res.items);  
254 - }  
255 - })  
256 - .catch(() => {  
257 - //联网失败, 结束加载  
258 - this.mescroll.endErr();  
259 }); 257 });
  258 + this.total = total;
  259 + uni.stopPullDownRefresh();
  260 + this.mescroll.endByPage(items.length, total); //必传参数(当前页的数据个数, 总页数)
  261 + if (pageNo == 1) {
  262 + this.list = items;
  263 + } else {
  264 + this.list = this.list.concat(items);
  265 + }
  266 + } catch {
  267 + this.mescroll.endErr();
  268 + }
260 }, 269 },
261 openOrg() { 270 openOrg() {
262 uni.navigateTo({ 271 uni.navigateTo({
@@ -264,7 +273,6 @@ export default { @@ -264,7 +273,6 @@ export default {
264 }); 273 });
265 }, 274 },
266 close() { 275 close() {
267 - this.resetFilter();  
268 this.show = false; 276 this.show = false;
269 }, 277 },
270 openSearchDialog() { 278 openSearchDialog() {
@@ -371,4 +379,4 @@ export default { @@ -371,4 +379,4 @@ export default {
371 } 379 }
372 } 380 }
373 } 381 }
374 -</style> 382 +</style>
@@ -157,7 +157,7 @@ export default { @@ -157,7 +157,7 @@ export default {
157 //设备状态查询 157 //设备状态查询
158 navigatorDeviceStatus(e) { 158 navigatorDeviceStatus(e) {
159 uni.reLaunch({ 159 uni.reLaunch({
160 - url: '../device/device?type=' + JSON.stringify(e) 160 + url: `../device/device?deviceState=${e}`
161 }); 161 });
162 } 162 }
163 } 163 }