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"
placement="bottom" effect="dark"
popper-class="dark-tooltip" placement="bottom"
:disabled="!cardData.storeName"> popper-class="dark-tooltip">
<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 }}
</div> </div>
</template> </template>
<div class="company-name"> <div class="company-name">
{{ cardData.storeName }} {{ cardData.storeName }}
</div>
</el-tooltip>
<el-checkbox v-model="cardData.checked"
class="card-checkbox"
@change="handleCheckboxChange">
</el-checkbox>
</div> </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="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"
placement="top" effect="dark"
popper-class="dark-tooltip" placement="top"
:disabled="!cardData.mainBrands"> popper-class="dark-tooltip">
<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 }}
</div>
</template>
<span class="val">{{ cardData.mainBrands || '-' }}</span>
</el-tooltip>
</div> </div>
<div class="row-item"> </template>
<span class="label">线上运营:</span> <span class="val">{{ cardData.mainBrands || '-' }}</span>
<el-tooltip :disabled="!cardData.onlineOperators" </el-tooltip>
effect="dark" </div>
placement="top" <div class="row-item">
popper-class="dark-tooltip"> <span class="label">线上运营:</span>
<template #content> <el-tooltip :disabled="!cardData.onlineOperators"
<div style="max-width:236px;line-height:1.6;"> effect="dark"
{{ cardData.onlineOperators }} placement="top"
</div> popper-class="dark-tooltip">
</template> <template #content>
<span class="val">{{ cardData.onlineOperators || '-' }}</span> <div style="max-width:236px;line-height:1.6;">
</el-tooltip> {{ cardData.onlineOperators }}
</div> </div>
<div class="row-item"> </template>
<span class="label">区域运营:</span> <span class="val">{{ cardData.onlineOperators || '-' }}</span>
<el-tooltip :disabled="!cardData.regionalOperators" </el-tooltip>
effect="dark" </div>
placement="top" <div class="row-item">
popper-class="dark-tooltip"> <span class="label">区域运营:</span>
<template #content> <el-tooltip :disabled="!cardData.regionalOperators"
<div style="max-width:236px;line-height:1.6;"> effect="dark"
{{ cardData.regionalOperators }} placement="top"
</div> popper-class="dark-tooltip">
</template> <template #content>
<span class="val">{{ cardData.regionalOperators || '-' }}</span> <div style="max-width:236px;line-height:1.6;">
</el-tooltip> {{ cardData.regionalOperators }}
</div> </div>
<div class="row-item"> </template>
<span class="label">区域督导:</span> <span class="val">{{ cardData.regionalOperators || '-' }}</span>
<el-tooltip :disabled="!cardData.regionalOperators" </el-tooltip>
effect="dark" </div>
placement="top" <div class="row-item">
popper-class="dark-tooltip"> <span class="label">区域督导:</span>
<template #content> <el-tooltip :disabled="!cardData.regionalOperators"
<div style="max-width:236px;line-height:1.6;"> effect="dark"
{{ cardData.regionalOperators }} placement="top"
</div> popper-class="dark-tooltip">
</template> <template #content>
<span class="val">{{ cardData.regionalOperators || '-' }}</span> <div style="max-width:236px;line-height:1.6;">
</el-tooltip> {{ cardData.regionalOperators }}
</div> </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-if="cardData.warningSummary && cardData.warningSummary.length > 0" class="alert-group">
<div v-for="(item, index) in cardData.warningSummary" <div v-for="(item, index) in cardData.warningSummary"
: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>
</div>
</div>
<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>
<script> <script>
......
<template> <template>
<el-popover <el-dropdown :disabled="disabled"
placement="bottom-start" placement="bottom-start"
:width="popoverWidth" trigger="click"
trigger="click" @command="handleSelect">
popper-class="pure-popover" <div class="icon-text-btn"
v-model="popoverVisible" :class="{ 'has-selected': value && value.label && value.label !== defaultText, 'is-disabled': disabled }">
> <img v-if="triggerIconType === 'image'"
<ul class="popover-list"> alt=""
<li class="icon-img"
v-for="(item, index) in options" :src="triggerIcon">
:key="index" <i v-else-if="triggerIconType === 'icon'"
:class="{ 'is-selected': isSelected(item) }" :class="triggerIcon">
@click="handleSelect(item)" </i>
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>
<span>{{ label }}:{{ currentValue }}</span> <span>{{ label }}:{{ currentValue }}</span>
</div> </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> </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: {
// 当前选中的值 type: Object,
value: { default: () => ({ label: "盯防类型", value: "" }),
type: Object, },
default: () => ({ label: '盯防类型', value: '' }) label: {
}, type: String,
// 标签文本(如"盯防类型"、"指标类型") required: true,
label: { },
type: String, triggerIcon: {
required: true type: String,
}, required: true,
// 触发按钮的图标(可以是图片路径或图标类名) },
triggerIcon: { triggerIconType: {
type: String, type: String,
required: true default: "icon",
}, validator: value => ["image", "icon"].includes(value),
// 触发按钮图标类型:'image' | 'icon' },
triggerIconType: { defaultText: {
type: String, type: String,
default: 'icon', default: "全部",
validator: (value) => ['image', 'icon'].includes(value) },
}, popoverWidth: {
// 默认文本(用于判断是否选中状态) type: Number,
defaultText: { default: 120,
type: String, },
default: '全部' disabled: {
}, type: Boolean,
// popover宽度 default: false,
popoverWidth: { },
type: Number, },
default: 120 computed: {
} currentValue() {
}, if (this.value && typeof this.value === "object" && this.value.label) {
data() { return this.value.label;
return { }
popoverVisible: false return this.defaultText;
}; },
}, },
computed: { methods: {
// 当前显示的值 handleSelect(item) {
currentValue() { this.$emit("change", item);
if (this.value && typeof this.value === 'object' && this.value.label) { const selectedValue = {
return this.value.label; label: item.label,
} value: item.value !== undefined ? item.value : item.label,
return this.defaultText; };
} this.$emit("input", selectedValue);
}, },
methods: { isSelected(item) {
// 处理选择 if (!this.value)
handleSelect(item) { return false;
this.popoverVisible = false; const itemValue = item.value !== undefined ? item.value : item.label;
// 触发change事件,传递选中的项 const currentValue = this.value.value !== undefined ? this.value.value : this.value.label;
this.$emit('change', item); return itemValue === currentValue;
// 同时触发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;
}
}
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.icon-text-btn { .icon-text-btn {
cursor: pointer; cursor: pointer;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 4px 8px; padding: 4px 8px;
border-radius: 4px; border-radius: 4px;
transition: all 0.3s; transition: all 0.3s;
font-size: 14px; font-size: 14px;
color: #333333; color: #333333;
&:hover { &:hover {
color: #2A58AD; color: #2a58ad;
} }
i { i {
margin-right: 6px; margin-right: 6px;
font-size: 16px; font-size: 16px;
} }
.icon-img { .icon-img {
width: 16px; width: 16px;
height: 16px; height: 16px;
margin-right: 6px; margin-right: 6px;
object-fit: contain; object-fit: contain;
vertical-align: middle; vertical-align: middle;
} }
&.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; }
.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 { .select-custom-dropdown .el-dropdown-menu__item .icon-img {
list-style: none; width: 18px;
margin: 0; height: 18px;
padding: 0; border-radius: 3px;
margin-right: 8px;
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;
}
}
} }
</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,22 +195,35 @@ export default { ...@@ -194,22 +195,35 @@ 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 [
const iconConfig = WATCH_TYPE_ICON_CONFIG[item.typeCode] || WATCH_TYPE_ICON_CONFIG.default; allOption,
return { ...this.monitorTypeData.map((item) => {
label: item.typeName, const iconConfig = WATCH_TYPE_ICON_CONFIG[item.typeCode] || WATCH_TYPE_ICON_CONFIG.default;
value: item.typeCode, return {
icon: iconConfig.icon, label: item.typeName,
iconUrl: iconConfig.iconUrl, value: item.typeCode,
}; icon: iconConfig.icon,
}); 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!