فهرست منبع

feat: models加入标签的颜色映射关系

lanjianrong 5 سال پیش
والد
کامیت
45cbe8a522
1فایلهای تغییر یافته به همراه15 افزوده شده و 2 حذف شده
  1. 15 2
      src/models/customer.js

+ 15 - 2
src/models/customer.js

@@ -1,4 +1,5 @@
 import consts from '@/consts'
 import consts from '@/consts'
+import { LabelStatusColorMap } from '@/pages/Customer/Company/components/PersonLabel'
 import { queryNatures } from '@/services/contact'
 import { queryNatures } from '@/services/contact'
 import { queryTagList } from '@/services/customer'
 import { queryTagList } from '@/services/customer'
 
 
@@ -7,7 +8,9 @@ export default {
   state: {
   state: {
     natures: [], // 客户性质列表
     natures: [], // 客户性质列表
     personTags: [], // 个人标签
     personTags: [], // 个人标签
-    teamTags: [] // 协作标签
+    personTagColorMap: {}, // 个人标签的颜色映射关系
+    teamTags: [], // 协作标签
+    teamTagColorMap: {} // 协作标签的颜色映射关系
   },
   },
   effects: {
   effects: {
     *fetch({ payload }, { call, put }) {
     *fetch({ payload }, { call, put }) {
@@ -26,6 +29,7 @@ export default {
       const response = yield call(queryTagList, payload)
       const response = yield call(queryTagList, payload)
       if (response?.code === consts.RET_CODE.SUCCESS) {
       if (response?.code === consts.RET_CODE.SUCCESS) {
         const { tagType } = payload
         const { tagType } = payload
+
         yield put({
         yield put({
           type: 'changeState',
           type: 'changeState',
           payload: {
           payload: {
@@ -33,13 +37,22 @@ export default {
             data: response.data
             data: response.data
           }
           }
         })
         })
+        yield put({
+          type: 'changeState',
+          payload: {
+            key: tagType === 0 ? 'personTagColorMap' : 'teamTagColorMap',
+            data: response.data.reduce((curr, prev, idx) => {
+              const item = { ...curr, [prev.id]: LabelStatusColorMap[tagType][idx] }
+              return item
+            }, {})
+          }
+        })
       }
       }
     }
     }
   },
   },
   reducers: {
   reducers: {
     // 通用reducer
     // 通用reducer
     changeState(state, action) {
     changeState(state, action) {
-      console.log('action', action)
       return {
       return {
         ...state,
         ...state,
         [action.payload.key]: action.payload.data
         [action.payload.key]: action.payload.data