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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<template>
  <a-card :bordered="false">
    <a-row type="flex" :gutter="16">
      <a-col :md="5" :sm="24">
        <base-tree @sendSelectBaseTree="changeSelection" @getCurrSelected="changeSelectionNode"></base-tree>
      </a-col>
      <a-col :md="24-5" :sm="24">
        <div class="device-status-info">
          <a-space v-for="item in deviceStatusList" :key="item.value" class="single-status-info">
            <div>{{ item.label }}</div>
            <div v-if="item.value!=99" class="status-square" :style="{ backgroundColor: item.color }"></div>
            <div>{{getDeviceNumberByStatus(item.value) }}</div>
          </a-space>
        </div>
 
        <div>
          <a-tabs default-active-key="1">
            <a-tab-pane key="1" tab="布局图">
              <equipment-layout :dataList="dataList" :equipmentId="selectEquipmentId" :node="selectEquipment"/>
            </a-tab-pane>
            <a-tab-pane key="2" tab="列表" force-render>
              <equipment-list :dataSource="dataList"/>
            </a-tab-pane>
          </a-tabs>
        </div>
      </a-col>
    </a-row>
  </a-card>
</template>
 
<script>
  import { getAction } from '@/api/manage'
  import BaseTree from '../common/BaseTree'
  import EquipmentLayout from './modules/DeviceBaseInfo/EquipmentLayout'
  import EquipmentList from './modules/DeviceBaseInfo/EquipmentList'
 
  export default {
    name: 'DeviceBaseInfo',
    components: {
      BaseTree,
      EquipmentLayout,
      EquipmentList
    },
    data() {
      return {
        description: '设备信息',
        selectEquipmentId: '',
        selectEquipment: {},
        equipmentStatisticsInfo: {},
        dataList: [],
        url: {
          list: '/mdc/mdcEquipment/queryEquipmentMonitorList'
        },
        param: {},
        timer: null,
        deviceStatusList: [
          {
            label: '关机',
            value: 0,
            color: '#A8A8A8'
          },
          {
            label: '待机',
            value: 2,
            color: '#FFFF00'
          },
          {
            label: '运行',
            value: 3,
            color: '#00EE00'
          },
          {
            label: '报警',
            value: 22,
            color: '#FF0000'
          },
          {
            label: '故障',
            value: 5,
            color: '#C11900'
          },
          {
            label: '总数',
            value: 99,
            color: '#fff'
          }
        ]// 设备状态指示灯列表,
      }
    },
    created() {
      const { productionId } = this.$route.params
      if (productionId) this.param.key = productionId
    },
    methods: {
      equipmentStatistics(param, resopnse = { key: false }) {
        getAction(this.url.list, param)
          .then((res) => {
            this.dataList = []
            if (res.success) {
              if (res.result.length != 0) {
                this.dataList = res.result
                if (resopnse.key) {
                  this.$notification.success({
                    key: 'equipmentStatus',
                    message: '消息',
                    description: resopnse.message
                  })
                }
 
                // 筛选从车板跳转过来的需求数据
                const { signageData } = this.$route.params
                console.log('signageData', signageData)
                if (!signageData) return
                else this.filterDataList(signageData)
              } else {
                this.$notification.warning({
                  message: '消息',
                  description: '此车间下面无设备!!'
                })
              }
            }
            else {
              this.$notification.warning({
                message: '消息',
                description: res.message
              })
            }
          })
      },
 
      /**
       * 筛选满足从看板跳转过来时的条件的数据
       * @param signageData
       */
      filterDataList(signageData) {
        this.dataList = this.dataList.filter(item => item.oporationDict === signageData.name)
      },
 
      changeSelection(val) {
        this.selectEquipmentId = val
      },
      changeSelectionNode(val) {
        this.selectEquipment = val.equipmentId
        clearInterval(this.timer)
        this.timer = null
        if (!val.equipmentId) this.param.key = val.key
        else this.param.key = val.parentId
        this.equipmentStatistics(this.param)
        this.timer = setInterval(() => {
          setTimeout(this.equipmentStatistics(this.param), 0)
        }, 1000 * 10)
      },
 
      /**
       * 根据设备状态值获取对应设备数量
       * @param value 设备状态值
       * @returns {number} 设备数量
       */
      getDeviceNumberByStatus(value) {
        if (value === 99) return this.dataList.length
        return this.dataList.filter((item) => item.oporation === 1 && value === 2 || item.oporation === value).length
      }
    },
    mounted() {
      this.equipmentStatistics(this.param)
    },
    beforeDestroy() {
      clearInterval(this.timer)
      this.timer = null
    }
  }
</script>
<style scoped lang="less">
  @import '~@assets/less/common.less';
 
  .equipMessage {
    width: 100%;
    height: 20px;
  }
 
  .equipMessage table {
    width: 60%;
    height: 100%;
    line-height: 50%;
    float: right;
  }
 
  .equipMessage table td {
    text-align: center;
  }
 
  .equipMessage table td span {
    display: inline-block;
    width: 15px;
    height: 15px;
  }
 
  .device-status-info {
    display: flex;
    justify-content: flex-end;
    align-items: center;
 
    .single-status-info {
      margin: 10px;
      .status-square {
        width: 20px;
        height: 20px;
        border: 1px solid #ddd;
        border-radius: 3px;
      }
    }
  }
</style>