Parcourir la source

Merge branch 'master' of http://182.92.174.150:3000/dukai/CZO_Boss

lz il y a 3 ans
Parent
commit
a0d1ad0749

+ 26 - 0
src/api/system/menu.js

@@ -57,4 +57,30 @@ export function delMenu(menuId) {
     url: '/system/menu/' + menuId,
     method: 'delete'
   })
+}
+
+// 加载对应用户快捷菜单列表
+export function getUserShortcutMenuList(userId) {
+  return request({
+    url: '/system/menu/userShortcutMenuSelect/' + userId,
+    method: 'get'
+  })
+}
+
+// 删除用户快捷菜单
+export function deleteUserShortcutMenu(data) {
+  return request({
+    url: '/system/menu/deleteUserShortcutMenu',
+    method: 'delete',
+    data: data
+  })
+}
+
+// 新增用户快捷菜单
+export function addUserShortcutMenu(data) {
+  return request({
+    url: '/system/menu/addUserShortcutMenu',
+    method: 'post',
+    data: data
+  })
 }

+ 51 - 4
src/components/shortcutMenu/index.vue

@@ -1,9 +1,9 @@
 <template>
 	<div class="shortcut" :style="{ height: moreStatus ? 'auto' : '50px' }" @mouseleave="moreClose">
 		<div class="tags" @mouseenter="moreOpen">
-			<router-link v-for="i in 20" :key="i" to="/" class="tag">
-				<span class="font_name">系统管理</span>
-				<i class="el-icon-error" v-show="delStatus"></i>
+			<router-link v-for="item in shortcutMenuList" :key="item.menuId" :to="'/' + item.path + '/'" class="tag">
+				<span class="font_name">{{ item.menuName }}</span>
+				<i class="el-icon-error" v-show="delStatus" @click.prevent="deleteShortcutMenu(item)"></i>
 			</router-link>
 		</div>
 		<div class="btns">
@@ -15,11 +15,15 @@
 </template>
 
 <script>
+import { getUserShortcutMenuList, deleteUserShortcutMenu, addUserShortcutMenu } from '@/api/system/menu'
+import EventBus from '@/utils/eventBus'
 export default {
 	data() {
 		return {
 			moreStatus: false,
-			delStatus: false
+			delStatus: false,
+			shortcutMenuList: [], // 快捷菜单列表
+			userId: '' // 用户ID
 		}
 	},
 	computed: {
@@ -27,7 +31,50 @@ export default {
 			return this.$store.state.settings.theme
 		}
 	},
+	mounted() {
+		this.$nextTick(() => {
+			EventBus.$on('addShortcutMenu', obj => {
+				let param = {
+					menuId: obj.menuId,
+					userId: this.userId
+				}
+				addUserShortcutMenu(param).then(res => {
+					if (res.code === 200) {
+						this.getUserShortcutMenuList()
+					}
+				})
+			})
+		})
+	},
+	created() {
+		this.getUserShortcutMenuList()
+	},
 	methods: {
+		// 快捷菜单列表
+		getUserShortcutMenuList() {
+			this.userId = this.$store.state.user.userId
+			getUserShortcutMenuList(this.userId).then(res => {
+				this.shortcutMenuList = res.data
+			})
+		},
+		// 删除快捷菜单
+		deleteShortcutMenu(menu) {
+			let obj = {
+				menuId: menu.menuId,
+				userId: this.userId
+			}
+			this.$modal
+				.confirm('是否确认删除菜单名称为"' + menu.menuName + '"的数据项?')
+				.then(function () {
+					return deleteUserShortcutMenu(obj)
+				})
+				.then(res => {
+					this.getUserShortcutMenuList()
+					this.$modal.msgSuccess('删除成功')
+					this.delStatus = false
+				})
+				.catch(() => {})
+		},
 		isActive(route) {
 			return route.path === this.$route.path
 		},

+ 2 - 0
src/utils/eventBus.js

@@ -0,0 +1,2 @@
+import vue from "vue";
+export default  new vue()

+ 15 - 0
src/views/system/menu/index.vue

@@ -170,6 +170,21 @@
 							</el-radio-group>
 						</el-form-item>
 					</el-col>
+					<el-col :span="12" v-if="form.menuType == 'C'">
+						<el-form-item>
+							<span slot="label">
+								<el-tooltip content="菜单类别(工具类,分析类,设置类)" placement="top">
+									<i class="el-icon-question"></i>
+								</el-tooltip>
+								菜单类别
+							</span>
+							<el-select v-model="form.menuCategory" placeholder="请选择菜单类别" clearable>
+								<el-option label="工具类" :value="0" />
+								<el-option label="分析类" :value="1" />
+								<el-option label="设置类" :value="2" />
+							</el-select>
+						</el-form-item>
+					</el-col>
 					<el-col :span="12" v-if="form.menuType != 'F'">
 						<el-form-item>
 							<span slot="label">

+ 74 - 11
src/views/system/menu/mainMenu.vue

@@ -10,13 +10,33 @@
 				<div class="item bg_statistics">统计/分析区</div>
 				<div class="item bg_set">设置/编辑区</div>
 			</div>
-			<div class="clearboth"></div>
+			<!-- <div class="clearboth"></div> -->
+		</div>
+		<div class="conent">
+			<div class="area border_sending">
+				<div class="area_item bg_tool" v-for="item in sendingList" :key="item.menuId">
+					<a href="javascript:void(0);" title="" @click="pageTo(item)">{{ item.menuName }}</a>
+					<a href="javascript:void(0);"><i class="el-icon-s-promotion" @click="addShortcutMenu(item)"></i></a>
+				</div>
+			</div>
+			<div class="area border_analysis">
+				<div class="area_item bg_statistics" v-for="item in analysisList" :key="item.menuId">
+					<a href="javascript:void(0);" title="" @click="pageTo(item)">{{ item.menuName }}</a>
+					<a href="javascript:void(0);"><i class="el-icon-s-promotion" @click="addShortcutMenu(item)"></i></a>
+				</div>
+			</div>
+			<div class="area">
+				<div class="area_item bg_set" v-for="item in editList" :key="item.menuId">
+					<a href="javascript:void(0);" title="" @click="pageTo(item)">{{ item.menuName }}</a>
+					<a href="javascript:void(0);"><i class="el-icon-s-promotion" @click="addShortcutMenu(item)"></i></a>
+				</div>
+			</div>
 		</div>
 	</div>
 </template>
 
 <script>
-import { mapGetters, mapState } from 'vuex'
+import EventBus from "@/utils/eventBus";
 export default {
 	data() {
 		return {
@@ -29,13 +49,13 @@ export default {
 			// 菜单位置
 			type: undefined,
 			//当前菜单路由id
-			routeId: undefined
+			routeId: undefined,
+			sendingList: [], // 工具/发送区列表
+			analysisList: [], // 统计/分析区列表
+			editList: [] // 设置/编辑区列表
 		}
 	},
-	computed: {
-		...mapState(['settings']),
-		...mapGetters(['sidebarRouters', 'sidebar'])
-	},
+	computed: {},
 	watch: {
 		// 监听路由跳转
 		$route: {
@@ -56,10 +76,23 @@ export default {
 				const routes = this.$store.state.permission.routes
 				this.$nextTick(() => {
 					this.docList = routes.filter((item, index, c) => item.parentId == routeId)
-					console.log(this.docList)
+					// 工具/发送区列表
+					this.sendingList = this.docList.filter((item, index, c) => item.menuCategory == 0)
+					// 统计/分析区列表
+					this.analysisList = this.docList.filter((item, index, c) => item.menuCategory == 1)
+					// 设置/编辑区列表
+					this.editList = this.docList.filter((item, index, c) => item.menuCategory == 2)
 				})
 			}
-		}
+		},
+		// 页面跳转
+		pageTo(item) {
+			this.$router.push({ path: item.path })
+		},
+		// 添加快捷菜单
+		addShortcutMenu(item) {
+			EventBus.$emit("addShortcutMenu", item)
+		},
 	}
 }
 </script>
@@ -69,8 +102,6 @@ export default {
 	min-height: calc(100vh);
 	padding: 10px 10px 0 10px;
 	box-shadow: #dac488 0px 0px 14px inset;
-	/* margin-top: -10px; */
-	/* margin-left: -10px; */
 	background-color: #000;
 }
 .main-top2 {
@@ -112,6 +143,25 @@ export default {
 	font-size: 16px;
 	font-weight: 600;
 }
+.area {
+	display: flex;
+	flex-wrap: wrap;
+	padding: 26px 5px;
+}
+.area_item {
+	position: relative;
+	width: 160px;
+	height: 50px;
+	border-radius: 5px;
+	line-height: 50px;
+	text-align: center;
+	margin: 5px 5px;
+	a {
+		color: #000;
+		font-size: 16px;
+		font-weight: 400;
+	}
+}
 .bg_tool {
 	background: #c2e6f2;
 }
@@ -121,4 +171,17 @@ export default {
 .bg_set {
 	background: #fcf2d5;
 }
+.border_sending {
+	border-bottom: #c2e6f2 1px solid;
+}
+.border_analysis {
+	border-bottom: #c6efcd 1px solid;
+}
+.el-icon-s-promotion{
+	position: absolute;
+	right: 5%;
+	top: 55%;
+	font-size: 19px;
+	color: #000;
+}
 </style>