zmc
2023-11-22 a969126ac530da96b1edb02152db87f0ad317f6e
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!-- 异常类型复选框组件  
    自动获取扬尘历史表中不同异常类型
    将选中的多个异常以数组形式返回给父组件 
 
    **
    在父组件中设置
   <ExceptionType @submit-value="(n)=>form.exceptionName=n"></ExceptionType>
-->
 
<script>
export default {
  props: {
    // 禁用
    isDisabled: {
      type: Boolean,
      default: false
    },
    // 异常类型
    exception: {
      type: Number,
      default:-1
    }
  },
  emits: ['submitValue'],
  data() {
    return {
      // 返回的所有异常类型
      exceptionType: [],
      //已勾选的异常
      checkedList: [],
      // 全选
      checkAll: false,
      isIndeterminate: false
    }
  },
 
  mounted() {
    this.$watch(() => [this.exception], () => {
      if (this.exception != -1) {
        console.log('异常类型:',this.exception)
        this.checkedList.push(this.exception) 
      }
      
    });
    this.getExceptionType()
  },
  methods: {
    // 获取不同的异常名称
    getExceptionType() {
      this.$http.get('/dust/exceptiontype').then((response) => {
        // this.exceptionType = response.data.data
        response.data.data.forEach((item) => {
          this.exceptionType.push(item.exceptionType)
        })
        // console.log('获取到的异常类型:',this.exceptionType);
        let a = ['0', '1', '2', '3', '4', '5', '6', '7','8']
        a.forEach((item) => {
          if (this.exceptionType.indexOf(item) == -1) {
            this.exceptionType.push(item)
          }
        })
      })
    },
    handleCheckAllChange(val) {
      this.checkedList = val ? this.exceptionType : []
      this.isIndeterminate = false
      this.$emit('submitValue', this.checkedList)
    },
    handleCheckedExceptionChange(value) {
      const checkedCount = value.length
      this.checkAll = checkedCount === this.exceptionType.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.exceptionType.length
      this.$emit('submitValue', this.checkedList)
    }
  }
}
</script>
 
<template>
  <div class="excption">
    <h1 class="exception-text">异常类型:</h1>
    <el-checkbox
      v-model="checkAll"
      :indeterminate="isIndeterminate"
      @change="handleCheckAllChange"
      class="select-text"
     :disabled="isDisabled"
      >全选</el-checkbox
    >
    <el-checkbox-group v-model="checkedList" @change="handleCheckedExceptionChange" :disabled="isDisabled">
      <el-checkbox :label="item" v-for="item in exceptionType" :key="item"  >
        <template #default>
          <!-- <div style="display: flex; flex-flow: row wrap;">  -->
          <span v-if="item == '0'">数据缺失</span>
          <span v-else-if="item == '1'">数据超低</span>
          <span v-else-if="item == '2'">超标</span>
          <span v-else-if="item == '3'">数据长时段无波动</span>
          <span v-else-if="item == '4'">量级突变异常</span>
          <span v-else-if="item == '5'">临近超标异常</span>
          <span v-else-if="item == '6'">单日超标次数临界异常</span>
          <span v-else-if="item == '7'">变化趋势异常</span>
          <span v-else-if="item == '8'">有效率异常</span>
          <!-- </div> -->
        </template>
      </el-checkbox>
    </el-checkbox-group>
  </div>
</template>
 
<style lang="scss" scoped>
.excption {
  display: flex;
}
.exception-text {
  font-size: 14px;
  color: #333333;
  margin-top: 5px;
  margin-right: 7px;
}
.el-checkbox-group {
  margin-top: 5px;
}
.select-text {
  margin-top: 5px;
  margin-right: 5px;
}
</style>