src/views/Equipment/index.vue
@@ -5,25 +5,30 @@
        <div class="timee">
          {{ time }}
        </div>
        <div style="margin-left: 20px; margin-top: -12px">
        <div style="margin-left: 1.5rem; margin-top:-1.1rem">
          <span>设备和站点:</span>
          <el-cascader
           v-model="newMac"
            :options="options"
            :props="props"
            collapse-tags
            clearable
            @change="changeYz"
            placeholder="选择设备"
            style="width: 25rem"
          ></el-cascader>
        </div>
        <div style="margin-left: 20px; margin-top: -12px">
        <div style="margin-left: 1.5rem; margin-top: -12px">
          <span>选择因子:</span>
          <el-cascader
            :options="options"
            :options="newSensor"
            :props="props"
            collapse-tags
            clearable
            @change="res"
          ></el-cascader>
        </div>
        <div style="margin-left: 20px; margin-top: -12px">
        <div style="margin-left: 1.5rem; margin-top: -12px">
          <el-button type="primary">查询</el-button>
        </div>
      </div>
@@ -46,14 +51,31 @@
      props: { multiple: true },
      defaultData: [],
      options: [],
      newSensor:[],
      newMac:'',
      newMac1:[]
    }
  },
  // 计算属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  watch: {
     newMac(newVal, oldval) {
      this.newMac1 = []
      for (let i = 0; i < newVal.length; i++) {
        // console.log(newVal[i], 111)
        this.newMac1.push(newVal[i][1][1])
      }
      // 设备更新后,重新获取因子数据
      this.getSensor()
      console.log(this.newMac1)
    },
  },
  //方法集合
  methods: {
    res(res){
      console.log(res.toString());
    },
    getData() {
      this.$request({
        url: '/monitorPoint/queryMonitorPoints',
@@ -85,6 +107,30 @@
          console.log(error)
        })
    },
    changeYz(){
      console.log(11111);
      this.getSensor();
    },
     getSensor() {
      this.$request({
        url: '/deviceInfo/getMacSensors',
        method: 'post',
        data: {
          macs: this.newMac1,
        },
      })
        .then((result) => {
          console.log(result);
          var sensor = result.data
          for (var i in sensor) {
            this.newSensor.push({ value: i, label: sensor[i] })
          }
        })
        .catch((err) => {
          console.log(err)
        })
    },
  },
  //生命周期 - 创建完成(可以访问当前 this 实例)
  created() {
@@ -104,4 +150,5 @@
}
</script>
<style scoped>
</style>