#
whycq
2022-04-01 dafb6a0d9abaf3f9c595d8259664e2bb70786156
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
<template>
    <view>
        <view>
            <uni-table border stripe type="selection" emptyText="没有更多数据" @selection-change="selectionChange">
                <uni-tr>
                    <uni-th>商品编号</uni-th>
                    <uni-th>商品名称</uni-th>
                    <uni-th>规格</uni-th>
                    <uni-th>单价</uni-th>
                    <uni-th>修改时间</uni-th>
                </uni-tr>
                <uni-tr v-for="(item,index) in stockData" :key="index">
                    <uni-td>{{item.matnr}}</uni-td>
                    <uni-td>{{item.maktx}}</uni-td>
                    <uni-td>{{item.specs}}</uni-td>
                    <uni-td>{{item.price}}</uni-td>
                    <uni-td>{{item.updateTime$}}</uni-td>
                </uni-tr>
            </uni-table>
        </view>
        <view class="cu-bar foot input justify-center" style="height: 150rpx;">
            <view style="width: 30%;">
                <button class="cu-btn bg-yellow lg shadow-blur" style="width: 250rpx;color: #fff;" @click="getMat()">提取</button>
            </view>    
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                baseIP: '',
                basePORT: '',
                stockData: [],
                selectionData: [],
            }
        },
        onLoad(option) {
            this.baseIP = option.baseIP
            this.basePORT = option.basePORT
            this.getMatData() 
        },
        methods: {
            getMatData() {
                let that = this
                uni.request({
                    url: that.baseHttp + that.baseIP + ':' +that.basePORT + that.baseUrl + '/mat/list/auth',
                    header: {'token':uni.getStorageSync('token')},
                    success(res) {
                        var res = res.data
                        if (res.code === 200) {
                            that.stockData = res.data.records
                        }
                    }
                })
            },
            // 多选
            selectionChange(e) {
                // 获取选中状态
                this.selectedIndexs = e.detail.index
                this.selectedIndexs.sort(function(a,b){
                    return a-b
                });// 重新排序(升序)
            },
            getMat() {
                let that = this
                var index = this.selectedIndexs
                // 获取当前页面栈
                let pages = getCurrentPages()
                // pages数组中的最后一个为当前页面,倒数第二个为上一个页面
                let prevPage = pages[pages.length - 2]
                for (var i = 0;i < index.length; i++) {
                    that.selectionData.push(that.stockData[index[i]])
                }
                prevPage.$vm.otherFun(that.selectionData)
                uni.navigateBack()
            }
        }
    }
</script>
 
<style>
</style>