262 lines
7.0 KiB
Vue
Executable File
262 lines
7.0 KiB
Vue
Executable File
<template>
|
||
<view>
|
||
<!-- 常用事项 -->
|
||
<view class="main" >
|
||
<view class="m-title mt-center">
|
||
<text class="title" decode="true">常用事项</text>
|
||
</view>
|
||
<view v-if="comList.length==0" style="text-align: center;margin: 10px 0;">暂无常用事项,请添加!</view>
|
||
<view class="example-body" style="margin-bottom: 20px;">
|
||
<uni-grid :column="4" :show-border="false" :square="false" >
|
||
<uni-grid-item v-for="(item ,index) in comList" :key="index" >
|
||
<view class="grid-item-box" @click="MenuDelete(item,index)">
|
||
<image class="image" src="../../../static/icon/unchecked.png" v-if="item.FTYPE==4"/>
|
||
<!-- <image class="image" :src="item.src" v-else/> -->
|
||
<view class="image" :style="{backgroundImage:'url('+item.src+')'}"/>
|
||
<text class="text">{{item.NAME}}</text>
|
||
<view class="grid-dot-del">
|
||
<!-- <uni-badge text="-" type="warning" size="small" /> -->
|
||
</view>
|
||
</view>
|
||
</uni-grid-item>
|
||
</uni-grid>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 其他应用 -->
|
||
<view class="main">
|
||
<view class="m-title mt-center">
|
||
<text class="title" decode="true">其他应用 </text>
|
||
</view>
|
||
<!-- 工作 -->
|
||
<view class="main" v-for="(item ,index) in allMenu" :key="index">
|
||
<view class="m-title">
|
||
<text class="title" decode="true">{{item.NAME}}</text>
|
||
</view>
|
||
<view class="example-body">
|
||
<uni-grid :column="4" :show-border="false" :square="false" >
|
||
<uni-grid-item v-for="(subitem ,subindex) in item.SubMenus" :key="subindex" >
|
||
<view class="grid-item-box" v-show="!subitem.inComList" @click="MenuAdd(subitem,subindex)">
|
||
<image class="image" src="../../../static/icon/unchecked.png" v-if="subitem.FTYPE==4" />
|
||
<!-- <image class="image" :src="subitem.src" v-else /> -->
|
||
<view class="image" :style="{backgroundImage:'url('+subitem.src+')'}"/>
|
||
<text class="text">{{subitem.NAME}}</text>
|
||
<view class="grid-dot-add">
|
||
<!-- <uni-badge text="+" type="primary" size="small"/> -->
|
||
</view>
|
||
</view>
|
||
<view class="grid-item-box" v-show="subitem.inComList">
|
||
<image class="image" src="../../../static/icon/unchecked.png" v-if="subitem.FTYPE==4" />
|
||
<!-- <image class="image" :src="subitem.src" v-else /> -->
|
||
<view class="image" :style="{backgroundImage:'url('+subitem.src+')'}"/>
|
||
<text class="text">{{subitem.NAME}}</text>
|
||
<view class="grid-dot-sel" v-show="subitem.inComList">
|
||
<!-- <uni-badge text="+" type="default" size="small" /> -->
|
||
</view>
|
||
</view>
|
||
</uni-grid-item>
|
||
</uni-grid>
|
||
</view>
|
||
</view>
|
||
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import Vue from 'vue';
|
||
import uniGrid from '@/components/uni-grid/uni-grid.vue'
|
||
import uniGridItem from '@/components/uni-grid-item/uni-grid-item.vue'
|
||
import uniBadge from '@/components/uni-badge/uni-badge.vue'
|
||
|
||
export default {
|
||
components:{
|
||
uniGrid,
|
||
uniGridItem,
|
||
uniBadge
|
||
},
|
||
data() {
|
||
return {
|
||
allMenu:[],
|
||
comList:[],
|
||
itemKey:'',
|
||
}
|
||
},
|
||
onLoad() {
|
||
this.ShowMenuList();
|
||
},
|
||
methods: {
|
||
showAddonLoad(comList,allMenu){
|
||
let _self = this;
|
||
let comIDList = [];
|
||
if(comList.length==0){
|
||
return
|
||
}
|
||
comList.forEach(
|
||
function(e){
|
||
let arr = {
|
||
"ID":e.ID
|
||
}
|
||
comIDList.push(arr)
|
||
}
|
||
);
|
||
console.log(this.allMenu)
|
||
this.allMenu.forEach(
|
||
function(e){
|
||
e.SubMenus.forEach(
|
||
function(el,index){
|
||
comIDList.forEach(
|
||
function(comEl){
|
||
if(comEl.ID==el.ID){
|
||
let inComList = {
|
||
"inComList":true
|
||
};
|
||
Vue.set(e.SubMenus[index],'inComList',true)
|
||
}
|
||
}
|
||
);
|
||
}
|
||
);
|
||
}
|
||
);
|
||
console.log(this.allMenu)
|
||
},
|
||
ShowMenuList() {
|
||
let _self = this;
|
||
this.comList = uni.getStorageSync('ComMenu');
|
||
this.allMenu = uni.getStorageSync('AllMenu');
|
||
this.comList.forEach(e => {
|
||
e.src = "../../../static/icon/" + e.KEY +".png"
|
||
})
|
||
this.showAddonLoad(this.comList,this.allMenu);
|
||
},
|
||
MenuDelete:function(item,index){
|
||
let id = item.ID;
|
||
this.delFavorites(id);
|
||
if(index>=0){
|
||
this.comList.splice(index,1)
|
||
this.allMenu = uni.getStorageSync('AllMenu')
|
||
this.showAddonLoad(this.comList,this.allMenu)
|
||
}
|
||
},
|
||
MenuAdd:function(item,index){
|
||
let id = item.ID;
|
||
this.setFavorites(id);
|
||
if(item){
|
||
this.comList.push(item)
|
||
let obj = {};
|
||
this.comList= this.comList.reduce((cur,next) => {
|
||
obj[next.ID] ? "" : obj[next.ID] = true && cur.push(next);
|
||
return cur;
|
||
},[]);
|
||
this.allMenu = uni.getStorageSync('AllMenu')
|
||
this.showAddonLoad(this.comList,this.allMenu)
|
||
}
|
||
|
||
},
|
||
setFavorites(id) {
|
||
this.$request.post('/Service/SetFavorites',
|
||
JSON.stringify(id)).then(res => {
|
||
|
||
})
|
||
.catch(err => {
|
||
console.log(err);
|
||
});
|
||
},
|
||
delFavorites(id) {
|
||
this.$request.post('/Service/DelFavorites',
|
||
JSON.stringify(id)).then(res => {
|
||
|
||
})
|
||
.catch(err => {
|
||
console.log(err);
|
||
});
|
||
},
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
@import url("../../../common/iconindex.css");
|
||
|
||
page{
|
||
height: 100%;
|
||
}
|
||
|
||
/* 角标 */
|
||
.example-body {
|
||
flex-direction: row;
|
||
flex-wrap: wrap;
|
||
justify-content: center;
|
||
padding: 0;
|
||
font-size: 14px;
|
||
background-color: #ffffff;
|
||
}
|
||
.grid-item-box {
|
||
flex: 1;
|
||
/* position: relative;
|
||
*/
|
||
/* #ifndef APP-NVUE */
|
||
display: flex;
|
||
/* #endif */
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 15px 0;
|
||
border: 1upx solid #F2F2F2;
|
||
}
|
||
.text {
|
||
padding: 10upx 0;
|
||
word-break: break-all;
|
||
text-align: center;
|
||
line-height: 16px;
|
||
width: 64px;
|
||
|
||
}
|
||
.grid-dot-del {
|
||
position: absolute;
|
||
top: 10px;
|
||
right: 20px;
|
||
height: 15px;
|
||
width: 15px;
|
||
border-radius: 50%;
|
||
background-image: url('@/static/myinfo/del.png');
|
||
background-repeat: no-repeat;
|
||
background-size: cover;
|
||
|
||
}
|
||
.grid-dot-add {
|
||
position: absolute;
|
||
top: 10px;
|
||
right: 20px;
|
||
height: 15px;
|
||
width: 15px;
|
||
border-radius: 50%;
|
||
background-image: url('@/static/myinfo/add.png');
|
||
background-repeat: no-repeat;
|
||
background-size: cover;
|
||
|
||
}
|
||
.grid-dot-sel {
|
||
position: absolute;
|
||
top: 10px;
|
||
right: 20px;
|
||
height: 15px;
|
||
width: 15px;
|
||
border-radius: 50%;
|
||
background-image: url('@/static/myinfo/selected.png');
|
||
background-repeat: no-repeat;
|
||
background-size: cover;
|
||
|
||
}
|
||
.uni-badge{
|
||
width: 17upx !important;
|
||
}
|
||
.image{
|
||
height: 79.71rpx;
|
||
width: 79.71rpx;
|
||
background-repeat: no-repeat;
|
||
background-size: cover;
|
||
}
|
||
</style>
|