bodyLeft.vue
10.8 KB
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<template>
<div class="order-progress-list">
<div class="title-text">生成订单进度(当天)</div>
<!-- <div v-for="(item, index) in dataList" :key="index" class="progress-item">
<div class="order-id">{{ item }}</div>
<div class="progress-bar-container">
<el-progress :text-inside="true" :stroke-width="17" :percentage="70" text-color="#fff"></el-progress>
</div>
<div class="status-info">
总订单/完成 11/22
</div>
</div> -->
<div style="height: 90%;" class="table-container">
<vxe-table class="custom-row-height-table" border="none" ref="xTable" empty-text=" " :show-header="false"
height="100%" :data="dataList">
<vxe-column field="name1"></vxe-column>
<vxe-column field="name2">
<template #default="{ row }">
<el-progress :text-inside="true" :stroke-width="16" :percentage="70"
text-color="#fff"></el-progress>
</template>
</vxe-column>
<vxe-column field="name3">
<template #default="{ row }">
1233
</template>
</vxe-column>
</vxe-table>
</div>
</div>
</template>
<!--趋势图-->
<script>
// import { warehouseHealthOption } from '../../public/static/echartsConfig'
export default {
data() {
return {
// 各自动仓库状况
baseUrlOff: 'http://127.0.0.1:6001/api/BulletinBoard/Mes/V1/ReadData5',
baseUrlOnLine: window.appConfig.baseUrlOnLine5,
sysData: {
getwarehouseHealth: null,
},
dataList: [{ name1: 'CFW222011544' }, { name1: 'CFW222011545' }, { name1: 'CFW222011546' }, { name1: 'CFW222011547' }, { name1: 'CFW222011548' }, { name1: 'CFW222011549' }, { name1: 'CFW222011550' }, { name1: 'CFW222011551' }, { name1: 'CFW222011552' }, { name1: 'CFW222011553' }, { name1: 'CFW222011554' }, { name1: 'CFW222011555' }],
tempEcharts: [
{ name: 'SRM32', index: null },
{ name: 'SRM31', index: null },
{ name: 'SRM21', index: null },
{ name: 'SRM11', index: null },
{ name: 'SRM41', index: null },
{ name: 'SRM11_PLCHeatBeat', index: null },
{ name: 'SRM21_PLCHeatBeat', index: null },
{ name: 'SRM31_PLCHeatBeat', index: null },
{ name: 'SRM32_PLCHeatBeat', index: null },
{ name: 'SRM41_PLCHeatBeat', index: null },
],
getwarehouseHealth: null,
warehouseHealthOption: warehouseHealthOption,
warehouseHealthOption2: warehouseHealthOption2,
info: {
CutQuantity: 0,
PipeQuantity: 0
},
autoScrollTimer: null,
}
},
methods: {
// 中间柱状图
getData() {
let opt = {
urlSuffix: window.baseOnLineOrOff ? this.baseUrlOnLine : this.baseUrlOff,
logTitle: '中间柱状图',
isUrlALL: true,
headers: window.baseOnLineOrOff,
// header: window.baseOnLineOrOff,
}
let callBackFn = (res) => {
if (!this.ajaxSuccessDataBefore(res, opt.logTitle)) return
this.sysData.getwarehouseHealth = res.data.data
// this.dataAnalysis(res.data.data)
this.getwarehouseHealthbar(res.data.data)
}
''.ajax(this, opt, callBackFn)
},
dataAnalysis(data) {
//获取数据下标,用于数据对应name渲染
data.x.forEach((x, index) => {
if (x == 'SRM32') {
this.tempEcharts[0].index = index
}
if (x == 'SRM31') {
this.tempEcharts[1].index = index
}
if (x == 'SRM21') {
this.tempEcharts[2].index = index
}
if (x == 'SRM11') {
this.tempEcharts[3].index = index
}
if (x == 'SRM41') {
this.tempEcharts[4].index = index
}
if (x == 'SRM11_PLCHeatBeat') {
this.tempEcharts[5].index = index
}
if (x == 'SRM21_PLCHeatBeat') {
this.tempEcharts[6].index = index
}
if (x == 'SRM31_PLCHeatBeat') {
this.tempEcharts[7].index = index
}
if (x == 'SRM32_PLCHeatBeat') {
this.tempEcharts[8].index = index
}
if (x == 'SRM41_PLCHeatBeat') {
this.tempEcharts[9].index = index
}
})
},
// 中间柱状图
getwarehouseHealthbar(rawData) {
const dates = rawData.map(item => item.CurryDate);
const quantities = rawData.map(item => item.Quantity);
let myChart = this.$echarts.init(document.getElementById('warehouseHealth'))
this.warehouseHealthOption.xAxis.data = dates
this.warehouseHealthOption.series[0].data = quantities
myChart.clear()
myChart.setOption(this.warehouseHealthOption)
window.addEventListener('resize', () => {
myChart.resize();
});
},
getwarehouseHealthbar2(rawData) {
let data = this.sortedData(rawData);
const dates = data.map(item => item.CurryDate);
const quantities = data.map(item => item.Quantity);
let myChart2 = this.$echarts.init(document.getElementById('warehouseHealth2'))
this.warehouseHealthOption2.xAxis.data = this.monthDayDates(dates)
this.warehouseHealthOption2.series[0].data = quantities
myChart2.clear()
myChart2.setOption(this.warehouseHealthOption2)
window.addEventListener('resize', () => {
myChart2.resize();
});
},
setInfo(data) {
this.info = data;
},
sortedData(data) {
return data.slice().sort((a, b) => {
return new Date(a.CurryDate) - new Date(b.CurryDate); // 升序:早 → 晚
// return new Date(b.CurryDate) - new Date(a.CurryDate); // 降序:晚 → 早
});
},
monthDayDates(data) {
return data.map(date => {
const [year, month, day] = date.split('-');
return `${month}-${day}`;
});
},
ajaxSuccessDataBefore(res, title) {
if (res.data == null || res.data.data.length == 0) {
''.Log(title + '无数据', 'getData')
return false
}
return true
},
startAutoScroll() {
this.stopAutoScroll(); // 防止重复启动
this.autoScrollTimer = setInterval(() => {
const table = this.$refs.xTable;
if (!table) return;
// 尝试不同的选择器来找到滚动元素
let bodyElem = table.$el.querySelector('.vxe-table--body-wrapper');
if (!bodyElem) {
bodyElem = table.$el.querySelector('.vxe-body');
}
if (!bodyElem) {
bodyElem = table.$el.querySelector('.vxe-table--body');
}
if (!bodyElem) return;
// 每次滚动 1px
bodyElem.scrollTop += 1;
// 计算滚动位置和容器高度
const scrollTop = bodyElem.scrollTop;
const scrollHeight = bodyElem.scrollHeight;
const clientHeight = bodyElem.clientHeight;
const bottomPosition = scrollHeight - clientHeight;
// 如果接近底部(留有10px的缓冲区),重置到顶部(循环滚动)
if (scrollTop >= bottomPosition - 10) {
bodyElem.scrollTop = 0; // 循环滚动
}
}, 50); // 速度:数值越小越快
},
stopAutoScroll() {
if (this.autoScrollTimer) {
clearInterval(this.autoScrollTimer);
this.autoScrollTimer = null;
}
}
},
mounted() {
// this.getData()
// const item = {
// x: ['1号堆垛机', '1号RGV', '2号RGV'],
// running: [50, 40, 44],
// free: [49, 59, 55],
// error: [1, 1, 0.9],
// }
// this.getwarehouseHealthbar(item)
this.startAutoScroll();
},
beforeDestroy() {
this.stopAutoScroll();
},
}
</script>
<style lang="less" scoped>
.order-progress-list {
width: 100%;
height: 100%;
// background-color: #0a1428;
color: #fff;
font-size: 1vw;
}
.progress-item {
display: flex;
align-items: center;
padding: 8px 0;
border-bottom: 1px solid #1e3a5f;
height: 8%;
&:last-child {
border-bottom: none;
}
}
.order-id {
// flex: 1;
width: 25%;
padding-right: 0px;
text-align: center;
}
.progress-bar-container {
// flex: 2;
width: 35%;
position: relative;
text-align: center;
// height: 20px;
// overflow: hidden;
margin: 0 10px;
}
.progress-bar {
height: 100%;
transition: width 0.3s ease;
}
.progress-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 12px;
font-weight: bold;
pointer-events: none;
}
.status-info {
// flex: 1;
width: 40%;
// text-align: right;
color: #67c8fb;
}
.title-text {
width: 100%;
height: 2vh;
font-size: 2vh;
font-weight: 600;
color: #fff;
text-align: left;
padding-left: 1vw;
}
::v-deep .vxe-table--render-default .vxe-table--body-wrapper>table {
background-color: transparent;
}
::v-deep .vxe-table--render-wrapper {
background-color: transparent;
}
::v-deep .vxe-table--render-default {
color: #fff;
font-size: 1vw;
}
.table-container {
height: 90%;
overflow: hidden; // 隐藏容器的溢出内容
}
.custom-row-height-table {
--vxe-ui-table-row-height-default: 6vh;
--vxe-ui-table-column-padding-default: 1vh;
}
::v-deep .table-container .vxe-table--body-wrapper {
overflow-y: auto !important;
}
// 隐藏滚动条但保留滚动功能
::v-deep .table-container .vxe-table--body-wrapper::-webkit-scrollbar {
display: none;
}
::v-deep .table-container .vxe-table--body-wrapper {
-ms-overflow-style: none;
scrollbar-width: none;
}
</style>