skyouc
4 天以前 4c94dc71afd85a903ebed62db99b4ca11a2cd46d
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
<template>
    <view>
        <view class="code">
            <!-- <uni-search-bar :focus="matFocus" v-model="matnr"  @input="matInput()" ma
                maxlength="500" ancel="cancel" @clear="clear" placeholder="输入 / 扫描商品">
            </uni-search-bar> -->
            <view class="code-title">
                <view></view>
                <view>商品列表</view>
                <view @click="allChecked">{{allCheckBtnTitle}}</view>
            </view>
        </view>
        <view class="list" v-for="(item,i) in dataList">
            <view class="list-left">
                <view>编号:{{item.matnr}}</view>
                <view>名称:{{item.maktx}}</view>
                <view>规格:{{item.specs}}</view>
                <view>批号:{{item.batch}}</view>
                <view class="list-anfme">数量:{{item.anfme}}</view>
                <view class="list-qty-1" v-if="item.anfme > item.qty">作业数量:{{item.qty}}</view>
                <view class="list-qty-2" v-if="item.anfme <= item.qty">作业数量:{{item.qty}}</view>
                <view class="card-id">{{i + 1}}</view>
                <view>货位:{{item.locNo}}</view>
                <view style="display: flex;">出库站:
                    <view class="dropdown" >
                        <input type="text" style="width: 270rpx;" v-model="item.agvStaNo" placeholder="请选择出库站">
                        <uni-icons :type="item.isOpen ? 'top' : 'bottom'" color="#c1c1c1" style="margin-left: 10rpx;"></uni-icons>
                        <scroll-view scroll-y="ture" class="dropdown-content" v-if="item.isOpen">
                            <view class="dropdown-item" v-for="option in item.agvStaNos" @click="selected(option,item)">{{option}}</view>
                        </scroll-view>
                    </view>
                </view>
            </view>
            <view class="list-right" @click="checkboxChange(item)">
                <label >
                    <checkbox :value="item.orderNo" :checked="item.checked" color="" :disabled="item.anfme <= item.qty" style="transform:scale(0.7)" /><text></text>
                </label>
            </view>
        </view>
        <view style="height: 100rpx;"></view>
        
        <!-- 底部操作按钮 -->
        <view class="buttom">
            <button size="mini" @click="reset('warn')">稍后处理</button>
            <button size="mini" type="primary" @click="combConfirm('warn')">立即出库</button>
        </view>
        
        
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                baseUrl: '',
                token: '',
                orderId: '',
                matFocus: true,
                matnr: '',
                checck: true,
                dataList: [],
                oldDataList: [],
                newDataList: [],
                allCheck: false,
                allCheckBtnTitle: '全选',
                orderType: 'out',
                ids: [],
                isOpen: false,
                selects: [
                    {value: "CS-101-001-01@1"},
                    {value: "CS-101-001-02@1"},
                    {value: "CS-101-001-03@1"},
                    {value: "CS-101-002-01@1"},
                    {value: "CS-101-002-02@1"},
                    {value: "CS-101-002-03@1"},
                ]
            }
        },
        onLoad() {
            let that = 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('mats', function(data) {
                console.log(data);
                for (let item of data.mats) {
                    that.ids.push(item.id)
                }
                that.getPakoutList(that.ids)
            })
        },
        onShow() {
            if (this.dataList.length > 0) {
                this.oldDataList = [...this.dataList]
            }
        },
        methods: {
            toggleDropdown(item) {
                item.isOpen = !item.isOpen;
            },
            selected(option,item) {
                item.agvStaNo = option
            },
            // 订单明细
            getPakoutList(ids) {
                let _this = this
                uni.request({
                    url: `${_this.baseUrl}/out/pakout/preview/auth`,
                    header: {'token': uni.getStorageSync('token')},
                    data: ids,
                    method: 'POST',
                    success(res) {
                        res = res.data
                        if (res.code === 200) {
                            for (let k of res.data) {
                                k['isOpen'] = false
                            }
                            _this.dataList = res.data
                            _this.oldDataList = [..._this.dataList]
                        } 
                    }
                })
            },
            matInput() {
                let count = 0
                let sign = 0
                if (this.oldDataList.length > 0) {
                    this.dataList = [...this.oldDataList]
                }
                this.newDataList = []
                for (let k in this.dataList) {
                    if (!this.dataList[k].matnr.includes(this.matnr)) {
                        count++;
                    } else {
                        this.newDataList.push(this.dataList[k])
                    }
                }
                if (this.matnr != '') {
                    for (let j in this.dataList) {
                        if (!this.dataList[j].maktx.includes(this.matnr)) {
                        } else {
                            for (let i in this.newDataList) {
                                if (this.newDataList[i].matnr ==  this.dataList[j].matnr) {
                                    sign++
                                }
                            }
                            if (sign == 0) {
                                this.newDataList.push(this.dataList[j])
                            }
                        }
                    }
                }
                this.dataList = this.newDataList
            },
            checkboxChange(e) {
                let items = this.dataList,
                values = e.orderNo;
                if (e.checked) {
                    this.$set(e,'checked',false)
                } else {
                    if (e.anfme == e.qty) {
                        this.$set(e,'checked',false)
                    } else {
                        this.$set(e,'checked',true)
                    }
                    
                }
            },
            allChecked() {
                if (this.allCheck) {
                    this.allCheck = false
                    this.allCheckBtnTitle = '全选'
                } else {
                    this.allCheck = true
                    this.allCheckBtnTitle = '取消'
                }
                for (let item of this.dataList) {
                    if (this.allCheck) {
                        if (item.anfme == item.qty) {
                            this.$set(item,'checked',false)
                        } else {
                            this.$set(item,'checked',true)
                        }
                    } else {
                        this.$set(item,'checked',false)
                    }
                }
            },
            clear() {
                this.matnr = ''
                this.dataList = [...this.oldDataList]
            },
            combConfirm(type) {
                let _this = this
                let combList = []
                for (let k of _this.dataList) {
                    if (k.checked) {
                        if (k.agvStaNo == null) {
                            uni.showToast({ title: `${k.locNo}当前货位没有选择出库站`, icon: "error", position: 'top'})
                            return
                        } else {
                            combList.push(k)
                        }
                    }
                }
                if (combList.length == 0) {
                    uni.showToast({ title: '请选择出库商品', icon: "error", position: 'top'})
                    return
                }
                uni.request({
                    url: `${_this.baseUrl}/out/pakout/auth`,
                    header: {'token': uni.getStorageSync('token')},
                    data: combList,
                    method: 'POST',
                    success(res) {
                        res = res.data
                        console.log(res);
                        if (res.code === 200) {
                            uni.showToast({ title: '出库成功', icon: "success", position: 'top'})
                            setTimeout(()=> {
                                uni.navigateBack({
                                    delta: 2
                                });
                            },700)
                        }
                    }
                })
            },
            combConfirm2(type) {
                let _this = this
                let combList = []
                for (let k of _this.dataList) {
                    if (k.checked) {
                        combList.push(k)
                    }
                }
                if (combList.length == 0) {
                    uni.showToast({ title: '请选择出库商品', icon: "error", position: 'top'})
                    return
                }
                uni.navigateTo({
                    url: "../AGV/AGVPakin2",
                    success: function(res) {
                        // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                        res.eventChannel.emit('mats', {
                            mats: combList
                        })
                    },
                });
            },
            // 稍后处理
            reset() {
                setTimeout(()=> {
                    uni.navigateBack({
                        delta: 2
                    });
                },700)
            }
        }
    }
</script>
 
<style>
    @import url('../../../static/css/common/order.css');
    .list-anfme {
        color: #0082ff;
        font-weight: bold;
    }
    .list-qty-1 {
        color: #33ba43;
        font-weight: bold;
    }
    .list-qty-2 {
        color: #e2231a;
        font-weight: bold;
    }
</style>