|
|
@@ -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('添加成功')
|
|
|
}
|
|
|
|