From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/views/crm/statistics/customer/components/CustomerDealCycleByProduct.vue | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 153 insertions(+), 0 deletions(-)
diff --git a/src/views/crm/statistics/customer/components/CustomerDealCycleByProduct.vue b/src/views/crm/statistics/customer/components/CustomerDealCycleByProduct.vue
new file mode 100644
index 0000000..74558d1
--- /dev/null
+++ b/src/views/crm/statistics/customer/components/CustomerDealCycleByProduct.vue
@@ -0,0 +1,153 @@
+<!-- 鎴愪氦鍛ㄦ湡鍒嗘瀽 -->
+<template>
+ <!-- Echarts鍥� -->
+ <el-card shadow="never">
+ <el-skeleton :loading="loading" animated>
+ <Echart :height="500" :options="echartsOption" />
+ </el-skeleton>
+ </el-card>
+
+ <!-- 缁熻鍒楄〃 -->
+ <el-card shadow="never" class="mt-16px">
+ <el-table v-loading="loading" :data="list">
+ <el-table-column label="搴忓彿" align="center" type="index" width="80" />
+ <el-table-column label="浜у搧鍚嶇О" align="center" prop="productName" min-width="200" />
+ <el-table-column
+ label="鎴愪氦鍛ㄦ湡(澶�)"
+ align="center"
+ prop="customerDealCycle"
+ min-width="200"
+ />
+ <el-table-column label="鎴愪氦瀹㈡埛鏁�" align="center" prop="customerDealCount" min-width="200" />
+ </el-table>
+ </el-card>
+</template>
+<script setup lang="ts">
+import {
+ StatisticsCustomerApi,
+ CrmStatisticsCustomerDealCycleByProductRespVO
+} from '@/api/crm/statistics/customer'
+import { EChartsOption } from 'echarts'
+
+defineOptions({ name: 'CustomerDealCycleByProduct' })
+
+const props = defineProps<{ queryParams: any }>() // 鎼滅储鍙傛暟
+
+const loading = ref(false) // 鍔犺浇涓�
+const list = ref<CrmStatisticsCustomerDealCycleByProductRespVO[]>([]) // 鍒楄〃鐨勬暟鎹�
+
+/** 鏌辩姸鍥鹃厤缃細绾靛悜 */
+const echartsOption = reactive<EChartsOption>({
+ grid: {
+ left: 20,
+ right: 40, // 璁� X 杞村彸渚ф樉绀哄畬鏁�
+ bottom: 20,
+ containLabel: true
+ },
+ legend: {},
+ series: [
+ {
+ name: '鎴愪氦鍛ㄦ湡(澶�)',
+ type: 'bar',
+ data: [],
+ yAxisIndex: 0
+ },
+ {
+ name: '鎴愪氦瀹㈡埛鏁�',
+ type: 'bar',
+ data: [],
+ yAxisIndex: 1
+ }
+ ],
+ toolbox: {
+ feature: {
+ dataZoom: {
+ xAxisIndex: false // 鏁版嵁鍖哄煙缂╂斁锛歒 杞翠笉缂╂斁
+ },
+ brush: {
+ type: ['lineX', 'clear'] // 鍖哄煙缂╂斁鎸夐挳銆佽繕鍘熸寜閽�
+ },
+ saveAsImage: { show: true, name: '鎴愪氦鍛ㄦ湡鍒嗘瀽' } // 淇濆瓨涓哄浘鐗�
+ }
+ },
+ tooltip: {
+ trigger: 'axis',
+ axisPointer: {
+ type: 'shadow'
+ }
+ },
+ yAxis: [
+ {
+ type: 'value',
+ name: '鎴愪氦鍛ㄦ湡(澶�)',
+ min: 0,
+ minInterval: 1 // 鏄剧ず鏁存暟鍒诲害
+ },
+ {
+ type: 'value',
+ name: '鎴愪氦瀹㈡埛鏁�',
+ min: 0,
+ minInterval: 1, // 鏄剧ず鏁存暟鍒诲害
+ splitLine: {
+ lineStyle: {
+ type: 'dotted', // 鍙充晶缃戞牸绾胯櫄鍖�, 鍑忓皯娣蜂贡
+ opacity: 0.7
+ }
+ }
+ }
+ ],
+ xAxis: {
+ type: 'category',
+ name: '浜у搧鍚嶇О',
+ data: []
+ }
+}) as EChartsOption
+
+/** 鑾峰彇鏁版嵁骞跺~鍏呭浘琛� */
+const fetchAndFill = async () => {
+ // 1. 鍔犺浇缁熻鏁版嵁
+ const customerDealCycleByProduct = (
+ await StatisticsCustomerApi.getCustomerDealCycleByProduct(props.queryParams)
+ ).map((s: CrmStatisticsCustomerDealCycleByProductRespVO) => {
+ return {
+ productName: s.productName ?? '鏈煡',
+ customerDealCycle: s.customerDealCount,
+ customerDealCount: s.customerDealCount
+ }
+ })
+ // 2.1 鏇存柊 Echarts 鏁版嵁
+ if (echartsOption.xAxis && echartsOption.xAxis['data']) {
+ echartsOption.xAxis['data'] = customerDealCycleByProduct.map(
+ (s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.productName
+ )
+ }
+ if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
+ echartsOption.series[0]['data'] = customerDealCycleByProduct.map(
+ (s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.customerDealCycle
+ )
+ }
+ if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) {
+ echartsOption.series[1]['data'] = customerDealCycleByProduct.map(
+ (s: CrmStatisticsCustomerDealCycleByProductRespVO) => s.customerDealCount
+ )
+ }
+ // 2.2 鏇存柊鍒楄〃鏁版嵁
+ list.value = customerDealCycleByProduct
+}
+
+/** 鑾峰彇缁熻鏁版嵁 */
+const loadData = async () => {
+ loading.value = true
+ try {
+ await fetchAndFill()
+ } finally {
+ loading.value = false
+ }
+}
+defineExpose({ loadData })
+
+/** 鍒濆鍖� */
+onMounted(() => {
+ loadData()
+})
+</script>
--
Gitblit v1.8.0