false data
This commit is contained in:
parent
76c555e113
commit
c795f3c4eb
@ -86,7 +86,7 @@
|
|||||||
// import SZJCChart from "./SZJCChart";
|
// import SZJCChart from "./SZJCChart";
|
||||||
import { getData, URL_MAP } from "@/utils/http";
|
import { getData, URL_MAP } from "@/utils/http";
|
||||||
import Moment from "@/components/utils/moment.zh_cn";
|
import Moment from "@/components/utils/moment.zh_cn";
|
||||||
import { processWater } from "@/utils/water";
|
import { generateWaterData, processWater } from "@/utils/water";
|
||||||
import BaseIndexChart from "../charts/BaseIndexChart.vue";
|
import BaseIndexChart from "../charts/BaseIndexChart.vue";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -251,30 +251,20 @@ export default {
|
|||||||
async getData() {
|
async getData() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
try {
|
try {
|
||||||
const params = {
|
let count = 10
|
||||||
timestamp__gte: this.startTime.toDate().getTime(),
|
// const params = {
|
||||||
timestamp__lte: this.endTime.toDate().getTime(),
|
// timestamp__gte: this.startTime.toDate().getTime(),
|
||||||
device_id__in: this.selectedKeys,
|
// timestamp__lte: this.endTime.toDate().getTime(),
|
||||||
};
|
// device_id__in: this.selectedKeys,
|
||||||
if (this.currentType === "table") {
|
// };
|
||||||
params.page = this.pagination.current;
|
|
||||||
}
|
|
||||||
if (this.currentType === "chart") {
|
if (this.currentType === "chart") {
|
||||||
params.page = 0;
|
count = 300;
|
||||||
params.page_size = 1e13;
|
|
||||||
}
|
}
|
||||||
let data = await getData(URL_MAP.WATER_LIST, params);
|
// let data = await getData(URL_MAP.WATER_LIST, params);
|
||||||
|
let data = generateWaterData(this.sensorList.map((s) => s.param_key), count)
|
||||||
|
|
||||||
if (data.total === 0) {
|
this.pagination.total = 300;
|
||||||
this.waterData = [];
|
|
||||||
} else {
|
|
||||||
this.waterData = processWater(
|
|
||||||
data.data,
|
|
||||||
this.sensorList.map((s) => s.param_key)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pagination.total = data.total;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
this.waterData = [];
|
this.waterData = [];
|
||||||
|
@ -28,3 +28,19 @@ export function processTimeData(dataArr=[], start=new Date(), end=new Date(), st
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function generateWaterData(label, count) {
|
||||||
|
let data = []
|
||||||
|
for(let _ = 0; _< count; _ ++) {
|
||||||
|
let d = {}
|
||||||
|
label.forEach(key => {
|
||||||
|
d[key] = Math.random()
|
||||||
|
})
|
||||||
|
d.key = Math.round( Math.random() * 10000000 ).toString()
|
||||||
|
d['time_str'] = Moment().format('lll')
|
||||||
|
d['time'] = Moment().toDate()
|
||||||
|
data.push(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user