false data
This commit is contained in:
parent
76c555e113
commit
c795f3c4eb
@ -86,7 +86,7 @@
|
||||
// import SZJCChart from "./SZJCChart";
|
||||
import { getData, URL_MAP } from "@/utils/http";
|
||||
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";
|
||||
export default {
|
||||
components: {
|
||||
@ -251,30 +251,20 @@ export default {
|
||||
async getData() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const params = {
|
||||
timestamp__gte: this.startTime.toDate().getTime(),
|
||||
timestamp__lte: this.endTime.toDate().getTime(),
|
||||
device_id__in: this.selectedKeys,
|
||||
};
|
||||
if (this.currentType === "table") {
|
||||
params.page = this.pagination.current;
|
||||
}
|
||||
let count = 10
|
||||
// const params = {
|
||||
// timestamp__gte: this.startTime.toDate().getTime(),
|
||||
// timestamp__lte: this.endTime.toDate().getTime(),
|
||||
// device_id__in: this.selectedKeys,
|
||||
// };
|
||||
|
||||
if (this.currentType === "chart") {
|
||||
params.page = 0;
|
||||
params.page_size = 1e13;
|
||||
count = 300;
|
||||
}
|
||||
let data = await getData(URL_MAP.WATER_LIST, params);
|
||||
|
||||
if (data.total === 0) {
|
||||
this.waterData = [];
|
||||
} else {
|
||||
this.waterData = processWater(
|
||||
data.data,
|
||||
this.sensorList.map((s) => s.param_key)
|
||||
);
|
||||
}
|
||||
|
||||
this.pagination.total = data.total;
|
||||
// let data = await getData(URL_MAP.WATER_LIST, params);
|
||||
let data = generateWaterData(this.sensorList.map((s) => s.param_key), count)
|
||||
|
||||
this.pagination.total = 300;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
this.waterData = [];
|
||||
|
@ -27,4 +27,20 @@ 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