chenhaozhe
2026-01-22 338ba5bb8d76eb391621ae2830fa8802347c224b
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<template>
    <view>
        <view class="tabs" id="tabs">
            <view :class="tabs == 0 ? 'on':''" @tap="switchTab(0)">待维修</view>
            <view :class="tabs == 1 ? 'on':''" @tap="switchTab(1)">已维修</view>
            <!-- <view :class="tabs == 2 ? 'on':''" @tap="switchTab(2)">全部任务</view> -->
        </view>
 
        <!-- 设备维修任务列表列表 -->
        <view v-show="tabs == 0">
            <view class="list" v-for="(item,index) in reportBillsDisplay" :key="index">
                <uni-card :title="item.故障登记单号" :extra="`日期: ${dayjs(item.设备故障日期).format('YYYY-MM-DD')}`"
                    style="margin: 10px;">
                    <view class="card-detail">
                        <view class="detail" v-for="(field, index) in CommonUtils.emptyValueFilter(item, HFieldList)"
                            :key="index">
                            <text>{{field.ColmCols}}:</text>{{item[field.ColmCols]}}
                        </view>
                    </view>
                </uni-card>
            </view>
            <view class="over" v-if="reportBillsDisplay.length == 0">暂无数据</view>
        </view>
        <!-- OEE 折线图 -->
        <view v-show="tabs == 1" class="graph-container" style="padding: 40rpx 0; text-align: center;">
            <view class="graph"><l-echart ref="chartRef" @finished="initChart()"></l-echart>
            </view>
        </view>
    </view>
</template>
 
<script>
    import {
        getUserInfo
    } from '../../../utils/auth';
    import {
        CommonUtils
    } from '../../../utils/common';
    import dayjs from 'dayjs';
    import * as echarts from 'echarts'
    export default {
        // 设备状态 模块
        name: 'Sc_OEEStatusReport',
        data() {
            return {
                dayjs,
                CommonUtils,
                tabs: 0,
                HEquipID: 0,
                HEquipNumber: "",
                reportBillsDisplay: [],
                reportBills: [], // 待维修
                HFieldList: [], // 字段列表
            }
        },
        methods: {
            switchTab(tabIndex) {
                this.tabs = tabIndex
                switch (tabIndex) {
                    case 0:
                        this.reportBillsDisplay = this.reportBills;
                        break;
                        // case 1:
                        //     this.reportBillsDisplay = this.reportBillsRepaired;
                        //     break;
                        // case 2:
                        //     this.reportBillsDisplay = this.reportBillsAll;
                        //     break;
                }
            },
            async getEquipFileMain(HInterID) {
                try {
                    let res = await CommonUtils.doRequest2Sync({
                        url: "/Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown_ListByHEquipID",
                        data: {
                            HEquipID: HInterID,
                        },
                    })
 
 
                    if (!res) {
                        return
                    }
 
                    let {
                        data,
                        count,
                        Message
                    } = res.data
 
                    if (count == 1) {
                        console.log('data: ', data);
                        // this.hform.HQty = 1
                        this.HEquipID = data[0]["hmainid"]
                        this.HEquipNumber = data[0]["设备编码"]
                        this.enableEdit = false
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: Message
                        })
                    }
 
                } catch (err) {
                    CommonUtils.showTips({
                        title: "温馨提示",
                        message: err
                    })
                }
            },
            async getReportList() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/Sc_OEEReport/list',
                        data: {
                            sWhere: `4,'${this.HEquipNumber}','','','','${dayjs(new Date()).subtract(2, 'weeks').format("YYYY-MM-DD")}', '${dayjs(new Date()).format("YYYY-MM-DD")}'`,
                            user: getUserInfo()["Czymc"]
                        }
                    })
 
                    let {
                        count,
                        data,
                        Message,
                        list
                    } = res.data
                    if (count == 1) {
                        // console.log('data: ', data);
                        this.reportBills = data
 
                        let fieldList = CommonUtils.fieldListFilterRole({
                            ExcludeKeys: ['设备编码'],
                            FieldList: list
                        })
 
                        if (fieldList.status == false) {
                            CommonUtils.showTips({
                                title: '温馨提示',
                                message: `获取表单结构失败: ${fieldList.Message}`
                            })
                        }
 
                        this.HFieldList = fieldList.data
 
                        this.switchTab(0)
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `获取设备OEE异常: ${Message}`
                        })
                    }
 
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: `获取维修单异常: ${err}`
                    })
                }
            },
            async initChart() {
                let option_ZZT1 = {}
                var H_X1 = []; //X轴标题
                var HOEE = []; //设备OEE
                var PerformanceUtilizationRate = []; //性能稼动率
                var TimeUtilizationRate = []; //时间稼动率
                var HTitle = "设备OEE"; //图形标题
                if (this.reportBills.length > 0) {
                    for (let i = 0; i < this.reportBills.length; i++) {
                        H_X1.push(this.reportBills[i].日期);
                    }
                    // 填充数据
                    for (let i = 0; i < this.reportBills.length; i++) {
 
                        HOEE.push((this.reportBills[i].OEE).replace('%', ''));
                        PerformanceUtilizationRate.push((this.reportBills[i].性能稼动率).replace('%', ''));
                        TimeUtilizationRate.push((this.reportBills[i].时间稼动率).replace('%', ''));
                    }
                }
                option_ZZT1 = {
                    title: {
                        text: HTitle,
                        left: 'center'
                    },
                    tooltip: {
                        trigger: 'axis',
                        formatter: function(params) {
                            let tooltipHtml = params[0].axisValue + '<br>'; // X轴数值
 
                            params.forEach(function(item) {
                                let valueToShow = parseFloat(item.value); // 将字符串转换为数值
                                tooltipHtml += item.seriesName + ': ' + valueToShow.toFixed(3) +
                                    '%' + '<br>'; // Y轴数值,并添加百分号
                            });
 
                            return tooltipHtml;
                        }
                    },
                    legend: {
                        data: ['OEE', '性能稼动率', '时间稼动率'],
                        top: 'bottom',
                        left: 'center'
                    },
                    toolbox: {
                        show: false,
                        orient: 'vertical',
                        left: 'right',
                        top: 'center',
                        feature: {
                            mark: {
                                show: true
                            },
                            dataView: {
                                show: true,
                                readOnly: false
                            },
                            magicType: {
                                show: true,
                                type: ['line', 'bar', 'stack']
                            },
                            restore: {
                                show: true
                            },
                            saveAsImage: {
                                show: true
                            }
                        }
                    },
                    xAxis: [{
                        type: 'category',
                        axisTick: {
                            show: false
                        },
                        data: H_X1
                    }],
                    yAxis: [{
                        type: 'value',
                        axisLabel: {
                            formatter: '{value} %'
                        }
                    }],
                    series: [{
                            name: 'OEE',
                            type: 'line',
                            label: {
                                show: true,
                                formatter: '{c}%'
                            },
                            itemStyle: {
                                normal: {
                                    lineStyle: {
                                        color: '#00FF00' // 设置线条颜色为绿色
                                    },
                                    color: '#00FF00' // 设置线条颜色为绿色
                                }
                            },
                            data: HOEE
                        },
                        {
                            name: '性能稼动率',
                            type: 'line',
                            label: {
                                show: true,
                                formatter: '{c}%'
                            },
                            itemStyle: {
                                normal: {
                                    lineStyle: {
                                        color: '#FF0000' // 设置线条颜色为红色‌
                                    },
                                    color: '#FF0000' // 设置线条颜色为红色
                                }
                            },
                            data: PerformanceUtilizationRate
                        },
                        {
                            name: '时间稼动率',
                            type: 'line',
                            label: {
                                show: true,
                                formatter: '{c}%'
                            },
                            itemStyle: {
                                normal: {
                                    lineStyle: {
                                        color: '#00FFFF' // 设置线条颜色为青色
                                    },
                                    color: '#00FFFF' // 设置线条颜色为青色
                                }
                            },
                            data: TimeUtilizationRate
                        }
                    ]
                };
                // chart 图表实例不能存在data里
                const chart = await this.$refs.chartRef.init(echarts);
                chart.setOption(option_ZZT1)
            }
        },
        async onLoad(e) {
            if (e.HEquipID) {
                await this.getEquipFileMain(e.HEquipID)
                await this.$nextTick()
                await this.getReportList()
                await this.initChart()
 
            }
        }
    }
</script>
 
<style lang="scss">
    @import "@/pages/MJGL/style/MJBillStyle.scss"
</style>