cuiqian2004
2025-09-19 d8743368ffda9bc0fb2c6818f695a9a6b1079e57
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<template>
    <view class="pages-task-item">
        <view class="item-content">
            <view class="btn-no " :class="taskIsRun?'active':'' " @click="clickButton">
                {{taskData.taskButton}}
            </view>
            <view class="content" @click="clickTask">
                <view class="line">
                    <view class="title"> {{taskData.taskGroupName}}</view>
                </view>
                <view class="line">
                    <view class="desc">
                        {{taskListDesc}}
                    </view>
                    <view class="cycle">
                        {{taskCycleTime}}
                    </view>
                </view>
            </view>
            <view class="action-button" v-if="taskIsRun">
                <!--             <button type="primary" v-show="false" :plain="true" class="button" @click.stop="clickRepeatTask">
                <text class="ico repeat" />
            </button> -->
                <button type="primary" :plain="true" class="button" @click.stop="clickSkipTask">
                    <text class="ico skip-next-rounded" />
                </button>
                <button type="primary" :plain="true" class="button" @click.stop="clickStopTask">
                    <text class="ico stop" />
                </button>
                <!--             <button type="primary" v-show="false" :plain="true" class="button" @click.stop="clickPauseTask">
                <text class="ico pause-rounded" />
            </button>
            <button type="primary" v-show="false" :plain="true" class="button" @click.stop="clickPlayTask">
                <text class="ico play-filled" />
            </button> -->
            </view>
            <view class="action-button" v-else>
                <button :type=" !taskCanRun ? 'default':'primary'" :plain="true" class="button" :disabled=" !taskCanRun"
                    @click.stop="clickPlayTask">
                    <text class="ico play-filled " :class="taskCanRun ? '':'disabled'" />
                </button>
            </view>
        </view>
        <view class="item-sub" v-if="showTaskRunning && taskIsRun">
            <view class="sub-item" v-for="(item,index) in taskStatusList" :key="item.taskID">
                <text class="text">{{getStatusText(item.status)}}</text>
                <text class="text">{{"目标点"+(index+ 1)}}</text>
                <text class="text">{{getDestText(item)}}</text>
                <text class="text">{{getActionText(item)}}</text>
            </view>
        </view>
    </view>
 
</template>
 
<script>
    import {
        showToast,
        showModal
    } from "@/comm/utils.js"
    import {
        Button
    } from 'antd-mobile-vue-next'
    export default {
        name: "PagesTaskItem",
        components: {
            'a-button': Button
        },
        props: {
            taskData: {
                type: Object,
                default () {
                    return {};
                }
            },
            taskStatus: {
                type: Object,
                default () {
                    return {};
                }
            },
            deleteX: {
                type: Number,
                default () {
                    return 0;
                }
            },
            showTaskRunning: {
                type: Boolean,
                default () {
                    return false;
                }
            },
 
        },
        data() {
            return {}
        },
        computed: {
            taskListDesc() {
                let list = this.taskData.taskList || []
                list = list.map((a) => a.dest?.name)
 
                return list.join("-")
            },
            taskCycleTime() {
 
                if (this.taskIsRun)
                    return `第${this.taskStatus?.curCycleNumber || 0}/${this.taskStatus?.cycleTotleNumber || 0}次`
 
                else
                    return `重复${this.taskData.cycleTime || 0}次`
 
 
            },
            taskIsRun() {
                if (this.taskStatus?.taskGroupID == this.taskData.taskGroupID) {
                    return true
                } else {
                    return false
                }
            },
            taskCanRun() {
                if (this.taskStatus?.taskGroupID) {
                    return false
                } else {
                    return true
                }
            },
 
            taskStatusList() {
                if (this.taskIsRun) {
                    let list = this.taskStatus.taskStatusList || []
                    list = list.filter((a) => a.cycleNumber == this.taskStatus.curCycleNumber)
                    return list
                } else {
                    return []
                }
            }
 
        },
 
        methods: {
            setData(obj) {
                let that = this;
                let keys = [];
                let val, data;
 
                Object.keys(obj).forEach(function(key) {
                    keys = key.split(".");
                    val = obj[key];
                    data = that.$data;
                    keys.forEach(function(key2, index) {
                        if (index + 1 == keys.length) {
                            that.$set(data, key2, val);
                        } else {
                            if (!data[key2]) {
                                that.$set(data, key2, {});
                            }
                        }
                        data = data[key2];
                    });
                });
            },
            clickButton() {
                if (this.taskIsRun)
                    this.$emit('click-btn', this.taskData)
            },
 
            clickTask() {
                this.$emit('click-item', this.taskData)
            },
            clickPlayTask() {
                if (this.taskStatus?.taskGroupID)
                    return
                this.$emit('click-play', this.taskData)
            },
 
            clickStopTask() {
                this.$emit('click-stop', this.taskData)
            },
 
            clickSkipTask() {
                this.$emit('click-skip', this.taskData)
            },
 
            clickRepeatTask() {
                this.$emit('click-repeat', this.taskData)
            },
 
            clickPauseTask() {
                this.$emit('click-pause', this.taskData)
            },
 
            clickDelete() {
                this.$emit('click-delete', this.taskData)
            },
 
            getStatusText(status) {
                var statusText = "未知"
                if (!status) {
                    statusText = "未开始"
                } else if (status === 5) {
                    statusText = "强制完成"
                } else if (status === 4) {
                    statusText = "异常结束"
                } else if (status === 3) {
                    statusText = "已取消"
                } else if (status === 2) {
                    statusText = "已完成"
                } else if (status === 1) {
                    statusText = "执行中"
                }
                return statusText
            },
            getDestText(item) {
                const index = this.taskData.taskList.findIndex((a) => a.taskID == item.taskID)
                if (index > -1) {
                    return this.taskData.taskList[index].dest?.name || ""
                }
                return ""
            },
            getActionText(item) {
                const index = this.taskData.taskList.findIndex((a) => a.taskID == item.taskID)
                if (index > -1) {
                    const task = this.taskData.taskList[index]
                    var actionText = "未知"
                    if (task.actionType === 1) {
                        actionText = "导航"
                    } else if (task.actionType === 2) {
                        actionText = "取货"
                    } else if (task.actionType === 3) {
                        actionText = `卸货 等待${task.wait || 0}秒`
                    } else if (task.actionType === 4) {
                        actionText = "人工"
                    }
                    return actionText
                }
                return ""
            },
 
        }
    }
</script>
 
<style lang="scss" scoped>
    .pages-task-item {
 
        width: 100%;
        display: flex;
        flex-direction: column;
 
        .item-content {
            width: 100%;
            display: flex;
            flex-direction: row;
            align-items: center;
        }
 
        .item-sub {
            display: flex;
            flex-direction: column;
            padding: 10rpx 30rpx 10rpx 50rpx;
 
            .sub-item {
                color: gray;
                padding: 10rpx;
                border-bottom: 1px solid #ddd;
                display: flex;
                flex-direction: row;
                .text {
                    color: gray;
                    padding: 10rpx;
                }
            }
 
            .sub-item:last-child {
                border-bottom: 0;
            }
        }
 
        .btn-no {
            display: flex;
            margin: 0 10rpx 0 20rpx;
            border-radius: 25rpx;
            background-color: #E6F7FF;
            color: #1890FF;
            width: 50rpx;
            height: 50rpx;
            line-height: 54rpx;
            justify-content: center;
            align-items: center;
            text-align: center;
        }
 
        .active {
            background-color: #1890FF;
            color: #fff;
        }
 
        .content {
            display: flex;
            flex-direction: column;
            flex: 1;
            min-width: 0;
            padding: 5px;
 
            .line {
                padding: 5px 0;
                width: 100%;
                display: flex;
                flex-direction: row;
 
                .title {
                    font-size: 36rpx;
                    font-weight: 600;
                    min-width: 0;
                    /* 关键:允许收缩到比内容还窄 */
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }
 
                .desc {
                    flex: 1;
                    color: gray;
                    min-width: 0;
                    /* 关键:允许收缩到比内容还窄 */
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }
 
                .cycle {
                    color: gray;
                    padding: 0 10rpx;
                }
 
 
            }
        }
 
        .action-button {
            display: flex;
            flex-direction: row;
 
            .button {
                display: flex;
                margin: 10rpx;
                border-radius: 50%;
                //padding: 5rpx !important;
                width: 60rpx;
                height: 60rpx;
                justify-content: center;
                align-items: center;
 
                .ico {
                    font-size: 30rpx;
                    color: #1890FF;
 
                }
 
                .disabled {
                    color: gray !important;
                }
 
            }
 
            .disabled {
                color: gray;
            }
 
 
        }
 
    }
</style>