#
whycq
2022-06-22 9f15199ffb3de977720759623ae47309e6bcc8f0
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
<template>
    <view>
        <form>
            <view class="cu-form-group margin-top">
                <view class="title">出库单号:</view>
                <input v-model="billNo" placeholder="扫码 / 输入" name="input" @input="searchBillNo">
            </view>
            <view class="cu-form-group margin-top">
                
                <view class="title" >出库口:</view>
                <view class="combox" >
                    <uni-combox :candidates="sites" placeholder="请选择出库站点" v-model="siteId" @click="staNoSelect()"></uni-combox>
                </view>
            </view>
        </form>
        
        <view style="margin-top: 10px;">
            <uni-table ref="table" border stripe emptyText="暂无更多数据">
                <uni-tr>
                    <uni-th align="center" width="50">出库数量</uni-th>
                    <uni-th align="center" width="70">产品ID</uni-th>
                    <uni-th align="center" width="80">产品代号</uni-th>
                    <uni-th align="center" width="70">产品名称</uni-th>
                </uni-tr>
                <uni-tr v-for="(item, index) in matData" :key="index">
                    <uni-td align="center">{{item.qty}}</uni-td>
                    <uni-td align="center">{{item.matNo}}</uni-td>
                    <uni-td align="center">{{item.size}}</uni-td>
                    <uni-td align="center">{{item.matName}}</uni-td>
                </uni-tr>
            </uni-table>
        </view>
        
        <view class="cu-bar foot input" style="height: 130rpx;">
            <view class="flex solid-bottom padding justify-start">
                <button class="cu-btn bg-yellow main-btn margin-xs" style="width: 430rpx;" @click="outbound()">启动出库</button>
                <button class="cu-btn bg-grey main-btn margin-xs" @click="reset">重 置</button>
            </view>
        </view>
        
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                billNo: null,
                matData: [],
                sites: [],
                siteId: ''
            }
        },
        mounted(){
            const UIP = uni.getStorageSync('UIP');
            this.baseIP = UIP;
            const UPORT = uni.getStorageSync('UPORT');
            this.basePORT = UPORT;
            this.staNoSelect();
        },
        methods: {
            searchBillNo() {
                let that = this;
                uni.request({
                    url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + "/waitMatout/list/auth",
                    header: {'token':uni.getStorageSync('token')},
                    data: {
                        curr:1,
                        limit:10,
                        typeCode:1,
                        bill_no:that.billNo
                    },
                    success(result) {
                        let res = result.data
                        if (res.code === 200 ) {
                            that.matData = res.data.records
                            that.staNoSelect()
                        } else if (res.code == 403) {
                            uni.showToast({title: res.msg, icon: "none", position: 'top'})
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../login/login'
                                });
                            }, 1000);
                        } else {
                            uni.showToast({title: res.msg, icon: "none",position: 'top'})
                        }
                    },
                })
            },
            staNoSelect() {
                let that = this;
                uni.request({
                    url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + "/available/take/site",
                    header: {'token':uni.getStorageSync('token')},
                    success(result) {
                        let res = result.data
                        if (res.code === 200 ) {
                            that.sites = [];
                            for (var i = 0; i < res.data.length; i++) {
                                that.sites.push(res.data[i].desc)
                            }
                        } else if (res.code == 403) {
                            uni.showToast({title: res.msg, icon: "none", position: 'top'})
                            setTimeout(() => {
                                uni.reLaunch({
                                    url: '../login/login'
                                });
                            }, 1000);
                        } else {
                            uni.showToast({title: res.msg, icon: "none",position: 'top'})
                        }
                    }
                })
            },
            outbound() {
                let that = this
                if (that.matData.length === 0) {
                    uni.showToast({title: "请先添加产品", icon: "none",position: 'top'})
                } else {
                    if (that.siteId == '') {
                        uni.showToast({title: "请选择出库口", icon: "none",position: 'top'})
                        return;
                    }
                };
                var staNo = that.siteId.substring(0,3)
                
                var locDetls = [];
                that.matData.forEach(function(elem) {
                    locDetls.push({billNo:elem.billNo,seqNo:elem.seqNo, matNo: elem.matNo, count: elem.qty,});
                });
                let param = {
                    outSite: 173,
                    locDetls: locDetls
                }
                uni.request({
                    url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + "/mat/out/start",
                    header: {
                        'token':uni.getStorageSync('token')},
                    data: JSON.stringify(param),
                    method:"POST",
                    success(result) {
                        if (result.data.code === 200) {
                            uni.showToast({title: result.data.msg, icon: "none",position: 'top'})
                            that.reset()
                        } else {
                            uni.showToast({title: result.data.msg, icon: "none",position: 'top'})
                        }
                    }
                })
            },
            reset() {
                this.billNo = '';
                this.matData = [];
                this.siteId = '';
            }
        }
    }
</script>
 
<style>
    .pda-btn1 {
        margin-left:260rpx;
        margin-right: auto;
        margin-top: 150rpx;
        width: 200rpx;
        height: 80rpx;
        font-size: 30upx;
        font-weight: bold;
    }
    .combox {
        width: 200px;
        padding: 12px;
    }
</style>