吉安感知网项目-前端
shuishen
2026-02-03 89380e6260a75d1d3b94de687ebcc2f50d50659d
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
<template>
    <div class="inspectionTask" :style="{ paddingTop: route.query.topMargin + 'px' }">
        <van-search v-model="app_key_word" enterkeyhint="go" placeholder="请输入任务编号/名称/机巢名称/创建人" shape="round"
            @search="handleSearch" @clear="onCancel" />
 
        <van-tabs v-model:active="currentTab" @click-tab="onClickTab" line-width="26">
            <van-tab title="我的任务">
                <template #title>
                    <div class="custom-tab-title">
                        <div class="tab-text">我的任务</div>
                        <div class="tab-badge">{{ tabList[0].number }}</div>
                    </div>
                </template>
                <MyTask :indexTab="indexTab" :searchTxt="search_txt" @taskDetails="taskDetails"></MyTask>
            </van-tab>
            <van-tab title="计划执行">
                <template #title>
                    <div class="custom-tab-title">
                        <div class="tab-text">计划执行</div>
                        <div class="tab-badge">{{ tabList[1].number }}</div>
                    </div>
                </template>
                <planExecute :indexTab="indexTab" :searchTxt="search_txt" @taskDetails="taskDetails"></planExecute>
            </van-tab>
            <van-tab title="执行中">
                <template #title>
                    <div class="custom-tab-title">
                        <div class="tab-text">执行中</div>
                        <div class="tab-badge">{{ tabList[2].number }}</div>
                    </div>
                </template>
                <executeing :indexTab="indexTab" :searchTxt="search_txt" @taskDetails="taskDetails"></executeing>
            </van-tab>
            <van-tab title="待执行">
                <template #title>
                    <div class="custom-tab-title">
                        <div class="tab-text">待执行</div>
                        <div class="tab-badge">{{ tabList[3].number }}</div>
                    </div>
                </template>
                <pendingExecution :indexTab="indexTab" :searchTxt="search_txt" @taskDetails="taskDetails">
                </pendingExecution>
            </van-tab>
            <van-tab title="已执行">
                <template #title>
                    <div class="custom-tab-title">
                        <div class="tab-text">已执行</div>
                        <div class="tab-badge">{{ tabList[4].number }}</div>
                    </div>
                </template>
                <executioned :indexTab="indexTab" :searchTxt="search_txt" @taskDetails="taskDetails"></executioned>
            </van-tab>
            <van-tab title="执行失败">
                <template #title>
                    <div class="custom-tab-title">
                        <div class="tab-text">执行失败</div>
                        <div class="tab-badge">{{ tabList[5].number }}</div>
                    </div>
                </template>
                <executionError :indexTab="indexTab" :searchTxt="search_txt" @taskDetails="taskDetails">
                </executionError>
            </van-tab>
            <van-tab title="取消执行">
                <template #title>
                    <div class="custom-tab-title">
                        <div class="tab-text">取消执行</div>
                        <div class="tab-badge">{{ tabList[6].number }}</div>
                    </div>
                </template>
                <cancelExecution :indexTab="indexTab" :searchTxt="search_txt" @taskDetails="taskDetails">
                </cancelExecution>
            </van-tab>
        </van-tabs>
 
        <div class="add-task-btn" v-if="showAddBtn">
            <img :src="addBtnSvg" alt="" @click="addTask">
        </div>
    </div>
</template>
 
<script setup>
import addBtnSvg from '@/appDataSource/add.png'
import { getDeviceJobList, jobStatistics } from '@/api/home/task'
// import { useStore } from 'vuex'
import { showToast, showLoadingToast, closeToast } from 'vant'
import _ from 'lodash'
import MyTask from './compoment/myTask.vue'
import planExecute from './compoment/planExecute.vue'
import executeing from './compoment/executeing.vue'
import executioned from './compoment/executioned.vue'
import executionError from './compoment/executionError.vue'
import cancelExecution from './compoment/cancelExecution.vue'
import pendingExecution from './compoment/pendingExecution.vue'
import { useRoute } from 'vue-router'
const route = useRoute()
// const store = useStore()
 
const app_key_word = ref('')
const currentTab = ref(1)
const showAddBtn = ref(false)
const tabList = ref([
    { name: '我的任务', number: 0, id: 'my_planned_executions' },
    { name: '计划执行', number: 0, id: 'planned_executions' },
    { name: '执行中', number: 0, id: 'running_num' },
    { name: '待执行', number: 0, id: 'pending_executions' },
    { name: '已执行', number: 0, id: 'executed' },
    { name: '执行失败', number: 0, id: 'failed_executions' },
    { name: '取消执行', number: 0, id: 'go_home_executions' },
])
 
function getNumbers () {
    jobStatistics({ date_enum: '', app_key_word: app_key_word.value }).then(res => {
        // {executed:56,my_planned_executions:34,planned_executions:45 }
        tabList.value.forEach(tab => {
            if (res.data.data.hasOwnProperty(tab.id)) {
                tab.number = res.data.data[tab.id]
            }
        })
    })
}
function taskDetails (item) {
    const transmitData = { data: { type: 'taskDetails', rowItem: { ..._.cloneDeep(item) } } }
    if ([1, 2].includes(item.status)) {
        wx.miniProgram.navigateTo({ url: `/subPackages/taskDetail/inProgress/index?wayLineJobInfoId=${item.id}` })
    } else {
        wx.miniProgram.navigateTo({ url: `/subPackages/taskDetail/execution/index?wayLineJobInfoId=${item.id}&waylineJobId=${item.wayline_job_id}&batch_no=${item.batch_no}` })
    }
    wx.miniProgram.postMessage(transmitData)
    uni.postMessage(transmitData)
}
const search_txt = ref('')
function handleSearch () {
    search_txt.value = app_key_word.value
    getNumbers()
}
function onCancel () {
    search_txt.value = app_key_word.value
    getNumbers()
}
let indexTab = ref(0)
function onClickTab (index) {
    // app_key_word.value = ''
    indexTab.value = index
    search_txt.value = app_key_word.value
    getNumbers()
}
 
function addTask () {
    const transmitData = { data: { type: 'addTask' } }
    wx.miniProgram.navigateTo({ url: `/subPackages/taskDetail/addTask/index` })
    wx.miniProgram.postMessage(transmitData)
    uni.postMessage(transmitData)
}
 
watch(
    () => route.query,
    (newValue, oldValue) => {
        if (newValue.updateKey) {
            nextTick()
            app_key_word.value = ''
            currentTab.value = 1
            getNumbers()
        }
    },
    { deep: true })
 
onMounted(() => {
    if ('showAddBtn' in route.query) {
        showAddBtn.value = Number(route.query.showAddBtn)
    }
 
    getNumbers()
})
</script>
 
<style scoped lang="scss">
.inspectionTask {
    position: relative;
    height: 100%;
 
    //overflow: auto;
    //background: #f6f6f6;
    :deep(.van-search) {
        background: transparent;
    }
 
    :deep(.van-tabs) {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 54px);
    }
 
    :deep(.van-tabs__wrap) {
        height: 59px;
        margin-bottom: 10px;
    }
 
    :deep(.van-tabs__content) {
        flex: 1;
        overflow-y: auto;
        height: 0;
    }
 
    :deep(.van-tabs__nav--line) {
        background: transparent;
    }
 
    :deep(.van-badge) {
        background-color: #1d6fe9;
    }
 
    :deep(.van-empty) {
        //height: calc(100vh - 100px);
        margin-top: 100px;
    }
 
    :deep(.van-tab) {
        .custom-tab-title {
            padding-bottom: 8px;
            min-width: 60px;
            text-align: center;
 
            font-family: Source Han Sans CN, Source Han Sans CN;
            font-weight: 500;
 
            .tab-text {
                height: 21px;
                line-height: 21px;
                color: #676666 !important;
                font-size: 15px;
            }
 
            .tab-badge {
                margin-top: 2px;
                display: flex;
                align-items: center;
                justify-content: center;
                height: 18px;
                background: rgba(29, 111, 233, 0.14);
                border-radius: 4px 4px 4px 4px;
                color: #222324 !important;
                font-size: 12px;
            }
        }
    }
 
    :deep(.van-tab--active) {
        .custom-tab-title {
            .tab-text {
                color: #1d6fe9 !important;
            }
 
            .tab-badge {
                color: #0051ff !important;
            }
        }
    }
 
    :deep(.van-tabs__line) {
        background: #227bff !important;
    }
 
    .add-task-btn {
        position: absolute;
        right: 6px;
        bottom: 24px;
        
        img {
            width: 60px;
            height: 60px;
            vertical-align: middle;
            // border-radius: 50%;
        }
    }
}
</style>