|
@@ -27,22 +27,17 @@
|
|
align="right"
|
|
align="right"
|
|
class="date-picker"
|
|
class="date-picker"
|
|
></el-date-picker>
|
|
></el-date-picker>
|
|
- <article v-if="temperatureData || humidityData">
|
|
|
|
|
|
+ <article v-if="temperature || humidity">
|
|
<chart-a
|
|
<chart-a
|
|
- v-if="temperatureData"
|
|
|
|
- :data="temperatureData"
|
|
|
|
- :time="temperatureTime"
|
|
|
|
|
|
+ :option="temperature"
|
|
class="charts"
|
|
class="charts"
|
|
></chart-a>
|
|
></chart-a>
|
|
- <p v-else class="hint">当前时间段无温度数据...</p>
|
|
|
|
<chart-b
|
|
<chart-b
|
|
- v-if="humidityData"
|
|
|
|
- :data="humidityData"
|
|
|
|
- :time="humidityTime"
|
|
|
|
|
|
+ :option="humidity"
|
|
class="charts"
|
|
class="charts"
|
|
></chart-b>
|
|
></chart-b>
|
|
- <p v-else class="hint">当前时间段无温度数据...</p>
|
|
|
|
</article>
|
|
</article>
|
|
|
|
+ <p v-else class="hint">当前时间段无温度数据...</p>
|
|
</section>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -113,11 +108,8 @@ export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
mainInfo: {},
|
|
mainInfo: {},
|
|
- temperatureData: [],
|
|
|
|
- temperatureTime: [],
|
|
|
|
- humidityData: [],
|
|
|
|
- humidityTime: [],
|
|
|
|
-
|
|
|
|
|
|
+ temperature: {},
|
|
|
|
+ humidity: {},
|
|
pickerOptions,
|
|
pickerOptions,
|
|
value2: null,
|
|
value2: null,
|
|
SDate: Math.floor((new Date().getTime() - 3600 * 1000 * 6) / 1000), // 默认最近六小时
|
|
SDate: Math.floor((new Date().getTime() - 3600 * 1000 * 6) / 1000), // 默认最近六小时
|
|
@@ -159,20 +151,28 @@ export default {
|
|
},
|
|
},
|
|
// data: { deviceId: 666, type },
|
|
// data: { deviceId: 666, type },
|
|
success: res => {
|
|
success: res => {
|
|
- console.log(res);
|
|
|
|
|
|
+ let temperature = {};
|
|
|
|
+ let humidity = {}
|
|
console.log(type);
|
|
console.log(type);
|
|
if (type == 1) {
|
|
if (type == 1) {
|
|
res.content.forEach(item => {
|
|
res.content.forEach(item => {
|
|
- this.temperatureData.push(item.value);
|
|
|
|
- this.temperatureTime.push(item.created);
|
|
|
|
|
|
+ // 会有不止一组温度数据, 通过 channelNo 来判断 有几个不同的 channelNo 就渲染几条折线
|
|
|
|
+ if(!temperature[item.channelNo]) {
|
|
|
|
+ temperature[item.channelNo] = {data: [], time: []}
|
|
|
|
+ }
|
|
|
|
+ temperature[item.channelNo].data.push(item.value)
|
|
|
|
+ temperature[item.channelNo].time.push(item.created)
|
|
});
|
|
});
|
|
- console.log(this.temperature);
|
|
|
|
|
|
+ this.temperature = temperature
|
|
} else if (type == 2) {
|
|
} else if (type == 2) {
|
|
res.content.forEach(item => {
|
|
res.content.forEach(item => {
|
|
- this.humidityData.push(item.value);
|
|
|
|
- this.humidityTime.push(item.created);
|
|
|
|
|
|
+ if(!humidity[item.channelNo]) {
|
|
|
|
+ humidity[item.channelNo] = {data: [], time: []}
|
|
|
|
+ }
|
|
|
|
+ humidity[item.channelNo].data.push(item.value)
|
|
|
|
+ humidity[item.channelNo].time.push(item.created)
|
|
});
|
|
});
|
|
- console.log(this.temperature);
|
|
|
|
|
|
+ this.humidity = humidity
|
|
}
|
|
}
|
|
},
|
|
},
|
|
fail: err => {
|
|
fail: err => {
|