HistoryTaskView.vue
3.4 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
<template>
<div class="cmc-table-page">
<div class="task-section">
<div class="table-wrapper">
<table class="task-table">
<thead>
<tr>
<th>任务ID</th>
<th>任务类型</th>
<th>库区</th>
<th>任务起始位置</th>
<th>任务目标位置</th>
<th>托盘编码</th>
<th>任务优先级</th>
<th>任务状态</th>
<th>执行设备</th>
<!-- 🔥 只给这列加 class -->
<th class="time-column">任务开始时间</th>
<th>任务持续时间</th>
</tr>
</thead>
<tbody>
<tr
v-for="(item, index) in taskList"
:key="index"
:class="{
'green-text': item.taskDurationSeconds <= 10,
'yellow-text': item.taskDurationSeconds > 10 && item.taskDurationSeconds < 60,
'red-text': item.taskDurationSeconds >= 60,
}"
>
<td>{{ item.taskId }}</td>
<td>{{ item.taskTypeDescription }}</td>
<td>{{ item.zoneCodeDescription }}</td>
<td>{{ item.fromLocation }}</td>
<td>{{ item.toLocation }}</td>
<td>{{ item.containerCode }}</td>
<td>{{ item.taskPriority }}</td>
<td>{{ item.taskStatusDescription }}</td>
<td>{{ item.executionEquipmentId }}</td>
<!-- 🔥 只给这列加 class -->
<td class="time-column">{{ item.taskStartTime }}</td>
<td>{{ item.taskDurationSecondsFormat }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script>
import { CMC_OFFLINE_TASK_API } from '@/api/cmcApi'
export default {
name: 'HistoryTaskView',
props: {
userName: {
type: String,
default: '',
},
},
watch: {
userName: {
immediate: true,
handler(newVal) {
if (newVal) {
// this.getData()
}
},
},
},
data() {
return {
baseUrlOffOne: CMC_OFFLINE_TASK_API,
baseUrlOnLineOne: window.appConfig.baseUrlintHistory,
sysData: {},
taskList: [],
direction: 'rtl',
device: {},
temp: 0,
refreshTimer: null,
}
},
methods: {
getAGVDataOne() {
const opt = {
urlSuffix: window.baseOnLineOrOff ? `${this.baseUrlOnLineOne}?zoneCode=${this.userName}` : `${this.baseUrlOffOne}?zoneCode=${this.userName}`,
logTitle: '历史任务列表',
isUrlALL: true,
headers: window.baseOnLineOrOff,
header: window.baseOnLineOrOff,
type: 'post',
}
const callBackFn = (res) => {
if (!this.ajaxSuccessDataBefore(res, opt.logTitle)) return
res.data.result.forEach((x) => {
x.taskDurationSeconds = Number((x.taskDurationSeconds / 60).toFixed(2))
})
this.taskList = res.data.result
}
''.ajax(this, opt, callBackFn)
},
ajaxSuccessDataBefore(res, title) {
if (!res || !res.data || res.data.result == null || res.data.result.length === 0) {
this.sysData = []
''.Log(`${title}无数据`, 'getData')
return false
}
return true
},
intInterval() {
if (this.refreshTimer) {
clearInterval(this.refreshTimer)
}
this.refreshTimer = setInterval(() => {
this.getAGVDataOne()
}, 10000)
},
pauseApiRequest() {
if (this.refreshTimer) {
clearInterval(this.refreshTimer)
this.refreshTimer = null
}
},
},
mounted() {
this.getAGVDataOne()
this.intInterval()
},
beforeDestroy() {
this.pauseApiRequest()
},
activated() {
this.intInterval()
},
deactivated() {
this.pauseApiRequest()
},
}
</script>
<style src="../../styles/cmc-table.css"></style>