shaogen1995 11 maanden geleden
bovenliggende
commit
cefc7367fa
1 gewijzigde bestanden met toevoegingen van 14 en 5 verwijderingen
  1. 14 5
      src/store/action/A2exhibition.ts

+ 14 - 5
src/store/action/A2exhibition.ts

@@ -9,12 +9,21 @@ export const A2_APIgetList = (data: any): any => {
   return async (dispatch: AppDispatch) => {
     const res = await http.post('cms/exhibition/pageList', data)
     if (res.code === 0) {
+      const arr: any = []
+
+      res.data.records.forEach((v: any) => {
+        let activityTime = ''
+
+        if (v.type !== 'long') {
+          if (v.dateStart) activityTime += v.dateStart
+          if (v.dateEnd) activityTime += ` 至 ${v.dateEnd}`
+        }
+        v.activityTime = activityTime
+        arr.push(v)
+      })
+
       const obj = {
-        list: res.data.records.map((v: any) => ({
-          ...v,
-          activityTime:
-            v.type === 'long' ? '' : v.dateStart + ' 至 ' + (v.dateEnd ? v.dateEnd : '长期有效')
-        })),
+        list: arr,
         total: res.data.total
       }
       dispatch({ type: 'A2/getList', payload: obj })