whychw
2020-09-27 dfafc9e73a912f76b20227eb8682d10468510548
U 对接电机历史数据
1个文件已修改
199 ■■■■ 已修改文件
src/views/motor/index.vue 199 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/motor/index.vue
@@ -302,16 +302,9 @@
              :categoryLen="categoryLen2"
              :show-zoom='true'
              :subtext="true"  trigger-on="mousemove"></line-chart-mul>
            <!-- <line-chart
              id="G_drawer_data"
              ref="G_drawer_data"
              title="电机加载试验数据归档" height="400"
              :max-size='true'
              :show-zoom='true'
              :subtext="true"  trigger-on="mousemove" ></line-chart> -->
          </div>
        </div>
        <div class="wrap_table" :class="{'fullScreen': isMaxSize2}">
        <!-- <div class="wrap_table" :class="{'fullScreen': isMaxSize2}">
          <div class="tool_bar clearfix">
            <i class="iconfont f_right" :class="{'icon-zuidahua': !isMaxSize2, 'icon-zuidahuahuanyuan': isMaxSize2}" @click="changeSize2"></i>
          </div>
@@ -341,7 +334,7 @@
              </el-table>
            </div>
          </div>
        </div>
        </div> -->
      </div>
    </el-drawer>
  </div>
@@ -819,14 +812,14 @@
    ,showControl () {
      this.control.show = true;
      // 曲线图
      /*let obj = this.formatAlarmList(r);
      /*let obj = this.formatData(r);
      let last_time = r[r.length - 1].record_time;
      this.categoryLen = obj.series.length;*/
      let list = [];
      let _obj = this.formatAlarmList([]);
      let _obj = this.formatData([]);
      this.categoryLen = _obj.series.length;
      console.log(_obj, '==obj');
      // console.log(_obj, '==obj');
      let last_time = '';
      this.$nextTick(() => {
@@ -841,7 +834,7 @@
              list.shift();
            }
            last_time = this.nowInfo.record_time;
            let obj = this.formatAlarmList(list);
            let obj = this.formatData(list);
            this.$refs['G_dialog_id'].setOption(obj);
          }
          this.timer_g_control.open();
@@ -914,102 +907,37 @@
    ,showData () {
      this.drawer_data.show = true;
      // TODO
      this.categoryLen2 = 4;
      this.$nextTick(() => {
        this.$refs['G_drawer_data'].setOption({
          xLabel: [20191010, 20191011, 20191012, 20191013, 20191014, 20191015, 20191016],
          series: [
            {
                name: '电压',
                unit: 'V',
                data: [120, 132, 101, 134, 90, 230, 210]
            },
            {
                unit: 'A',
                name: '电流',
                data: [220, 182, 191, 234, 290, 330, 310]
            },
            {
                name: '功率',
                unit: 'kW',
                data: [150, 232, 201, 154, 190, 330, 410]
            },
            {
                name: '转速',
                unit: 'rpm',
                data: [320, 332, 301, 334, 390, 330, 320]
            }
          ]
        });
      this.categoryLen2 = 5;
      this.getHisData(this.select_date).then((res) => {
        // console.log(res, 9999);
        this.$refs['G_drawer_data'].setOption(res);
      }).catch(e => {
        this.$refs['G_drawer_data'].setOption(this.formatData([]));
        console.warn(e);
      });
      /*this.$nextTick(() => {
        this.$refs['G_drawer_data'].setOption();
      });*/
    }
    ,changeSize1 () {
      this.isMaxSize1 = !this.isMaxSize1;
      console.log(this.$G.chartManage.get('G_drawer_data'), 63)
      this.$nextTick(() => {
        if (this.$G.chartManage.get('G_drawer_data')) {
          this.$refs['G_drawer_data'].setOption({
          xLabel: [20191010, 20191011, 20191012, 20191013, 20191014, 20191015, 20191016],
          series: [
            {
                name: '电压',
                unit: 'V',
                data: [120, 132, 101, 134, 90, 230, 210]
            },
            {
                unit: 'A',
                name: '电流',
                data: [220, 182, 191, 234, 290, 330, 310]
            },
            {
                name: '功率',
                unit: 'kW',
                data: [150, 232, 201, 154, 190, 330, 410]
            },
            {
                name: '转速',
                unit: 'rpm',
                data: [320, 332, 301, 334, 390, 330, 320]
            }
          ]
        }).resize();
        }
      this.getHisData(this.select_date).then((res) => {
        this.$refs['G_drawer_data'].setOption(res);
      }).catch(e => {
        this.$refs['G_drawer_data'].setOption(this.formatData([]));
        console.warn(e);
      });
    }
    ,changeSize2 () {
    /*,changeSize2 () {
      this.isMaxSize2 = !this.isMaxSize2;
      this.$nextTick(() => {
        if (this.$G.chartManage.get('G_drawer_data')) {
          console.dir(this.$refs['G_drawer_data']);
          this.$refs['G_drawer_data'].setOption({
          xLabel: [20191010, 20191011, 20191012, 20191013, 20191014, 20191015, 20191016],
          series: [
            {
                name: '电压',
                unit: 'V',
                data: [120, 132, 101, 134, 90, 230, 210]
            },
            {
                unit: 'A',
                name: '电流',
                data: [220, 182, 191, 234, 290, 330, 310]
            },
            {
                name: '功率',
                unit: 'kW',
                data: [150, 232, 201, 154, 190, 330, 410]
            },
            {
                name: '转速',
                unit: 'rpm',
                data: [320, 332, 301, 334, 390, 330, 320]
            }
          ]
        }).resize();
        }
      this.getHisData(this.select_date).then((res) => {
        console.log(res, 9977);
        this.$refs['G_drawer_data'].setOption(res);
      }).catch(e => {
        this.$refs['G_drawer_data'].setOption(this.formatData([]));
        console.warn(e);
      });
    }
    }*/
    ,updateTemp () {
      for (let i = 0; i < 6; i++) {
        this.$refs['G_temp_' + i][0].drawPoint(this.GList[i].value);
@@ -1024,6 +952,7 @@
        .then(()=> {
          this.updateTemp();
          this.$refs['circuit'].update();
          this.getHisData(this.select_date);
          this.timer.open();
        }).catch((err)=>{
@@ -1033,10 +962,10 @@
      }, 1000);
    }
    ,controlChange (item) {
      console.log('change', item);
      // console.log('change', item);
      item.upDate = item.value == item.oldValue;
    }
    ,formatAlarmList (list) {
    ,formatData (list) {
      let xLabel = [];
      let series = [];
      let obj = {};
@@ -1085,67 +1014,30 @@
    }
    // 历史曲线 查询
    ,search () {
      /*const reg = /A|B|C|D/;
      reg.test(this.G_title);
      const group = RegExp.lastMatch;
      // console.log(group, this.select_date, 9878);
      this.getHisData(group, this.select_date).then((res) => {
        // console.log(res, 9999);
        this.$refs['G_dialog_id'].setOption(res);
      this.getHisData(this.select_date).then((res) => {
        this.$refs['G_drawer_data'].setOption(res);
      }).catch(e => {
        this.$refs['G_dialog_id'].setOption(this.format([]));
        this.$refs['G_drawer_data'].setOption(this.formatData([]));
        console.warn(e);
      });*/
    }
    ,format (data) {
      let xLabel = [],
          series = [],
          data_dccurr = [],
          data_dcvol = [],
          data_controlangle = [],
          data_localgivecurr = [],
          data_localgivevol = [];
      data.forEach((v) => {
        xLabel.push(v.record_time);
        data_dccurr.push(v.dccurr  / 10);
        data_dcvol.push(v.dcvol / 10);
        data_controlangle.push(v.controlangle / 10);
      });
      series.push({
        name: '支路电流',
        unit: 'A',
        data: data_dccurr
      }, {
        name: '支路电压',
        unit: 'V',
        data: data_dcvol
      }, {
        name: '控制角',
        unit: '度',
        data: data_controlangle
      });
      // console.log(xLabel, series);
      return {
        xLabel,
        series
      }
    }
    // 查询历史数据
    ,getHisData (date) {
      /*const param = {
        electric_id: info[group],
      const param = {
        motor_id: this.motor_id,
        record_time: (date ? date : new Date().format('yyyy-MM-dd')) + " 00:00:00"
      };
      // console.log(param, 'his', info, group);
      // console.log(param, 'his');
      // console.trace('getHis_callStack');
      return this.$api.electric.getHisData(param).then((res) => {
      return this.$api.motor.getHisData(param).then((res) => {
        res = JSON.parse(res.data.result);
        if (res.code) {
          return this.format(res.data);
          // console.log(res.data, 'hisData');
          return this.formatData(res.data);
        } else {
          throw res.msg;
        }
      });*/
      });
    }
    ,exportCsv () {
      //json:{"dev_name":"1#蓄电池组","dev_id":"1000004","test_record_count":"1","export_num":"3","table_name":"2020_09_14"}
@@ -1160,7 +1052,7 @@
        table_name: this.select_date.replace(/-/g, '_'),
        record_time: this.select_date + " 00:00:00"
      };
      console.log(param, 'param');
      // console.log(param, 'param');
      this.$axios({
        method: 'post'
        ,url: 'CsvFileDownloadAction!searchDownloadFile'
@@ -1168,7 +1060,7 @@
        ,timeout: 0
      }).then(res=>{
          res = JSON.parse(res.data.result);
          console.log(res, 'download res');
          // console.log(res, 'download res');
          if(res.code == 1) {
              // 关闭进度条
              // this.progress.show = false;
@@ -1671,7 +1563,8 @@
  }
  .drawer_data_contain > * {
    /*flex: 1;*/
    height: 50%;
    /*height: 50%;*/
    height: 100%;
    display: -webkit-flex;
    display: flex;
    flex-direction: column;