Commit a0a22d52 by chenwq

feat(行为路径分析): 重构路径流程图组件并添加数据过滤功能

- 将PathFlowChart改为接收props数据而非静态导入
- 添加无数据状态显示
- 在pathList中实现基于筛选条件的数据过滤
- 移除未使用的客户名称搜索字段
- 优化图表标题样式和布局
1 parent 393abdee
<template>
<div class="path-flow-container">
<div ref="chart" class="chart-container"></div>
<div class="chart-title">用户行为路径分析</div>
<div v-show="hasData" ref="chart" class="chart-container"></div>
<div v-show="!hasData" class="no-data-container">
<div class="no-data-text">暂无数据</div>
</div>
</div>
</template>
<script>
import * as echarts from 'echarts'
import { nodes, links } from './chartData'
export default {
name: 'PathFlowChart',
props: {
chartNodes: {
type: Array,
default: () => []
},
chartLinks: {
type: Array,
default: () => []
}
},
computed: {
hasData() {
return this.chartNodes && this.chartNodes.length > 0
}
},
data() {
return {
chart: null
}
},
watch: {
chartNodes: {
handler() {
this.updateChart()
},
deep: true
}
},
mounted() {
this.$nextTick(() => {
this.initChart()
......@@ -33,16 +59,23 @@ export default {
this.chart.resize()
}
},
updateChart() {
if (this.chart) {
this.chart.setOption({
series: [
{
data: this.chartNodes,
links: this.chartLinks
}
]
})
}
},
initChart() {
const chartDom = this.$refs.chart
this.chart = echarts.init(chartDom)
const option = {
title: {
text: '用户行为路径分析',
left: 'center',
top: 10
},
tooltip: {
trigger: 'item',
triggerOn: 'mousemove'
......@@ -50,8 +83,8 @@ export default {
series: [
{
type: 'sankey',
data: nodes,
links: links,
data: this.chartNodes,
links: this.chartLinks,
left: '3%',
right: '3%',
top: '5%',
......@@ -112,8 +145,28 @@ export default {
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.chart-title {
text-align: center;
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 20px;
}
.chart-container {
width: 100%;
height: 800px;
}
.no-data-container {
width: 100%;
height: 800px;
display: flex;
justify-content: center;
align-items: center;
background-color: #f5f7fa;
border-radius: 4px;
}
.no-data-text {
font-size: 16px;
color: #909399;
}
</style>
......@@ -3,7 +3,7 @@
<div class="scrm-sub-client-container">
<div class="pageContent">
<GLCombiForm ref="combiForm" :formObj="searchForm" :formData="clientManageFormList" @handleOk="searchTable" @handleRest="resetTable"></GLCombiForm>
<PathFlowChart />
<PathFlowChart :chartNodes="chartNodes" :chartLinks="chartLinks" />
</div>
</div>
</div>
......@@ -11,6 +11,7 @@
<script>
import PathFlowChart from './components/PathFlowChart'
import { nodes, links } from './components/chartData'
const EVENT_OPTIONS = [
// App相关
......@@ -36,19 +37,21 @@ export default {
},
data() {
return {
chartNodes: [],
chartLinks: [],
searchForm: {
addWay: [],
customerName: '',
purchaseCar: ''
},
clientManageFormList: [
{
type: 'input',
inputType: 'text',
name: 'customerName',
label: '客户名称',
placeholder: '请输入客户名称'
},
// {
// type: 'input',
// inputType: 'text',
// name: 'customerName',
// label: '客户名称',
// placeholder: '请输入客户名称'
// },
{
type: 'select',
name: 'addWay',
......@@ -78,21 +81,40 @@ export default {
]
}
},
created() {},
created() {
this.chartNodes = nodes
this.chartLinks = links
},
methods: {
//搜索表格
searchTable() {
this.$refs.clientManage.refreshTable()
// Check if filters are effectively empty
const isAddWayEmpty = !this.searchForm.addWay || this.searchForm.addWay.length === 0
const isDateEmpty = !this.searchForm.purchaseCar
if (isAddWayEmpty && isDateEmpty) {
// Show current data source
this.chartNodes = nodes
this.chartLinks = links
} else {
// Show empty
this.chartNodes = []
this.chartLinks = []
}
// this.$refs.clientManage.refreshTable() // Removed as clientManage ref might not exist or is not shown in template provided
},
//重置表格
resetTable() {
this.searchForm = {}
this.$refs.clientManage.refreshTable()
// 点击之后强制页面刷新
// this.reload()
// this.$forceUpdate() // 没用
// this.$router.go(0)//没有预期效果,会出现一段空白页,用户体验不好
// location.reload() //没有预期效果,会出现一段空白页,用户体验不好
this.searchForm = {
addWay: [],
customerName: '',
purchaseCar: ''
}
// Reset to original data
this.chartNodes = nodes
this.chartLinks = links
// this.$refs.clientManage.refreshTable()
},
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!