longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
<template>
  <el-popover
    :disabled="isDisabled"
    placement="right"
    popper-class="light-popover"
    width="360"
    trigger="focus">
    <el-row :gutter="8">
      <el-col
        :span="12"
        v-for="(item, key) in list" :key="'key'+key">
        <div class="inline-block-box">
          <hdw-light-input :text="item.label" :type="item.value"></hdw-light-input>
        </div>
      </el-col>
    </el-row>
    <div slot="reference" class="inline-block-box">
      <hdw-light-input
        :text="text"
        :type="totalType"></hdw-light-input>
    </div>
  </el-popover>
 
</template>
 
<script>
import HdwLightInput from "@/pages/dataMager/components/HdwLightInput";
export default {
  name: "HdwLightInputInline",
  components: {
    HdwLightInput
  },
  props: {
    text: {
      type: String,
      default: "",
    },
    list: {
      type: Array,
      default() {
        return []
      }
    },
  },
  data() {
    return {
      type: 0,
    }
  },
  methods: {},
  computed: {
    isDisabled() {
      return (this.list.length == 0 || this.list.length==1)?true:false;
    },
    totalType() {
      let list = this.list;
      let type = -1;
      for(let i=0; i<list.length; i++) {
        let item = list[i];
        // 设置红灯
        if(item.value == 1) {
          type = 1;
          break;
        }
 
        // 设置绿灯
        if(item.value == 0) {
          type = 0;
        }
      }
      return type;
    }
  },
  mounted() {
  },
  beforeDestroy() {
  }
}
</script>
 
<style scoped>
.inline-block-box {
  display: inline-block;
}
</style>