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
<template>
    <view>
        <view class="view-bg">
            <uni-section title="播种位" type="line" />
            <uni-data-select v-model="siteNo" :localdata="range" @change="change" style="padding: 20rpx; height: 100rpx;background-color: white;">
            </uni-data-select>
        </view>
        <view class="view-bg">
            <uni-section title="订单" type="line" />
            <input placeholder="PDA扫描站点标签" v-model="orderNo"/>
        </view>
        <view class="view-bg">
            <uni-section title="容器" type="line" />
            <input maxlength="8" placeholder="PDA扫描托盘/料箱标签" v-model="barcode"/>
        </view>
        
        <view class="button-sp-buttom">
            <button class="btn-span" type="primary" @click="bindOrder('bind')">绑定</button>
            <button class="btn-span" type="default">解绑</button>
        </view>
        <template>
            <!-- 确认出库 -->
            <view>
                <uni-popup ref="combConfirm" type="dialog">
                    <uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" :title="title" :content="content"
                        @confirm="confirm" @close="combClose"></uni-popup-dialog>
                </uni-popup>
            </view>
            <view>
                <!-- 提示信息弹窗 -->
                <uni-popup ref="message" type="message">
                    <uni-popup-message :type="msgType1" :message="messageText" :duration="2000"></uni-popup-message>
                </uni-popup>
            </view>
        </template>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                range: [],
                orderNo: '',
                barcode: '',
                msgType1: '',
                messageText: '',
                msgType: '',
                title: '',
                content: '',
            }
        },
        
        onLoad () {
            this.baseUrl = uni.getStorageSync('baseUrl');
            this.token = uni.getStorageSync('token');
            this.getSeedLocs()
        },
        
        methods: {
            getSeedLocs() {
                let that = this
                toast.loading('加载中')
                uni.request({
                    url: this.baseUrl +  '/pda/pick/seed/locs',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(res) {
                        let result = res.data;
                        if (result.code === 200) {
                            if (result.data != undefined && result.data.length > 0) {
                                let array = result.data
                                console.log(array)
                                that.range = array.map((item, index) => {
                                    return {text: item.siteNo, value: item.siteNo}
                                })
                                console.log(that.range)    
                            }
                        }
                    },
                    complete() {
                        toast.hideLoading()
                    }
                    
                })
            },
            
            change(e) {
                console.log("e:", e);
            },
            //绑定订单至播种墙
            bindOrder(type) {
                let that = this
                if (this.barcode == undefined || this.barcode == '') {
                    this.messageToggle('error', '拖盘码不能为空!!')
                    return
                }
                
                if (this.orderNo == undefined || this.orderNo == '') {
                    this.messageToggle('error', '订单编码不能为空!!')
                    return
                }
                
                if (this.siteNo == undefined || this.siteNo == '') {
                    this.messageToggle('error', '播种站点不能为空!!')
                    return
                }
                
                if (type == undefined || type == null || type == null) {
                    type = 'bind'
                }
                toast.loading('绑定中..')
                uni.request({
                    url: that.baseUrl +  "/pda/pick/seed/bind",
                    data: {barcode: that.barcode, orderNo: that.orderNo, siteNo: that.siteNo, type: type},
                    method: 'POST',
                    header: {
                        'token': uni.getStorageSync('token')
                    },
                    success(res) {
                        let result = res.data;
                        if (result.code === 200) {
                            toast.hideLoading()
                            this.messageToggle('success', '绑定成功!')
                        } else {
                            toast.hideLoading()
                            this.messageToggle('error', result.msg)
                        }
                    },
                    fail(res) {
                        toast.hideLoading()
                        this.messageToggle('error', '服务器错误')
                        
                    },
                    complete() {
                        that.barcode = ''
                        that.orderNo = ''
                        that.siteNo = ''
                    }
                })
            },
            //解绑 
            unbindOrder() {
                this.bindOrder('unbind')
            },
            //dialog弹框信息
            dialogToggle(type,title, msg) {
                this.msgType = type
                this.title = title
                this.content = msg
                this.$refs.combConfirm.open()
            },
            
            //消息弹框
            messageToggle(type, msg) {
                this.msgType1 = type
                if (msg != undefined || msg != null) {
                    this.messageText = msg
                } 
                this.$refs.message.open()
            },
        }
    }
</script>
 
<style>
    @import url('../../static/css/wms.css/wms.css');
 
    .view-bg {
        background-color: white;
        
        input {
            padding: 30rpx;;
        }
        
        .uni-section__content-title {
            font-size: 16px;
        }
        
        .uni-section__head {
            .line {
                background-color: #007aff;
            }
        }
    }
    
    .button-sp-buttom {
        margin-top: 90rpx;
        padding: 40rpx;
        
        .btn-span {
            margin: 30rpx 20rpx;
        }
    }
</style>