Sfoglia il codice sorgente

feat:仪表盘弹窗

outaozhen 5 anni fa
parent
commit
c6526c55c9

+ 9 - 15
src/pages/workbench/Dashboard/components/ReminderList/index.jsx

@@ -1,8 +1,7 @@
 import React, { useState, useEffect } from 'react'
 import { Button } from 'antd'
 import consts from '@/consts'
-import { useDispatch } from 'dva'
-import { connect } from 'dva'
+import { useDispatch, useRequest, connect } from 'umi'
 import ProTable from '@ant-design/pro-table'
 import { queryReminderList } from '@/services/dashboard'
 import { CloseOutlined } from '@ant-design/icons'
@@ -10,25 +9,20 @@ import styles from './index.less'
 
 const ReminderList = props => {
   const dispatch = useDispatch()
-  const { visible, dataId = '', dataType, reminderCyclical } = props
+  const { dataType, reminderCyclical } = props
   const [state, setState] = useState({
     loading: false,
     client: []
   })
-  const initData = async id => {
-    setState({ ...state, loading: true })
-    const {
-      data: { client = [] },
-      code = -1
-    } = await queryReminderList(id)
-    if (code === consts.RET_CODE.SUCCESS) {
-      setState({ ...state, client, loading: false })
+  const { run: tryGetList } = useRequest(params => queryReminderList(params), {
+    manual: true,
+    onSuccess: result => {
+      setState({ ...state, loading: false, client: result })
     }
-  }
-  console.log(state.client)
+  })
   useEffect(() => {
-    visible && initData(dataId, dataType, reminderCyclical)
-  }, [visible])
+    tryGetList({ dataType, reminderCyclical, current: 1, pageSize: consts.MAX_PAGE_SIZE })
+  }, [])
 
   const closeModal = () => {
     dispatch({

+ 7 - 22
src/pages/workbench/Dashboard/index.jsx

@@ -11,17 +11,9 @@ import ReminderList from './components/ReminderList'
 const Dashboard = () => {
   const { Option } = Select
   const dataTypeNum = {
-    0: '联系人',
-    1: '客户',
-    2: '商机'
-  }
-  const reminderDayNum = {
-    3: '7day',
-    4: '15day',
-    5: '30day',
-    6: '3month',
-    7: '6month',
-    8: 'reminder'
+    联系人: 0,
+    客户: 1,
+    商机: 2
   }
   const [state, setState] = useState({
     visible: false,
@@ -37,17 +29,10 @@ const Dashboard = () => {
   })
   const { toggleModal, setModalProps } = useModal()
   // 展示服务弹窗详情
-  const handleReminderList = id => {
+  const handleReminderList = () => {
     setModalProps({
       width: '90vw',
-      modalRender: node => (
-        <ReminderList
-          dataId={id}
-          node={node}
-          dataType={dataTypeNum[dataTypeNum]}
-          reminderCyclical={reminderDayNum[reminderDayNum]}
-        />
-      ),
+      modalRender: node => <ReminderList node={node} dataType={0} reminderCyclical={'7day'} />,
       onCancel: () => toggleModal()
     })
     toggleModal()
@@ -96,7 +81,7 @@ const Dashboard = () => {
       render: (name, record) => (
         // console.log(record)
         <span
-          onClick={() => handleReminderList(record.day7)}
+          onClick={() => handleReminderList(dataTypeNum[record.name], 'day7')}
           className="text-primary cursor-pointer hover:text-[#967bbd]">
           {name}
         </span>
@@ -107,7 +92,7 @@ const Dashboard = () => {
       dataIndex: 'day15',
       render: (name, record) => (
         <span
-          onClick={() => handleReminderList(record.day15)}
+          onClick={() => handleReminderList(dataTypeNum[record.name], 'day15')}
           className="text-primary cursor-pointer hover:text-[#967bbd]">
           {name}
         </span>