wzp
2022-03-08 1f478b4b033d518f6de21f931d828d2a175b2a3e
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
<template>
    <view>
        <view class="">
            <cu-custom bgColor="bg-gradual-blue" >
                <!-- <block slot="backText">返回</block> -->
                <block slot="content">我的申请</block>
            </cu-custom>
        </view>
        
        <view class="tabBox">
            <u-subsection
                :list="curlist"
                mode="button"
                :current="current"
                @change="changeCurrent"
            ></u-subsection>
        </view>
        
        <view class="contentBox">
            
                <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
                    <view class="cu-list menu-avatar">
                        <view class="cu-item" v-for="(item,index) in assetsList" :key="index" @click="navTo(item.id)">
                            <view class="cu-avatar radius lg bg-white"
                                style="background-image:url(../../static/device.png);">
                            </view>
                            <view class="content">
                                <view>
                                    <view class="text-cut text-bold text-xl">{{item.approvalAssets[0].assets.name}}</view>
                                    <view class="cu-tag radius bg-orange sm">数量:{{item.approvalAssets[0].quantity}}</view>
                                </view>
                                <view class="text-gray text-sm flex">
                                    <view class="text-cut">申请时间:{{item.createTime}}</view>
                                </view>
                                
                            </view>
                            <view class="action">
                            <view class="text-grey text-xs">申请状态</view>
                            <view class="cu-tag round bg-red sm">{{current+1===1?'待审批':current+1===2?'通过':"未通过"}}</view>
                            </view>
                        </view>
                    </view>
                    
                    
                </mescroll-body>
            
            
            <view class=""  v-if="assetsList.length===0">
                <u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png">
                </u-empty>
            </view>
        </view>
        
    
    
    
    </view>
</template>
 
<script>
    import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
    export default {
        mixins: [MescrollMixin], // 使用mixin
        data() {
            return {
                assetsList:[],
                
                current: 0,
                status:0,
                curlist: ['待审批', '已完成', '未通过'],
            }
        },
        onShow() {
            // this.getAssetList();
            this.page = 1;
            let page ={};
            page.num =1;
            this.upCallback(page);
        },
        methods: {
            changeCurrent(index) {
                this.current = index
                // this.getAssetList();
                this.page = 1;
                let page ={};
                page.num =1;
                this.upCallback(page);
            },
            
            
            //接口有问题
            upCallback(page) {
                let pageNum = page.num; //页码,默认从1开始
                let pageSize = 10; //页长,默认每页10条
                
                console.log("this.current",this.current)
                this.$http.get('/assets/approval/myApply',{params:{
                    "pageNum":1,
                    "pageSize":100,
                    "type":this.current+1
                }})
                    .then(res => {
                        // debugger;
                        if (res.data.code === 0) {
                            let data = res.data.data;
                            console.log('列表:'+ data.length)
                            if (page.num == 1) this.assetsList = []; //如果是第一页,需手动置空列表
                            this.assetsList = this.assetsList.concat(data); //追加新数据
                            // console.log('数据',JSON.stringify(this.assetsList[0]));
                            this.mescroll.endBySize(this.assetsList.length, res.data.total);
                        }
                        else{
                            this.mescroll.endBySize(0, 0);
                        }
                        
                    })
                    .catch(err => {
                        this.mescroll.endErr();
                        console.log('异常', err);
                    });
            },
            
            //请求
            getAssetList() {
                this.$http.get('/assets/approval/myApply',{params:{
                    "pageNum":1,
                    "pageSize":100,
                    "type":this.current+1
                }})
                    .then(res => {
                        // debugger;
                        
                        if(res.data.code===0 ){
                            let data =res.data.data;
                            this.assetsList =data;
                            console.log("结果",data)
                            
                        }
                        
                    }).catch(err => {
                        console.log(err.data)
                    })
            },
            
            navTo(id) {
                uni.navigateTo({
                    url: `./applyInfo?id=${id}&type=${this.current+1}`
                })
            }
        }
    }
</script>
 
<style>
.tabBox{
    z-index: 100;
    position: fixed;
    width: 100%;
    top:90rpx;
    
 
}
.contentBox{
    z-index: 99;
    position: fixed;
    width: 100%;
    top:165rpx;
}
</style>