#
whycq
2024-04-15 caffaccc7c6f76503f8618368ef612146252ef8a
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
<template>
    <view>
        <view class="list list-font-color" :class="locDetl.color" v-for="(locDetl,index) in dataList" :key="index">
            <view class="list-left">
                <view>销售订单号:{{locDetl.threeCode}}</view>
                <view>主订单号:{{locDetl.orderNo}}</view>
                <view>商品编码:{{locDetl.matnr}}</view>
                <view>商品名称:{{locDetl.maktx}}</view>
                <view>库存:{{locDetl.anfme}}</view>
                <view>调整库存为:{{locDetl.barcode}}</view>
            </view>
            <view class="list-right" @click="goToLocDetl(locDetl)">
                <uni-icons type="right" size="25"  color="#fff"></uni-icons>
            </view>
        </view>
        <view style="height: 100rpx;display: flex;align-items: center;justify-content: center;" @click="add()">
            <uni-icons type="folder-add" size="25"  color="#000" style="padding-right: 20rpx;"></uni-icons> 添加物料
        </view>
        <!-- 底部操作按钮 -->
        <view class="buttom">
            <button size="mini" type="primary" @click="agvStart('warn')">添加物料</button>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                baseUrl: '',
                token: '',
                dataList: []
                
            }
        },
        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) {
                console.log(data);
                _this.dataList = data.item.data
            })
        },
        methods: {
            add() {
                let _this = this
                uni.navigateTo({
                    url: "../mat/mat",
                    events: {
                        // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据  另外一个页面传过来的
                        acceptDataFromOpenedPage: function(data) {
                            console.log(data.data);
                            setTimeout(()=> {
                                _this.findMat(data.data)
                            },100)
                        }
                    },
                });
            },
            findMat(mat) {
                let _this = this
                uni.navigateTo({
                    url: "../mat/matSelected",
                    success: function(res) {
                        // 通过eventChannel向被打开页面传送数据   向另外一个页面传递值的
                        res.eventChannel.emit('item', {
                            item: mat
                        })
                    },
                    events: {
                        matList: function(data) {
                            _this.checkMat(data.data)
                        },
                    },
                });
            },
            checkMat(mat) {
                var len = this.dataList.length
                var add = true ,sameItem = false
                for (var i = 0; i < len; i++) {
                    if (mat.matnr == this.dataList[i].matnr) {
                        for (var j = 0; j < len; j++) {
                            if (mat.batch == this.dataList[j].batch) {
                                sameItem = true
                            }
                        }
                        // 相同物料 不同批号  新加列表
                        if (mat.batch != this.dataList[i].batch) {
                            this.$forceUpdate() // 强制刷新
                            if (sameItem) {
                                add = false
                            } else {
                                add = true
                            }
                            
                        } else {
                            // 相同物料相同批号 数量累加
                            this.dataList[i].anfme += mat.anfme
                            this.$forceUpdate() // 强制刷新
                            add = false
                        }
                    }
                }
                if (add) {
                    this.dataList.unshift(mat)
                }
            }
        }
    }
</script>
 
<style>
    @import url('../../../static/css/common/order.css');
</style>