lanjianrong 4 lat temu
rodzic
commit
47070aecdf
1 zmienionych plików z 50 dodań i 29 usunięć
  1. 50 29
      src/pages/Workbench/Dashboard/index.jsx

+ 50 - 29
src/pages/Workbench/Dashboard/index.jsx

@@ -91,8 +91,12 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       setState({ ...state, staffList: list })
     }
   }
-  const queryStaffClick = id => {
-    setState({ ...state, params: { ...state.params, dataPermission: 'custom', staffIds: [id] } })
+  const handleStaffClick = id => {
+    setState({
+      ...state,
+      immediate: true,
+      params: { ...state.params, staffIds: [id] }
+    })
   }
   const initData = async payload => {
     if (timer.current) clearTimeout(timer.current)
@@ -151,7 +155,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
 
   useEffect(() => {
     initData(state.params)
-    if (state.params.dataPermission === 'all') {
+    if (!departments?.length && state.params.dataPermission === 'all') {
       dispatch({
         type: 'staff/fetchDepartments'
       })
@@ -173,7 +177,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '7day')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {name}
         </span>
       )
@@ -184,7 +189,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '15day')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {name}
         </span>
       )
@@ -195,7 +201,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '30day')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {name}
         </span>
       )
@@ -206,7 +213,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '3month')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {name}
         </span>
       )
@@ -217,7 +225,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, '6month')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {name}
         </span>
       )
@@ -228,7 +237,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       render: (name, record) => (
         <span
           onClick={() => handleReminderList(record.type, 'reminder')}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {name}
         </span>
       )
@@ -244,6 +254,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
       setState({
         ...state,
         immediate: true,
+        staffList: [],
         params: { ...state.params, staffIds, dataPermission: 'custom' }
       })
       return
@@ -251,6 +262,7 @@ const Dashboard = ({ dispatch, departments = [] }) => {
     setState({
       ...state,
       immediate: true,
+      staffList: [],
       params: { ...state.params, staffIds: null, dataPermission }
     })
   }
@@ -310,19 +322,20 @@ const Dashboard = ({ dispatch, departments = [] }) => {
             />
           </span>
         ) : null}
-        {state.staffList.map(item => (
-          <div className="ml-4" key={item.id} onClick={queryStaffClick}>
-            <div className="relative w-30px h-30px rounded-1/2">
-              <img
-                src={
-                  (isDevMode() ? 'http://cld2qa.com' : 'http://zhcld.com') +
-                  (item?.avatar ? item.avatar : '/global/img/avtra_2.jpg')
-                }
-              />
-              <span className={styles.avtraName}>{item.username}</span>
+        {state.params.dataPermission === 'all' &&
+          state.staffList.map(item => (
+            <div className="ml-4" key={item.id} onClick={() => handleStaffClick(item.id)}>
+              <div className="relative w-30px h-30px rounded-1/2">
+                <img
+                  src={
+                    (isDevMode() ? 'http://cld2qa.com' : 'http://zhcld.com') +
+                    (item?.avatar ? item.avatar : '/global/img/avtra_2.jpg')
+                  }
+                />
+                <span className={styles.avtraName}>{item.username}</span>
+              </div>
             </div>
-          </div>
-        ))}
+          ))}
       </div>
       <div className="mt-4">
         <Row gutter={[8, 8]}>
@@ -346,7 +359,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
                           state.clientChainRatio.percentage.startsWith('-')
                             ? 'text-green-500'
                             : 'text-red-500'
-                        ].join(' ')}>
+                        ].join(' ')}
+                      >
                         {state.clientChainRatio.percentage}
                       </span>
                     </div>
@@ -368,7 +382,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
               ) : (
                 <Row
                   className="cursor-pointer"
-                  onClick={() => handleRatioCard(cardTypeMap.COMPANY)}>
+                  onClick={() => handleRatioCard(cardTypeMap.COMPANY)}
+                >
                   <Col span={6}>
                     <div className="w-full max-w-48px h-48px border rounded-48px bg-[#0c7cd5] flex items-center justify-center">
                       <City size="26" fill="#fff" />
@@ -383,7 +398,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
                           state.customerChainRatio.percentage.startsWith('-')
                             ? 'text-green-500'
                             : 'text-red-500'
-                        ].join(' ')}>
+                        ].join(' ')}
+                      >
                         {state.customerChainRatio.percentage}
                       </span>
                     </div>
@@ -406,7 +422,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
               ) : (
                 <Row
                   className="cursor-pointer"
-                  onClick={() => handleRatioCard(cardTypeMap.BUSINESS)}>
+                  onClick={() => handleRatioCard(cardTypeMap.BUSINESS)}
+                >
                   <Col span={6}>
                     <div className="w-full max-w-48px h-48px border rounded-48px bg-[#0c7cd5] flex items-center justify-center">
                       <Finance size="26" fill="#fff" />
@@ -421,7 +438,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
                           state.businessChainRatio.percentage.startsWith('-')
                             ? 'text-green-500'
                             : 'text-red-500'
-                        ].join(' ')}>
+                        ].join(' ')}
+                      >
                         {state.businessChainRatio.percentage}
                       </span>
                     </div>
@@ -444,7 +462,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
               ) : (
                 <Row
                   onClick={() => handleRatioCard(cardTypeMap.SERVICE)}
-                  className="cursor-pointer">
+                  className="cursor-pointer"
+                >
                   <Col span={6}>
                     <div className="w-full max-w-48px h-48px border rounded-48px bg-[#0c7cd5] flex items-center justify-center">
                       <Comment size="26" fill="#fff" />
@@ -459,7 +478,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
                           state.serviceLogChainRatio.percentage.startsWith('-')
                             ? 'text-green-500'
                             : 'text-red-500'
-                        ].join(' ')}>
+                        ].join(' ')}
+                      >
                         {state.serviceLogChainRatio.percentage}
                       </span>
                     </div>
@@ -493,7 +513,8 @@ const Dashboard = ({ dispatch, departments = [] }) => {
               title="数据汇总"
               className="shadow-card"
               bodyStyle={{ padding: state.loading ? '24px' : 0 }}
-              loading={state.loading}>
+              loading={state.loading}
+            >
               <ul>
                 <li className="px-12px py-16px border-b-1">
                   新增客户<b className="px-1">{state.aggregation.clientCount}</b>个,服务