quanyawei
2024-01-15 c9fc948cfa3cf91c072a13787aed5cb50fb31669
src/views/Equidata/index.vue
@@ -26,23 +26,33 @@
        :picker-options="pickerOptions"
        end-placeholder="结束日期"
        style="margin-left: 1rem"
      >
      </el-date-picker>
      />
      <el-button type="primary" @click="toExcel()" style="margin-left: 20px"
        >导出</el-button
      <el-button
        type="primary"
        style="margin-left: 20px"
        @click="toExcel()"
      >
      <el-button @click="exportMon">查询</el-button>
        导出
      </el-button>
      <el-button @click="exportMon">
        查询
      </el-button>
    </div>
    <el-table :data="dateList" id="exportTab" style="margin-top: 20px" border max-height="800">
    <el-table
      id="exportTab"
      :data="dateList"
      style="margin-top: 20px"
      border
      max-height="800"
    >
      <el-table-column
        v-for="item in columnList"
        :key="item"
        :prop="item"
        :label="item"
        width="180px"
        :key="item"
      >
      </el-table-column>
      />
    </el-table>
  </div>
</template>
@@ -56,7 +66,7 @@
export default {
  // import 引入的组件需要注入到对象中才能使用props
  data() {
  data () {
    // 这里存放数据
    return {
      props: { multiple: true },
@@ -68,7 +78,7 @@
      // newMac2:'',
      newSensor: [],
      timevalue: [],
      columnList: [], //表头的数组
      columnList: [], // 表头的数组
      dateList: [],
      pickerOptions: {
        disabledDate: (time) => {
@@ -81,12 +91,12 @@
  computed: {},
  // 监控data中的数据变化
  watch: {
    newMac(newVal, oldval) {
    newMac (newVal, oldval) {
      this.newMac1 = []
      this.newMac1.push(newVal[1][1])
      this.getSensor()
    },
    value(n, o) {
    value (n, o) {
      this.value1 = []
      for (let i = 0; i < n.length; i++) {
        this.value1.push(n[i][0])
@@ -94,22 +104,22 @@
    },
  },
  // 生命周期 - 创建完成(可以访问当前 this 实例)
  created() {
  created () {
    this.getData()
  },
  // 生命周期 - 挂载完成(可以访问 DOM 元素)
  mounted() {},
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {},
  mounted () {},
  beforeCreate () {}, // 生命周期 - 创建之前
  beforeMount () {}, // 生命周期 - 挂载之前
  beforeUpdate () {}, // 生命周期 - 更新之前
  updated () {}, // 生命周期 - 更新之后
  beforeDestroy () {}, // 生命周期 - 销毁之前
  destroyed () {}, // 生命周期 - 销毁完成
  activated () {},
  // 方法集合
  methods: {
    // 请求左侧设备数据
    getData() {
    getData () {
      this.$request({
        url: '/monitorPoint/queryMonitorPoints',
        method: 'get',
@@ -127,14 +137,16 @@
              label: this.defaultData[i].name,
            })
            this.options[i].children = []
            for (let j = 0; j < this.defaultData[i].devices.length; j++) {
              this.options[i].children.push({
                value: [
                  this.defaultData[i].devices[j].name,
                  this.defaultData[i].devices[j].mac,
                ],
                label: this.defaultData[i].devices[j].name,
              })
            if (this.defaultData[i].devices) {
              for (let j = 0; j < this.defaultData[i].devices.length; j++) {
                this.options[i].children.push({
                  value: [
                    this.defaultData[i].devices[j].name,
                    this.defaultData[i].devices[j].mac,
                  ],
                  label: this.defaultData[i].devices[j].name,
                })
              }
            }
          }
        })
@@ -143,7 +155,7 @@
        })
    },
    // 通过mac号获得因子
    getSensor() {
    getSensor () {
      this.$request({
        url: '/deviceInfo/getMacSensors',
        method: 'post',
@@ -163,7 +175,7 @@
          console.log(err)
        })
    },
    exportMon() {
    exportMon () {
      console.log(this.timevalue)
      if (this.newMac == '') {
        this.$message.warning('请选择站点')
@@ -173,7 +185,7 @@
        this.$message.warning('请选择因子')
        return
      }
      this.dateList = []
      this.columnList = []
      this.$request({
@@ -197,7 +209,7 @@
        }
      })
    },
    toExcel() {
    toExcel () {
      let wb = XLSX.utils.table_to_book(document.querySelector('#exportTab'), {
        sheet: '分组表',
      })
@@ -215,9 +227,9 @@
      }
      return ws
    },
    setExlStyle(data) {
    setExlStyle (data) {
      let borderAll = {
        //单元格外侧框线
        // 单元格外侧框线
        top: {
          style: 'thin',
        },
@@ -237,7 +249,7 @@
          data[key].s = {
            border: borderAll,
            alignment: {
              horizontal: 'center', //水平居中对齐
              horizontal: 'center', // 水平居中对齐
              vertical: 'center',
            },
            font: {