whyczyk
2021-03-22 fc74998431982dc1385d2930adcf339cbf15ffd6
模块定时请求提交
6个文件已修改
363 ■■■■ 已修改文件
src/components/charts/abeamProChart.vue 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/charts/imgPieChart.vue 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/charts/latticeBar.vue 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/charts/powerChart.vue 122 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/charts/triangleBarChart.vue 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/exhibition.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/charts/abeamProChart.vue
@@ -43,7 +43,7 @@
        let dataColor = posData.color;
        let bgColor = posData.bgColor;
        let yData = posData.yData;
        let radius = (this.$refs.chart.clientHeight / 3 - 7) > 0 ? this.$refs.chart.clientHeight / 3 - 7 : 0;
        let radius = (this.$refs.chart.clientHeight / 4 - 7) > 0 ? this.$refs.chart.clientHeight / 4 - 7 : 0;
        let data = posData.data;
        let max = posData[0];
        data.map(item => {
@@ -173,30 +173,36 @@
          this.$options.chartData = sendData;
          this.organizeData(sendData)
        } else {
          let userId = localStorage.getItem('userId');
          let params = {
            userId: userId
          }
          batteryStatus(params).then((res) => {
            if (res.data.code == 1) {
              let optionData = {
                yData: [],
                color: ['#f58881', '#b4d465', '#ffcb29'],
                bgColor: ['rgba(245,136,129,0.35)', 'rgba(255,255,255,0.35)', 'rgba(255,203,41,0.35)'],
                data: []
              }
              let resData = res.data.data;
              for (let key in resData) {
                optionData.yData.push(key);
                optionData.data.push(resData[key]);
              }
              this.$options.chartData = optionData;
              this.organizeData(optionData)
            }
          }).catch((err) => {
            console.log(err)
          });
          this.postData()
          setInterval(() => {
            this.postData()
          }, 3000)
        }
      },
      postData() {
        let userId = localStorage.getItem('userId');
        let params = {
          userId: userId
        }
        batteryStatus(params).then((res) => {
          if (res.data.code == 1) {
            let optionData = {
              yData: [],
              color: ['#f58881', '#b4d465', '#ffcb29'],
              bgColor: ['rgba(245,136,129,0.35)', 'rgba(255,255,255,0.35)', 'rgba(255,203,41,0.35)'],
              data: []
            }
            let resData = res.data.data;
            for (let key in resData) {
              optionData.yData.push(key);
              optionData.data.push(resData[key]);
            }
            this.$options.chartData = optionData;
            this.organizeData(optionData)
          }
        }).catch((err) => {
          console.log(err)
        });
      },
      resize() {
        setTimeout(() => {
@@ -230,6 +236,6 @@
  .flexCon .con {
    width: 100%;
    height: 70%;
    height: 80%;
  }
</style>
src/components/charts/imgPieChart.vue
@@ -168,30 +168,36 @@
          this.$options.chartData = sendData;
          this.organizeData(sendData)
        } else {
          let userId = localStorage.getItem('userId');
          let params = {
            userId: userId
          }
          rectifier(params).then((res) => {
            if (res.data.code == 1) {
              let optionData = {
                data: []
              }
              let resData = res.data.data;
              for (let key in resData) {
                let obj = {};
                obj.name = key;
                obj.value = resData[key];
                optionData.data.push(obj)
              }
              this.$options.chartData = optionData;
              this.organizeData(optionData)
            }
          }).catch((err) => {
            console.log(err)
          });
          this.postData()
          setInterval(() => {
            this.postData()
          }, 3000)
        }
      },
      postData() {
        let userId = localStorage.getItem('userId');
        let params = {
          userId: userId
        }
        rectifier(params).then((res) => {
          if (res.data.code == 1) {
            let optionData = {
              data: []
            }
            let resData = res.data.data;
            for (let key in resData) {
              let obj = {};
              obj.name = key;
              obj.value = resData[key];
              optionData.data.push(obj)
            }
            this.$options.chartData = optionData;
            this.organizeData(optionData)
          }
        }).catch((err) => {
          console.log(err)
        });
      },
      resize() {
        setTimeout(() => {
          this.$options.chart.resize();
src/components/charts/latticeBar.vue
@@ -172,48 +172,54 @@
          this.$options.chartData = sendData;
          this.organizeData(sendData)
        } else {
          let userId = localStorage.getItem('userId');
          let params = {
            userId: userId
          }
          chargeAnalysis(params).then((res) => {
            if (res.data.code == 1) {
              let optionData = {
                xData: [],
                series: [{
                  name: '放电',
                  data: [],
                  color: '#90ec7d'
                }, {
                  name: '充电',
                  data: [],
                  color: '#ff6b6b'
                }]
              }
              let resData = res.data.data;
              for (let key in resData.reCharge) {
                if (typeof resData.reCharge[key] == 'string') {
                  optionData.series[0].data.push(Number(resData.reCharge[key].split('%')[0]))
                } else {
                  optionData.series[0].data.push(resData.reCharge[key])
                }
              }
              for (let key in resData.disCharge) {
                optionData.xData.push(key)
                if (typeof resData.disCharge[key] == 'string') {
                  optionData.series[1].data.push(Number(resData.disCharge[key].split('%')[0]))
                } else {
                  optionData.series[1].data.push(resData.disCharge[key])
                }
              }
              this.$options.chartData = optionData;
              this.organizeData(optionData)
            }
          }).catch((err) => {
            console.log(err)
          });
          this.postData()
          setInterval(() => {
            this.postData()
          }, 3000)
        }
      },
      postData() {
        let userId = localStorage.getItem('userId');
        let params = {
          userId: userId
        }
        chargeAnalysis(params).then((res) => {
          if (res.data.code == 1) {
            let optionData = {
              xData: [],
              series: [{
                name: '放电',
                data: [],
                color: '#90ec7d'
              }, {
                name: '充电',
                data: [],
                color: '#ff6b6b'
              }]
            }
            let resData = res.data.data;
            for (let key in resData.reCharge) {
              if (typeof resData.reCharge[key] == 'string') {
                optionData.series[0].data.push(Number(resData.reCharge[key].split('%')[0]))
              } else {
                optionData.series[0].data.push(resData.reCharge[key])
              }
            }
            for (let key in resData.disCharge) {
              optionData.xData.push(key)
              if (typeof resData.disCharge[key] == 'string') {
                optionData.series[1].data.push(Number(resData.disCharge[key].split('%')[0]))
              } else {
                optionData.series[1].data.push(resData.disCharge[key])
              }
            }
            this.$options.chartData = optionData;
            this.organizeData(optionData)
          }
        }).catch((err) => {
          console.log(err)
        });
      },
      resize() {
        setTimeout(() => {
          this.$options.chart.resize();
src/components/charts/powerChart.vue
@@ -46,68 +46,74 @@
              chart.resize();
            })
          } else {
            let userId = localStorage.getItem('userId');
            let params = {
              userId: userId
            }
            powerAlarmStatus(params).then((res) => {
              if (res.data.code == 1) {
                let optionData = [{
                  title: '',
                  data: 0,
                  unit: '',
                  color: '#37a9b3',
                }, {
                  title: '',
                  data: 0,
                  unit: '',
                  color: '#f3535f'
                }, {
                  title: '',
                  data: 0,
                  unit: '',
                  color: '#ff8b00'
                }, {
                  title: '',
                  data: 0,
                  unit: '',
                  color: '#757ffb'
                }, {
                  title: '',
                  data: 0,
                  unit: '',
                  color: '#4ba0d9'
                }, {
                  title: '',
                  data: 0,
                  unit: '',
                  color: '#7fc57c'
                }]
                let index = 0;
                let resData = res.data.data;
                for (let key in resData) {
                  optionData[index].title = key;
                  if (typeof resData[key] == 'string') {
                    optionData[index].data = Number(resData[key].split('%')[0]);
                    optionData[index].unit = '%';
                  } else {
                    optionData[index].data = resData[key];
                  }
                  index++;
                }
                optionData.map((item, i) => {
                  let chart = this.$refs[`prossPieChart${i}`];
                  chart.setData(item);
                  chart.resize();
                })
              }
            }).catch((err) => {
              console.log(err)
            });
            this.postData()
            setInterval(() => {
              this.postData()
            }, 3000)
          }
        })
      },
      postData() {
        let userId = localStorage.getItem('userId');
        let params = {
          userId: userId
        }
        powerAlarmStatus(params).then((res) => {
          if (res.data.code == 1) {
            let optionData = [{
              title: '',
              data: 0,
              unit: '',
              color: '#37a9b3',
            }, {
              title: '',
              data: 0,
              unit: '',
              color: '#f3535f'
            }, {
              title: '',
              data: 0,
              unit: '',
              color: '#ff8b00'
            }, {
              title: '',
              data: 0,
              unit: '',
              color: '#757ffb'
            }, {
              title: '',
              data: 0,
              unit: '',
              color: '#4ba0d9'
            }, {
              title: '',
              data: 0,
              unit: '',
              color: '#7fc57c'
            }]
            let index = 0;
            let resData = res.data.data;
            for (let key in resData) {
              optionData[index].title = key;
              if (typeof resData[key] == 'string') {
                optionData[index].data = Number(resData[key].split('%')[0]);
                optionData[index].unit = '%';
              } else {
                optionData[index].data = resData[key];
              }
              index++;
            }
            optionData.map((item, i) => {
              let chart = this.$refs[`prossPieChart${i}`];
              chart.setData(item);
              chart.resize();
            })
          }
        }).catch((err) => {
          console.log(err)
        });
      },
      resize() {
        this.$refs.prossPieChart0.resize();
        this.$refs.prossPieChart1.resize();
src/components/charts/triangleBarChart.vue
@@ -172,29 +172,35 @@
          this.$options.chartData = sendData;
          this.organizeData(sendData)
        } else {
          let userId = localStorage.getItem('userId');
          let params = {
            userId: userId
          }
          batteryGroup(params).then((res) => {
            if (res.data.code == 1) {
              let optionData = {
                xData: [],
                data: []
              }
              let resData = res.data.data;
              for (let key in resData) {
                optionData.xData.push(key);
                optionData.data.push(resData[key]);
              }
              this.$options.chartData = optionData;
              this.organizeData(optionData)
            }
          }).catch((err) => {
            console.log(err)
          });
          this.postData()
          setInterval(() => {
            this.postData()
          }, 3000)
        }
      },
      postData() {
        let userId = localStorage.getItem('userId');
        let params = {
          userId: userId
        }
        batteryGroup(params).then((res) => {
          if (res.data.code == 1) {
            let optionData = {
              xData: [],
              data: []
            }
            let resData = res.data.data;
            for (let key in resData) {
              optionData.xData.push(key);
              optionData.data.push(resData[key]);
            }
            this.$options.chartData = optionData;
            this.organizeData(optionData)
          }
        }).catch((err) => {
          console.log(err)
        });
      },
      resize() {
        setTimeout(() => {
          this.$options.chart.resize();
src/pages/exhibition.vue
@@ -58,7 +58,6 @@
      })
    },
    methods: {
      // 加载布局数据
      loadLayout() {
        let sendData = {