Bläddra i källkod

feat: 客户增加来源功能

lanjianrong 4 år sedan
förälder
incheckning
f47b2e985b

+ 16 - 6
src/components/EditableForm/src/useOptions.js

@@ -25,7 +25,8 @@ const typeEnum = {
   GENDER: 'gender',
   DEPARTMENTID: 'departmentId',
   MARRIAGE: 'marriage',
-  PRIORITY: 'priority'
+  PRIORITY: 'priority',
+  CLIENT_SOURCE: 'sourceId'
 }
 
 export default function useOptions(type) {
@@ -34,19 +35,26 @@ export default function useOptions(type) {
 
   useEffect(() => {
     if (type === typeEnum.NATUREIDS) {
-      if (!store.getState().company.natures.length) {
+      if (!store.getState()?.company.natures?.length) {
         dispatch({
           type: 'company/fetchNatures'
         })
       }
     }
     if (type === typeEnum.DEPARTMENTID) {
-      if (!store.getState().staff.departments.length) {
+      if (!store.getState()?.staff.departments?.length) {
         dispatch({
           type: 'staff/fetchDepartments'
         })
       }
     }
+    if (type === typeEnum.CLIENT_SOURCE) {
+      if (!store.getState()?.client.sourceList?.length) {
+        dispatch({
+          type: 'client/fetchSourceList'
+        })
+      }
+    }
   }, [type])
   let options = null
   switch (type) {
@@ -54,10 +62,10 @@ export default function useOptions(type) {
       options = genderOptions
       break
     case typeEnum.NATUREIDS:
-      options = store.getState().company.natures
+      options = store.getState()?.company.natures
       break
     case typeEnum.DEPARTMENTID:
-      options = store.getState().staff.departments
+      options = store.getState()?.staff.departments
       break
     case typeEnum.MARRIAGE:
       options = marriageOptions
@@ -65,7 +73,9 @@ export default function useOptions(type) {
     case typeEnum.PRIORITY:
       options = priorityOptions
       break
-
+    case typeEnum.CLIENT_SOURCE:
+      options = store.getState()?.client.sourceList
+      break
     default:
       break
   }

+ 6 - 0
src/pages/Customer/Client/components/ClientDetail/Form.jsx

@@ -167,6 +167,12 @@ const ContanctForm = props => {
         label: '优先级',
         span: 24,
         editCellType: 'select'
+      },
+      {
+        dataIndex: 'sourceId',
+        label: '来源',
+        span: 24,
+        editCellType: 'select'
       }
     ]
     if (!filterTag) {

+ 20 - 7
src/pages/Customer/Client/model.js

@@ -1,6 +1,6 @@
 import consts from '@/consts'
 import { LabelStatusColorMap } from '@/pages/Customer/Company/components/PersonLabel/const'
-import { queryTagList } from '@/services/customer'
+import { queryClientSourceList, queryTagList } from '@/services/customer'
 
 export default {
   namespace: 'client',
@@ -8,7 +8,8 @@ export default {
     personTags: [], // 个人标签
     personTagColorMap: {}, // 个人标签的颜色映射关系
     teamTags: [], // 协作标签
-    teamTagColorMap: {} // 协作标签的颜色映射关系
+    teamTagColorMap: {}, // 协作标签的颜色映射关系
+    sourceList: [] // 来源列表
   },
   // 用于处理异步操作和业务逻辑,由action触发,但不能修改state
   effects: {
@@ -20,14 +21,14 @@ export default {
           type: 'changeState',
           payload: {
             key: 'personTags',
-            data: response.data || []
+            value: response.data || []
           }
         })
         yield put({
           type: 'changeState',
           payload: {
             key: 'personTagColorMap',
-            data:
+            value:
               response.data?.reduce((curr, prev, idx) => {
                 const item = { ...curr, [prev.id]: LabelStatusColorMap[tagType][idx] }
                 return item
@@ -44,14 +45,14 @@ export default {
           type: 'changeState',
           payload: {
             key: 'teamTags',
-            data: response.data || []
+            value: response.data || []
           }
         })
         yield put({
           type: 'changeState',
           payload: {
             key: 'teamTagColorMap',
-            data:
+            value:
               response.data?.reduce((curr, prev, idx) => {
                 const item = { ...curr, [prev.id]: LabelStatusColorMap[tagType][idx] }
                 return item
@@ -59,6 +60,18 @@ export default {
           }
         })
       }
+    },
+    *fetchSourceList(_, { call, put }) {
+      const response = yield call(queryClientSourceList)
+      if (response?.code === consts.RET_CODE.SUCCESS) {
+        yield put({
+          type: 'changeState',
+          payload: {
+            key: 'sourceList',
+            value: response.data.map(item => ({ value: item.id, label: item.name }))
+          }
+        })
+      }
     }
   },
   // reducers:用于处理同步操作,由action触发,可修改state
@@ -67,7 +80,7 @@ export default {
     changeState(state, action) {
       return {
         ...state,
-        [action.payload.key]: action.payload.data
+        [action.payload.key]: action.payload.value
       }
     }
   }

+ 5 - 0
src/services/customer.js

@@ -230,3 +230,8 @@ export async function syncToClient(params) {
     data: params
   })
 }
+
+/** 获取客户来源列表 */
+export async function queryClientSourceList() {
+  return request('/client/source')
+}