Browse Source

事件列表搜索缓存

seimin 11 months ago
parent
commit
4984aa120b
2 changed files with 70 additions and 33 deletions
  1. 39 33
      pages/incidentList/incidentList.vue
  2. 31 0
      stores/incidentListSearch.js

+ 39 - 33
pages/incidentList/incidentList.vue

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