Commit d6748ebe by Lin

refactor: 优化早期预警管理相关组件与API

- 移除策略分析模块的冗余注释,提升代码整洁性。
- 调整策略分析页面中的选项顺序,确保权益与轻改的顺序一致。
- 更新策略中心组件,默认盯防类型与指标类型均为「全部」,增强用户体验。
- 优化自定义选择组件,支持禁用状态,提升交互体验与可读性。
1 parent b6365d35
......@@ -415,7 +415,6 @@ export function getMonitorTypeDictList(data = {}) {
return request(data, RequestMethods.POST);
}
// 策略分析模块
/**
* 策略分析-总数统计
*/
......
......@@ -230,8 +230,8 @@ export default {
currentTab: { label: "延保", value: 1 },
tabs: [
{ label: "延保", value: 1 },
{ label: "权益", value: 2 },
{ label: "轻改", value: 3 },
{ label: "权益", value: 3 },
{ label: "轻改", value: 2 },
],
// 时间范围类型
timeRangeType: { label: "月", value: 2 },
......
<template>
<div class="monitor-card" :class="{ 'is-checked': cardData.checked }">
<div class="card-head">
<el-tooltip effect="dark"
placement="bottom"
popper-class="dark-tooltip"
:disabled="!cardData.storeName">
<template #content>
<div style="width:236px;line-height:1.6;word-break:break-all;">
{{ cardData.storeName }}
</div>
</template>
<div class="company-name">
{{ cardData.storeName }}
</div>
</el-tooltip>
<el-checkbox v-model="cardData.checked"
class="card-checkbox"
@change="handleCheckboxChange">
</el-checkbox>
<div class="monitor-card" :class="{ 'is-checked': cardData.checked }">
<div class="card-head">
<el-tooltip :disabled="!cardData.storeName"
effect="dark"
placement="bottom"
popper-class="dark-tooltip">
<template #content>
<div style="width:236px;line-height:1.6;word-break:break-all;">
{{ cardData.storeName }}
</div>
</template>
<div class="company-name">
{{ cardData.storeName }}
</div>
</el-tooltip>
<el-checkbox v-model="cardData.checked"
class="card-checkbox"
@change="handleCheckboxChange">
</el-checkbox>
</div>
<div class="card-body" @click="handleViewDetail">
<div class="row-item">
<span class="label">主营品牌:</span>
<el-tooltip effect="dark"
placement="top"
popper-class="dark-tooltip"
:disabled="!cardData.mainBrands">
<template #content>
<div style="max-width:236px;line-height:1.6;word-break:break-all;">
{{ cardData.mainBrands }}
</div>
</template>
<span class="val">{{ cardData.mainBrands || '-' }}</span>
</el-tooltip>
<div class="card-body" @click="handleViewDetail">
<div class="row-item">
<span class="label">主营品牌:</span>
<el-tooltip :disabled="!cardData.mainBrands"
effect="dark"
placement="top"
popper-class="dark-tooltip">
<template #content>
<div style="max-width:236px;line-height:1.6;word-break:break-all;">
{{ cardData.mainBrands }}
</div>
<div class="row-item">
<span class="label">线上运营:</span>
<el-tooltip :disabled="!cardData.onlineOperators"
effect="dark"
placement="top"
popper-class="dark-tooltip">
<template #content>
<div style="max-width:236px;line-height:1.6;">
{{ cardData.onlineOperators }}
</div>
</template>
<span class="val">{{ cardData.onlineOperators || '-' }}</span>
</el-tooltip>
</template>
<span class="val">{{ cardData.mainBrands || '-' }}</span>
</el-tooltip>
</div>
<div class="row-item">
<span class="label">线上运营:</span>
<el-tooltip :disabled="!cardData.onlineOperators"
effect="dark"
placement="top"
popper-class="dark-tooltip">
<template #content>
<div style="max-width:236px;line-height:1.6;">
{{ cardData.onlineOperators }}
</div>
<div class="row-item">
<span class="label">区域运营:</span>
<el-tooltip :disabled="!cardData.regionalOperators"
effect="dark"
placement="top"
popper-class="dark-tooltip">
<template #content>
<div style="max-width:236px;line-height:1.6;">
{{ cardData.regionalOperators }}
</div>
</template>
<span class="val">{{ cardData.regionalOperators || '-' }}</span>
</el-tooltip>
</template>
<span class="val">{{ cardData.onlineOperators || '-' }}</span>
</el-tooltip>
</div>
<div class="row-item">
<span class="label">区域运营:</span>
<el-tooltip :disabled="!cardData.regionalOperators"
effect="dark"
placement="top"
popper-class="dark-tooltip">
<template #content>
<div style="max-width:236px;line-height:1.6;">
{{ cardData.regionalOperators }}
</div>
<div class="row-item">
<span class="label">区域督导:</span>
<el-tooltip :disabled="!cardData.regionalOperators"
effect="dark"
placement="top"
popper-class="dark-tooltip">
<template #content>
<div style="max-width:236px;line-height:1.6;">
{{ cardData.regionalOperators }}
</div>
</template>
<span class="val">{{ cardData.regionalOperators || '-' }}</span>
</el-tooltip>
</template>
<span class="val">{{ cardData.regionalOperators || '-' }}</span>
</el-tooltip>
</div>
<div class="row-item">
<span class="label">区域督导:</span>
<el-tooltip :disabled="!cardData.regionalOperators"
effect="dark"
placement="top"
popper-class="dark-tooltip">
<template #content>
<div style="max-width:236px;line-height:1.6;">
{{ cardData.regionalOperators }}
</div>
</template>
<span class="val">{{ cardData.regionalOperators || '-' }}</span>
</el-tooltip>
</div>
<!-- 预警标签组 -->
<div v-if="cardData.warningSummary && cardData.warningSummary.length > 0" class="alert-group">
<div v-for="(item, index) in cardData.warningSummary"
:key="index"
class="alert-tag"
:class="[item.includes('兜底预警') ? 'red' : 'orange']">
<img :src="getAlertIcon(item)"
alt=""
class="icon-img">
<span style=" font-size: 13px;">{{ item }}</span>
</div>
</div>
<!-- 预警标签组 -->
<div v-if="cardData.warningSummary && cardData.warningSummary.length > 0" class="alert-group">
<div v-for="(item, index) in cardData.warningSummary"
:key="index"
class="alert-tag"
:class="[item.includes('兜底预警') ? 'red' : 'orange']">
<img alt=""
class="icon-img"
:src="getAlertIcon(item)">
<span style=" font-size: 13px;">{{ item }}</span>
</div>
</div>
</div>
<div class="card-foot" @click="handleViewDetail">
<span class="info">共{{ cardData.warningTotalCount }}项预警</span>
<span class="link">
查看详情 <img src="@/assets/strategy/icon-strategy-arrow-r.png"
alt=""
srcset=""
class="icon-arrow">
</span>
</div>
<div class="card-foot" @click="handleViewDetail">
<span class="info">共{{ cardData.warningTotalCount }}项预警</span>
<span class="link">
查看详情 <img alt=""
class="icon-arrow"
src="@/assets/strategy/icon-strategy-arrow-r.png"
srcset="">
</span>
</div>
</div>
</template>
<script>
......
<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"
:class="{ 'is-selected': isSelected(item) }"
@click="handleSelect(item)"
style="font-size: 14px;"
>
<!-- 支持图片图标 -->
<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': value && value.label && value.label !== defaultText }"
>
<!-- 触发按钮图标:支持图片和字体图标 -->
<img
v-if="triggerIconType === 'image'"
:src="triggerIcon"
alt=""
class="icon-img"
>
<i
v-else-if="triggerIconType === 'icon'"
:class="triggerIcon"
></i>
<el-dropdown :disabled="disabled"
placement="bottom-start"
trigger="click"
@command="handleSelect">
<div class="icon-text-btn"
:class="{ 'has-selected': value && value.label && value.label !== defaultText, 'is-disabled': disabled }">
<img v-if="triggerIconType === 'image'"
alt=""
class="icon-img"
:src="triggerIcon">
<i v-else-if="triggerIconType === 'icon'"
:class="triggerIcon">
</i>
<span>{{ label }}:{{ currentValue }}</span>
</div>
</el-popover>
<template #dropdown>
<el-dropdown-menu class="select-custom-dropdown"
:style="{ minWidth: `${popoverWidth}px` }">
<el-dropdown-item v-for="(item, index) in options"
:key="index"
:class="{ 'is-selected': isSelected(item) }"
:command="item">
<div class="icon-img">
<img v-if="item.iconUrl"
alt=""
class="icon-img"
:src="item.iconUrl">
<i v-else-if="item.icon"
:class="item.icon">
</i>
</div>
{{ item.label }}
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<script>
export default {
name: 'SelectCustom',
props: {
// 选项列表
options: {
type: Array,
required: true,
default: () => []
},
// 当前选中的值
value: {
type: Object,
default: () => ({ label: '盯防类型', value: '' })
},
// 标签文本(如"盯防类型"、"指标类型")
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() {
if (this.value && typeof this.value === 'object' && this.value.label) {
return this.value.label;
}
return this.defaultText;
}
},
methods: {
// 处理选择
handleSelect(item) {
this.popoverVisible = false;
// 触发change事件,传递选中的项
this.$emit('change', item);
// 同时触发input事件,支持v-model,传递包含label和value的对象
const selectedValue = {
label: item.label,
value: item.value !== undefined ? item.value : item.label
};
this.$emit('input', selectedValue);
},
// 判断选项是否被选中
isSelected(item) {
if (!this.value) return false;
// 优先比较value属性,如果没有value则比较label
const itemValue = item.value !== undefined ? item.value : item.label;
const currentValue = this.value.value !== undefined ? this.value.value : this.value.label;
return itemValue === currentValue;
}
}
name: "SelectCustom",
props: {
options: {
type: Array,
required: true,
default: () => [],
},
value: {
type: Object,
default: () => ({ label: "盯防类型", value: "" }),
},
label: {
type: String,
required: true,
},
triggerIcon: {
type: String,
required: true,
},
triggerIconType: {
type: String,
default: "icon",
validator: value => ["image", "icon"].includes(value),
},
defaultText: {
type: String,
default: "全部",
},
popoverWidth: {
type: Number,
default: 120,
},
disabled: {
type: Boolean,
default: false,
},
},
computed: {
currentValue() {
if (this.value && typeof this.value === "object" && this.value.label) {
return this.value.label;
}
return this.defaultText;
},
},
methods: {
handleSelect(item) {
this.$emit("change", item);
const selectedValue = {
label: item.label,
value: item.value !== undefined ? item.value : item.label,
};
this.$emit("input", selectedValue);
},
isSelected(item) {
if (!this.value)
return false;
const itemValue = item.value !== undefined ? item.value : item.label;
const currentValue = this.value.value !== undefined ? this.value.value : this.value.label;
return itemValue === currentValue;
},
},
};
</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;
}
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;
}
&.is-disabled {
cursor: not-allowed;
color: #c0c4cc;
&:hover {
color: #c0c4cc;
}
}
}
</style>
<style>
/* 全局样式,与父组件保持一致 */
.pure-popover {
padding: 4px 0 !important;
border-color: #E5E6EB !important;
box-shadow: 0 4px 10px rgba(0,0,0,0.1) !important;
.select-custom-dropdown {
padding: 4px 0 !important;
border-color: #e5e6eb !important;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
}
.select-custom-dropdown .el-dropdown-menu__item {
display: flex;
align-items: center;
padding: 9px 16px;
font-size: 14px;
color: #333333;
line-height: 1.5;
}
.select-custom-dropdown .el-dropdown-menu__item.is-selected {
background-color: #f7f7f7;
}
.select-custom-dropdown .el-dropdown-menu__item i {
margin-right: 8px;
font-size: 14px;
}
.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;
&.is-selected {
background-color: #f7f7f7;
}
&:hover {
background-color: #F2F3F5;
}
i {
margin-right: 8px;
font-size: 14px;
}
.icon-img {
width: 18px;
height: 18px;
border-radius: 3px;
margin-right: 8px;
}
}
.select-custom-dropdown .el-dropdown-menu__item .icon-img {
width: 18px;
height: 18px;
border-radius: 3px;
margin-right: 8px;
}
</style>
......@@ -29,7 +29,8 @@
<span class="v-divider">|</span>
<!-- 指标类型 -->
<SelectCustom label="指标类型"
<SelectCustom :disabled="isIndicatorTypeDisabled"
label="指标类型"
:options="indicatorTypeOptions"
:trigger-icon="require('@/assets/strategy/icon-strategy-type06.png')"
trigger-icon-type="image"
......@@ -145,8 +146,8 @@ export default {
currentTab: { label: "延保", value: 1 },
tabs: [
{ label: "延保", value: 1 },
{ label: "权益", value: 2 },
{ label: "轻改", value: 3 },
{ label: "权益", value: 3 },
{ label: "轻改", value: 2 },
],
filters: {
storeName: "",
......@@ -182,7 +183,7 @@ export default {
// 存储原始监控类型数据(接口返回的完整数据)
monitorTypeData: [],
// 当前选中的盯防类型
currentWatchType: { label: "", value: null },
currentWatchType: { label: "全部", value: null },
// 当前选中的指标类型
currentIndicatorType: { label: "全部", value: null },
// 门店列表数据
......@@ -194,22 +195,35 @@ export default {
computed: {
// 盯防类型选项数据格式化:label: 盯防类型, value: 盯防类型编码, icon: 图标, iconUrl: 图标路径(自动根据原始数据生成)
watchTypeOptions() {
const allOption = { label: "全部", value: null };
if (!this.monitorTypeData || this.monitorTypeData.length === 0) {
return [];
return [allOption];
}
return this.monitorTypeData.map((item) => {
const iconConfig = WATCH_TYPE_ICON_CONFIG[item.typeCode] || WATCH_TYPE_ICON_CONFIG.default;
return {
label: item.typeName,
value: item.typeCode,
icon: iconConfig.icon,
iconUrl: iconConfig.iconUrl,
};
});
return [
allOption,
...this.monitorTypeData.map((item) => {
const iconConfig = WATCH_TYPE_ICON_CONFIG[item.typeCode] || WATCH_TYPE_ICON_CONFIG.default;
return {
label: item.typeName,
value: item.typeCode,
icon: iconConfig.icon,
iconUrl: iconConfig.iconUrl,
};
}),
];
},
// 盯防类型为「全部」时,指标类型不可选
isIndicatorTypeDisabled() {
return this.currentWatchType.value == null;
},
// 指标类型选项(自动根据当前盯防类型生成)
indicatorTypeOptions() {
if (this.currentWatchType.value == null) {
return [{ label: "全部", value: null }];
}
// 查找当前选中的盯防类型对应的数据
const currentTypeData = this.monitorTypeData.find(
item => item.typeCode === this.currentWatchType.value,
......@@ -579,15 +593,8 @@ export default {
if (res && res.length) {
// 保存原始数据(计算属性会自动基于此生成选项)
this.monitorTypeData = res;
// 初始化当前选中的盯防类型为第一个
if (res[0]) {
this.currentWatchType = {
label: res[0].typeName,
value: res[0].typeCode,
};
}
// 初始化当前选中的指标类型为"全部"
// 默认盯防类型、指标类型均为「全部」
this.currentWatchType = { label: "全部", value: null };
this.currentIndicatorType = { label: "全部", value: null };
} else {
console.warn("指标类型列表接口返回为空");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!