wgl il y a 4 ans
Parent
commit
6b40a244c8

+ 6 - 11
src/projects/business/views/Master/EditFun.vue

@@ -1,10 +1,5 @@
 <template>
 	<div id="app">
-		<!-- <header class="mui-bar mui-bar-nav">
-			<a herf="" class="mui-pull-left close color4fc5f7">取消</a>
-			<h1 class="mui-title">管理常用服务</h1>
-			<a class="mui-pull-right mui-btn mui-btn-primary">完成</a>
-		</header> -->
 
 		<common ref="common" @asynCallBack="asynCallBack"></common>
 		<top-header :pageTitle="pageTitle" :rightLink="rightLink" :doRightLink="doRightLink"></top-header>
@@ -16,8 +11,8 @@
 				<ul class="mui-table-view mui-grid-view mui-grid-9">
 					<li draggable="true" v-for="(item,index) in menu_list" class="mui-table-view-cell mui-media mui-col-xs-3">
 						<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
-							<img :src="requirePic(item.iconPic)" />
-							<div class="mui-media-body" v-text="item.iconName"></div>
+						<img :src="requirePic(item.iconPic)" />
+						<div class="mui-media-body" v-text="item.iconName"></div>
 						<!-- </router-link> -->
 						<span @click="del(item.id,index)" class="mui-icon mui-icon-closeempty vongi-close"></span>
 					</li>
@@ -30,8 +25,8 @@
 					<ul class="mui-table-view mui-grid-view mui-grid-9">
 						<li v-show="item.is_show" v-for="(item,index) in iten.list" :class="'mui-table-view-cell mui-media mui-col-xs-3 '+(item.iconRoute?'':'kfz')">
 							<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
-								<img :src="requirePic(item.iconPic)" />
-								<div class="mui-media-body" v-text="item.iconName"></div>
+							<img :src="requirePic(item.iconPic)" />
+							<div class="mui-media-body" v-text="item.iconName"></div>
 							<!-- </router-link> -->
 							<span @click="add(indey,index)" class="mui-icon mui-icon-plusempty vongi-add"></span>
 						</li>
@@ -107,16 +102,16 @@
 			//重置数组
 			resetAllFunList(list) {
 				for (var i = 0; i < list.length; i++) {
+					var num = 0;
 					for (var j = 0; j < list[i]['list'].length; j++) {
-						var num = 0;
 						if (this.idList.indexOf(list[i]['list'][j]['id']) > -1) {
 							list[i]['list'][j]['is_show'] = 0;
 						} else {
 							list[i]['list'][j]['is_show'] = 1;
 							num++;
 						}
-						list[i]['cun_num'] = num;
 					}
+					list[i]['cun_num'] = num;
 				}
 				return list;
 			},

+ 11 - 0
src/projects/pension/router/master.js

@@ -53,6 +53,17 @@ const routesMaster = [
 					title: '切换角色',
 				}
 			},
+			//编辑常用功能
+			{
+				path: 'editFun',
+				name: 'MasterEditFun',
+				component: () => import('../views/Master/EditFun.vue'),
+				meta: {
+					requireAuth: false,
+					role: [],
+					title: '编辑常用功能',
+				}
+			},
 
 			//我的
 			{

+ 30 - 11
src/projects/pension/views/Master/AllFun.vue

@@ -3,8 +3,26 @@
 		<common ref="common" @asynCallBack="asynCallBack"></common>
 		<top-header :pageTitle="pageTitle"></top-header>
 
-		<div class="mui-content">
-			<div class="vongi-icons vongi-all">
+		<div class="mui-content vongi-icons">
+			<div class="vongi-all">
+				<h2>常用服务</h2>
+				<ul class="mui-table-view mui-grid-view mui-grid-9">
+					<li v-for="(item,index) in menu_list" class="mui-table-view-cell mui-media mui-col-xs-3">
+						<router-link :to="{name:item.iconRoute,query:item.iconParam}">
+							<img :src="requirePic(item.iconPic)" />
+							<div class="mui-media-body" v-text="item.iconName"></div>
+						</router-link>
+					</li>
+					<li class="mui-table-view-cell mui-media mui-col-xs-3">
+						<router-link :to="{name:'MasterEditFun'}">
+							<img src="~$project/assets/img/icon_edit.png" />
+							<div class="mui-media-body">编辑</div>
+						</router-link>
+					</li>
+				</ul>
+			</div>
+			<div class="vongi-all">
+				<h2>全部服务</h2>
 				<div v-for="(iten,indey) in fun_list">
 					<h4 v-text="iten.name"></h4>
 					<ul class="mui-table-view mui-grid-view mui-grid-9">
@@ -18,7 +36,7 @@
 				</div>
 			</div>
 		</div>
-		
+
 		<loading :visible="isLoading"></loading>
 	</div>
 </template>
@@ -51,13 +69,13 @@
 		methods: {
 			//引入图片
 			requirePic(file) {
-                if (file) {
-                    if (file.indexOf('http') == 0) {
-                        return file;
-                    } else {
-                        return require('$project/assets/img/' + file);
-                    }
-                }
+				if (file) {
+					if (file.indexOf('http') == 0) {
+						return file;
+					} else {
+						return require('$project/assets/img/' + file);
+					}
+				}
 			},
 			asynCallBack() {
 
@@ -73,7 +91,8 @@
 				token: 'token',
 				person_data: 'person_data',
 				person_popedom: 'person_popedom',
-				fun_list: 'fun_list'
+				fun_list: 'fun_list',
+				menu_list: 'menu_list'
 			})
 		}
 	}

+ 190 - 0
src/projects/pension/views/Master/EditFun.vue

@@ -0,0 +1,190 @@
+<template>
+	<div id="app">
+
+		<common ref="common" @asynCallBack="asynCallBack"></common>
+		<top-header :pageTitle="pageTitle" :rightLink="rightLink" :doRightLink="doRightLink"></top-header>
+
+
+		<div class="mui-content vongi-icons">
+			<div class="vongi-all">
+				<h4 class="vongi-center">您可以将常用的应用添加到主页</h4>
+				<ul class="mui-table-view mui-grid-view mui-grid-9">
+					<li draggable="true" v-for="(item,index) in menu_list" class="mui-table-view-cell mui-media mui-col-xs-3">
+						<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
+						<img :src="requirePic(item.iconPic)" />
+						<div class="mui-media-body" v-text="item.iconName"></div>
+						<!-- </router-link> -->
+						<span @click="del(item.id,index)" class="mui-icon mui-icon-closeempty vongi-close"></span>
+					</li>
+				</ul>
+			</div>
+			<div class="vongi-all">
+				<h2>全部服务</h2>
+				<div v-if="iten.cun_num" v-for="(iten,indey) in allFunList">
+					<h4 v-text="iten.name"></h4>
+					<ul class="mui-table-view mui-grid-view mui-grid-9">
+						<li v-show="item.is_show" v-for="(item,index) in iten.list" :class="'mui-table-view-cell mui-media mui-col-xs-3 '+(item.iconRoute?'':'kfz')">
+							<!-- <router-link :to="{name:item.iconRoute,query:item.iconParam}"> -->
+							<img :src="requirePic(item.iconPic)" />
+							<div class="mui-media-body" v-text="item.iconName"></div>
+							<!-- </router-link> -->
+							<span @click="add(indey,index)" class="mui-icon mui-icon-plusempty vongi-add"></span>
+						</li>
+					</ul>
+				</div>
+			</div>
+		</div>
+
+		<loading :visible="isLoading"></loading>
+	</div>
+</template>
+
+<script>
+	import * as API_User from '$project/apis/user'
+	import Common from '$project/components/Common.vue'
+	import Loading from '$project/components/Loading.vue'
+	import TopHeader from '$project/components/TopHeader.vue'
+	import NavMenu from '@/components/NavMenu.vue'
+	import {
+		mapGetters,
+		mapMutations
+	} from 'vuex'
+	export default {
+		name: 'MasterEditFun',
+		components: {
+			Common,
+			Loading,
+			TopHeader,
+			NavMenu
+		},
+		data() {
+			return {
+				isLoading: false,
+
+				pageTitle: '管理常用服务',
+
+				rightLink: {
+					show: true,
+					icon: 'mui-btn mui-btn-primary',
+					style: 'width: 55px;height: 25px;margin-top:5px;margin-right: 0px;line-height: 5px;color: #fff;font-size:16px;',
+					title: '完成'
+				},
+
+				allFunList: [],
+				menuList: [],
+				idList: [],
+			}
+		},
+		created() {
+			this.resetIdList();
+		},
+		methods: {
+			//引入图片
+			requirePic(file) {
+				if (file) {
+					if (file.indexOf('http') == 0) {
+						return file;
+					} else {
+						return require('$project/assets/img/' + file);
+					}
+				}
+			},
+			//获取所有的功能列表包括常用功能
+			getAllFunList() {
+				this.isLoading = true;
+				API_User.getAllFunList().then(response => {
+					this.isLoading = false;
+					this.allFunList = this.resetAllFunList(response.allIcon);
+				}).catch(error => {
+					mui.toast(error);
+				})
+			},
+			//重置数组
+			resetAllFunList(list) {
+				for (var i = 0; i < list.length; i++) {
+					var num = 0;
+					for (var j = 0; j < list[i]['list'].length; j++) {
+						if (this.idList.indexOf(list[i]['list'][j]['id']) > -1) {
+							list[i]['list'][j]['is_show'] = 0;
+						} else {
+							list[i]['list'][j]['is_show'] = 1;
+							num++;
+						}
+					}
+					list[i]['cun_num'] = num;
+				}
+				return list;
+			},
+			resetIdList() {
+				var list = [];
+				for (var i = 0; i < this.menu_list.length; i++) {
+					list.push(this.menu_list[i]['id']);
+				}
+				this.idList = list;
+			},
+			//添加图标
+			add(indy, index) {
+				this.menu_list.push(this.allFunList[indy]['list'][index])
+				this.allFunList[indy]['list'][index]['is_show'] = 0;
+				this.allFunList[indy]['cun_num']--;
+			},
+			//减少图标
+			del(id, index) {
+
+				for (var i = 0; i < this.menu_list.length; i++) {
+					if (this.menu_list[i]['id'] == id) {
+						this.menu_list.splice(i, 1);
+					}
+				}
+
+				var allFunList = this.allFunList;
+				for (var i = 0; i < allFunList.length; i++) {
+					var item = allFunList[i];
+					for (var j = 0; j < item['list'].length; j++) {
+						if (item['list'][j]['id'] == id) {
+							item['list'][j]['is_show'] = 1;
+							item['cun_num']++;
+							this.$set(this.allFunList, i, item)
+						}
+					}
+				}
+			},
+			//保存常用图片
+			doRightLink() {
+				this.isLoading = true;
+				this.resetIdList();
+				API_User.saveFun(this.idList.join(',')).then(response => {
+					this.isLoading = false;
+					mui.toast('保存成功');
+					this.$router.go(-1);
+				}).catch(error => {
+					mui.toast(error);
+				})
+			},
+			asynCallBack() {
+
+			},
+		},
+		mounted() {
+			this.getAllFunList()
+		},
+		destroyed() {
+
+		},
+		computed: {
+			...mapGetters({
+				openId: 'wx_openid',
+				token: 'token',
+				person_data: 'person_data',
+				person_popedom: 'person_popedom',
+				menu_list: 'menu_list'
+			})
+		}
+	}
+</script>
+
+<style src="$project/assets/css/iconfont.css"></style>
+<style scoped src="$project/assets/css/xpgj.css"></style>
+<style scoped src="$project/assets/css/xpwyfyy.css"></style>
+<style>
+</style>