瀏覽代碼

事件列表搜索缓存

seimin 11 月之前
父節點
當前提交
4984aa120b
共有 2 個文件被更改,包括 70 次插入33 次删除
  1. 39 33
      pages/incidentList/incidentList.vue
  2. 31 0
      stores/incidentListSearch.js

+ 39 - 33
pages/incidentList/incidentList.vue

@@ -13,7 +13,7 @@
13 13
         <view class="body_item_head ellipsis-multiline">
14 14
           <text :style="priorityStyle(data.priority)">{{data.priority ? data.priority.name + ' ' : ''}}</text>{{data.description}}
15 15
         </view>
16
-        
16
+
17 17
         <view class="body_item_content">
18 18
           <view class="body_item_content_p" v-if="data.department">
19 19
             <text class="name ellipsis">报修科室:{{data.department.dept}}</text>
@@ -35,7 +35,7 @@
35 35
             </view>
36 36
           </view>
37 37
         </view>
38
-        
38
+
39 39
         <view class="body_item_foot">
40 40
           <view class="foot_info">
41 41
             <view class="name" @click.stop="makePhoneCall(data.contactsInformation)">联系电话:{{data.contactsInformation}}<uni-icons type="phone-filled" class="phone-filled" :size="18" :color="primaryColor"></uni-icons></view>
@@ -72,22 +72,24 @@
72 72
   import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
73 73
   import { useLoginUserStore } from '@/stores/loginUser'
74 74
   import { useIncidentNumStore } from '@/stores/incidentNum'
75
-  
75
+  import { useIncidentListSearchStore } from '@/stores/incidentListSearch'
76
+
76 77
   useSetTitle();
77 78
   const loginUserStore = useLoginUserStore();
78 79
   const incidentNumStore = useIncidentNumStore();
80
+  const incidentListSearchStore = useIncidentListSearchStore();
79 81
   const { formatDate }  = filterFormatDate();
80 82
   const { priorityStyle }  = computedPriorityStyle();
81 83
   const { stateStyle }  = computedStateStyle();
82 84
   const { currentLogOverTime }  = computedCurrentLogOverTime();
83 85
   const { makePhoneCall }  = useMakePhoneCall();
84
-  
86
+
85 87
   // 主题颜色
86 88
   const primaryColor = ref(defaultColor)
87
-  
89
+
88 90
   const assignFlag = ref(false);//指派权限
89 91
   const qiangdan = ref(false);//接单权限
90
-  
92
+
91 93
   // 判断是否显示接单按钮
92 94
   const computedReceive = computed(() => (data) => {
93 95
     let inUser = data.currentLog && data.currentLog.workerId == loginUserStore.loginUser.user.id;
@@ -101,7 +103,7 @@
101 103
     })
102 104
     return data.state.value === 'pending' && (inUser || inGroup) && qiangdan.value;
103 105
   })
104
-  
106
+
105 107
   // 数据
106 108
   const dataInfo = reactive({
107 109
     tabs: [{id: 0, name: '全部', value: 'all', num: ''}],
@@ -119,14 +121,14 @@
119 121
       category: {id: 0, category: '全部'},
120 122
     },//筛选框数据
121 123
   })
122
-  
124
+
123 125
   // 工单详情
124 126
   function toIncidentDetail(data){
125 127
     uni.navigateTo({
126 128
       url: `/pages/incidentDetail/incidentDetail?incidentId=${data.id}`
127 129
     })
128 130
   }
129
-  
131
+
130 132
   // 获取tab选项
131 133
   function getTabs(){
132 134
     uni.showLoading({
@@ -147,59 +149,59 @@
147 149
       getList(0);
148 150
     })
149 151
   }
150
-  
152
+
151 153
   // 点击tab
152 154
   function clickTab(tabId){
153 155
     dataInfo.tabActiveId = tabId;
154 156
     getList(0);
155 157
   }
156
-  
158
+
157 159
   // 点击筛选
158 160
   function filterClick(){
159 161
     dataInfo.isFilter = true;
160 162
   }
161
-  
163
+
162 164
   // 确认筛选
163 165
   function conformFilter(evtFilter){
164 166
     dataInfo.evtFilter = evtFilter;
165 167
     dataInfo.isFilter = false;
166 168
     getList(0);
167 169
   }
168
-  
170
+
169 171
   // 关闭筛选
170 172
   function cancelFilter(){
171 173
     dataInfo.isFilter = false;
172 174
   }
173
-  
175
+
174 176
   // 点击图片和录音
175 177
   function attachmentClick(incidentData){
176 178
     dataInfo.incidentData = incidentData;
177 179
     dataInfo.isAttachment = true;
178 180
   }
179
-  
181
+
180 182
   // 知道了图片和录音
181 183
   function knowAttachment(){
182 184
     dataInfo.isAttachment = false;
183 185
   }
184
-  
186
+
185 187
   // 处理按钮
186 188
   function handler(type, incidentId){
187 189
     uni.navigateTo({
188 190
       url: `/pages/${type}/${type}?incidentId=${incidentId}`
189 191
     })
190 192
   }
191
-  
193
+
192 194
   // 接单调用方案
193 195
   function receiveFn(incidentData){
194 196
     uni.showLoading({
195 197
       title: "加载中",
196 198
       mask: true,
197 199
     });
198
-    
200
+
199 201
     let postData = {
200 202
       incident: incidentData,
201 203
     }
202
-    
204
+
203 205
     api_incidentTask('receive', postData).then(res => {
204 206
       uni.hideLoading();
205 207
       if(res.state == 200){
@@ -230,7 +232,7 @@
230 232
       }
231 233
     });
232 234
   }
233
-  
235
+
234 236
   // 获取列表信息
235 237
   function getList(idx){
236 238
     uni.showLoading({
@@ -250,12 +252,12 @@
250 252
             "statusId": dataInfo.tabActiveId || undefined,
251 253
         }
252 254
     }
253
-    
255
+
254 256
     // 请求参数调整
255 257
     if(!postData.incident){
256 258
         postData.incident = {};
257 259
     }
258
-    
260
+
259 261
     if(postData.incident.queryTask === 'all' || postData.incident.queryTask === 'callback'){
260 262
       if(loginUserStore.loginUser.user.duty){
261 263
         // 当前的所属责任科室
@@ -268,21 +270,22 @@
268 270
       delete postData.incident.duty;
269 271
       delete postData.incident.branch;
270 272
     }
271
-    
273
+
272 274
     if(postData.incident.queryTask === 'todo' || postData.incident.queryTask === 'owns' || postData.incident.queryTask === 'todoingAll'){
273 275
         postData.incident.candidateGroups = loginUserStore.loginUser.user.group.map(v => v.id).toString();
274 276
     }else{
275 277
         delete postData.incident.candidateGroups;
276 278
     }
277
-    
279
+
278 280
     if(dataInfo.evtFilter && dataInfo.evtFilter.category && dataInfo.evtFilter.category.id){
279 281
       postData.incident.levelCategory = { id: dataInfo.evtFilter.category.id };
280 282
     }
281
-    
283
+
282 284
     if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
283 285
       postData.incident.area = dataInfo.evtFilter.area
284 286
     }
285
-    
287
+
288
+    incidentListSearchStore.setIncidentListSearchData(dataInfo);
286 289
     api_incident(postData).then(res => {
287 290
       uni.hideLoading();
288 291
       uni.stopPullDownRefresh();
@@ -301,10 +304,10 @@
301 304
         });
302 305
       }
303 306
     })
304
-    
307
+
305 308
     getCount(postData.incident);
306 309
   }
307
-  
310
+
308 311
   // 获取列表数量
309 312
   function getCount(incident = {}){
310 313
     let postData = {
@@ -314,7 +317,7 @@
314 317
     dataInfo.tabs.forEach(v => {
315 318
         postData.incidentList.push({...incident, ...{statusId: v.id || undefined}});
316 319
     })
317
-    
320
+
318 321
     api_incident_count(postData).then(res => {
319 322
       if(res.state == 200){
320 323
         let myData = res.data || [];
@@ -329,15 +332,18 @@
329 332
       }
330 333
     })
331 334
   }
332
-  
335
+
333 336
   onLoad((option) => {
334 337
     // 我的-数量跳转
335 338
     if(incidentNumStore.incidentNum.data){
336 339
       dataInfo.evtFilter.selected = incidentNumStore.incidentNum.data.queryTask;
337 340
       dataInfo.tabActiveId = incidentNumStore.incidentNum.data.statusId;
338 341
       incidentNumStore.clearIncidentNumData();
342
+    }else if(incidentListSearchStore.incidentListSearch.data){
343
+      // 缓存的搜索条件
344
+      Object.assign(dataInfo, incidentListSearchStore.incidentListSearch.data);
339 345
     }
340
-    
346
+
341 347
     for (let i = 0; i < loginUserStore.loginUser.menu.length; i++) {
342 348
       if (loginUserStore.loginUser.menu[i].link == "shijianliebiao_assign") {
343 349
         assignFlag.value = true;
@@ -348,11 +354,11 @@
348 354
     }
349 355
     getTabs();
350 356
   })
351
-  
357
+
352 358
   onPullDownRefresh(() => {
353 359
     getList(0)
354 360
   })
355
-  
361
+
356 362
   onReachBottom(() => {
357 363
     dataInfo.idx += 1;
358 364
     if (dataInfo.hasMore) {

+ 31 - 0
stores/incidentListSearch.js

@@ -0,0 +1,31 @@
1
+import { defineStore } from "pinia"
2
+import { reactive } from 'vue'
3
+
4
+export const useIncidentListSearchStore = defineStore(
5
+  "incidentListSearch",
6
+  () => {
7
+    const incidentListSearch = reactive({
8
+      data: null,
9
+    });
10
+
11
+    // 保存
12
+    function setIncidentListSearchData(data) {
13
+      incidentListSearch.data = data;
14
+    }
15
+    
16
+    // 清空
17
+    function clearIncidentListSearchData() {
18
+      console.log(incidentListSearch.data)
19
+      incidentListSearch.data = null;
20
+    }
21
+
22
+    return {
23
+      incidentListSearch,
24
+      setIncidentListSearchData,
25
+      clearIncidentListSearchData,
26
+    };
27
+  },
28
+  {
29
+    unistorage: true, // 开启后对 state 的数据读写都将持久化
30
+  },
31
+);