Commit eb176dd4 by Lin

feat: 策略分析页面开发

1 parent dff74f3b
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<header-custom <header-custom
v-model="currentTab" v-model="currentTab"
:tabs="tabs" :tabs="tabs"
:filters="filters"
></header-custom> ></header-custom>
<div class="content-area"> <div class="content-area">
<!-- 2. KPI 核心指标 --> <!-- 2. KPI 核心指标 -->
...@@ -132,18 +131,71 @@ ...@@ -132,18 +131,71 @@
</el-row> </el-row>
</div> </div>
</div> </div>
<!-- 4. 效果分析表格展示 -->
<div class="bottom-content">
<div class="d2-container-content">
<d2-table-header title="效果分析">
<div class="tool-left">
<!-- 盯防类型 -->
<select-custom
:options="watchTypeOptions"
:value="currentWatchType"
label="盯防类型"
:trigger-icon="require('@/assets/strategy/icon-strategy-type.png')"
trigger-icon-type="image"
@change="selectWatchType"
/>
<span class="v-divider">|</span>
<!-- 指标类型 -->
<select-custom
:options="indicatorTypeOptions"
:value="currentIndicatorType"
label="指标类型"
trigger-icon="el-icon-set-up"
trigger-icon-type="icon"
@change="selectIndicatorType"
/>
</div>
</d2-table-header>
<d2-table
ref="table"
:search-form="searchFormSearch"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn"
@pageChange="handlePageChange"
>
<div slot="areaOperator" slot-scope="scope">
<el-tooltip v-if="scope.columnsObj.formatter(scope.scope) && scope.columnsObj.formatter(scope.scope) !== '-' && scope.columnsObj.formatter(scope.scope) !== '、'" effect="dark" placement="top">
<div slot="content" class="tooltip-content-max">
<div>{{ scope.columnsObj.formatter(scope.scope) }}</div>
</div>
<span class="two-line-ellipsis">{{ scope.columnsObj.formatter(scope.scope) }}</span>
</el-tooltip>
<span v-else>{{ scope.columnsObj.formatter(scope.scope) }}</span>
</div>
</d2-table>
</div>
</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import HeaderCustom from '../strategyCentre/compoments/headerCustom.vue'; import HeaderCustom from '../strategyCentre/compoments/headerCustom.vue';
import SelectCustom from '../strategyCentre/compoments/selectCustom.vue';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import { getBIMatterList } from "@/api/earlyWarningManager";
import { Util, deepClone } from "@/common/util";
export default { export default {
name: 'strategyAnalysis', name: 'strategyAnalysis',
components: { components: {
HeaderCustom HeaderCustom,
SelectCustom
}, },
data() { data() {
return { return {
...@@ -239,12 +291,113 @@ export default { ...@@ -239,12 +291,113 @@ export default {
{ name: '李光铭', strategyCount: 34, strategyPercent: 34, storeCount: 18, storePercent: 34 }, { name: '李光铭', strategyCount: 34, strategyPercent: 34, storeCount: 18, storePercent: 34 },
{ name: '郑豪豪豪豪豪豪豪...', strategyCount: 78, strategyPercent: 78, storeCount: 12, storePercent: 78 }, { name: '郑豪豪豪豪豪豪豪...', strategyCount: 78, strategyPercent: 78, storeCount: 12, storePercent: 78 },
{ name: '冯超', strategyCount: 26, strategyPercent: 26, storeCount: 15, storePercent: 26 } { name: '冯超', strategyCount: 26, strategyPercent: 26, storeCount: 15, storePercent: 26 }
],
// 盯防类型选项
watchTypeOptions: [
{ label: '全部', icon: 'el-icon-warning-outline',iconUrl:require('@/assets/strategy/icon-strategy-type01.png') },
{ label: '兜底指标', icon: 'el-icon-warning-outline',iconUrl:require('@/assets/strategy/icon-strategy-type01.png') },
{ label: '生态系数', icon: 'el-icon-data-line',iconUrl:require('@/assets/strategy/icon-strategy-type02.png') },
{ label: '流量', icon: 'el-icon-odometer',iconUrl:require('@/assets/strategy/icon-strategy-type03.png') }
],
currentWatchType: '全部', // 当前选中的盯防类型
// 指标类型选项
indicatorTypeOptions: [
{ label: '全部' },
{ label: '整车延保渗透率' },
{ label: '安心包渗透率' },
{ label: '电池渗透率' },
{ label: '轮胎渗透率' },
{ label: '整车延保转化率' },
{ label: '安心包转化率' },
{ label: '电池转化率' },
{ label: '轮胎转化率' }
],
currentIndicatorType: '全部', // 当前选中的指标类型
// 表格相关数据
searchFormSearch: {},
getListApi: getBIMatterList,
pageInfo: {
pageSize: 10,
currentPage: 1
},
tableParams: {
listName: "list",
tableColumns: [
{
label: "门店名称",
prop: "storeName",
minWidth: 160,
},
{
label: "主营品牌",
prop: "description",
minWidth: 100
},
{
label: "线上运营",
prop: "onlineOperator",
type: "slot",
minWidth: 80,
addHtml: "onlineOperator",
formatter: (cellValue) => {
if (!cellValue.onlineOperator || !Array.isArray(cellValue.onlineOperator)) {
return "-"
}
return cellValue.onlineOperator
.map(item => item.username)
.filter(username => username)
.join("/") || "-"
},
},
{
label: "区域运营",
prop: "areaOperator",
minWidth: 80,
formatter: (cellValue) => {
if (!cellValue.areaOperator || !Array.isArray(cellValue.areaOperator)) {
return "-"
}
return cellValue.areaOperator
.map(item => item.username)
.filter(username => username)
.join("/") || "、"
},
},
{
label: "当期指标",
prop: "creator",
minWidth: 140
},
{
label: "执行策略总数",
prop: "areaOperator",
type: "slot",
minWidth: 80,
addHtml: "areaOperator",
formatter: (cellValue) => {
if (!cellValue.areaOperator || !Array.isArray(cellValue.areaOperator)) {
return "-"
}
return cellValue.areaOperator
.map(item => item.username)
.filter(username => username)
.join("/") || "、"
},
},
{
label: "效果分析",
prop: "creator",
minWidth: 120
},
] ]
}
}; };
}, },
mounted() { mounted() {
this.initChart(); this.initChart();
window.addEventListener('resize', this.resizeChart); window.addEventListener('resize', this.resizeChart);
// 启用页面滚动
this.enablePageScroll();
}, },
beforeDestroy() { beforeDestroy() {
if (this.myChart) { if (this.myChart) {
...@@ -252,6 +405,8 @@ export default { ...@@ -252,6 +405,8 @@ export default {
this.myChart = null; this.myChart = null;
} }
window.removeEventListener('resize', this.resizeChart); window.removeEventListener('resize', this.resizeChart);
// 禁用页面滚动
this.disablePageScroll();
}, },
methods: { methods: {
handleTabChange(tab) { handleTabChange(tab) {
...@@ -362,6 +517,73 @@ export default { ...@@ -362,6 +517,73 @@ export default {
if (this.myChart) { if (this.myChart) {
this.myChart.resize(); this.myChart.resize();
} }
},
/**
* 导出功能
*/
handleExport() {
// TODO: 实现导出功能
console.log('导出功能待实现');
},
/**
* 搜索前处理
*/
beforeSearchFn(type = 1) {
return new Promise((resolve, reject) => {
this.searchFormSearch = deepClone({})
resolve()
})
},
/**
* 分页变化处理
*/
handlePageChange(page) {
this.pageInfo = page
},
/**
* 启用页面滚动 - 动态添加样式到父容器
*/
enablePageScroll() {
this.$nextTick(() => {
// 查找父容器
const parentContainer = this.$el?.closest('.d2-theme-container-main-body') ||
this.$el?.closest('.container-component');
if (parentContainer) {
// 添加唯一标识类名,避免影响其他页面
parentContainer.classList.add('strategy-analysis-scroll-container');
// 直接设置样式,允许垂直滚动
parentContainer.style.overflowY = 'auto';
parentContainer.style.overflowX = 'hidden';
parentContainer.style.height = '100%';
}
});
},
/**
* 禁用页面滚动 - 移除样式
*/
disablePageScroll() {
const parentContainer = document.querySelector('.strategy-analysis-scroll-container');
if (parentContainer) {
parentContainer.classList.remove('strategy-analysis-scroll-container');
parentContainer.style.overflowY = '';
parentContainer.style.overflowX = '';
}
},
/**
* 选择盯防类型
*/
selectWatchType(item) {
this.currentWatchType = item.label;
// 这里可以触发数据更新逻辑
console.log('选择盯防类型:', item.label);
},
/**
* 选择指标类型
*/
selectIndicatorType(item) {
this.currentIndicatorType = item.label;
// 这里可以触发数据更新逻辑
console.log('选择指标类型:', item.label);
} }
} }
}; };
...@@ -375,10 +597,12 @@ $bg-white: #fff; ...@@ -375,10 +597,12 @@ $bg-white: #fff;
padding: 0 19px 20px; padding: 0 19px 20px;
box-sizing: border-box; box-sizing: border-box;
height: auto; height: auto;
overflow: visible;
} }
.content-area { .content-area {
min-height: 0; min-height: 0;
width: 100%;
.top-content { .top-content {
background-color: $bg-white; background-color: $bg-white;
padding: 16px 20px; padding: 16px 20px;
...@@ -464,7 +688,7 @@ $bg-white: #fff; ...@@ -464,7 +688,7 @@ $bg-white: #fff;
.card-title { .card-title {
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 500;
color: #303133; color: #303133;
} }
...@@ -573,5 +797,41 @@ $bg-white: #fff; ...@@ -573,5 +797,41 @@ $bg-white: #fff;
} }
} }
} }
/* 效果分析表格展示 */
.bottom-content {
background-color: $bg-white;
padding: 16px 20px;
margin-top: 20px;
}
}
.tooltip-content-max {
max-height: 320px;
overflow-y: scroll;
}
.two-line-ellipsis {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
line-clamp: 2;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
line-height: 1.5;
padding: 0 10px;
}
.tool-left {
display: flex;
align-items: center;
font-size: 14px;
color: #333333;
line-height: normal; // 重置 line-height,避免受 .table-header 影响
.v-divider {
margin: 0 20px;
color: #E5E6EB;
line-height: normal; // 重置 line-height,避免受 .table-header 影响
}
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<template>
<el-popover
placement="bottom-start"
:width="popoverWidth"
trigger="click"
popper-class="pure-popover"
v-model="popoverVisible"
>
<ul class="popover-list">
<li
v-for="(item, index) in options"
:key="index"
@click="handleSelect(item)"
>
<!-- 支持图片图标 -->
<img
v-if="item.iconUrl"
:src="item.iconUrl"
alt=""
class="icon-img"
>
<!-- 支持字体图标 -->
<i
v-else-if="item.icon"
:class="item.icon"
></i>
{{ item.label }}
</li>
</ul>
<div
slot="reference"
class="icon-text-btn"
:class="{ 'has-selected': currentValue !== defaultText }"
>
<!-- 触发按钮图标:支持图片和字体图标 -->
<img
v-if="triggerIconType === 'image'"
:src="triggerIcon"
alt=""
class="icon-img"
>
<i
v-else-if="triggerIconType === 'icon'"
:class="triggerIcon"
></i>
<span>{{ label }}:{{ currentValue }}</span>
</div>
</el-popover>
</template>
<script>
export default {
name: 'SelectCustom',
props: {
// 选项列表
options: {
type: Array,
required: true,
default: () => []
},
// 当前选中的值
value: {
type: String,
default: '全部'
},
// 标签文本(如"盯防类型"、"指标类型")
label: {
type: String,
required: true
},
// 触发按钮的图标(可以是图片路径或图标类名)
triggerIcon: {
type: String,
required: true
},
// 触发按钮图标类型:'image' | 'icon'
triggerIconType: {
type: String,
default: 'icon',
validator: (value) => ['image', 'icon'].includes(value)
},
// 默认文本(用于判断是否选中状态)
defaultText: {
type: String,
default: '全部'
},
// popover宽度
popoverWidth: {
type: Number,
default: 120
}
},
data() {
return {
popoverVisible: false
};
},
computed: {
// 当前显示的值
currentValue() {
return this.value || this.defaultText;
}
},
methods: {
// 处理选择
handleSelect(item) {
this.popoverVisible = false;
// 触发change事件,传递选中的项
this.$emit('change', item);
// 同时触发input事件,支持v-model
this.$emit('input', item.label);
}
}
};
</script>
<style lang="scss" scoped>
.icon-text-btn {
cursor: pointer;
display: flex;
align-items: center;
padding: 4px 8px;
border-radius: 4px;
transition: all 0.3s;
font-size: 14px;
color: #333333;
&:hover {
color: #2A58AD;
}
i {
margin-right: 6px;
font-size: 16px;
}
.icon-img {
width: 16px;
height: 16px;
margin-right: 6px;
object-fit: contain;
vertical-align: middle;
}
&.has-selected {
background-color: #EFF3F6;
}
}
</style>
<style>
/* 全局样式,与父组件保持一致 */
.pure-popover {
padding: 4px 0 !important;
border-color: #E5E6EB !important;
box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
}
.popover-list {
list-style: none;
margin: 0;
padding: 0;
li {
padding: 9px 16px;
cursor: pointer;
color: #333333;
font-size: 12px;
display: flex;
align-items: center;
&:hover {
background-color: #F2F3F5;
color: #3266E3;
}
i {
margin-right: 8px;
font-size: 14px;
}
.icon-img {
width: 18px;
height: 18px;
border-radius: 3px;
margin-right: 8px;
}
}
}
</style>
...@@ -16,60 +16,26 @@ ...@@ -16,60 +16,26 @@
<div class="toolbar-container"> <div class="toolbar-container">
<div class="tool-left"> <div class="tool-left">
<!-- 盯防类型 --> <!-- 盯防类型 -->
<el-popover <select-custom
placement="bottom-start" :options="watchTypeOptions"
width="120" :value="currentWatchType"
trigger="click" label="盯防类型"
popper-class="pure-popover" :trigger-icon="require('@/assets/strategy/icon-strategy-type.png')"
v-model="watchTypePopoverVisible" trigger-icon-type="image"
> @change="selectWatchType"
<ul class="popover-list"> />
<li
v-for="(item, index) in watchTypeOptions"
:key="index"
@click="selectWatchType(item)"
>
<img :src="item.iconUrl" alt="" class="icon-img"> {{ item.label }}
</li>
</ul>
<div
slot="reference"
class="icon-text-btn"
:class="{ 'has-selected': currentWatchType !== '全部' }"
>
<img src="@/assets/strategy/icon-strategy-type.png" alt="" class="icon-img">
<span>盯防类型:{{ currentWatchType }}</span>
</div>
</el-popover>
<span class="v-divider">|</span> <span class="v-divider">|</span>
<!-- 指标类型 --> <!-- 指标类型 -->
<el-popover <select-custom
placement="bottom-start" :options="indicatorTypeOptions"
width="120" :value="currentIndicatorType"
trigger="click" label="指标类型"
popper-class="pure-popover" trigger-icon="el-icon-set-up"
v-model="indicatorTypePopoverVisible" trigger-icon-type="icon"
> @change="selectIndicatorType"
<ul class="popover-list"> />
<li
v-for="(item, index) in indicatorTypeOptions"
:key="index"
@click="selectIndicatorType(item)"
>
<i :class="item.icon"></i> {{ item.label }}
</li>
</ul>
<div
slot="reference"
class="icon-text-btn"
:class="{ 'has-selected': currentIndicatorType !== '全部' }"
>
<i class="el-icon-set-up"></i>
<span>指标类型:{{ currentIndicatorType }}</span>
</div>
</el-popover>
<!-- 时间切换 --> <!-- 时间切换 -->
<div class="time-control-group"> <div class="time-control-group">
...@@ -117,27 +83,17 @@ ...@@ -117,27 +83,17 @@
</div> </div>
<!-- 4. 底部翻页 --> <!-- 4. 底部翻页 -->
<div class="footer-bar"> <div class="footer-bar" v-if="cardList.length > 0">
<div class="total">共 800 条</div>
<el-pagination <el-pagination
background background
layout="prev, pager, next, slot" @size-change="handleSizeChange"
:total="800" @current-change="handleCurrentChange"
:page-size="10" :current-page="page.currentPage"
:current-page="2" :page-sizes="[10, 20, 30, 40]"
> :page-size="page.pageSize"
<span class="jump-slot"> :total="total"
每页 :layout="layout"
<el-select size="mini" value="10" class="mini-select"> />
<el-option value="10" label="10"></el-option>
</el-select>
条
<span class="sep"></span>
跳至
<input class="jump-input" value="5" />
页
</span>
</el-pagination>
</div> </div>
</div> </div>
</template> </template>
...@@ -145,12 +101,14 @@ ...@@ -145,12 +101,14 @@
<script> <script>
import MonitorCard from './compoments/monitorCard.vue'; import MonitorCard from './compoments/monitorCard.vue';
import HeaderCustom from './compoments/headerCustom.vue'; import HeaderCustom from './compoments/headerCustom.vue';
import SelectCustom from './compoments/selectCustom.vue';
export default { export default {
name: 'DashboardExact', name: 'DashboardExact',
components: { components: {
MonitorCard, MonitorCard,
HeaderCustom HeaderCustom,
SelectCustom
}, },
data() { data() {
return { return {
...@@ -279,16 +237,26 @@ ...@@ -279,16 +237,26 @@
{ label: '流量', icon: 'el-icon-odometer',iconUrl:require('@/assets/strategy/icon-strategy-type03.png') } { label: '流量', icon: 'el-icon-odometer',iconUrl:require('@/assets/strategy/icon-strategy-type03.png') }
], ],
currentWatchType: '全部', // 当前选中的盯防类型 currentWatchType: '全部', // 当前选中的盯防类型
watchTypePopoverVisible: false, // 盯防类型popover显示状态
// 指标类型选项 // 指标类型选项
indicatorTypeOptions: [ indicatorTypeOptions: [
{ label: '全部', icon: 'el-icon-warning-outline' }, { label: '全部' },
{ label: '兜底指标', icon: 'el-icon-warning-outline' }, { label: '整车延保渗透率' },
{ label: '生态系数', icon: 'el-icon-data-line' }, { label: '安心包渗透率' },
{ label: '流量', icon: 'el-icon-odometer' } { label: '电池渗透率' },
{ label: '轮胎渗透率' },
{ label: '整车延保转化率' },
{ label: '安心包转化率' },
{ label: '电池转化率' },
{ label: '轮胎转化率' }
], ],
currentIndicatorType: '全部', // 当前选中的指标类型 currentIndicatorType: '全部', // 当前选中的指标类型
indicatorTypePopoverVisible: false, // 指标类型popover显示状态 // 分页相关
page: {
pageSize: 10,
currentPage: 1
},
layout: "sizes,total,->,prev,pager,next,jumper",
total: 800,
// 简化数据,保留关键示例 // 简化数据,保留关键示例
cardList: [ cardList: [
{ {
...@@ -630,14 +598,12 @@ ...@@ -630,14 +598,12 @@
// 选择盯防类型 // 选择盯防类型
selectWatchType(item) { selectWatchType(item) {
this.currentWatchType = item.label; this.currentWatchType = item.label;
this.watchTypePopoverVisible = false;
// 这里可以触发数据更新逻辑 // 这里可以触发数据更新逻辑
console.log('选择盯防类型:', item.label); console.log('选择盯防类型:', item.label);
}, },
// 选择指标类型 // 选择指标类型
selectIndicatorType(item) { selectIndicatorType(item) {
this.currentIndicatorType = item.label; this.currentIndicatorType = item.label;
this.indicatorTypePopoverVisible = false;
// 这里可以触发数据更新逻辑 // 这里可以触发数据更新逻辑
console.log('选择指标类型:', item.label); console.log('选择指标类型:', item.label);
}, },
...@@ -648,6 +614,23 @@ ...@@ -648,6 +614,23 @@
item.checked = shouldSelectAll; item.checked = shouldSelectAll;
}); });
}, },
// 每页条数
handleSizeChange(value) {
this.page.pageSize = value;
this.page.currentPage = 1;
this.refreshTable();
},
// 页码
handleCurrentChange(value) {
this.page.currentPage = value;
this.refreshTable();
},
// 重置请求
refreshTable() {
// 这里可以调用接口获取数据
// 暂时留空,等待实际接口对接
console.log('刷新表格数据', this.page);
},
// 启用页面滚动 - 动态添加样式到父容器 // 启用页面滚动 - 动态添加样式到父容器
enablePageScroll() { enablePageScroll() {
this.$nextTick(() => { this.$nextTick(() => {
...@@ -710,24 +693,6 @@ ...@@ -710,24 +693,6 @@
align-items: center; align-items: center;
font-size: 14px; font-size: 14px;
color: $text-sub; color: $text-sub;
.icon-text-btn {
cursor: pointer;
display: flex;
align-items: center;
padding: 4px 8px;
border-radius: 4px;
transition: all 0.3s;
&:hover { color: $primary; }
i { margin-right: 6px; font-size: 16px; }
.icon-img {
width: 16px;
height: 16px;
margin-right: 6px;
object-fit: contain;
vertical-align: middle;
}
&.has-selected { background-color: $bg-gray; }
}
.v-divider { margin: 0 20px; color: $border; } .v-divider { margin: 0 20px; color: $border; }
.time-control-group { .time-control-group {
margin: 0 16px 0 24px; margin: 0 16px 0 24px;
...@@ -784,33 +749,8 @@ ...@@ -784,33 +749,8 @@
} }
.footer-bar { .footer-bar {
display: flex; background: white;
align-items: center; padding: 20px 20px;
font-size: 13px;
color: $text-sub;
background-color: $bg-white;
height: 68px;
padding: 0 20px;
.total { margin-right: 16px; font-size: 14px; color: #606266; }
.jump-slot {
margin-left: 12px;
display: inline-flex;
align-items: center;
.mini-select { width: 55px; margin: 0 4px; }
.sep { margin: 0 6px; }
.jump-input {
width: 32px;
height: 24px;
margin: 0 6px;
border: 1px solid $border;
border-radius: 2px;
text-align: center;
outline: none;
color: $text-main;
&:hover { border-color: #C9CDD4; }
&:focus { border-color: $primary; }
}
}
} }
::v-deep { ::v-deep {
...@@ -835,27 +775,3 @@ ...@@ -835,27 +775,3 @@
} }
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
<style>
.pure-popover {
padding: 4px 0 !important;
border-color: #E5E6EB !important;
box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
}
.popover-list {
list-style: none;
margin: 0;
padding: 0;
li {
padding: 9px 16px;
cursor: pointer;
color: #333333;
font-size: 12px;
display: flex;
align-items: center;
&:hover { background-color: #F2F3F5; color: #3266E3; }
i { margin-right: 8px; font-size: 14px; }
.icon-img { width: 18px; height: 18px; border-radius: 3px; margin-right: 8px; }
}
}
</style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!