瀏覽代碼

feat: 客户来源设置

outaozhen 3 年之前
父節點
當前提交
a9d04ff387
共有 3 個文件被更改,包括 89 次插入21 次删除
  1. 79 21
      src/pages/Business/Contact/index.tsx
  2. 5 0
      src/services/user/api.ts
  3. 5 0
      src/services/user/typings.d.ts

+ 79 - 21
src/pages/Business/Contact/index.tsx

@@ -11,7 +11,8 @@ import {
   changeBusinessGroupStatus,
   delBusinessGroupById,
   getBusinessgroupList,
-  updateBusinessGroup
+  updateBusinessGroup,
+  getClientSourceList
 } from '@/services/user/api'
 import type { ColumnsType } from 'antd/lib/table'
 import { Delete } from '@icon-park/react'
@@ -56,21 +57,23 @@ const defaultData = [
 
 const Contact: React.FC = () => {
   const { department, fetchDepartment } = useModel('department')
-  useEffect(() => {
-    if (!department.length) {
-      fetchDepartment()
-    }
-  }, [])
   const formRef = useRef<FormInstance>(null)
 
   const [editableKeys, setEditableRowKeys] = useState<React.Key[]>()
 
   const [state, setState] = useState({
     id: '',
+    menuId: 1,
     dataSource: [],
+    clientSourceList: [],
     visible: false,
     type: modalType.CREATE
   })
+  console.log(state.clientSourceList)
+
+  const onSelect = (menuId: string) => {
+    setState({ ...state, menuId })
+  }
 
   const columns: ProFormColumnsType<StageSettingsType>[] = [
     {
@@ -168,6 +171,21 @@ const Contact: React.FC = () => {
     }
   })
 
+  const { run: tryGetClientSourceList } = useRequest(getClientSourceList, {
+    manual: true,
+    onSuccess: result => {
+      setState({ ...state, clientSourceList: result })
+    }
+  })
+
+  useEffect(() => {
+    if (!department.length) {
+      fetchDepartment()
+    }
+    if (state.id) {
+      tryGetClientSourceList(state.id)
+    }
+  }, [state.id])
   const mainColumns: ColumnsType<API.BusinessgroupItem> = [
     {
       dataIndex: 'name',
@@ -237,25 +255,65 @@ const Contact: React.FC = () => {
       )
     }
   ]
+  const clientSource: ColumnsType<API.ClientSourceList> = [
+    {
+      dataIndex: 'name',
+      title: '来源名称'
+    },
+    {
+      dataIndex: 'opreate',
+      title: '操作'
+    }
+  ]
   return (
     <div className="h-full w-full flex flex-row">
-      <ShowTitleMenu options={[{ label: '商机状态组', value: 1 }]} defaultValue={1} />
+      <ShowTitleMenu
+        onSelect={onSelect}
+        options={[
+          { label: '商机状态组', value: 1 },
+          { label: '来源设置', value: 2 }
+        ]}
+        defaultValue={1}
+      />
       <div className="w-max-3/4">
         <div className="ml-8 bg-white p-4 shadow-md shadow-hex-3e2c5a relative">
-          <div className="pb-3 border-b border-b-black border-opacity-8 mb-3 flex items-center justify-between">
-            <div>商机状态组</div>
-            <Button
-              type="primary"
-              onClick={() => setState({ ...state, visible: true, type: modalType.CREATE })}>
-              添加新组
-            </Button>
-          </div>
-          <Table
-            columns={mainColumns}
-            dataSource={state.dataSource}
-            bordered
-            rowKey={row => row.id}
-          />
+          {state.menuId === 1 ? (
+            <>
+              <div className="pb-3 border-b border-b-black border-opacity-8 mb-3 flex items-center justify-between">
+                <div>商机状态组</div>
+                <Button
+                  type="primary"
+                  onClick={() => setState({ ...state, visible: true, type: modalType.CREATE })}>
+                  添加新组
+                </Button>
+              </div>
+              <Table
+                columns={mainColumns}
+                dataSource={state.dataSource}
+                bordered
+                rowKey={row => row.id}
+              />
+            </>
+          ) : null}
+          {state.menuId === 2 ? (
+            <>
+              <div className="pb-3 border-b border-b-black border-opacity-8 mb-3 flex items-center justify-between">
+                <div>来源设置</div>
+                <Button
+                  type="primary"
+                  onClick={() => setState({ ...state, visible: true, type: modalType.CREATE })}>
+                  添加来源
+                </Button>
+              </div>
+              <Table
+                columns={clientSource}
+                dataSource={state.clientSourceList}
+                bordered
+                rowKey={row => row.id}
+                params={{ msgType: 'notification' }}
+              />
+            </>
+          ) : null}
         </div>
       </div>
       <ModalForm

+ 5 - 0
src/services/user/api.ts

@@ -187,3 +187,8 @@ export async function sendNotice(params: Api.SendNoticeParams) {
     data: params
   })
 }
+
+/** 获得商来源列表 */
+export async function getClientSourceList() {
+  return request<API.ClientSourceList[]>('/ClientSource/list')
+}

+ 5 - 0
src/services/user/typings.d.ts

@@ -276,4 +276,9 @@ declare namespace API {
     content: string
     msgType: 1 | 2
   }
+
+  type ClientSourceList = {
+    id: string
+    name: string
+  }
 }