schangxiang@126.com
2024-08-16 65bd2dc1d4c1fb136af853c7ede93a338431be29
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
<template>
  <div>
    <!-- 标签页 -->
    <a-card :bordered="false" :bodyStyle="tstyle2">
      <a-tabs tab-position="top" :animated="false" v-model="activeKey" @change="change">
        <a-tab-pane
          v-for="(equipment) in equipmentList"
          :key="equipment.equipmentId"
          :tab="equipment.equipmentName"
        >
        </a-tab-pane>
      </a-tabs>
    </a-card>
    <!-- 表单部分 -->
    <x-card :bordered="false" v-if="hasPerm('WorkPieceProcess:page')">
      <div slot="content" class="table-page-search-wrapper">
        <a-form :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row :gutter="gutter">
            <a-col :md="colMd" :sm="colSm">
              <a-form-item label="日期范围">
                <a-range-picker v-model="queryParam.dates" format="YYYY-MM" />
              </a-form-item>
            </a-col>
            <!-- 是否显示下列表单 advanced true时显示-->
            <template v-if="advanced">
              <!-- <a-col :md="8" :sm="24">
                <a-form-item label="设备所属工序">
                  <a-input v-model="queryParam.workingProcedure" allow-clear placeholder="请输入设备所属工序"/>
                </a-form-item>
              </a-col> -->
            </template>
            <a-col :md="colMd" :sm="colSm">
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="getData">查询</a-button>
                <a-button style="margin-left: 8px" @click="resetData">重置</a-button>
                <!-- 是否显示展开收起 flag为true时显示 -->
                <a @click="toggleAdvanced" style="margin-left: 8px" v-if="flag">
                  {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'" />
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </x-card>
    <!-- 图表部分1 -->
    <a-card :bordered="false" :bodyStyle="tstyle">
      <Echarts title="报警分析" :data="data"></Echarts>
    </a-card>
    <!-- 图标部分2 -->
    <a-card :bordered="false" :bodyStyle="tstyle">
      <Echarts title="状态占比分析" :data="data"></Echarts>
    </a-card>
  </div>
</template>
<script>
import Echarts from './modules/Echarts.vue'
import moment from 'moment'
import { XCard } from '@/components'
import { getEquipmentStatus } from './api/getData.js'
import { GetEquipmentStateAnalysisInfo } from '@/api/modular/main/EquipmentStatusAnalyseManage'
import { getEquipmentList } from '@/api/modular/main/QualityDataInfoManage'
 
export default {
  name: 'EquipmentStatusAnalyse',
  components: { Echarts, XCard },
  data() {
    return {
      gutter: 36,
      colMd: 6,
      colSm: 18,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 }
      },
      advanced: false, // 高级搜索 展开/关闭
      flag: false, // 显示隐藏展开按钮
      // 标签页
      tabs: [],
      activeKey: 0,
      equipmentList: [],
      // 查询数据
      queryParam: {
         equipmentId: '',
         dates: [moment().subtract(1, 'years'), moment()]
     },
      data: [],
      tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
      tstyle2: { 'padding-bottom': '0px', 'margin-bottom': '0px' }
    }
  },
  created() {
    this.getEquipment()
  },
  watch: {
    'queryParam.equipmentId': {
      deep: true,
      handler() {
        this.getData()
      }
    }
  },
  methods: {
    moment,
    /**
     * 查询参数组装
     */
     switchingDate() {
      const dates = this.queryParam.dates
      if (dates != null) {
        this.queryParam.startTime = moment(dates[0]).format('YYYY-MM-DD ')
        this.queryParam.endTime = moment(dates[1]).format('YYYY-MM-DD')
        if (dates.length < 1) {
          delete this.queryParam.startTime
          delete this.queryParam.endTime
        }
      }
      const obj = JSON.parse(JSON.stringify(this.queryParam))
      return obj
    },
    toggleAdvanced() {
      this.advanced = !this.advanced
    },
    // 发起请求获取数据
    async getData() {
      try {
        const { data } = await GetEquipmentStateAnalysisInfo(this.switchingDate())
        console.log(data, 'data')
        this.data = data
      } catch (error) {
console.log(error)
      }
    },
    // 查询所有设备名称
    getEquipment() {
      this.equipmentList = []
      getEquipmentList().then(res => {
        this.equipmentList = res.data
        this.equipmentList.unshift({ equipmentName: '全部设备', equipmentId: null })
        this.activeKey = this.equipmentList[0].equipmentId
        this.queryParam.equipmentId = this.equipmentList[0].equipmentId
      })
    },
    // 标签页改变
    change(val) {
      this.queryParam.equipmentId = val
    },
    // 重置按钮
    resetData() {
      // 参数重置
      this.queryParam = {
         equipmentId: '',
         dates: [moment().subtract(1, 'years'), moment()]
     }
      this.getData()
      // 页面重置
      this.activeKey = this.equipmentList[0].equipmentId
    }
  }
}
</script>
<style>
.table-operator {
  margin-bottom: 18px;
}
 
button {
  margin-right: 8px;
}
</style>