Browse Source

Merge branch 'dev' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager into dev

xujing 5 years ago
parent
commit
2dd64be4dd
2 changed files with 24 additions and 4 deletions
  1. 5
    1
      src/pages/building/list/add/index.jsx
  2. 19
    3
      src/pages/building/list/index.jsx

+ 5
- 1
src/pages/building/list/add/index.jsx View File

5
 import apis from '../../../../services/apis';
5
 import apis from '../../../../services/apis';
6
 import Styles from './style.less';
6
 import Styles from './style.less';
7
 import { router } from 'umi';
7
 import { router } from 'umi';
8
-
8
+import Prompt from 'umi/prompt';
9
 
9
 
10
 import ImageUpload from '../../../../components/XForm/ImageUpload'
10
 import ImageUpload from '../../../../components/XForm/ImageUpload'
11
 import Wangedit from '../../../../components/Wangedit/Wangedit'
11
 import Wangedit from '../../../../components/Wangedit/Wangedit'
77
         { (tab === 'poster' && <Poster building={buildingData} />)}
77
         { (tab === 'poster' && <Poster building={buildingData} />)}
78
         { (tab === 'share' && <Share building={buildingData} />)}
78
         { (tab === 'share' && <Share building={buildingData} />)}
79
       </div>
79
       </div>
80
+      <Prompt message={location =>
81
+                          location.pathname.startsWith("/building/list")
82
+                            ? true
83
+                            : localStorage.removeItem("pageParams")} />
80
     </>
84
     </>
81
     // <Tabs defaultActiveKey="1" onChange={tabsCallback}>
85
     // <Tabs defaultActiveKey="1" onChange={tabsCallback}>
82
     //   <TabPane tab="基本信息" key="1">
86
     //   <TabPane tab="基本信息" key="1">

+ 19
- 3
src/pages/building/list/index.jsx View File

5
 import apis from '../../../services/apis';
5
 import apis from '../../../services/apis';
6
 import Styles from './style.less';
6
 import Styles from './style.less';
7
 import { router } from 'umi';
7
 import { router } from 'umi';
8
+import Prompt from 'umi/prompt';
8
 import AuthButton from '@/components/AuthButton';
9
 import AuthButton from '@/components/AuthButton';
9
 import SelectCity from '../../../components/SelectButton/CitySelect'
10
 import SelectCity from '../../../components/SelectButton/CitySelect'
10
 
11
 
179
 
180
 
180
   // eslint-disable-next-line react-hooks/rules-of-hooks
181
   // eslint-disable-next-line react-hooks/rules-of-hooks
181
   useEffect(() => {
182
   useEffect(() => {
182
-    getList({ pageNum: 1, pageSize: 9 })
183
+    if(localStorage.getItem("pageParams")){
184
+      getList(JSON.parse(localStorage.getItem("pageParams")))
185
+    }else{
186
+      getList({ pageNum: 1, pageSize: 9 })
187
+    } 
183
   }, [])
188
   }, [])
184
 
189
 
185
   function getList(params) {
190
   function getList(params) {
212
 
217
 
213
           values.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00.000')}Z`
218
           values.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00.000')}Z`
214
         }
219
         }
220
+        localStorage.setItem("pageParams",JSON.stringify({ pageNum: 1, pageSize: 9, ...values }));
215
         getList({ pageNum: 1, pageSize: 9, ...values })
221
         getList({ pageNum: 1, pageSize: 9, ...values })
216
       }
222
       }
217
     });
223
     });
225
 
231
 
226
   // 分页
232
   // 分页
227
   function onChange(pageNumber) {
233
   function onChange(pageNumber) {
234
+    localStorage.setItem("pageParams",JSON.stringify({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() }));
228
     // eslint-disable-next-line react-hooks/rules-of-hooks
235
     // eslint-disable-next-line react-hooks/rules-of-hooks
229
     getList({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() })
236
     getList({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() })
230
   }
237
   }
258
    */
265
    */
259
   function handleReset() {
266
   function handleReset() {
260
     props.form.resetFields();
267
     props.form.resetFields();
268
+    localStorage.setItem("pageParams",JSON.stringify({ pageNum: 1, pageSize: 9 }));
261
     getList({ pageNum: 1, pageSize: 9 })
269
     getList({ pageNum: 1, pageSize: 9 })
262
   }
270
   }
263
 
271
 
264
   function onSuccess() {
272
   function onSuccess() {
265
-    getList({ pageNum: 1, pageSize: 9 })
273
+    if(localStorage.getItem("pageParams")){
274
+      getList(JSON.parse(localStorage.getItem("pageParams")))
275
+    }else{
276
+      getList({ pageNum: 1, pageSize: 9 })
277
+    } 
266
   }
278
   }
267
 
279
 
268
 
280
 
348
       </Row>
360
       </Row>
349
       {/* 分页 */}
361
       {/* 分页 */}
350
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
362
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
351
-        <Pagination showQuickJumper defaultCurrent={1} total={dataSource.total} onChange={onChange} pageSize={dataSource.size} />
363
+        <Pagination showQuickJumper current={dataSource.current} total={dataSource.total} onChange={onChange} pageSize={dataSource.size} />
352
       </div>
364
       </div>
365
+      <Prompt message={location =>
366
+                          location.pathname.startsWith("/building/list")
367
+                            ? true
368
+                            : localStorage.removeItem("pageParams")} />
353
     </>
369
     </>
354
   );
370
   );
355
 }
371
 }