#
whycq0520
2022-03-25 2d256c80b73cb675a210f750d01360cb689bc870
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
<template>
    <view>
        <view>
            <uni-table border stripe type="selection" emptyText="没有更多数据">
                <uni-tr>
                    <uni-th align="center">数量</uni-th>
                    <uni-th align="center">批号</uni-th>
                    <uni-th align="center">商品编号</uni-th>
                    <uni-th align="center">商品名称</uni-th>
                    <uni-th align="center">规格</uni-th>
                    <uni-th align="center">单价</uni-th>
                    <uni-th align="center">操作</uni-th>
                </uni-tr>
                <uni-tr v-for="(item,index) in stockInData" :key="index">
                    <uni-td width="50">
                        <view class="flex justify-center">
                            <button class="cu-btn bg-orange sm" style="width: 60rpx;" @click="changeCount(index,item)">{{item.count}}</button>
                        </view>
                    </uni-td>
                    <uni-td align="center" width="50">{{item.batch}}</uni-td>
                    <uni-td align="center" width="100">{{item.matnr}}</uni-td>
                    <uni-td align="center" width="100">{{item.maktx}}</uni-td>
                    <uni-td align="center" width="50">{{item.specs}}</uni-td>
                    <uni-td align="center" width="50">{{item.price}}</uni-td>
                    <uni-td align="center" width="50">空</uni-td>
                </uni-tr>
            </uni-table>
        </view>
        <view class="cu-bar foot input justify-center" style="height: 150rpx;">
            <view style="width: 80%;">
                <button class="cu-btn bg-yellow lg shadow-blur" style="width: 250rpx;color: #fff;" @click="getMat()">新 增</button>
                <button class="cu-btn bg-orange lg shadow-blur" style="float: right;width: 250rpx;color: #fff;" @click="confirm()">确认入库</button>
            </view>    
        </view>
        <!-- ******************************************************************************************* -->
        <view>
            <!-- 修改数量弹框 -->
            <uni-popup ref="inputDialog" type="dialog">
                <uni-popup-dialog ref="inputClose" mode="input" title="物料数量" @confirm="dialogInputConfirm">
                        <uni-number-box  :max="999" v-model="value" />
                </uni-popup-dialog>
            </uni-popup>
        </view>
        <view>
            <!-- 提示信息弹窗 -->
            <uni-popup ref="message" type="message">
                <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
            </uni-popup>
        </view>
        <view>
            <!-- 显示表单弹窗 -->
            <uni-popup ref="showNodeSelect" type="dialog">
                <uni-popup-dialog ref="inputClose" mode="input" title="选择入库货位" >
                        
                </uni-popup-dialog>
            </uni-popup>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                type:'bottom',
                stockInData: [],
                value:'',
                rowNum:'',
                msgType: '',
                messageText: '',
            }
        },
        mounted(){
            const UIP = uni.getStorageSync('UIP');
            this.baseIP = UIP;
            const UPORT = uni.getStorageSync('UPORT');
            this.basePORT = UPORT
        },
        methods: {
            // 弹出层
            toggle(type) {
                this.type = type
                // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
                this.$refs.popup.open(type)
            },
            // 提醒弹窗
            messageToggle(type) {
                this.msgType = type
                this.messageText = '提取失败'
                this.$refs.message.open()
            },
            getMat() {
                let that = this
                uni.navigateTo({
                    url: 'stockIn?baseIP=' + that.baseIP + '&basePORT=' + that.basePORT
                });
            },
            // 初始化上架数量
            initCount() {
                this.stockInData.forEach(function(element){
                    element.count = 0
                })
            },
            otherFun(object){ // 接收上个页面的传值
                let that = this
                if(!!object){
                    if ( that.stockInData.length == 0 ) {
                        that.stockInData = object
                    } else {
                        that.addSotokInData(object)
                    }
                    
                    
                }
                that.initCount()
            },
            addSotokInData(object) {
                let that = this
                for (var i = 1; i < object.length; i++) {
                    var toPush = true
                    for (var j = 0; j < that.stockInData.length; j++) {
                        if (object[i].matnr == that.stockInData[j].matnr) {
                            toPush = false
                        }
                    }
                    if (toPush) {
                        that.stockInData.push(object[i])
                    }
                    
                }
            },
            // 修改数量
            changeCount(index,item) {
                this.$refs.inputDialog.open()
                this.rowNum = index
                this.value = 0
            },
            // 修改数量弹窗
            dialogInputConfirm() {
                this.stockInData[this.rowNum].count = this.value
            },
            // 确认入库
            confirm() {
                let that = this
                if (that.stockInData.length == 0) {
                    that.messageToggle('error')
                    that.messageText = '请先添加物料'
                    return;
                }
                for (var i = 0; i < that.stockInData.length; i++) {
                    if (that.stockInData[i].count === 0){
                        that.messageToggle('error')
                        that.messageText = '数量不能为零'
                        return;
                    }
                }
                this.$refs.showNodeSelect.open()
                uni.request({
                    url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + "/work/stock/pakin",
                    header: { 'token':uni.getStorageSync('token') },
                    data: {},
                    method:'POST',
                    success(res) {
                        console.log(res)
                    }
                })
            }
        }
    }
</script>
 
<style>
    
</style>