1.对接环境监测接口
2.开发环境监测-配置监测点位 2.修改监测中心多个时间筛选逻辑
This commit is contained in:
@@ -58,8 +58,9 @@
|
||||
placeholder="请选择日期类型"
|
||||
style="width: 100%; margin-bottom: 10px"
|
||||
:options="options2" />
|
||||
<a-date-picker
|
||||
<a-range-picker
|
||||
style="width: 100%; margin-bottom: 10px"
|
||||
@change="onChangeDate"
|
||||
v-model:value="dateValue"
|
||||
:picker="dateTypeValue" />
|
||||
<a-button type="primary" style="width: 100%; margin-bottom: 10px" @click="getSelect">
|
||||
@@ -105,7 +106,7 @@
|
||||
// 日期类型
|
||||
const dateTypeValue = ref<string | undefined>('month');
|
||||
// 时间
|
||||
const dateValue = ref<Dayjs | undefined>(dayjs());
|
||||
const dateValue = ref<[Dayjs, Dayjs] | undefined>([dayjs(), dayjs()]);
|
||||
|
||||
// 页面初始化参数
|
||||
const getOptionsList = async () => {
|
||||
@@ -122,6 +123,10 @@
|
||||
console.error('Failed to fetch options:', error);
|
||||
}
|
||||
options2.value = [
|
||||
{
|
||||
value: 'date',
|
||||
label: '日',
|
||||
},
|
||||
{
|
||||
value: 'month',
|
||||
label: '月',
|
||||
@@ -159,15 +164,55 @@
|
||||
}
|
||||
changeMode();
|
||||
};
|
||||
const startDate = ref<String>();
|
||||
const endDate = ref<String>();
|
||||
const onChangeDate = (val: RangeValue, dateStrings: any) => {
|
||||
if (dateStrings && dateStrings.length === 2) {
|
||||
dateValue.value = val;
|
||||
startDate.value = dateStrings[0];
|
||||
endDate.value = dateStrings[1];
|
||||
}
|
||||
};
|
||||
const getSelect = () => {
|
||||
const date = dateValue.value;
|
||||
let year = 0;
|
||||
let month = 0;
|
||||
if (date) {
|
||||
year = date.year();
|
||||
month = date.month() + 1;
|
||||
// const date = dateValue.value;
|
||||
// let year = 0;
|
||||
// let month = 0;
|
||||
// if (date) {
|
||||
// year = date.year();
|
||||
// month = date.month() + 1;
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
let startTime = '';
|
||||
let endTime = '';
|
||||
if (startDate.value && endDate.value) {
|
||||
if (dateTypeValue.value == 'month') {
|
||||
startTime = startDate.value + '-01';
|
||||
const [year, month] = endDate.value.split('-').map(Number);
|
||||
|
||||
// 创建下一个月的第一天
|
||||
const date = new Date(year, month, 1);
|
||||
|
||||
// 减去一天得到当月的最后一天
|
||||
// date.setDate(date.getDate() - 1);
|
||||
endTime = date.toISOString().split('T')[0];
|
||||
// endTime = endDate.value + '-01';
|
||||
} else if (dateTypeValue.value == 'year') {
|
||||
startTime = startDate.value + '-01-01';
|
||||
endTime = endDate.value + '-12-31';
|
||||
} else {
|
||||
startTime = startDate.value + '';
|
||||
endTime = endDate.value + '';
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
// 获取当天的时间
|
||||
const today = new Date();
|
||||
const year = today.getFullYear();
|
||||
const month = String(today.getMonth() + 1).padStart(2, '0'); // getMonth() 返回的月份是0-11
|
||||
const day = String(today.getDate()).padStart(2, '0');
|
||||
|
||||
startTime = year + '-' + month + '-' + day;
|
||||
endTime = year + '-' + month + '-' + day;
|
||||
}
|
||||
|
||||
// 图表数据
|
||||
@@ -180,9 +225,10 @@
|
||||
dateType: dateTypeValue.value == 'year' ? 0 : 1, //0 年 1月
|
||||
deviceInfoCodes: mode.value == '0' ? checkedKeys.value : [], // 设备需要传 device_info_code
|
||||
energyQueryType: mode.value, // 0 设备 1 节点
|
||||
month: month,
|
||||
|
||||
nodeIds: mode.value == '1' ? checkedKeys.value : [],
|
||||
year: year,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
})
|
||||
.then((res) => {
|
||||
let selectedValueName = '';
|
||||
@@ -209,9 +255,10 @@
|
||||
dateType: dateTypeValue.value == 'year' ? 0 : 1, //0 年 1月
|
||||
deviceInfoCodes: mode.value == '0' ? checkedKeys.value : [], // 设备需要传 device_info_code
|
||||
energyQueryType: mode.value, // 0 设备 1 节点
|
||||
month: month,
|
||||
|
||||
nodeIds: mode.value == '1' ? checkedKeys.value : [],
|
||||
year: year,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
})
|
||||
.then((res) => {
|
||||
pageData.analysisTableList = res.data.dataList;
|
||||
@@ -350,6 +397,7 @@
|
||||
treeLoading,
|
||||
changeEnergyType,
|
||||
shebei,
|
||||
onChangeDate,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user