#
whycq
2024-04-05 7839d94fc246556baf6f05db92e3ae20bcf36245
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
<template>
    <view>
        <!-- 站点详情 -->
        <view class="station" :class="station.style" v-if="station">
            <view class="mt-flex">
                <view class="station-title" style="flex: 1;">{{station.devNo}}</view>
                <view><button size="mini" :loading="reload.loading" @click="reloadStation()">{{reload.loadingText}}</button></view>
            </view>
            <view>站点类型:{{station.locType1$}}区</view>
            <view>货架前两位:{{station.locType2$}}</view>
            <view>站点状态:{{station.locSts$}}</view>
            <view class="mt-flex">
                <view class="station-barcode" style="flex: 1">货架码:<text>{{station.barcode ? station.barcode : '--'}}</text></view>
                <view v-if="station.barcode"><button size="mini" type="warn" @click="unbind()">解除绑定</button></view>
            </view>
        </view>
        
        <!-- 弹窗 -->
        <!-- 修改数量 -->
        <view>
            <uni-popup ref="emptyPakin" type="dialog">
                <view class="popup">
                    <!-- 标题 -->
                    <view class="title">请输入空货架码</view>
                    <view class="popup-item">
                        <view class="popup-item-left">货架码:</view>
                        <view class="popup-item-right"><input type="text" v-model="barcode"></view>
                    </view>
                    <view class="btn">
                        <view class="btn-left" @click="emptyPakinClose">取消</view>
                        <view class="btn-right" @click="emptyPakinConfirm()">入库</view>
                    </view>
                </view>
            </uni-popup>
        </view>
        
        
        
        
        <!-- 底部操作按钮 -->
        <view class="buttom">
            <button size="mini" type="primary" @click="emptyPakin()" v-if="btnType == 'emptyPakin'">空板入库</button>
            <button size="mini" type="primary" @click="emptyPakin()" v-if="btnType == 'emptyPakin'">空板入库</button>
            <button size="mini" type="primary" @click="containerMoveOut()" v-if="btnType == 'out'">确认出库</button>
            <button size="mini" type="primary" @click="pickIn()" v-if="btnType == 'pick'">已拣料回库</button>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                station: null,
                reload: {
                    loading: false,
                    loadingText: '更新状态'
                },
                btnType: 'emptyPakin',
                barcode: ''
            }
        },
        onShow() {
            let _this = this
            this.baseUrl = uni.getStorageSync('baseUrl');
            this.token = uni.getStorageSync('token');
            // const eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
            const eventChannel = this.getOpenerEventChannel();
            // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
            eventChannel.on('item', function(data) {
                console.log(data);
                _this.station = data.item
                _this.reloadStation()
            })
        },
        methods: {
            // 更新站点
            reloadStation()  {
                let _this = this
                _this.reload.loading = true
                _this.reload.loadingText = '更新中...'
                uni.request({
                    url: `${_this.baseUrl}/agv/basDevp/list/auth`,
                    header: {'token': uni.getStorageSync('token')},
                    data: { curr: 1, limit: 1000,  dev_no: _this.station.devNo },
                    method: 'GET',
                    success(res) {
                        res = res.data
                        if (res.code === 200) {
                            if (res.data.records[0].locSts == 'O') {
                                _this.btnType = 'emptyPakin' 
                            } else if (res.data.records[0].locSts == 'F') {
                                _this.btnType = 'pakin' 
                            } else {
                                _this.btnType = 'working' 
                            }
                            setTimeout(()=>{
                                for  (let k of res.data.records) {
                                    if (k.locSts != 'O') {
                                        k['style'] = 'station-wrk'
                                    } else {
                                        k['style'] = 'station-nowrk'
                                    }
                                }
                                _this.station = res.data.records[0]
                                _this.reload.loading = false
                                _this.reload.loadingText = '更新状态'
                            },500)
                        } else if (res.code == 403) {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                            setTimeout(() => { uni.reLaunch({ url: '../login/login' }); }, 1000);
                        } else {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                        }
                    }
                })
            },
            // 站点解绑 
            unbind() {
                let  _this = this
                let data = {param: JSON.stringify(_this.station)}
                uni.request({
                    url: `${_this.baseUrl}/agv/basDevp/unbind/auth`,
                    header: {
                        'token': uni.getStorageSync('token'),
                        'content-type': 'application/x-www-form-urlencoded'
                    },
                    data: data,
                    method: 'POST',
                    success(res) {
                        res = res.data
                        if (res.code === 200) {
                            _this.reloadStation()
                        } else if (res.code == 403) {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                            setTimeout(() => { uni.reLaunch({ url: '../login/login' }); }, 1000);
                        } else {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                        }
                    }
                })
            },
            // 空板入库确认
            emptyPakin() {
                this.$refs.emptyPakin.open()
            },
            emptyPakinClose() {
                this.$refs.emptyPakin.close()
            },
            emptyPakinConfirm() {
                this.emptyPakinClose()
                let _this = this;
                let params = []
                let param = { devNo: this.station.devNo, containerCode: this.barcode, }
                params.push(param)
                uni.request({
                    url: `${_this.baseUrl}/agvMobile/pakin/empty/auth`,
                    data: { pad: params },
                    method: 'POST',
                    header: { 'token': uni.getStorageSync('token') },
                    success(res) {
                        var res = result.data
                        if (res.code === 200) {
                            setTimeout(()=> {
                                _this.barcode = ''
                                _this.reloadStation()
                            },1000)
                            uni.showToast({ title: '启动入库', icon: "success", position: 'top' })
                        } else if (res.code == 403) {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                            setTimeout(() => { uni.reLaunch({ url: '../login/login' }); }, 1000);
                        } else {
                            uni.showToast({ title: res.msg, icon: "error", position: 'top' })
                        }
                    }
                });
            }
        }
    }
</script>
 
<style>
    @import url('../../../static/css/common/order.css');
    .station-title {
        font-size: 32px;
        font-weight: bold;
        padding: 24rpx 0;
    }
    .station {
        font-size: 18px;
        padding: 24rpx;
    }
    .station-barcode {
        font-size: 24px;
        font-weight: bold;
        padding: 24rpx 0;
    }
    .station-wrk {
        background-color: #ff7356;
        color: #fff;
    }
    .station-nowrk {
        background-color: #3eb689;
        color: #fff;
    }
    
    
    .popup {
        width: 80vw;
        min-height: 100rpx;
        background-color: #FFF;
        border-radius: 25rpx;
    }
    .title {
        height: 100rpx;
        line-height: 100rpx;
        width: 100%;
        color: #606266;
        text-align: center;
        font-size: 16px;
    }
    .popup-item {
        height: 80rpx;
        line-height: 80rpx;
        display: flex;
        align-items: center;
        font-size: 14px;
    }
    .popup-item-left {
        width: 16vw;
        padding-right: 20rpx;
        text-align: right;
        color: #606266;
    }
    .popup-item-right {
        display: flex;
        align-items: center;
        width: 50vw;
        height: 50rpx;
        padding: 2px 5px;
        border: 1px solid #E4E7ED;
        border-radius: 5rpx;
    }
    .popup-item-right input{
        color: #606266;
    }
    .btn {
        display: flex;
        height: 90rpx;
        margin-top: 20rpx;
        border-top: 1px solid #DCDFE6;
        justify-content: center;
        align-items: center;
    }
    .btn-left {
        display: flex;
        flex: 1;
        height: 100%;
        justify-content: center;
        align-items: center;
        color: #606266;
        border-right: 1px solid #DCDFE6;
    }
    .btn-right {
        display: flex;
        flex: 1;
        justify-content: center;
        align-items: center;
        color: #409EFF;
    }
</style>