spring
4 天以前 f26f29d84e0a68831a6af14dab3eec5500496d2e
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
<template>
    <view class="wrap">
        <scroll-view class="scroll-list" scroll-y="true" @scrolltolower="loadMore">
            <u-cell-group class="list" :border="false">
                <u-card :title="item.name" v-for="(item, index) in list" :key="item.id" :index="item.id"
                    @click="cardClick(item.id)">
                    <view slot="body">
                        <view class="row-list">
                            <span class="span-lable">名称: </span>{{item.name}}
                        </view>
                        <view class="row-list">
                            <span class="span-lable">编码: </span>{{item.code}}
                        </view>
                        <view class="row-list">
                            <span class="span-lable">域名: </span>{{item.tenantDomain}}
                        </view>
                        <view class="row-list">
                            <span class="span-lable">开始时间: </span>{{item.startTime}}
                        </view>
                        <view class="row-list">
                            <span class="span-lable">结束时间: </span>{{item.endTime}}
                        </view>
                        <view class="row-list">
                            <span class="span-lable">状态: </span>
                            <dict-tag dict-type="status_type" :value="item.status"></dict-tag>
                        </view>
                    </view>
                    <view class="card-foot" slot="foot">
                        <u-button type="primary" size="medium" @click="cardClick(item.id)">编辑</u-button>
                        <u-button size="medium" @click="del(item.id)">删除</u-button>
                    </view>
                </u-card>
            </u-cell-group>
            <view class="loadmore" @click="loadMore">
                <u-loadmore :status="loadStatus"></u-loadmore>
            </view>
        </scroll-view>
        <view class="btn-plus" @click="cardClick()">
            <u-icon name="plus-circle-fill" size="90" color="#3d87ff"></u-icon>
        </view>
    </view>
</template>
<script>
    export default {
        data() {
            return {
                keywords: '',
                query: {
                    current: 1,
                    size: 20
                },
                list: [],
                count: 0,
                loadStatus: 'loadmore',
                options: [{
                    text: '删除',
                    style: {
                        background: '#dd524d'
                    }
                }]
            };
        },
        onLoad() {
            this.loadList();
        },
        onShow() {
            if (uni.getStorageSync('refreshList') === true) {
                uni.removeStorageSync('refreshList');
                this.search('');
            }
        },
        methods: {
            cardClick(id) {
                uni.navigateTo({
                    url: '/pages/sys/pigxTenant/form?id=' + id
                })
            },
            loadMore() {
                this.loadStatus = "loading";
                setTimeout(() => {
                    this.query.current += 1;
                    this.loadList();
                }, 100);
            },
            loadList() {
                this.$u.api.pigxTenant.fetchList(this.query).then(res => {
                    if (!res.data.records || res.data.records.length === 0) {
                        this.loadStatus = "nomore";
                        return;
                    }
                    this.list = this.list.concat(res.data.records);
                    this.total = res.data.total;
                    this.query.current = res.data.current;
                    this.query.size = res.data.size;
 
                    this.loadStatus = "loadmore";
                });
            },
            del(id) {
                let self = this;
                uni.showModal({
                    title: '提示',
                    content: '确认要删除该数据吗?',
                    showCancel: true,
                    success: function(res2) {
                        if (res2.confirm) {
                            self.$u.api.pigxTenant.delObj({
                                id: id
                            }).then(res => {
                                self.$u.toast('删除成功');
                                self.query.current = 1
                                self.list = []
                                self.loadList()
                            });
                        }
                    }
                });
            }
        }
    };
</script>