Kaynağa Gözat

添加客户来源分布

Fan 3 hafta önce
ebeveyn
işleme
38fdcc0222

+ 2 - 1
ui/smarttrade-platform/src/api/marketing/index.js

@@ -21,4 +21,5 @@ export const setMarketingStatus = (data = {}) => post('/router/rest/marketing/st
 export const getTradeCustomer = (data = {}) => post('/router/rest/customerTrade/list', data)
 export const saveGenerateEmail = (data = {}) => post('/router/rest/marketing/campaign/sop-detail/edit', data)
 export const getEmailDetail = (data = {}) => get('/router/rest/marketEmails/getById', data)
-export const editEmail = (data = {}) => post('/router/rest/marketEmails/editContent', data)
+export const editEmail = (data = {}) => post('/router/rest/marketEmails/editContent', data)
+export const getCustomerSource = (data = {}) => get('/router/rest/customerTrade/source-distribution', data)

+ 19 - 15
ui/smarttrade-platform/src/components/addMarketing.vue

@@ -290,12 +290,12 @@
                     <div class="customer-source" v-if="customerList.length != 0">
                         <h5><i class="fas fa-chart-pie"></i> 客户来源分布</h5>
                         <div class="source-bars">
-                            <div class="source-item" v-for="(value, item) in sourceData">
-                                <span class="source-label">{{ item }}</span>
+                            <div class="source-item" v-for="(item) in sourceData">
+                                <span class="source-label">{{ item.sourceLabel }}</span>
                                 <div class="source-bar">
-                                    <div class="source-fill" :style="{ width: (value / customerList.length) * 100 + '%', background: 'var(--success)' }"></div>
+                                    <div class="source-fill" :style="{ width: item.ratio + '%', background: 'var(--success)' }"></div>
                                 </div>
-                                <span class="source-value">{{ (value / customerList.length * 100).toFixed(2) }}%</span>
+                                <span class="source-value">{{ item.ratio }}%</span>
                             </div>
                         </div>
                     </div>
@@ -740,7 +740,7 @@
 
 <script setup>
     import { ref, computed } from 'vue'
-    import { getSopList, getMarketingById, addMarketing, editMarketing, addSop, editSop, getTradeCustomer } from '@/api/marketing'
+    import { getSopList, getMarketingById, addMarketing, editMarketing, addSop, editSop, getTradeCustomer, getCustomerSource } from '@/api/marketing'
     import { getUserEmails } from '@/api/emails'
     import { region } from '@/utils/region';
     import CustomerDetail from '@/components/marketing/customerDetail.vue'
@@ -1165,26 +1165,29 @@
         customerLevelDictValue: ''
     })
     const customerList = ref([])
-    const sourceData = ref({})
+    const sourceData = ref([])
     const getCustomerData = () => {
         getTradeCustomer({ pageIndex: 1, pageSize: 10000, ...customerParams.value }).then(res => {
             customerList.value = res.result.records || []
             newCampaign.value.filters.selectedTags = customerList.value.map(item => item.customerName)
-            sourceData.value = {}
-            customerList.value.map(item => {
-                if(!item.customerSourceName) return
-                if(sourceData.value[item.customerSourceName]){
-                    sourceData.value[item.customerSourceName] += 1
-                }else{
-                    sourceData.value[item.customerSourceName] = 1
-                }
-            })
+            sourceData.value = []
+            getSource()
+        })
+    }
+
+    const getSource = () => {
+        let params = {
+            idList: customerList.value.map(item => item.id).join(',')
+        }
+        getCustomerSource(params).then(res => {
+            sourceData.value = res.result || []
         })
     }
 
     const deleteCustomer = (data) => {
         customerList.value = customerList.value.filter(item => item.id !== data.id)
         ElMessage.success('删除成功')
+        getSource()
     }
 
     const addCustomer = (data, type) => {
@@ -1204,6 +1207,7 @@
             return
         }
         customerList.value.push(data)
+        getSource()
         ElMessage.success('添加成功')
     }
 

+ 1 - 1
ui/smarttrade-platform/src/views/MarketingView.vue

@@ -59,7 +59,7 @@
         <div class="stat-icon-lg warning"><i class="fas fa-exclamation-circle"></i></div>
         <div class="stat-content-lg">
           <h3>{{ statsData?.pendingReview }}</h3>
-          <p>待审核</p>
+          <p>未开始</p>
         </div>
       </div>
     </div>