zhoulisen 5 年 前
コミット
e0135abec6
共有2 個のファイルを変更した28 個の追加20 個の削除を含む
  1. 5
    1
      src/pages/activity/helpActivity/list.jsx
  2. 23
    19
      src/pages/building/list/index.jsx

+ 5
- 1
src/pages/activity/helpActivity/list.jsx ファイルの表示

21
   useEffect(() => {
21
   useEffect(() => {
22
 
22
 
23
     if (localStorage.getItem("helpActivePageParams")) {
23
     if (localStorage.getItem("helpActivePageParams")) {
24
-      props.form.setFieldsValue(JSON.parse(localStorage.getItem("helpActivePageParams")));
24
+      // props.form.setFieldsValue(JSON.parse(localStorage.getItem("helpActivePageParams")));
25
       // const { getFieldDecorator } = JSON.parse(localStorage.getItem("pageParams"))
25
       // const { getFieldDecorator } = JSON.parse(localStorage.getItem("pageParams"))
26
+      const localStorageValue = JSON.parse(localStorage.getItem("helpActivePageParams"))
27
+      localStorageValue.startTime = localStorageValue.startTime ? moment(localStorageValue.startTime) : ''
28
+      localStorageValue.endTime = localStorageValue.endTime ? moment(localStorageValue.endTime) : ''
26
 
29
 
30
+      props.form.setFieldsValue(localStorageValue);
27
       getList(JSON.parse(localStorage.getItem("helpActivePageParams")))
31
       getList(JSON.parse(localStorage.getItem("helpActivePageParams")))
28
     } else {
32
     } else {
29
       localStorage.setItem("helpActivePageParams", JSON.stringify({ pageNum: 1, pageSize: 10 }));
33
       localStorage.setItem("helpActivePageParams", JSON.stringify({ pageNum: 1, pageSize: 10 }));

+ 23
- 19
src/pages/building/list/index.jsx ファイルの表示

109
     // bodyStyle={{ padding: '10px 20px' }}
109
     // bodyStyle={{ padding: '10px 20px' }}
110
     >
110
     >
111
       {/* 因为 background 方式设置图片背景,如果 图片url 存在空格或者其他特殊字符,导致显示不出来,需要进行 encodeURI(xxx) 转码 */}
111
       {/* 因为 background 方式设置图片背景,如果 图片url 存在空格或者其他特殊字符,导致显示不出来,需要进行 encodeURI(xxx) 转码 */}
112
-        <span className={Styles.recommderTag}>{data.isMain === 1 ? '首页推荐':''}</span>
113
-        <img className={Styles.cover} style={{ backgroundImage: `url('${encodeURI(((data.buildingListImg && data.buildingListImg[0]) || {}).url)}')` }}   ></img>
112
+      <span className={Styles.recommderTag}>{data.isMain === 1 ? '首页推荐' : ''}</span>
113
+      <img className={Styles.cover} style={{ backgroundImage: `url('${encodeURI(((data.buildingListImg && data.buildingListImg[0]) || {}).url)}')` }}   ></img>
114
       <div style={{ padding: '10px 20px' }}>
114
       <div style={{ padding: '10px 20px' }}>
115
         <p className={Styles.cardText}>
115
         <p className={Styles.cardText}>
116
           <span className={Styles.title}>楼盘编号</span>
116
           <span className={Styles.title}>楼盘编号</span>
130
           <span className={Styles.title}>均价</span>
130
           <span className={Styles.title}>均价</span>
131
           <span >
131
           <span >
132
             :<span style={{ color: '#FF0707', fontSize: '20px' }}> {data.price || '待定'} </span>
132
             :<span style={{ color: '#FF0707', fontSize: '20px' }}> {data.price || '待定'} </span>
133
-        </span>
133
+          </span>
134
         </p>
134
         </p>
135
         <p className={Styles.cardItem}>
135
         <p className={Styles.cardItem}>
136
           <span className={Styles.title}>项目地址</span>
136
           <span className={Styles.title}>项目地址</span>
154
           </AuthButton>
154
           </AuthButton>
155
           <AuthButton name="admin.building.delete" noRight={null}>
155
           <AuthButton name="admin.building.delete" noRight={null}>
156
             <span style={{
156
             <span style={{
157
-              color: '#FF4A4A', position: 'absolute', right: '0',bottom:'0'
157
+              color: '#FF4A4A', position: 'absolute', right: '0', bottom: '0'
158
             }} onClick={() => deleteBuilding(data)}>
158
             }} onClick={() => deleteBuilding(data)}>
159
               删除
159
               删除
160
                 <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
160
                 <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
177
   const { getFieldDecorator } = props.form
177
   const { getFieldDecorator } = props.form
178
 
178
 
179
   // eslint-disable-next-line react-hooks/rules-of-hooks
179
   // eslint-disable-next-line react-hooks/rules-of-hooks
180
-  const [dataSource, setDataSource] = useState({ records: [],size: 0 })
180
+  const [dataSource, setDataSource] = useState({ records: [], size: 0 })
181
 
181
 
182
   // eslint-disable-next-line react-hooks/rules-of-hooks
182
   // eslint-disable-next-line react-hooks/rules-of-hooks
183
   useEffect(() => {
183
   useEffect(() => {
184
-    if(localStorage.getItem("pageParams")){
185
-      props.form.setFieldsValue(JSON.parse(localStorage.getItem("pageParams")));
184
+    if (localStorage.getItem("pageParams")) {
185
+
186
       // const { getFieldDecorator } = JSON.parse(localStorage.getItem("pageParams"))
186
       // const { getFieldDecorator } = JSON.parse(localStorage.getItem("pageParams"))
187
-      getList(JSON.parse(localStorage.getItem("pageParams")))
188
-    }else{
187
+      const localStorageValue = JSON.parse(localStorage.getItem("pageParams"))
188
+      localStorageValue.startDate = localStorageValue.startDate ? moment(localStorageValue.startDate) : ''
189
+      props.form.setFieldsValue(localStorageValue);
190
+
191
+      getList({ pageNum: 1, pageSize: 9, ...JSON.parse(localStorage.getItem("pageParams")) })
192
+    } else {
189
       getList({ pageNum: 1, pageSize: 9 })
193
       getList({ pageNum: 1, pageSize: 9 })
190
-    } 
194
+    }
191
   }, [])
195
   }, [])
192
 
196
 
193
   function getList(params) {
197
   function getList(params) {
220
 
224
 
221
           values.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00.000')}Z`
225
           values.startDate = `${moment(startDate).format('YYYY-MM-DDT00:00:00.000')}Z`
222
         }
226
         }
223
-        localStorage.setItem("pageParams",JSON.stringify({ pageNum: 1, pageSize: 9, ...values }));
227
+        localStorage.setItem("pageParams", JSON.stringify({ pageNum: 1, pageSize: 9, ...values }));
224
         getList({ pageNum: 1, pageSize: 9, ...values })
228
         getList({ pageNum: 1, pageSize: 9, ...values })
225
       }
229
       }
226
     });
230
     });
234
 
238
 
235
   // 分页
239
   // 分页
236
   function onChange(pageNumber) {
240
   function onChange(pageNumber) {
237
-    localStorage.setItem("pageParams",JSON.stringify({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() }));
241
+    localStorage.setItem("pageParams", JSON.stringify({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() }));
238
     // eslint-disable-next-line react-hooks/rules-of-hooks
242
     // eslint-disable-next-line react-hooks/rules-of-hooks
239
     getList({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() })
243
     getList({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() })
240
   }
244
   }
268
    */
272
    */
269
   function handleReset() {
273
   function handleReset() {
270
     props.form.resetFields();
274
     props.form.resetFields();
271
-    localStorage.setItem("pageParams",JSON.stringify({ pageNum: 1, pageSize: 9 }));
275
+    localStorage.setItem("pageParams", JSON.stringify({ pageNum: 1, pageSize: 9 }));
272
     getList({ pageNum: 1, pageSize: 9 })
276
     getList({ pageNum: 1, pageSize: 9 })
273
   }
277
   }
274
 
278
 
275
   function onSuccess() {
279
   function onSuccess() {
276
-    if(localStorage.getItem("pageParams")){
280
+    if (localStorage.getItem("pageParams")) {
277
       getList(JSON.parse(localStorage.getItem("pageParams")))
281
       getList(JSON.parse(localStorage.getItem("pageParams")))
278
-    }else{
282
+    } else {
279
       getList({ pageNum: 1, pageSize: 9 })
283
       getList({ pageNum: 1, pageSize: 9 })
280
-    } 
284
+    }
281
   }
285
   }
282
 
286
 
283
 
287
 
366
         <Pagination showQuickJumper current={dataSource.current} total={dataSource.total} onChange={onChange} pageSize={dataSource.size} />
370
         <Pagination showQuickJumper current={dataSource.current} total={dataSource.total} onChange={onChange} pageSize={dataSource.size} />
367
       </div>
371
       </div>
368
       <Prompt message={location =>
372
       <Prompt message={location =>
369
-                          location.pathname.startsWith("/building/list")
370
-                            ? true
371
-                            : localStorage.removeItem("pageParams")} />
373
+        location.pathname.startsWith("/building/list")
374
+          ? true
375
+          : localStorage.removeItem("pageParams")} />
372
     </>
376
     </>
373
   );
377
   );
374
 }
378
 }