From 7103e7d611bc2210252c99e3b010a5d3a0642bab Mon Sep 17 00:00:00 2001 From: enilu <82552623@qq.com> Date: Thu, 10 Jan 2019 16:31:28 +0800 Subject: [PATCH] fix bug --- guns-admin-vuejs/config/index.js | 2 +- .../src/views/system/menu/menu.js | 1 + .../src/views/system/role/role.js | 75 +++++++++---------- .../service/system/impl/ConstantFactory.java | 3 + 4 files changed, 40 insertions(+), 41 deletions(-) diff --git a/guns-admin-vuejs/config/index.js b/guns-admin-vuejs/config/index.js index 6486366b..584cc030 100644 --- a/guns-admin-vuejs/config/index.js +++ b/guns-admin-vuejs/config/index.js @@ -67,7 +67,7 @@ module.exports = { * then assetsPublicPath should be set to "/bar/". * In most cases please use '/' !!! */ - assetsPublicPath: '/vue/', // If you are deployed on the root path, please use '/' + assetsPublicPath: '/', // If you are deployed on the root path, please use '/' /** * Source Maps diff --git a/guns-admin-vuejs/src/views/system/menu/menu.js b/guns-admin-vuejs/src/views/system/menu/menu.js index 0c11d6d4..64a1f7e6 100644 --- a/guns-admin-vuejs/src/views/system/menu/menu.js +++ b/guns-admin-vuejs/src/views/system/menu/menu.js @@ -79,6 +79,7 @@ export default { return false }, add() { + this.form = {} this.formTitle = '添加菜单' this.formVisible = true this.isAdd = true diff --git a/guns-admin-vuejs/src/views/system/role/role.js b/guns-admin-vuejs/src/views/system/role/role.js index 3dfa295e..dadafff2 100644 --- a/guns-admin-vuejs/src/views/system/role/role.js +++ b/guns-admin-vuejs/src/views/system/role/role.js @@ -1,27 +1,25 @@ - -import { remove , getList , save , getRoleTree ,getPermissons , savePermissons } from '@/api/system/role' -import { list as getDeptList } from '@/api/system/dept' +import { remove, getList, save, getRoleTree, getPermissons, savePermissons } from '@/api/system/role' +import { list as getDeptList } from '@/api/system/dept' import { menuTreeListByRoleId } from '@/api/system/menu' - export default { data() { return { formVisible: false, formTitle: '添加角色', - deptList:[], - roleList:[], + deptList: [], + roleList: [], isAdd: true, - checkedPermissionKeys:[], - permissons:[], + checkedPermissionKeys: [], + permissons: [], defaultProps: { id: "id", label: 'name', children: 'children' }, - permissonVisible:false, - deptTree:{ + permissonVisible: false, + deptTree: { show: false, defaultProps: { id: "id", @@ -29,7 +27,7 @@ export default { children: 'children' } }, - roleTree:{ + roleTree: { show: false, defaultProps: { id: "id", @@ -42,12 +40,12 @@ export default { tips: '', name: '', deptid: '', - pid: '', + pid: 0, id: '', version: '', deptName: '', pName: '', - num:1 + num: 1 }, rules: { tips: [ @@ -62,10 +60,10 @@ export default { listQuery: { name: undefined }, - total:0, + total: 0, list: null, listLoading: true, - selRow:{} + selRow: {} } }, filters: { @@ -83,9 +81,9 @@ export default { }, methods: { init() { - getDeptList().then(response => { - this.deptList = response.data - }) + getDeptList().then(response => { + this.deptList = response.data + }) this.fetchData() }, fetchData() { @@ -107,38 +105,36 @@ export default { handleFilter() { this.getList() }, - fetchNext(){ + fetchNext() { this.listQuery.page = this.listQuery.page + 1 this.fetchData(); }, - fetchPrev(){ + fetchPrev() { this.listQuery.page = this.listQuery.page - 1 this.fetchData(); }, - fetchPage(page){ + fetchPage(page) { this.listQuery.page = page this.fetchData() }, - changeSize(limit){ + changeSize(limit) { this.listQuery.limit = limit; this.fetchData(); }, - handleCurrentChange(currentRow,oldCurrentRow){ - console.log('-------') - console.log(currentRow) + handleCurrentChange(currentRow, oldCurrentRow) { this.selRow = currentRow }, resetForm() { - this.form = { + this.form = { tips: '', name: '', deptid: '', - pid: '', + pid: 0, id: '', version: '', deptName: '', pName: '', - num:1 + num: 1 } }, @@ -149,7 +145,6 @@ export default { this.isAdd = true }, save() { - var self = this this.$refs['form'].validate((valid) => { if (valid) { save(this.form).then(response => { @@ -171,8 +166,8 @@ export default { }, - checkSel(){ - if(this.selRow && this.selRow.id){ + checkSel() { + if (this.selRow && this.selRow.id) { return true } this.$message({ @@ -181,8 +176,8 @@ export default { }); return false }, - edit(){ - if(this.checkSel()){ + edit() { + if (this.checkSel()) { this.isAdd = false console.log(this.selRow) this.form = this.selRow @@ -192,8 +187,8 @@ export default { this.formVisible = true } }, - remove(){ - if(this.checkSel()){ + remove() { + if (this.checkSel()) { var id = this.selRow.id this.$confirm('确定删除该记录?', '提示', { @@ -218,7 +213,7 @@ export default { }, openPermissions() { - if(this.checkSel()){ + if (this.checkSel()) { console.log(this.selRow) menuTreeListByRoleId(this.selRow.id).then(response => { console.log(response.data) @@ -232,12 +227,12 @@ export default { savePermissions() { var checkedPermissons = this.$refs.permissonTree.getCheckedKeys() var menuIds = ''; - for(var index in checkedPermissons){ - menuIds+=checkedPermissons[index]+',' + for (var index in checkedPermissons) { + menuIds += checkedPermissons[index] + ',' } var data = { - roleId:this.selRow.id, - permissions:menuIds + roleId: this.selRow.id, + permissions: menuIds } savePermissons(data).then(response => { console.log(response.data) diff --git a/guns-service/src/main/java/cn/enilu/guns/service/system/impl/ConstantFactory.java b/guns-service/src/main/java/cn/enilu/guns/service/system/impl/ConstantFactory.java index 6160e819..07fd7fb7 100644 --- a/guns-service/src/main/java/cn/enilu/guns/service/system/impl/ConstantFactory.java +++ b/guns-service/src/main/java/cn/enilu/guns/service/system/impl/ConstantFactory.java @@ -148,6 +148,9 @@ public String getSingleRoleTip(Long roleId) { */ @Override public String getDeptName(Long deptId) { + if(deptId==null){ + return null; + } String val = get(CacheKey.DEPT_NAME+deptId); if(StringUtils.isNotEmpty(val)){ return val;