yichenxi
2022-12-12 eb07bc16cb0b06f3b96a4f59d74f82b62195f096
src/views/Monitoringstation/index.vue
@@ -1,6 +1,6 @@
<template>
  <div class="zong" >
    <div style="display: flex;">
    <div style="display: flex">
      <el-select
        v-model="value"
        placeholder="请选择检查设备"
@@ -53,7 +53,7 @@
   
    <el-table
      :data="dateList"
      style="margin-top: 20px;"
      style="margin-top: 20px"
      id="exportTab"
      border
       max-height="800"
@@ -125,27 +125,27 @@
        url:'sensor/getSensorsByMonitorPointIds',
        method:'get',
        params:{
          monitorPointIds:res
        }
          monitorPointIds: res,
        },
      }).then((res)=>{
        console.log(res);
        console.log(res)
        this.Monfactors=res.data
      })
    },
    exportMon() {
      if(this.value===""){
      if (this.value === '') {
         this.$message.warning('请选择检查设备')
        return
      }
       if(this.value1===""){
      if (this.value1 === '') {
         this.$message.warning('请选择因子')
        return
      }
       if(this.startvalue===""){
      if (this.startvalue === '') {
         this.$message.warning('请选择开始时间')
        return
      }
       if(this.endvalue===""){
      if (this.endvalue === '') {
         this.$message.warning('请选择结束时间')
        return
      }
@@ -171,7 +171,7 @@
          this.dateList.push(item)
        }
      })
      console.log(1);
      console.log(1)
    },
    getMonitorPointId() {
      this.$request({
@@ -190,71 +190,70 @@
              label: res.data[i].name,
            })
          }
        console.log(this.options);
          console.log(this.options)
        })
        .catch((err) => {
          console.log(err)
        })
    },
    toExcel() {
      let wb = XLSX.utils.table_to_book(document.querySelector('#exportTab'), { sheet: "分组表" });
      this.setExlStyle(wb["Sheets"]["分组表"]);
      let wb = XLSX.utils.table_to_book(document.querySelector('#exportTab'), {
        sheet: '分组表',
      })
      this.setExlStyle(wb['Sheets']['分组表'])
      var ws = XLSX2.write(wb, {
        type: "buffer",
      });
        type: 'buffer',
      })
      try {
        FileSaver.saveAs(
          new Blob([ws], { type: "application/octet-stream" }),
          new Blob([ws], { type: 'application/octet-stream' }),
          `监测站点数据表.xlsx`
        );
        )
      } catch (e) {
        if (typeof console !== "undefined") console.log(e, ws);
        if (typeof console !== 'undefined') console.log(e, ws)
      }
      return ws;
      return ws
    },
    setExlStyle(data) {
      let borderAll = {
        //单元格外侧框线
        top: {
          style: "thin",
          style: 'thin',
        },
        bottom: {
          style: "thin",
          style: 'thin',
        },
        left: {
          style: "thin",
          style: 'thin',
        },
        right: {
          style: "thin",
          style: 'thin',
        },
      };
      data["!cols"] = [];
      }
      data['!cols'] = []
      for (let key in data) {
        if (data[key] instanceof Object) {
          data[key].s = {
            border: borderAll,
            alignment: {
              horizontal: "center", //水平居中对齐
              vertical: "center",
              horizontal: 'center', //水平居中对齐
              vertical: 'center',
            },
            font: {
              sz: 11,
            },
            bold: true,
            numFmt: 0,
          };
          data["!cols"].push({ wpx: 200 });
          }
          data['!cols'].push({ wpx: 200 })
        }
      }
      return data;
      return data
    },
  },
  //生命周期 - 创建完成(可以访问当前 this 实例)
  created() {
    this.getMonitorPointId();
    this.getMonitorPointId()
  },
  //生命周期 - 挂载完成(可以访问 DOM 元素)
  mounted() {},
@@ -271,5 +270,4 @@
.zong {
  padding: 20px;
}
</style>