Commit d6748ebe by Lin

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

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