zjj
6 天以前 9884e489c1ba7abbf412e99d4901a223ad2fbb53
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="list list-font-color shop-car" :class="orderDetl.color" v-for="(orderDetl,index) in orderCarList" :key="index">
            <view class="list-left">
                <view class="detl-threeCode">{{orderDetl.threeCode}}</view>
                <view>主单号:{{orderDetl.orderNo}}</view>
                <view>编号:{{orderDetl.matnr}}</view>
                <view>名称:{{orderDetl.maktx}}</view>
                <view>总数量:{{orderDetl.anfme}}</view>
                <view>入库数量:{{orderDetl.pakinQty}}</view>
            </view>
            <view class="list-right" @click="chageDetl(index)">
                <uni-icons type="settings" size="25"  color="#fff"></uni-icons>
            </view>
        </view>
        <!-- 垫高 -->
        <view style="height: 120rpx;"></view>
        <!-- 底部操作按钮 -->
        <view class="buttom">
            <button size="mini" type="primary" @click="agvStart('warn')">启动入库</button>
        </view>
        <!-- 弹窗 -->
        <view>
            <uni-popup ref="chageDetl" type="dialog">
                <view class="popup">
                    <!-- 标题 -->
                    <view class="title">入库数量</view>
                    <view class="popup-item">
                        <uni-number-box :value="count" :step='0.01' :max="9999999" color="#747474" @change="changeValue" />
                    </view>
                    <view class="btn">
                        <view class="btn-left" @click="remove()">移除物料</view>
                        <view class="btn-right" @click="changeCount()">修改数量</view>
                    </view>
                </view>
            </uni-popup>
        </view>
        <!-- 弹窗 -->
        <view>
            <uni-popup ref="agvStart" 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="popup-item">
                        <view class="popup-item-left">站点码:</view>
                        <view class="popup-item-right"><input type="text" v-model="agvDevp"></view>
                    </view>
                    <view class="btn">
                        <button class="btn-left" @click="agvStartClose()">取消</button>
                        <button class="btn-right" @click="agvStartConfirm()" :disabled="agvStartDis">入库</button>
                    </view>
                </view>
            </uni-popup>
        </view>
    </view>
</template>
 
<script>
    // todo: 购物车优化,存储购物车内容,退出页面再进后购物车还在
    export default {
        data() {
            return {
                orderCarList: [],
                count: 0,
                index: 0,
                barcode: '',
                agvDevp: '',
                agvStartDis: false
            }
        },
        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) {
                _this.orderCarList = data.item
                console.log(data.item);
            })
        },
        methods: {
            chageDetl(index) {
                this.index = index
                this.count = this.orderCarList[index].pakinQty
                this.$refs.chageDetl.open()
            },
            // 修改数量
            changeCount() {
                if (this.count > this.orderCarList[this.index].anfme) {
                    uni.showToast({ title: '数量不合法!', icon: "none", position: 'top' })
                    return
                }
                this.orderCarList[this.index].pakinQty = this.count
                this.$forceUpdate() // 强制刷新
                this.$refs.chageDetl.close()
            },
            // 移除物料
            remove() {
                this.orderCarList.splice(this.index, 1)
                this.$refs.chageDetl.close()
            },
            changeValue(value) {
                this.count = value
            },
            agvStart() {
                this.$refs.agvStart.open()
            },
            agvStartClose() {
                this.barcode = ''
                this.agvDevp = ''
                this.$refs.agvStart.close()
            },
            agvStartConfirm() {
                this.barcode = this.barcode.replace(/\s+/g, '')
                this.agvDevp = this.agvDevp.replace(/\s+/g, '')
                let _this = this
                if (_this.barcode === '') {
                    uni.showToast({ title: '货架码为空!', icon: "error", position: 'top' })
                    return;
                }
                if (_this.agvDevp === '') {
                    uni.showToast({ title: '站点码为空!', icon: "error", position: 'top' })
                    return;
                }
                if (_this.orderCarList.length === 0) {
                    uni.showToast({ title: '组托列表为空!', icon: "error", position: 'top' })
                    return;
                }
                for (let k of _this.orderCarList) {
                    if (k.pakinQty == 0) {
                        uni.showToast({ title: `${k.matnr}数量不能为 0 !`, icon: "error", position: 'top' })
                        return;
                    } 
                }
                let combMat = { orderNo:'', barcode: '', locNo: '', combMats: [] }
                let combMats = []
                for (let item of _this.orderCarList) {
                    combMat.orderNo = item.orderNo
                    combMat.barcode = _this.barcode
                    combMat.locNo = _this.agvDevp
                    combMat.combMats = []
                    let combM = {csocode: item.threeCode,isoseq: item.deadTime,matnr: item.matnr,batch: item.batch,anfme: item.pakinQty,maktx: item.maktx,specs: item.specs,processSts: item.processSts}
                    combMat.combMats.push(combM)
                    combMats.push({...combMat})
                }
                this.comb(combMats)
                
            },
            comb(combMats) {
                let _this = this;
                this.agvStartDis = true
                uni.request({
                    url: _this.baseUrl + '/agvMobile/start/pakin/auth',
                    data: JSON.stringify({
                        barcode: _this.barcode,
                        containerCode: _this.barcode,
                        devNo: _this.agvDevp,
                        combParams: combMats
                    }),
                    method: 'POST',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(result) {
                        var res = result.data
                        _this.agvStartDis = false
                        if (res.code === 200) {
                            _this.orderCarList = []
                            _this.$refs.agvStart.close()
                            uni.showToast({ title: '启动成功!', icon: "success", position: 'top' })
                            setTimeout(()=> {
                                _this.getOpenerEventChannel().emit('acceptDataFromOpenedPage', {data: 1});
                                uni.navigateBack({})
                            },1000)
                        } 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' })
                        }
                    },
                    fail(res) {
                        _this.agvStartDis = false
                    }
                });
            },
        }
    }
</script>
 
<style>
    @import url('../../../static/css/common/order.css');
    .shop-car {
        background-color: #2299ff;
        color: #fff;
    }
    .detl-threeCode {
        font-size: 28px;
        font-weight: bold;
    }
    .popup {
        width: 80vw;
        min-height: 100rpx;
        background-color: #FFF;
        border-radius: 25rpx;
        position: relative;
    }
    .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;
        justify-content: center;
    }
    .popup-item-left {
        width: 20vw;
        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: #e2231a;
        border-right: 1px solid #DCDFE6;
    }
    .btn-right {
        display: flex;
        flex: 1;
        justify-content: center;
        align-items: center;
        color: #409EFF;
    }
</style>