Commit 53e2be46 by 李伟康

Merge branch 'SAAS+V5.6.0' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.6.0
2 parents 48b9f0a7 01d86a8f
<template>
<div class="dashboard-card rank-card">
<div class="card-header">
<span class="card-title">线上运营分布</span>
</div>
<div class="rank-list">
<!-- 表头 -->
<div class="rank-header">
<span class="rank-header-col" style="flex: 1;">排名</span>
<span class="rank-header-col" style="flex: 1;">姓名</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">策略总数</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">占比</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">门店总数</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">占比</span>
</div>
<!-- 列表内容 -->
<div
class="rank-item"
v-for="(item, index) in rankData"
:key="index"
>
<!-- 排名 Icon 处理 -->
<div
class="rank-index"
:class="'rank-' + (index + 1)"
>
<img
v-if="index < 3"
:src="require(`@/assets/strategy/icon-strategy-rank0${index + 1}.png`)"
style="width: 24px; height: 24px;"
/>
<span
v-else
style="width: 20px; height: 20px; border-radius: 50%; opacity: 1; background: #2a58ad1a; display: inline-block; text-align: center; line-height: 20px;"
>{{ index + 1 }}</span>
</div>
<div class="rank-name" :title="item.staffName">{{ item.staffName }}</div>
<div class="rank-col">{{ item.strategyCount }}</div>
<div class="rank-col">{{ item.strategyCountPercent }}%</div>
<div class="rank-col">{{ item.storeCount }}</div>
<div class="rank-col">{{ item.storeCountPercent }}%</div>
</div>
</div>
</div>
</template>
<script>
import { getStrategyOnlineDist } from "@/api/earlyWarningManager";
export default {
name: 'OnlineOperatorRanking',
props: {
// 开始日期
startDate: {
type: String,
required: true
},
// 结束日期
endDate: {
type: String,
required: true
},
// 业务类型
businessType: {
type: Number,
required: true
}
},
data() {
return {
// 排行榜数据
rankData: [],
// 加载状态
loading: false
};
},
watch: {
// 监听 props 变化,自动刷新数据
startDate: {
handler() {
this.fetchStrategyOnlineDist();
},
immediate: false
},
endDate: {
handler() {
this.fetchStrategyOnlineDist();
},
immediate: false
},
businessType: {
handler() {
this.fetchStrategyOnlineDist();
},
immediate: false
}
},
mounted() {
// 调用线上运营分布接口
this.fetchStrategyOnlineDist();
},
methods: {
/**
* 获取线上运营分布
*/
async fetchStrategyOnlineDist() {
this.loading = true;
try {
const params = {
startDate: this.startDate,
endDate: this.endDate,
businessType: this.businessType
};
const res = await getStrategyOnlineDist(params);
if (res) {
this.rankData = res;
}
} catch (error) {
console.error('获取线上运营分布失败:', error);
this.$message.error('获取线上运营分布失败,请稍后重试');
} finally {
this.loading = false;
}
},
/**
* 刷新数据(供外部调用)
*/
refresh() {
this.fetchStrategyOnlineDist();
}
}
};
</script>
<style lang="scss" scoped>
$bg-white: #fff;
.dashboard-card {
background: $bg-white;
border-radius: 4px;
padding: 20px;
padding-right: 28px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
&.rank-card {
height: 332px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
.card-title {
font-size: 16px;
font-weight: 500;
color: #303133;
}
}
}
/* 排行榜样式 */
.rank-list {
font-size: 13px;
.rank-header {
display: flex;
color: #909399;
.rank-header-col {
display: inline-block;
}
}
.rank-item {
display: flex;
align-items: center;
box-sizing: border-box;
margin-top: 16px;
&:last-child {
border-bottom: none;
}
.rank-index {
flex: 1;
}
.rank-name {
flex: 1;
color: #303133;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.rank-col {
flex: 1;
text-align: center;
color: #606266;
}
}
}
</style>
......@@ -33,6 +33,7 @@
end-placeholder="结束日期"
:picker-options="pickerOptions"
@change="handleDatePickerChange"
@pick="handleDatePick"
class="hidden-date-picker"
></el-date-picker>
</div>
......@@ -40,6 +41,8 @@
</template>
<script>
import util from '@/libs/util'
// 日期工具方法
const DateUtils = {
// 格式化日期为 YYYY-MM-DD
......@@ -295,6 +298,11 @@ export default {
dateFormat: {
type: String,
default: null
},
// 是否限制日期选择范围为半年(前半年或后半年)
limitHalfYear: {
type: Boolean,
default: true
}
},
data() {
......@@ -305,15 +313,38 @@ export default {
endDate: this.dateRange.endDate ? new Date(this.dateRange.endDate) : null
},
datePickerValue: null,
pickerOptions: {
disabledDate: (time) => {
// 禁用未来日期
return time.getTime() > Date.now();
}
}
selectedStartDate: null // 记录当前选择的开始日期,用于半年限制
};
},
computed: {
// 日期选择器配置
pickerOptions() {
return {
disabledDate: (time) => {
// 禁用未来日期
if (time.getTime() > Date.now()) {
return true;
}
// 如果开启了半年限制且已选择开始日期
if (this.limitHalfYear && this.selectedStartDate) {
const startDate = new Date(this.selectedStartDate);
const currentDate = new Date(time);
// 计算月份差(更精确的半年计算)
const monthDiff = Math.abs(
(currentDate.getFullYear() - startDate.getFullYear()) * 12 +
(currentDate.getMonth() - startDate.getMonth())
);
// 限制只能选择开始日期前后6个月内的日期
return monthDiff > 6;
}
return false;
}
};
},
// 日期范围显示文本
dateRangeText() {
if (!this.internalDateRange.startDate || !this.internalDateRange.endDate) {
......@@ -361,12 +392,22 @@ export default {
deep: true
}
},
created() {
// 创建防抖版本的 notifyDateRangeChange
this.debouncedNotifyDateRangeChange = util.debounce(this.notifyDateRangeChange, 300);
},
mounted() {
// 初始化日期范围
if (!this.internalDateRange.startDate || !this.internalDateRange.endDate) {
this.initDateRange();
}
},
beforeDestroy() {
// 组件销毁时取消防抖函数的延迟执行
if (this.debouncedNotifyDateRangeChange && typeof this.debouncedNotifyDateRangeChange.cancel === 'function') {
this.debouncedNotifyDateRangeChange.cancel();
}
},
methods: {
// 处理时间范围类型切换
handleTimeRangeChange(type) {
......@@ -423,7 +464,7 @@ export default {
const now = new Date();
const range = this.currentStrategy.init(now);
this.internalDateRange = range;
this.notifyDateRangeChange();
this.debouncedNotifyDateRangeChange();
},
// 切换日期范围(左右箭头)
......@@ -441,7 +482,7 @@ export default {
if (newRange) {
this.internalDateRange = newRange;
this.notifyDateRangeChange();
this.debouncedNotifyDateRangeChange();
}
},
......@@ -483,6 +524,10 @@ export default {
new Date(this.internalDateRange.startDate),
new Date(this.internalDateRange.endDate)
];
// 如果开启了半年限制,设置开始日期以便应用限制
if (this.limitHalfYear) {
this.selectedStartDate = new Date(this.internalDateRange.startDate);
}
}
// 使用 nextTick 确保 DOM 更新后再触发显示
this.$nextTick(() => {
......@@ -496,6 +541,14 @@ export default {
});
},
// 处理日期选择事件(选择第一个日期时触发)
handleDatePick({ minDate, maxDate }) {
if (this.limitHalfYear) {
// 记录用户选择的第一个日期
this.selectedStartDate = minDate || maxDate || null;
}
},
// 处理日期选择器变化
handleDatePickerChange(value) {
if (value && value.length === 2) {
......@@ -510,7 +563,18 @@ export default {
startDate: startDate,
endDate: finalEndDate
};
this.notifyDateRangeChange();
// 选择完成后清空临时记录的开始日期
if (this.limitHalfYear) {
this.selectedStartDate = null;
}
this.debouncedNotifyDateRangeChange();
} else if (!value) {
// 清空选择时,重置临时记录
if (this.limitHalfYear) {
this.selectedStartDate = null;
}
}
}
}
......
......@@ -18,9 +18,9 @@
</div>
<div class="row-item">
<span class="label">线上运营:</span>
<el-tooltip :disabled="!cardData.fullOnlineOps" effect="dark" placement="top" popper-class="dark-tooltip">
<div slot="content" style="max-width:236px;line-height:1.6;">{{ cardData.fullOnlineOps }}</div>
<span class="val">{{ cardData.fullOnlineOps || '-' }}</span>
<el-tooltip :disabled="!cardData.onlineOperators" effect="dark" placement="top" popper-class="dark-tooltip">
<div slot="content" style="max-width:236px;line-height:1.6;">{{ cardData.onlineOperators }}</div>
<span class="val">{{ cardData.onlineOperators || '-' }}</span>
</el-tooltip>
</div>
<div class="row-item">
......@@ -33,8 +33,8 @@
<!-- 预警标签组 -->
<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', index === 0 ? 'red' : 'orange']">
<img :src="getAlertIcon(index)" alt="" class="icon-img">
<div v-for="(item, index) in cardData.warningSummary" :key="index" :class="['alert-tag', item.includes('兜底预警') ? 'red' : 'orange']">
<img :src="getAlertIcon(item)" alt="" class="icon-img">
<span>{{ item }}</span>
</div>
</div>
......@@ -80,8 +80,9 @@ export default {
}
},
// 获取预警图标
getAlertIcon(index) {
return index === 0
getAlertIcon(item) {
// Tode: 数据未返回具体字段类型,因此经沟通智能暂时先通过字符串截取判断
return item.includes('兜底预警')
? require('@/assets/strategy/icon-strategy-type01.png')
: require('@/assets/strategy/icon-strategy-type02.png');
},
......
......@@ -85,7 +85,7 @@ import SelectCustom from './compoments/selectCustom.vue';
import CalendarCustom from './compoments/clendarCustom.vue';
import AddStrategy from './storeSignboard/components/AddStrategy/index.vue';
import { getDistrictDetail,getCarBrandList,getMonitorTypeDictList,getMonitorList } from '@/api/earlyWarningManager';
import { merchantStaffByRoleList } from '@api/index'
import { merchantStaffByRoleList,findMerchantStaffList } from '@api/index'
import util from '@/libs/util'
// 盯防类型图标配置(配置化管理,易于扩展)
......@@ -379,12 +379,14 @@ export default {
if (dateRange) {
this.dateRange = { ...dateRange };
}
this.getMonitorListData();
console.log('切换时间范围类型:', this.timeRangeType, this.dateRange);
},
// 处理日期范围变化
handleDateRangeChange(dateRange) {
this.dateRange = { ...dateRange };
console.log('日期范围变化:', this.dateRange);
this.getMonitorListData();
},
// 选择盯防类型
selectWatchType(item) {
......@@ -394,6 +396,7 @@ export default {
};
// watch会自动处理后续逻辑(重置指标类型、触发查询)
console.log('选择盯防类型:', item.label);
this.getMonitorListData();
},
// 选择指标类型
selectIndicatorType(item) {
......@@ -403,6 +406,7 @@ export default {
};
// watch会自动处理后续逻辑(触发查询)
console.log('选择指标类型:', item.label);
this.getMonitorListData();
},
// 全选/取消全选
toggleSelectAll() {
......@@ -500,7 +504,7 @@ export default {
},
// 获取线上运营列表
getOnlineOpsList() {
merchantStaffByRoleList({ roleName: "线上运营" }).then((res) => {
findMerchantStaffList({merchantId: -1}).then((res) => {
if (res && res.length) {
// 将返回的数据转换为选择器需要的格式
this.baseData.onlineOpsList = res.map(item => ({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!