Pārlūkot izejas kodu

feat: 排序字段处理

lanjianrong 5 gadi atpakaļ
vecāks
revīzija
ddd86c84a8

+ 2 - 1
.eslintrc.js

@@ -31,6 +31,7 @@ module.exports = {
       {
         allowShortCircuit: true
       }
-    ]
+    ],
+    '@typescript-eslint/no-unused-expressions': 0
   }
 }

+ 14 - 14
src/pages/Customer/Client/index.jsx

@@ -144,12 +144,12 @@ const Client = props => {
   }
 
   const columns = [
-    {
-      title: '关键字',
-      dataIndex: 'search',
-      hideInTable: true,
-      search: false
-    },
+    // {
+    //   title: '关键字',
+    //   dataIndex: 'search',
+    //   hideInTable: true,
+    //   search: false
+    // },
     {
       title: '联系人',
       dataIndex: 'clientName',
@@ -163,7 +163,7 @@ const Client = props => {
           {clientName}
         </span>
       ),
-      sorter: (a, b) => a.clientName.localeCompare(b.clientName),
+      sorter: (a, b) => a.clientName - b.clientName,
       search: false
     },
     {
@@ -177,7 +177,7 @@ const Client = props => {
           {companyName}
         </span>
       ),
-      sorter: (a, b) => a.companyName.localeCompare(b.companyName),
+      sorter: (a, b) => a.companyName - b.companyName,
       search: false
     },
     {
@@ -192,15 +192,15 @@ const Client = props => {
       title: '电话',
       dataIndex: 'phone',
       key: 'phone',
-      width: 65
-      // sorter: (a, b) => a.phone.localeCompare(b.phone)
+      width: 65,
+      sorter: (a, b) => a.phone - b.phone
     },
     {
       title: '手机',
       dataIndex: 'telephone',
       key: 'telephone',
       width: 75,
-      sorter: (a, b) => a.telephone.localeCompare(b.telephone),
+      sorter: (a, b) => a.telephone - b.telephone,
       search: false
     },
     {
@@ -208,7 +208,7 @@ const Client = props => {
       dataIndex: 'qq',
       key: 'qq',
       width: 75,
-      sorter: (a, b) => a.qq.localeCompare(b.qq),
+      sorter: (a, b) => a.qq - b.qq,
       search: false
     },
     {
@@ -216,7 +216,7 @@ const Client = props => {
       dataIndex: 'email',
       key: 'email',
       width: 75,
-      sorter: (a, b) => a.email.localeCompare(b.email),
+      sorter: (a, b) => a.email - b.email,
       search: false
     },
     {
@@ -321,7 +321,7 @@ const Client = props => {
       key: 'address',
       ellipsis: true,
       width: 150,
-      sorter: (a, b) => a.address.localeCompare(b.address),
+      sorter: (a, b) => a.address - b.address,
       search: false
     },
     {

+ 5 - 13
src/pages/Customer/Company/index.jsx

@@ -153,7 +153,7 @@ const Company = props => {
       width: 150,
       fixed: 'left',
       search: false,
-      sorter: (a, b) => a.companyName.localeCompare(b.companyName),
+      sorter: (a, b) => a.companyName - b.companyName,
       render: (companyName, record) => (
         <span
           onClick={() => showDrawer(record.id)}
@@ -174,7 +174,7 @@ const Company = props => {
       dataIndex: 'phone',
       key: 'phone',
       search: false,
-      sorter: (a, b) => a.phone.localeCompare(b.phone),
+      sorter: (a, b) => a.phone - b.phone,
       width: 80
     },
     {
@@ -184,12 +184,6 @@ const Company = props => {
       filters: true,
       search: false,
       valueEnum: tag.personTagMap,
-      // valueType: 'select',
-      // fieldProps: {
-      //   mode: 'multiple',
-      //   options: tag.personOptions,
-      //   showArrow: true
-      // },
       render: (_, record) => (
         <div className="items-center flex-wrap">
           {record.tagIds.map(item => (
@@ -268,7 +262,7 @@ const Company = props => {
       dataIndex: 'address',
       key: 'address',
       search: false,
-      sorter: (a, b) => a.address.localeCompare(b.address),
+      sorter: (a, b) => a.address - b.address,
       width: 150
     },
     {
@@ -460,10 +454,8 @@ const Company = props => {
         params={state.params}
         request={async (params, sort, filter) => {
           const srotOrder = refactorSortField(sort)
-          const {
-            code = -1,
-            data: { customer = [], total = 0 } = { customer: [], total: 0 }
-          } = await queryCompany({ ...params, ...srotOrder, ...filter })
+          const { code = -1, data: { customer = [], total = 0 } = { customer: [], total: 0 } } =
+            await queryCompany({ ...params, ...srotOrder, ...filter })
           setState({ ...state, orderIds: customer.map(item => item.id) })
           return {
             data: customer,

+ 28 - 24
src/pages/workbench/Dashboard/components/RatioPanels.jsx

@@ -4,10 +4,10 @@ import CustomModal from '@/components/Modal/src/components/CustomModal'
 import { queryRatioPanelsList, queryServiceRatioPanelsList } from '@/services/dashboard'
 import consts from '@/consts'
 import { servicelogEnum } from '@/pages/Customer/Company/components/CompanyDetail/LowerList'
-import ClientDetail from '@/pages/Customer/Client/components/ClientDetail'
+// import ClientDetail from '@/pages/Customer/Client/components/ClientDetail'
 import { Badge } from 'antd'
 import { cardTypeMap } from '../consts'
-import { useModal } from '@/components/Modal'
+// import { useModal } from '@/components/Modal'
 
 const dataTypeEunm = {
   0: {
@@ -43,7 +43,7 @@ const renderBadge = (count, active = false) => {
 }
 
 /** 服务环比数据Tab切换表格 */
-const ServiceRatioPanels = ({ cyclical, dataPermission }) => {
+const ServiceRatioPanels = ({ staffIds, cyclical, dataPermission }) => {
   const activeKeyMap = {
     0: { key: 'clientName', title: '联系人' },
     1: { key: 'customerName', title: '客户' },
@@ -81,7 +81,7 @@ const ServiceRatioPanels = ({ cyclical, dataPermission }) => {
   return (
     <ProTable
       size="small"
-      params={{ dataType: state.activeKey, cyclical, dataPermission }}
+      params={{ dataType: state.activeKey, cyclical, dataPermission, staffIds }}
       rowKey={record => record.id}
       scroll={{ y: 400 }}
       border={true}
@@ -141,24 +141,24 @@ const ServiceRatioPanels = ({ cyclical, dataPermission }) => {
   )
 }
 
-const RatioPanels = ({ dataType, retioCyclical, dataPermission }) => {
-  const { toggleDrawer, setDrawerProps } = useModal()
-  const [state, setState] = useState({
-    orderIds: []
-  })
-  const showDrawer = id => {
-    setDrawerProps({
-      zIndex: '1200',
-      closable: true,
-      onClose: () => toggleDrawer(),
-      bodyStyle: {
-        height: '100vh',
-        overflowY: 'hidden'
-      },
-      children: <ClientDetail dataId={id} orderIds={state.orderIds} />
-    })
-    toggleDrawer()
-  }
+const RatioPanels = ({ dataType, staffIds, retioCyclical, dataPermission }) => {
+  // const { toggleDrawer, setDrawerProps } = useModal()
+  // const [state, setState] = useState({
+  //   orderIds: []
+  // })
+  // const showDrawer = id => {
+  //   setDrawerProps({
+  //     zIndex: '1200',
+  //     closable: true,
+  //     onClose: () => toggleDrawer(),
+  //     bodyStyle: {
+  //       height: '100vh',
+  //       overflowY: 'hidden'
+  //     },
+  //     children: <ClientDetail dataId={id} orderIds={state.orderIds} />
+  //   })
+  //   toggleDrawer()
+  // }
   const columnsMap = {
     0: [
       {
@@ -265,7 +265,11 @@ const RatioPanels = ({ dataType, retioCyclical, dataPermission }) => {
     <CustomModal title={`卡片详情(${dataTypeEunm[dataType].title})`}>
       <div className="pb-4">
         {dataType === cardTypeMap.SERVICE ? (
-          <ServiceRatioPanels cyclical={retioCyclical} dataPermission={dataPermission} />
+          <ServiceRatioPanels
+            cyclical={retioCyclical}
+            dataPermission={dataPermission}
+            staffIds={staffIds}
+          />
         ) : (
           <div className="mx-4">
             <ProTable
@@ -275,7 +279,7 @@ const RatioPanels = ({ dataType, retioCyclical, dataPermission }) => {
               rowKey={record => record.id}
               scroll={{ y: 400 }}
               columns={columnsMap[dataType]}
-              params={{ dataType, dataPermission, cyclical: retioCyclical }}
+              params={{ dataType, dataPermission, cyclical: retioCyclical, staffIds }}
               request={async params => {
                 const { code = -1, data } = await queryRatioPanelsList(params)
                 return {

+ 1 - 0
src/pages/workbench/Dashboard/index.jsx

@@ -49,6 +49,7 @@ const Dashboard = () => {
       modalRender: () => (
         <RatioPanels
           dataType={dataType}
+          staffIds={state.params.staffIds}
           retioCyclical={state.params.cyclical}
           dataPermission={state.params.dataPermission}
         />