<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.roleName" v-for="(item, index) in list" :key="item.roleId" :index="item.roleId"
|
@click="cardClick(item.roleId)">
|
<view slot="body">
|
<view class="row-list">
|
<span class="span-lable">角色编码: </span>{{ item.roleCode }}
|
</view>
|
<view class="row-list">
|
<span class="span-lable">角色描述: </span>{{ item.roleDesc }}
|
</view>
|
<view class="row-list">
|
<span class="span-lable">数据权限: </span>
|
<dict-tag :items="dsType" :value="item.dsType"></dict-tag>
|
</view>
|
</view>
|
<view class="card-foot" slot="foot">
|
<u-button size="medium" type="primary" @click="cardClick(item.roleId)">编辑</u-button>
|
<u-button size="medium" @click="del(item.roleId)">删除</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'
|
}
|
}],
|
dsType: [{
|
label: '全部',
|
value: '0'
|
}, {
|
label: '自定义',
|
value: '1'
|
}, {
|
label: '本级及子级',
|
value: '2'
|
}, {
|
label: '本级',
|
value: '3'
|
}]
|
};
|
},
|
onLoad() {
|
this.loadList();
|
},
|
onShow() {
|
if (uni.getStorageSync('refreshList') === true) {
|
uni.removeStorageSync('refreshList');
|
this.search('');
|
}
|
},
|
methods: {
|
cardClick(id) {
|
uni.navigateTo({
|
url: '/pages/sys/pigxRole/form?id=' + id
|
})
|
},
|
loadMore() {
|
this.loadStatus = "loading";
|
setTimeout(() => {
|
this.query.current += 1;
|
this.loadList();
|
}, 100);
|
},
|
loadList() {
|
this.$u.api.pigxRole.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.pigxRole.delObj({
|
id: id
|
}).then(res => {
|
self.$u.toast('删除成功');
|
self.query.current = 1
|
self.list = []
|
self.loadList()
|
});
|
}
|
}
|
});
|
}
|
}
|
};
|
</script>
|