餐饮油烟智能监测与监管一体化平台
riku
2026-03-17 45c217996d025d256fdd0ed5cb744750e68dd36d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!-- 获取店铺名 设备编号的级联下拉框组件
    将选择的设备编号返回给父组件
 -->
<script>
import axiosInstanceInstance from '@/utils/request.js'
export default {
  // 默认选择一个
  props: {
    devId: {
      type: Array,
      default() {
        return ['全部', '全部']
      },
    },
  },
  // props:['devId'],
  emits: ['submitId'],
  data() {
    return {
      // 选择店铺名
      deviceId: [],
      // 店铺名 级联选择器
      optionsShop: [],
      // 保存设备信息表所有信息
      deviceInfo: [],
    }
  },
  watch: {
    // 保证页面切换回来时,店铺组件还是保持默认选中的一家
    devId() {
      this.deviceId = this.devId
    },
  },
  mounted() {
    this.getDeviceInfo()
  },
  methods: {
    getDeviceInfo() {
      // 级联下拉框数据 从接口中动态获取
      axiosInstanceInstance.get('/fume/device').then((result) => {
        this.deviceInfo = result.data.data
        this.deviceInfo.forEach((item) => {
          this.optionsShop[this.optionsShop.length] = {
            value: item.diName,
            label: item.diName,
            children: [
              {
                value: item.diCode,
                label: item.diCode,
              },
            ],
          }
        })
      })
 
      // 打开时默认展示一个店铺
      this.deviceId = this.devId
    },
    changeDev() {
      if (this.deviceId == null) {
        this.deviceId = ['', '']
        this.$emit('submitId', this.deviceId[1])
      } else {
        this.$emit('submitId', this.deviceId[1])
      }
    },
  },
}
</script>
 
<template>
  <div>
    <span>
      <el-cascader
        v-model="deviceId"
        :options="optionsShop"
        :props="{ expandTrigger: 'hover' }"
        @change="changeDev"
        placeholder="全部"
        clearable
      />
      <!--   @change="$emit('submitId', deviceId[1])"  @change="changeDev"-->
    </span>
  </div>
</template>