Commit 89091d3f 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 3a3b37bd 6b7f9365
<template> <template>
<div class="dashboard-page"> <div class="dashboard-page">
<!-- 1. 顶部导航栏 --> <!-- 1. 顶部导航栏 -->
<div class="top-header-wrapper">
<header-custom <header-custom
v-model="currentTab" v-model="currentTab"
:tabs="tabs" :tabs="tabs"
></header-custom> ></header-custom>
<calendar-custom
v-model="timeRangeType"
:time-range-options="timeRangeOptions"
:date-range.sync="dateRange"
:date-format="dateFormat"
@time-range-change="handleTimeRangeChange"
@date-range-change="handleDateRangeChange"
/>
</div>
<div class="content-area"> <div class="content-area">
<!-- 2. KPI 核心指标 --> <!-- 2. KPI 核心指标 -->
<div class="top-content"> <div class="top-content">
...@@ -188,16 +198,19 @@ ...@@ -188,16 +198,19 @@
<script> <script>
import HeaderCustom from '../strategyCentre/compoments/headerCustom.vue'; import HeaderCustom from '../strategyCentre/compoments/headerCustom.vue';
import SelectCustom from '../strategyCentre/compoments/selectCustom.vue'; import SelectCustom from '../strategyCentre/compoments/selectCustom.vue';
import calendarCustom from '../strategyCentre/compoments/clendarCustom.vue';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import { getBIMatterList,getStrategyTotal,getStrategyTypeDist,getStrategyOnlineDist,getMonitorList, getMonitorTypeDictList } from "@/api/earlyWarningManager"; import { getBIMatterList,getStrategyTotal,getStrategyTypeDist,getStrategyOnlineDist,getMonitorList, getMonitorTypeDictList } from "@/api/earlyWarningManager";
import { Util, deepClone } from "@/common/util"; import { Util, deepClone } from "@/common/util";
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import log from '../../../libs/util.log';
export default { export default {
name: 'strategyAnalysis', name: 'strategyAnalysis',
components: { components: {
HeaderCustom, HeaderCustom,
SelectCustom SelectCustom,
calendarCustom
}, },
data() { data() {
return { return {
...@@ -205,25 +218,21 @@ export default { ...@@ -205,25 +218,21 @@ export default {
tabs: [ tabs: [
{label:'延保',value:1}, {label:'延保',value:1},
], ],
// KPI 指标数据列表 // 时间范围类型
kpiList: [ timeRangeType: { label: '周', value: 1 },
{ timeRangeOptions: [
label: '策略总数', { label: '周', value: 1 },
value: 3456, { label: '月', value: 2 },
unit: '个', { label: '自定义', value: 4 }
subLabel: '本月策略总数',
subValue: '200个',
trendClass: 'trend-up'
},
{
label: '门店总数',
value: 567,
unit: '家',
subLabel: '本月门店总数',
subValue: '200个',
trendClass: 'trend-up'
}
], ],
// 日期范围
dateRange: {
startDate: null,
endDate: null
},
dateFormat: 'YYYY-MM-DD', // 日期格式化模式
// KPI 指标数据列表
kpiList: [],
operatorFilter: 'all', operatorFilter: 'all',
myChart: null, myChart: null,
// 日期范围 // 日期范围
...@@ -652,6 +661,7 @@ export default { ...@@ -652,6 +661,7 @@ export default {
value: item.value !== undefined ? item.value : item.label value: item.value !== undefined ? item.value : item.label
}; };
// 这里可以触发数据更新逻辑 // 这里可以触发数据更新逻辑
this.getIndicatorTypeList();
console.log('选择指标类型:', item.label); console.log('选择指标类型:', item.label);
}, },
/** /**
...@@ -693,14 +703,32 @@ export default { ...@@ -693,14 +703,32 @@ export default {
const params = { const params = {
startDate: this.startDate, startDate: this.startDate,
endDate: this.endDate, endDate: this.endDate,
businessType: 1 businessType: this.currentTab.value
}; };
const res = await getStrategyTotal(params); // const res = await getStrategyTotal(params);
if (res && res.code === 200) { // if (res && res.code === 200) {
this.strategyTotalData = res.data; // this.strategyTotalData = res.data;
// 可以在这里处理返回的数据,更新页面显示 // // 可以在这里处理返回的数据,更新页面显示
console.log('策略总数数据:', this.strategyTotalData); // console.log('策略总数数据:', this.strategyTotalData);
// }
this.kpiList = [
{
label: '策略总数',
value: 3555,
unit: '个',
subLabel: '本月策略总数',
subValue: '200个',
trendClass: 'trend-up'
},
{
label: '门店总数',
value: 655,
unit: '家',
subLabel: '本月门店总数',
subValue: '200个',
trendClass: 'trend-up'
} }
];
} catch (error) { } catch (error) {
console.error('获取策略总数失败:', error); console.error('获取策略总数失败:', error);
} }
...@@ -757,6 +785,61 @@ export default { ...@@ -757,6 +785,61 @@ export default {
} catch (error) { } catch (error) {
console.error('获取线上运营分布失败:', error); console.error('获取线上运营分布失败:', error);
} }
},
/**
* 更新日期范围并刷新数据(公共方法)
*/
_updateDateRangeAndRefresh(dateRange) {
if (!dateRange) return;
this.dateRange = { ...dateRange };
// 组件已根据 dateFormat 返回格式化后的字符串,直接使用即可
// 保留类型判断以兼容可能的 Date 对象(当 dateFormat 未传递时)
this.startDate = dateRange.startDate
? (typeof dateRange.startDate === 'string'
? dateRange.startDate
: dayjs(dateRange.startDate).format('YYYY-MM-DD'))
: this.startDate;
this.endDate = dateRange.endDate
? (typeof dateRange.endDate === 'string'
? dateRange.endDate
: dayjs(dateRange.endDate).format('YYYY-MM-DD'))
: this.endDate;
// 重新获取数据
this.fetchStrategyTotal();
this.fetchStrategyTypeDist();
this.fetchStrategyOnlineDist();
},
/**
* 处理时间范围类型变化
*/
handleTimeRangeChange(type, dateRange) {
console.log('时间范围类型变化:', type, dateRange);
// 更新时间范围类型
if (typeof type === 'string') {
const option = this.timeRangeOptions.find(opt => opt.label === type);
if (option) {
this.timeRangeType = { label: option.label, value: option.value };
} else {
console.warn('未找到匹配的时间范围类型:', type);
}
} else if (typeof type === 'object' && type !== null) {
this.timeRangeType = type;
}
// 更新日期范围并刷新数据
this._updateDateRangeAndRefresh(dateRange);
},
/**
* 处理日期范围变化
*/
handleDateRangeChange(dateRange) {
console.log('日期范围变化:', dateRange);
this._updateDateRangeAndRefresh(dateRange);
} }
} }
}; };
...@@ -773,6 +856,13 @@ $bg-white: #fff; ...@@ -773,6 +856,13 @@ $bg-white: #fff;
overflow: visible; overflow: visible;
} }
.top-header-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #fff;
}
.content-area { .content-area {
min-height: 0; min-height: 0;
width: 100%; width: 100%;
...@@ -1002,6 +1092,7 @@ $bg-white: #fff; ...@@ -1002,6 +1092,7 @@ $bg-white: #fff;
word-break: break-all; word-break: break-all;
line-height: 1.5; line-height: 1.5;
padding: 0 10px; padding: 0 10px;
color: #2A58AD;
} }
.tool-left { .tool-left {
......
...@@ -51,6 +51,29 @@ const DateUtils = { ...@@ -51,6 +51,29 @@ const DateUtils = {
return `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
}, },
// 根据格式字符串格式化日期
formatDateByPattern(date, pattern = 'YYYY-MM-DD') {
if (!date) return '';
const d = new Date(date);
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
const hours = String(d.getHours()).padStart(2, '0');
const minutes = String(d.getMinutes()).padStart(2, '0');
const seconds = String(d.getSeconds()).padStart(2, '0');
// 支持的格式模式
let formatted = pattern
.replace(/YYYY/g, year)
.replace(/MM/g, month)
.replace(/DD/g, day)
.replace(/HH/g, hours)
.replace(/mm/g, minutes)
.replace(/ss/g, seconds);
return formatted;
},
// 重置时间为当天的开始(00:00:00) // 重置时间为当天的开始(00:00:00)
resetToStartOfDay(date) { resetToStartOfDay(date) {
const d = new Date(date); const d = new Date(date);
...@@ -109,12 +132,18 @@ const DateUtils = { ...@@ -109,12 +132,18 @@ const DateUtils = {
// 日期范围策略配置 // 日期范围策略配置
const DateRangeStrategies = { const DateRangeStrategies = {
'周': { '周': {
// 初始化:当前周(周一到当前时间) // 初始化:上一周(上一周的周一到周日)
init(now) { init(now) {
const monday = DateUtils.getCurrentWeekMonday(now); const currentWeekMonday = DateUtils.getCurrentWeekMonday(now);
// 获取上一周的周一(当前周周一减去7天)
const lastWeekMonday = new Date(currentWeekMonday);
lastWeekMonday.setDate(currentWeekMonday.getDate() - 7);
const prevWeekMonday = DateUtils.resetToStartOfDay(lastWeekMonday);
// 获取上一周的周日
const prevWeekSunday = DateUtils.getWeekSunday(prevWeekMonday);
return { return {
startDate: monday, startDate: prevWeekMonday,
endDate: new Date(now) endDate: prevWeekSunday
}; };
}, },
...@@ -155,11 +184,12 @@ const DateRangeStrategies = { ...@@ -155,11 +184,12 @@ const DateRangeStrategies = {
}, },
'月': { '月': {
// 初始化:当前月(1号到当前时间) // 初始化:上一月(上一月的1号到上一月的最后一天)
init(now) { init(now) {
const prevMonth = DateUtils.getPrevMonth(now);
return { return {
startDate: DateUtils.getMonthFirstDay(now), startDate: DateUtils.getMonthFirstDay(prevMonth),
endDate: new Date(now) endDate: DateUtils.getMonthLastDay(prevMonth)
}; };
}, },
...@@ -261,6 +291,10 @@ export default { ...@@ -261,6 +291,10 @@ export default {
startDate: null, startDate: null,
endDate: null endDate: null
}) })
},
dateFormat: {
type: String,
default: null
} }
}, },
data() { data() {
...@@ -359,7 +393,27 @@ export default { ...@@ -359,7 +393,27 @@ export default {
this.initDateRange(); this.initDateRange();
// emit 对象格式,与 value prop 类型一致 // emit 对象格式,与 value prop 类型一致
this.$emit('input', { label: selectedOption.label, value: selectedOption.value }); this.$emit('input', { label: selectedOption.label, value: selectedOption.value });
this.$emit('time-range-change', timeRangeLabel, { ...this.internalDateRange });
// 根据 dateFormat 格式化日期范围
let formattedDateRange;
if (this.dateFormat && this.dateFormat.trim() !== '') {
formattedDateRange = {
startDate: this.internalDateRange.startDate
? DateUtils.formatDateByPattern(this.internalDateRange.startDate, this.dateFormat)
: null,
endDate: this.internalDateRange.endDate
? DateUtils.formatDateByPattern(this.internalDateRange.endDate, this.dateFormat)
: null
};
} else {
// 如果没有指定格式化模式,返回 Date 对象
formattedDateRange = {
startDate: this.internalDateRange.startDate ? new Date(this.internalDateRange.startDate) : null,
endDate: this.internalDateRange.endDate ? new Date(this.internalDateRange.endDate) : null
};
}
this.$emit('time-range-change', timeRangeLabel, formattedDateRange);
}, },
// 初始化日期范围 // 初始化日期范围
...@@ -393,10 +447,26 @@ export default { ...@@ -393,10 +447,26 @@ export default {
// 通知父组件日期范围变化 // 通知父组件日期范围变化
notifyDateRangeChange() { notifyDateRangeChange() {
const dateRange = { let dateRange;
// 如果指定了格式化模式,则返回格式化后的字符串
if (this.dateFormat && this.dateFormat.trim() !== '') {
dateRange = {
startDate: this.internalDateRange.startDate
? DateUtils.formatDateByPattern(this.internalDateRange.startDate, this.dateFormat)
: null,
endDate: this.internalDateRange.endDate
? DateUtils.formatDateByPattern(this.internalDateRange.endDate, this.dateFormat)
: null
};
} else {
// 如果没有指定格式化模式,返回 Date 对象
dateRange = {
startDate: this.internalDateRange.startDate ? new Date(this.internalDateRange.startDate) : null, startDate: this.internalDateRange.startDate ? new Date(this.internalDateRange.startDate) : null,
endDate: this.internalDateRange.endDate ? new Date(this.internalDateRange.endDate) : null endDate: this.internalDateRange.endDate ? new Date(this.internalDateRange.endDate) : null
}; };
}
this.$emit('date-range-change', dateRange); this.$emit('date-range-change', dateRange);
this.$emit('update:dateRange', dateRange); this.$emit('update:dateRange', dateRange);
}, },
......
<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" placement="bottom" popper-class="dark-tooltip" :disabled="!cardData.name"> <el-tooltip effect="dark" placement="bottom" popper-class="dark-tooltip" :disabled="!cardData.storeName">
<div slot="content" style="width:236px;line-height:1.6;word-break:break-all;">{{ cardData.name }}</div> <div slot="content" style="width:236px;line-height:1.6;word-break:break-all;">{{ cardData.storeName }}</div>
<div class="company-name">{{ cardData.name }}</div> <div class="company-name">{{ cardData.storeName }}</div>
</el-tooltip> </el-tooltip>
<el-checkbox @change="handleCheckboxChange" v-model="cardData.checked" class="card-checkbox"></el-checkbox> <el-checkbox @change="handleCheckboxChange" v-model="cardData.checked" class="card-checkbox"></el-checkbox>
</div> </div>
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
<div class="card-body"> <div class="card-body">
<div class="row-item"> <div class="row-item">
<span class="label">主营品牌:</span> <span class="label">主营品牌:</span>
<el-tooltip effect="dark" placement="top" popper-class="dark-tooltip" :disabled="!cardData.brand"> <el-tooltip effect="dark" placement="top" popper-class="dark-tooltip" :disabled="!cardData.mainBrands">
<div slot="content" style="max-width:236px;line-height:1.6;word-break:break-all;">{{ cardData.brand }}</div> <div slot="content" style="max-width:236px;line-height:1.6;word-break:break-all;">{{ cardData.mainBrands }}</div>
<span class="val">{{ cardData.brand }}</span> <span class="val">{{ cardData.mainBrands }}</span>
</el-tooltip> </el-tooltip>
</div> </div>
<div class="row-item"> <div class="row-item">
...@@ -25,28 +25,24 @@ ...@@ -25,28 +25,24 @@
</div> </div>
<div class="row-item"> <div class="row-item">
<span class="label">区域运营:</span> <span class="label">区域运营:</span>
<el-tooltip v-if="cardData.regionOps" effect="dark" placement="top" popper-class="dark-tooltip"> <el-tooltip v-if="cardData.regionalOperators" effect="dark" placement="top" popper-class="dark-tooltip">
<div slot="content" style="max-width:236px;line-height:1.6;">{{ cardData.regionOps }}</div> <div slot="content" style="max-width:236px;line-height:1.6;">{{ cardData.regionalOperators }}</div>
<span class="val">{{ cardData.regionOps }}</span> <span class="val">{{ cardData.regionalOperators }}</span>
</el-tooltip> </el-tooltip>
</div> </div>
<!-- 预警标签组 --> <!-- 预警标签组 -->
<div v-if="cardData.alertCount" class="alert-group"> <div v-if="cardData.warningSummary && cardData.warningSummary.length > 0" class="alert-group">
<div v-if="cardData.bottomAlert" class="alert-tag red"> <div v-for="(item, index) in cardData.warningSummary" :key="index" :class="['alert-tag', index === 0 ? 'red' : 'orange']">
<img src="@/assets/strategy/icon-strategy-type01.png" alt="" class="icon-img"> <img :src="getAlertIcon(index)" alt="" class="icon-img">
<span>兜底指标:{{ cardData.bottomAlert }}</span> <span>{{ getAlertLabel(index) }}{{ item }}</span>
</div>
<div v-if="cardData.ecoAlert" class="alert-tag orange">
<img src="@/assets/strategy/icon-strategy-type02.png" alt="" class="icon-img">
<span>生态预警:{{ cardData.ecoAlert }}</span>
</div> </div>
</div> </div>
</div> </div>
<div class="card-foot"> <div class="card-foot">
<span class="info">共{{ cardData.alertCount }}项预警</span> <span class="info">共{{ cardData.warningTotalCount }}项预警</span>
<span class="link">查看详情 <img src="@/assets/strategy/icon-strategy-arrow-r.png" alt="" srcset="" class="icon-arrow"></span> <span class="link" @click="handleViewDetail">查看详情 <img src="@/assets/strategy/icon-strategy-arrow-r.png" alt="" srcset="" class="icon-arrow"></span>
</div> </div>
</div> </div>
</template> </template>
...@@ -71,6 +67,27 @@ export default { ...@@ -71,6 +67,27 @@ export default {
handleCheckboxChange() { handleCheckboxChange() {
// 触发复选框变化事件,传递卡片数据和索引 // 触发复选框变化事件,传递卡片数据和索引
this.$emit('checkbox-change', this.cardData, this.index); this.$emit('checkbox-change', this.cardData, this.index);
},
handleViewDetail() {
// 获取 merchantNo 并跳转到门店看板页面
if (this.cardData.merchantNo) {
this.$router.push({
path: '/storeSignboard',
query: {
merchantNo: this.cardData.merchantNo
}
});
}
},
// 获取预警图标
getAlertIcon(index) {
return index === 0
? require('@/assets/strategy/icon-strategy-type01.png')
: require('@/assets/strategy/icon-strategy-type02.png');
},
// 获取预警标签文本
getAlertLabel(index) {
return index === 0 ? '兜底指标:' : '生态预警:';
} }
} }
}; };
......
...@@ -81,6 +81,13 @@ export default { ...@@ -81,6 +81,13 @@ export default {
}, },
// 在你的Vue组件的mounted钩子中添加事件监听 // 在你的Vue组件的mounted钩子中添加事件监听
mounted () { mounted () {
// 获取路由参数 merchantNo
const merchantNo = this.$route.query.merchantNo;
if (merchantNo) {
console.log('接收到的 merchantNo:', merchantNo);
// 可以根据 merchantNo 更新 merchantInfo 或进行其他操作
// this.merchantInfo.merchantId = merchantNo;
}
history.pushState(null, null, document.URL) history.pushState(null, null, document.URL)
window.addEventListener('popstate', this.preventBack) window.addEventListener('popstate', this.preventBack)
}, },
......
...@@ -94,9 +94,10 @@ export default { ...@@ -94,9 +94,10 @@ export default {
}, },
//转入职 //转入职
handleWorking(data) { handleWorking(data) {
delete data.id let obj = deepClone({ ...data })
delete obj.id
this.$refs.entryInfo.handleEntry?.(true) this.$refs.entryInfo.handleEntry?.(true)
this.$refs.entryInfo.isEntryForm = deepClone({ ...data, skillTagIds: [] }) this.$refs.entryInfo.isEntryForm = deepClone({ ...obj, skillTagIds: [] })
}, },
//转试岗 //转试岗
handleTrial(data) { handleTrial(data) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!