时间取值修改
This commit is contained in:
@@ -38,11 +38,11 @@ import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number]},
|
||||
h: { type: [String, Number]},
|
||||
width: { type: [String, Number]},
|
||||
height: { type: [String, Number]},
|
||||
timeKey: { type: [String, Number]},
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
@@ -61,11 +61,10 @@ const timeCacheStore = useTimeCacheStore()
|
||||
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
||||
headerHeight.value = height
|
||||
|
||||
// 如果有传入 datePicker 的值
|
||||
if (datePickerValue) {
|
||||
// 更新表格参数
|
||||
tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1]
|
||||
if (datePickerValue && datePickerValue.timeValue) {
|
||||
// 更新时间参数
|
||||
tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
|
||||
tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +214,7 @@ const fullscreen = computed(() => {
|
||||
// }
|
||||
// })
|
||||
|
||||
var yAxisData=['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
|
||||
var yAxisData = ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
|
||||
|
||||
const echartList = ref({
|
||||
options: {
|
||||
@@ -231,7 +230,7 @@ const echartList = ref({
|
||||
borderWidth: 0,
|
||||
formatter: function (params: any) {
|
||||
console.log(params, '33344')
|
||||
var yIndex = params.value[1]; //获取y轴索引
|
||||
var yIndex = params.value[1] //获取y轴索引
|
||||
var tips = ''
|
||||
// tips += '指标类型: ' + params.name + '</br>'
|
||||
tips += '指标类型: ' + yAxisData[yIndex] + '</br>'
|
||||
@@ -297,7 +296,7 @@ const echartList = ref({
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30,
|
||||
// data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡'],
|
||||
data:yAxisData,
|
||||
data: yAxisData,
|
||||
nameTextStyle: {
|
||||
color: '#111'
|
||||
},
|
||||
@@ -363,7 +362,7 @@ const echartList = ref({
|
||||
name: '0-20%',
|
||||
data: [
|
||||
// [xIndex, yIndex, value]
|
||||
[0, 0, 5], // 闪变 - 0-20%
|
||||
[0, 0, 5], // 闪变 - 0-20%
|
||||
[0, 1, 10], // 谐波电压 - 0-20%
|
||||
[0, 2, 8], // 谐波电流 - 0-20%
|
||||
[0, 3, 15], // 电压偏差 - 0-20%
|
||||
@@ -393,10 +392,10 @@ const echartList = ref({
|
||||
type: 'bar3D',
|
||||
name: '20-40%',
|
||||
// data: chartData.map(function (item) {
|
||||
// return {
|
||||
// value: [item[1], item[0], item[2]]
|
||||
// };
|
||||
// }),
|
||||
// return {
|
||||
// value: [item[1], item[0], item[2]]
|
||||
// };
|
||||
// }),
|
||||
data: [
|
||||
[1, 0, 10], // 闪变 - 20-40%
|
||||
[1, 1, 20], // 谐波电压 - 20-40%
|
||||
@@ -714,21 +713,8 @@ const tableStore: any = new TableStore({
|
||||
showPage: false,
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
// 尝试从缓存获取时间值
|
||||
let beginTime, endTime
|
||||
|
||||
if (fullscreen.value) {
|
||||
const cached = timeCacheStore.getCache(route.path)
|
||||
if (cached && cached.timeValue) {
|
||||
beginTime = cached.timeValue[0]
|
||||
endTime = cached.timeValue[1]
|
||||
}
|
||||
}
|
||||
|
||||
// 如果缓存中没有则使用默认值
|
||||
tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
|
||||
|
||||
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.data = []
|
||||
@@ -751,12 +737,17 @@ watch(
|
||||
}
|
||||
)
|
||||
watch(
|
||||
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
|
||||
() => prop.timeValue,
|
||||
(newVal, oldVal) => {
|
||||
tableStore.index()
|
||||
// 当外部时间值变化时,更新表格的时间参数
|
||||
if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) {
|
||||
tableStore.table.params.searchBeginTime = newVal[0]
|
||||
tableStore.table.params.searchEndTime = newVal[1]
|
||||
tableStore.index()
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true // 若 timeValue 是对象/数组,需开启深度监听
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user