zhoulisen 5 vuotta sitten
vanhempi
commit
e0135abec6
2 muutettua tiedostoa jossa 28 lisäystä ja 20 poistoa
  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 Näytä tiedosto

@@ -21,9 +21,13 @@ const header = props => {
21 21
   useEffect(() => {
22 22
 
23 23
     if (localStorage.getItem("helpActivePageParams")) {
24
-      props.form.setFieldsValue(JSON.parse(localStorage.getItem("helpActivePageParams")));
24
+      // props.form.setFieldsValue(JSON.parse(localStorage.getItem("helpActivePageParams")));
25 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 31
       getList(JSON.parse(localStorage.getItem("helpActivePageParams")))
28 32
     } else {
29 33
       localStorage.setItem("helpActivePageParams", JSON.stringify({ pageNum: 1, pageSize: 10 }));

+ 23
- 19
src/pages/building/list/index.jsx Näytä tiedosto

@@ -109,8 +109,8 @@ function CartBody(props) {
109 109
     // bodyStyle={{ padding: '10px 20px' }}
110 110
     >
111 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 114
       <div style={{ padding: '10px 20px' }}>
115 115
         <p className={Styles.cardText}>
116 116
           <span className={Styles.title}>楼盘编号</span>
@@ -130,7 +130,7 @@ function CartBody(props) {
130 130
           <span className={Styles.title}>均价</span>
131 131
           <span >
132 132
             :<span style={{ color: '#FF0707', fontSize: '20px' }}> {data.price || '待定'} </span>
133
-        </span>
133
+          </span>
134 134
         </p>
135 135
         <p className={Styles.cardItem}>
136 136
           <span className={Styles.title}>项目地址</span>
@@ -154,7 +154,7 @@ function CartBody(props) {
154 154
           </AuthButton>
155 155
           <AuthButton name="admin.building.delete" noRight={null}>
156 156
             <span style={{
157
-              color: '#FF4A4A', position: 'absolute', right: '0',bottom:'0'
157
+              color: '#FF4A4A', position: 'absolute', right: '0', bottom: '0'
158 158
             }} onClick={() => deleteBuilding(data)}>
159 159
               删除
160 160
                 <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
@@ -177,17 +177,21 @@ function body(props) {
177 177
   const { getFieldDecorator } = props.form
178 178
 
179 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 182
   // eslint-disable-next-line react-hooks/rules-of-hooks
183 183
   useEffect(() => {
184
-    if(localStorage.getItem("pageParams")){
185
-      props.form.setFieldsValue(JSON.parse(localStorage.getItem("pageParams")));
184
+    if (localStorage.getItem("pageParams")) {
185
+
186 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 193
       getList({ pageNum: 1, pageSize: 9 })
190
-    } 
194
+    }
191 195
   }, [])
192 196
 
193 197
   function getList(params) {
@@ -220,7 +224,7 @@ function body(props) {
220 224
 
221 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 228
         getList({ pageNum: 1, pageSize: 9, ...values })
225 229
       }
226 230
     });
@@ -234,7 +238,7 @@ function body(props) {
234 238
 
235 239
   // 分页
236 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 242
     // eslint-disable-next-line react-hooks/rules-of-hooks
239 243
     getList({ pageNum: pageNumber, pageSize: 9, ...props.form.getFieldsValue() })
240 244
   }
@@ -268,16 +272,16 @@ function body(props) {
268 272
    */
269 273
   function handleReset() {
270 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 276
     getList({ pageNum: 1, pageSize: 9 })
273 277
   }
274 278
 
275 279
   function onSuccess() {
276
-    if(localStorage.getItem("pageParams")){
280
+    if (localStorage.getItem("pageParams")) {
277 281
       getList(JSON.parse(localStorage.getItem("pageParams")))
278
-    }else{
282
+    } else {
279 283
       getList({ pageNum: 1, pageSize: 9 })
280
-    } 
284
+    }
281 285
   }
282 286
 
283 287
 
@@ -366,9 +370,9 @@ function body(props) {
366 370
         <Pagination showQuickJumper current={dataSource.current} total={dataSource.total} onChange={onChange} pageSize={dataSource.size} />
367 371
       </div>
368 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
 }