246 lines
5.0 KiB
Vue
246 lines
5.0 KiB
Vue
<template>
|
|
<view>
|
|
<view class="secs">
|
|
<view
|
|
v-for="(part, index) in manageList"
|
|
:key="index"
|
|
class="list-area"
|
|
>
|
|
<image :src="`/static/${part.iconMark}.png`" mode=""></image>
|
|
<span>{{ part.iconName }}</span>
|
|
<view class="badge-stick">
|
|
<image src="/static/addMark.png" @click="toggleAdd(part.id)" v-show="part.isUsing != true" mode=""></image>
|
|
<image src="/static/reduceMark.png" @click="toggleReduce(part.id)" v-show="part.isUsing == true" mode=""></image>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
allChecked: false,
|
|
manageList: [
|
|
|
|
],
|
|
subList: [],
|
|
subIdArr: []
|
|
}
|
|
},
|
|
methods: {
|
|
checkAll() {
|
|
this.allChecked = !this.allChecked
|
|
if (this.allChecked) {
|
|
this.manageList.map(item => {
|
|
if (item.checked == false) {
|
|
item.checked = true
|
|
}
|
|
})
|
|
} else {
|
|
this.manageList.map(item => {
|
|
if (item.checked == true) {
|
|
item.checked = false
|
|
}
|
|
})
|
|
}
|
|
},
|
|
checkClick(item) {
|
|
item.checked = !item.checked
|
|
if (!item.checked) {
|
|
this.allChecked = false
|
|
} else {
|
|
const goods = this.manageList.every(item => {
|
|
return item.checked === true
|
|
})
|
|
if (goods) {
|
|
this.allChecked = true
|
|
} else {
|
|
this.allChecked = false
|
|
}
|
|
}
|
|
},
|
|
toggleAdd (id) {
|
|
let that = this
|
|
console.log(id);
|
|
uni.showModal({
|
|
title: '确认新增',
|
|
content: '确认新增模块吗?',
|
|
confirmText: '新增',
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
// 提交新增模块
|
|
that.$api.authManage.subAdd({
|
|
menuId: id
|
|
}).then(res => {
|
|
console.log(res);
|
|
if (res.data.code == 200) {
|
|
uni.showToast({
|
|
icon: 'none',
|
|
title: '添加成功!',
|
|
success: () => {
|
|
uni.redirectTo({
|
|
url: '/pages/authManage/authManage'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err);
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
toggleReduce (id) {
|
|
let that = this
|
|
console.log(id);
|
|
uni.showModal({
|
|
title: '确认删除',
|
|
content: '确认删除模块吗?',
|
|
confirmText: '删除',
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
// 提交删除模块
|
|
that.$api.authManage.subDel({
|
|
menuId: id
|
|
}).then(res => {
|
|
console.log(res);
|
|
if (res.data.code == 200) {
|
|
uni.showToast({
|
|
icon: 'none',
|
|
title: '删除成功!',
|
|
success: () => {
|
|
uni.redirectTo({
|
|
url: '/pages/authManage/authManage'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err);
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
onShow() {
|
|
let that = this
|
|
// 初始化获取模块列表
|
|
that.$api.authManage.fetchAuthList().then(res => {
|
|
console.log(res);
|
|
if (res.data.code == 200) {
|
|
// 获取正在使用的模块
|
|
that.$api.authManage.fetchIsUsing({
|
|
userId: uni.getStorageSync('userInfo').userid
|
|
}).then(subRes => {
|
|
console.log(subRes);
|
|
for (let i = 0; i < res.data.data.length; i++) {
|
|
res.data.data[i].checked = false
|
|
for (let k = 0; k < subRes.data.data.length; k++) {
|
|
if (subRes.data.data[k].menuId == res.data.data[i].id) {
|
|
res.data.data[i].isUsing = true
|
|
}
|
|
}
|
|
}
|
|
that.manageList = res.data.data
|
|
console.log(that.manageList);
|
|
}).catch(subErr => {
|
|
console.log(subErr);
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err);
|
|
})
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
body{
|
|
box-sizing: border-box;
|
|
padding-bottom: 10vh;
|
|
}
|
|
/* .single-manage{
|
|
width: 90%;
|
|
box-sizing: border-box;
|
|
padding: 20rpx;
|
|
margin: 20rpx auto;
|
|
background-color: #fff;
|
|
border-radius: 20rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 18px;
|
|
.img-area{
|
|
width: 12%;
|
|
height: 5vh;
|
|
border-radius: 50%;
|
|
margin-right: 15rpx;
|
|
image{
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
} */
|
|
.secs{
|
|
width: 90%;
|
|
margin: 40rpx auto;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
.list-area{
|
|
width: 25%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
margin-bottom: 2vh;
|
|
position: relative;
|
|
image{
|
|
width: 50%;
|
|
height: 6vh;
|
|
margin-bottom: 10rpx;
|
|
}
|
|
span{
|
|
font-size: 20rpx;
|
|
}
|
|
}
|
|
.badge-stick{
|
|
position: absolute;
|
|
right: 10%;
|
|
top: 0;
|
|
width: 20%;
|
|
height: 25%;
|
|
border-radius: 50%;
|
|
image{
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
.btm-sticky{
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
padding: 15rpx 30rpx;
|
|
background-color: #fff;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
.checked{
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.exam{
|
|
box-sizing: border-box;
|
|
padding: 10rpx 50rpx;
|
|
border-radius: 30rpx;
|
|
background-color: #3788FF;
|
|
font-size: 14px;
|
|
color: #fff;
|
|
}
|
|
}
|
|
</style>
|