outaozhen 5 лет назад
Родитель
Сommit
4918ce9d60
1 измененных файлов с 39 добавлено и 21 удалено
  1. 39 21
      src/pages/workbench/Dashboard/components/ReminderList/index.jsx

+ 39 - 21
src/pages/workbench/Dashboard/components/ReminderList/index.jsx

@@ -11,6 +11,9 @@ const ReminderList = props => {
   const dispatch = useDispatch()
   const { dataType, reminderCyclical } = props
   const [state, setState] = useState({
+    client: [],
+    customer: [],
+    business: [],
     params: { dataType, reminderCyclical }
   })
   const clientColumns = [
@@ -89,16 +92,24 @@ const ReminderList = props => {
       columns: businessColumns
     }
   }
-  // const [dataSource, setDataSource] = useState(null)
-  // const { run: tryGetList } = useRequest(params => queryReminderList(params), {
-  //   manual: true,
-  //   onSuccess: result => {
-  //     setDataSource(result[dataMap[dataType].key])
-  //   }
-  // })
-  // useEffect(() => {
-  //   initData({ dataType, reminderCyclical })
-  // }, [])
+
+  const initData = async params => {
+    const {
+      data: { client = [], customer = [], business = [], total = 0 } = {
+        client: [],
+        customer: [],
+        business: [],
+        total
+      },
+      code = -1
+    } = await queryReminderList(params)
+    if (code === consts.RET_CODE.SUCCESS) {
+      setState({ ...state, client, customer, business, total })
+    }
+  }
+  useEffect(() => {
+    initData()
+  }, [])
 
   const closeModal = () => {
     dispatch({
@@ -118,18 +129,25 @@ const ReminderList = props => {
           size="small"
           rowKey={record => record.id}
           columns={dataMap[dataType].columns}
-          // dataSource={dataSource}
+          dataSource={state.client}
           params={state.params}
-          request={async params => {
-            const { code = -1, data: { client = [], total = 0 } = { client: [], total: 0 } } =
-              await queryReminderList({ ...params })
-            setState({ ...state, client })
-            return {
-              data: client,
-              success: code === consts.RET_CODE.SUCCESS,
-              total
-            }
-          }}
+          // request={async params => {
+          //   const {
+          //     code = -1,
+          //     data: { client = [], customer = [], business = [], total = 0 } = {
+          //       client: [],
+          //       customer: [],
+          //       business: [],
+          //       total: 0
+          //     }
+          //   } = await queryReminderList({ ...params })
+          //   setState({ ...state, client, customer, business })
+          //   return {
+          //     data: customer,
+          //     success: code === consts.RET_CODE.SUCCESS,
+          //     total
+          //   }
+          // }}
           search={false}
           toolBarRender={false}
         />