ll
liukangdong
2025-02-07 abfb84c633a2bd1773cf9be27e753f787f1ed641
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<template>
    <view class="main_app">
        <view class="tabs">
            <view class="tab" :class="{active: queryStatus == 0}" @click="tabsClick(0)">
                <text>待办</text>
                <text class="border"></text>
            </view>
            <view class="tab" :class="{active: queryStatus == 1}" @click="tabsClick(1)">
                <text>已办</text>
                <text class="border"></text>
            </view>
        </view>
        <scroll-view scroll-y="true" class="scroll_Y" @scrolltolower="scrolltolower">
            <view class="list">
                <view class="item" @click="itemClick(item)" v-for="item in list">
                    <view class="img">
                        <image v-if="item.type == 0 && item.status == 0" src="@/static/side/ic_pandian@2x.png"></image>
                        <image v-if="item.type == 1 && item.status == 0" src="@/static/side/xunjianed.png"></image>
                        <image v-if="item.type == 2 && item.status == 0" src="@/static/side/workordered.png"></image>
                        <image v-if="item.type == 0 && item.status == 1" src="@/static/side/ic_pandian_grey@2x.png"></image>
                        <image v-if="item.type == 1 && item.status == 1" src="@/static/side/xunjian.png"></image>
                        <image v-if="item.type == 2 && item.status == 1" src="@/static/side/workorder.png"></image>
                    </view>
                    <view class="content">
                        <view class="title" v-if="item.obj">
                            <view>{{item.obj.key1}}</view>
                            <view v-if="item.status == 0 && item.type == 2" class="status">待处理</view>
                            <view v-if="item.status == 0 && item.param3 == 0 && (item.type == 0 || item.type == 1)" class="status">未开始
                            </view>
                            <view v-if="item.status == 0 && item.param3 == 1 && (item.type == 0 || item.type == 1)"
                                class="status green">{{ item.type == 0 ? '盘点中' : '进行中' }}</view>
                            <view v-if="item.status == 1 && item.type == 2" class="status gray">已处理</view>
                            <view v-if="item.status == 1 && (item.type == 0 || item.type == 1)" class="status gray">已完成</view>
                        </view>
                        <template v-if="item.obj && item.type == 1">
                            <view class="text">任务日期:{{item.obj.key2}}</view>
                            <view class="text">执行时间:{{item.obj.key3}}</view>
                            <view class="text">
                                <view class="">巡检负责人:{{item.obj.key4}}</view>
                                <view v-if="queryStatus == 0" class="btn" @click.stop="openSc(item)">
                                    <image src="@/static/side/ic_saoma@2x.png" mode=""></image>
                                    <view v-if="item.status == 0" class="">扫码巡检</view>
                                </view>
                            </view>
                        </template>
                        <template v-if="item.obj && item.type == 0">
                            <view class="content">
                                <view class="text">盘点日期:{{item.obj.key2}}</view>
                                <view class="text">盘点仓库:{{item.obj.key3}}</view>
                                <view class="text">
                                    <view class="">盘点员:{{item.obj.key4}}</view>
                                    <view v-if="item.status == 0 && item.param3 == 0" class="btn" @click.stop="startHandle(item)">开始盘点
                                    </view>
                                    <view v-if="item.status == 0 && item.param3 == 1" class="btn" @click.stop="startHandle(item)">继续盘点
                                    </view>
                                </view>
                            </view>
                        </template>
                        <template v-if="item.obj && item.type == 2">
                            <view class="content">
                                <view class="text">上报时间:{{item.obj.key2}}</view>
                                <view class="text">位置类型:{{item.obj.key3}}</view>
                                <view class="text">工单分类:{{item.obj.key4}}</view>
                            </view>
                        </template>
 
                    </view>
 
 
                </view>
            </view>
            <view class="empty" v-if="list.length == 0">
                <image src="@/static/empty.png" mode=""></image>
                <view class="">暂无数据</view>
            </view>
        </scroll-view>
        <!--  -->
        <view class="reader-box" @click="stopScan" v-if="isScaning">
            <view class="reader" id="reader"></view>
        </view>
    </view>
</template>
 
<script>
    import {
        myNoticesH5,
        ywStocktakingBegin,
        getPointRecordByCode
    } from '@/api'
    import {
        Html5Qrcode
    } from 'html5-qrcode';
    export default {
        data() {
            return {
                list: [],
                total: 0,
                page: 1,
                queryStatus: 0,
 
                html5Qrcode: null,
                isScaning: false,
            };
        },
        onShow() {
            this.page = 1
            this.list = []
            this.getList()
        },
        methods: {
            tabsClick(val) {
                this.list = []
                this.page = 1
                this.queryStatus = val
                this.getList()
            },
            itemClick(item) {
                if (item.objType == 0 && item.status == 1) {
                    uni.navigateTo({
                        url: `/pages/inventory/detail?id=${item.objId}`
                    })
                } else if (item.objType == 1) {
                    // return
                    uni.navigateTo({
                        url: `/pages/polling/detail?id=${item.objId}`
                    })
                } else if(item.objType == 2) {
                    uni.navigateTo({
                        url: `/pages/workOrder/detail?id=${item.objId}`
                    })
                }
            },
            startHandle(item) {
                if (item.param3 == 0) {
                    uni.showModal({
                        content: '盘点期间不可进行出入库操作',
                        success: (res) => {
                            if (res.confirm) {
                                ywStocktakingBegin(item.objId).then(() => {
                                    uni.navigateTo({
                                        url: '/pages/inventory/detail?id=' + item.objId
                                    })
                                })
 
                            }
                        }
                    })
                }else{
                    uni.navigateTo({
                        url: '/pages/inventory/detail?id=' + item.objId
                    })
                }
            },
            getList() {
                const {
                    page,
                    total,
                    list,
                    queryStatus
                } = this
                myNoticesH5({
                    page,
                    capacity: 20,
                    model: {
                        status: queryStatus
                    }
                }).then(res => {
                    this.list = [...this.list, ...res.data.records]
                    this.list.forEach(item => {
                        item.obj = JSON.parse(item.param2)
                    })
                    console.log(this.list);
                    this.total = res.data.total
                })
            },
            scrolltolower() {
                const {
                    total,
                    list
                } = this
                if (list.length < total) {
                    this.page = this.page + 1
                    this.getList()
                } else {
                    this.showToast('暂无更多数据')
                }
            },
            openSc(item) {
                this.isScaning = true;
                Html5Qrcode.getCameras().then((devices) => {
                    if (devices && devices.length) {
                        this.html5Qrcode = new Html5Qrcode('reader');
                        this.html5Qrcode.start({
                                facingMode: 'environment'
                            }, {
                                focusMode: 'continuous', //设置连续聚焦模式
                                fps: 5, //设置扫码识别速度
                                qrbox: 280 //设置二维码扫描框大小
                            },
                            (decodeText, decodeResult) => {
                                if (decodeText) { //这里decodeText就是通过扫描二维码得到的内容
                                    this.stopScan(); //关闭扫码功能
                                    const index = decodeText.indexOf('ywid')
                                    let pointCode = decodeText.slice(index + 5)
                                    getPointRecordByCode({
                                        taskId: item.objId,
                                        pointCode
                                    }).then(ress => {
                                        if (ress.data) {
                                            uni.navigateTo({
                                                url: '/pages/polling/point?id=' + ress.data.id
                                            })
                                        } else {
                                            this.showToast('未匹配到巡检点,请重新扫描')
                                        }
                                    })
                                }
                            },
                            (err) => {
                                // console.log(err);  //错误信息
                            }
                        );
                    }
                });
            },
 
            stopScan() {
                console.log('停止扫码')
                this.isScaning = false;
                if (this.html5Qrcode) {
                    this.html5Qrcode.stop();
                }
            },
        }
    }
</script>
 
<style lang="scss">
    page {
        background-color: #f7f7f7;
 
        .main_app {
            padding: 0;
            height: 100vh;
            overflow: hidden;
            background-color: #fff;
        }
 
        .tabs {
            display: flex;
            width: 750rpx;
            margin: 0rpx 0rpx 0;
            border-bottom: 1rpx solid #E5E5E5;
            background-color: #fff;
 
            .tab {
                font-size: 30rpx;
                color: #666666;
                flex: 1;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: flex-end;
                height: 88rpx;
 
                .name {
                    display: flex;
                    align-items: center;
                }
 
                .icon {
                    width: 28rpx;
                    height: 28rpx;
                    margin-right: 10rpx;
                }
 
                .border {
                    width: 54rpx;
                    height: 6rpx;
                    background-color: #fff;
                    border-radius: 3rpx;
                    margin-top: 16rpx;
                }
            }
 
            .active {
                font-weight: 600;
                font-size: 32rpx;
                color: #222222;
 
                .border {
                    background-color: $primaryColor;
                }
 
            }
 
        }
 
        .scroll_Y {
            height: calc(100vh - 120rpx);
 
            .empty {
                padding-top: 260rpx;
 
                image {
                    width: 360rpx;
                    height: 360rpx;
                    margin-bottom: 10rpx;
                }
 
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                color: #999999;
            }
        }
 
        .list {
            // padding-top: 20rpx;
 
            .item {
                width: 100%;
                background: #FFFFFF;
                border-radius: 8rpx;
                display: flex;
                padding: 30rpx 24rpx;
                border-bottom: 1rpx solid #e5e5e5;
 
                .img {
                    position: relative;
                    margin-right: 20rpx;
                    flex-shrink: 0;
                    position: relative;
 
                    image {
                        width: 72rpx;
                        height: 72rpx;
                    }
 
                    .dian {
                        position: absolute;
                        background-color: red;
                        width: 18rpx;
                        height: 18rpx;
                        border-radius: 50%;
                        top: -8rpx;
                        right: -8rpx;
                    }
                }
 
                .content {
                    flex: 1;
 
                    .title {
                        font-weight: 500;
                        font-size: 32rpx;
                        color: #222222;
                        margin-bottom: 6rpx;
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
 
                        .status {
                            color: $primaryColor;
                            font-weight: 400;
                            font-size: 28rpx;
                        }
 
                        .green {
                            color: #0ADE79;
                        }
 
                        .gray {
                            color: #999999;
                        }
                    }
 
                    .text {
                        font-size: 26rpx;
                        color: #666666;
                        height: 60rpx;
                        display: flex;
                        align-items: center;
                        justify-content: space-between;
 
                        .btn {
                            background-color: $primaryColor;
                            padding: 0 24rpx;
                            height: 60rpx;
                            border-radius: 30rpx;
                            display: flex;
                            align-items: center;
                            color: #fff;
 
                            image {
                                width: 28rpx;
                                height: 28rpx;
                                margin-right: 6rpx;
                            }
                        }
                    }
 
                    .time {
                        font-size: 26rpx;
                        color: #999999;
                    }
                }
            }
        }
    }
 
    .reader-box {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: rgba(0, 0, 0, 0.5);
    }
 
    .reader {
        width: 100%;
        // width: 540rpx;
        // height: 540rpx;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
</style>