From 8e8bdc5dc203406e9a41aff4b78d4d0131e26b85 Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Thu, 16 Apr 2020 20:16:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8A=9F=E8=83=BD=20=E4=BF=AE=E6=AD=A3=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E7=BB=86=E8=8A=82bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/api/v1/sys_user.go | 19 ++ server/router/sys_user.go | 1 + server/service/sys_base_menu.go | 11 +- server/service/sys_user.go | 13 ++ web/src/api/user.js | 17 ++ web/src/style/main.scss | 321 +++++++++++++------------- web/src/view/superAdmin/api/api.vue | 2 +- web/src/view/superAdmin/menu/menu.vue | 7 +- web/src/view/superAdmin/user/user.vue | 24 +- 9 files changed, 247 insertions(+), 168 deletions(-) diff --git a/server/api/v1/sys_user.go b/server/api/v1/sys_user.go index 592123d9..146a5291 100644 --- a/server/api/v1/sys_user.go +++ b/server/api/v1/sys_user.go @@ -229,3 +229,22 @@ func SetUserAuthority(c *gin.Context) { response.OkWithMessage("修改成功", c) } } + +// @Tags SysUser +// @Summary 删除用户 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.SetUserAuth true "删除用户" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" +// @Router /user/deleteUser [delete] +func DeleteUser(c *gin.Context) { + var reqId request.GetById + _ = c.ShouldBindJSON(&reqId) + err := service.DeleteUser(reqId.Id) + if err != nil { + response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c) + } else { + response.OkWithMessage("删除成功", c) + } +} diff --git a/server/router/sys_user.go b/server/router/sys_user.go index d59660a3..7c4369ca 100644 --- a/server/router/sys_user.go +++ b/server/router/sys_user.go @@ -13,5 +13,6 @@ func InitUserRouter(Router *gin.RouterGroup) { UserRouter.POST("uploadHeaderImg", v1.UploadHeaderImg) //上传头像 UserRouter.POST("getUserList", v1.GetUserList) // 分页获取用户列表 UserRouter.POST("setUserAuthority", v1.SetUserAuthority) //设置用户权限 + UserRouter.DELETE("deleteUser", v1.DeleteUser) //删除用户 } } diff --git a/server/service/sys_base_menu.go b/server/service/sys_base_menu.go index 48cdb71d..093699d7 100644 --- a/server/service/sys_base_menu.go +++ b/server/service/sys_base_menu.go @@ -35,6 +35,7 @@ func DeleteBaseMenu(id float64) (err error) { // @return err errorgetMenu func UpdateBaseMenu(menu model.SysBaseMenu) (err error) { + var oldMenu model.SysBaseMenu upDateMap := make(map[string]interface{}) upDateMap["keep_alive"] = menu.KeepAlive upDateMap["default_menu"] = menu.DefaultMenu @@ -46,7 +47,15 @@ func UpdateBaseMenu(menu model.SysBaseMenu) (err error) { upDateMap["title"] = menu.Title upDateMap["icon"] = menu.Icon upDateMap["sort"] = menu.Sort - err = global.GVA_DB.Where("id = ?", menu.ID).Find(&model.SysBaseMenu{}).Updates(upDateMap).Error + db := global.GVA_DB.Where("id = ?", menu.ID).Find(&oldMenu) + if oldMenu.Name != menu.Name { + notSame := global.GVA_DB.Where("id <> ? AND name = ?", menu.ID, menu.Name).First(&model.SysBaseMenu{}).RecordNotFound() + if !notSame { + global.GVA_LOG.Debug("存在相同name修改失败") + return errors.New("存在相同name修改失败") + } + } + err = db.Updates(upDateMap).Error global.GVA_LOG.Debug("菜单修改时候,关联菜单err:%v", err) return err } diff --git a/server/service/sys_user.go b/server/service/sys_user.go index b065507a..4c340860 100644 --- a/server/service/sys_user.go +++ b/server/service/sys_user.go @@ -95,6 +95,19 @@ func SetUserAuthority(uuid uuid.UUID, authorityId string) (err error) { return err } +// @title SetUserAuthority +// @description set the authority of a certain user, 设置一个用户的权限 +// @auth (2020/04/05 20:22) +// @param uuid UUID +// @param authorityId string +// @return err error + +func DeleteUser(id float64) (err error) { + var user model.SysUser + err = global.GVA_DB.Where("id = ?", id).Delete(&user).Error + return err +} + // @title UploadHeaderImg // @description upload avatar, 用户头像上传更新地址 // @auth (2020/04/05 20:22) diff --git a/web/src/api/user.js b/web/src/api/user.js index fbe51f12..70b8d3fc 100644 --- a/web/src/api/user.js +++ b/web/src/api/user.js @@ -77,4 +77,21 @@ export const setUserAuthority = (data) => { method: 'post', data: data }) +} + + +// @Tags SysUser +// @Summary 删除用户 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body request.SetUserAuth true "删除用户" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" +// @Router /user/deleteUser [delete] +export const deleteUser = (data) => { + return service({ + url: "/user/deleteUser", + method: 'delete', + data: data + }) } \ No newline at end of file diff --git a/web/src/style/main.scss b/web/src/style/main.scss index 05116234..09bfe405 100644 --- a/web/src/style/main.scss +++ b/web/src/style/main.scss @@ -530,11 +530,12 @@ ol, li { list-style-type: none; } -.el-table__body-wrapper{ - tr{ - td{ - .cell{ - .el-button+.el-button{ + +.el-table__body-wrapper { + tr { + td { + .cell { + .el-button+.el-button { margin-left: 0; } } @@ -542,210 +543,204 @@ li { } } - // navbar -.aside{ -.el-scrollbar { - .el-scrollbar__view { - .el-menu-vertical{ - background-color: #001529; - } - .el-menu-item:hover i, - .el-menu-item:hover span{ - color:#fff; - } - li{ - background-color: #001529; - - ul{ - .el-menu-item{ - background-color: #000408; - height: 44px; - line-height: 44px; - } - - .is-active{ - background-color:#1890ff; - } - } - } - .el-submenu__title:hover{ - background-color: #001529; - } - .el-submenu__title:hover i, - .el-submenu__title:hover span{ - color:#fff; - } - - .el-menu--inline{ - border-left: 5px solid #2c3b41; - } - } - } -} - -// layout - .layout-cont{ - .main-cont{ - position: relative; - &.el-main { - background-color: #ecf0f5; - padding: 0; +.aside { + .el-scrollbar { + .el-scrollbar__view { + .el-menu-vertical { + background-color: #001529; } - .breadcrumb{ - background-color: #fff; - padding: 0 0 15px 15px; + .el-menu-item:hover i, + .el-menu-item:hover span { + color: #fff; + } + li { + background-color: #001529; + ul { + .el-menu-item { + background-color: #000408; + height: 44px; + line-height: 44px; + } + .is-active { + background-color: #1890ff; + } + } + } + .el-submenu__title:hover { + background-color: #001529; + } + .el-submenu__title:hover i, + .el-submenu__title:hover span { + color: #fff; + } + .el-menu--inline { + border-left: 5px solid #2c3b41; } } } +} - .admin-box { - padding: 15px 20px; - .el-button{ - padding: 7px 10px; - } - .el-input__inner{ - height: 30px; - line-height: 30px; +// layout +.layout-cont { + .main-cont { + position: relative; + &.el-main { + background-color: #ecf0f5; + padding: 0; } - .el-input__icon{ - line-height: 30px; + .breadcrumb { + background-color: #fff; + padding: 0 0 15px 15px; } } - .button-box{ - background: #fff; - border: 1px solid #ebeef5; - border-bottom: none; +} +.admin-box { + padding: 15px 20px; + .el-button { + padding: 7px 10px; } - - .search-term{ - background: #fff; - padding: 0 15px; - border-left: 1px solid #ebeef5; - border-right: 1px solid #ebeef5; + .el-input__inner { + height: 30px; + line-height: 30px; + } + .el-input__icon { + line-height: 30px; } - +} +.button-box { + background: #fff; + border: 1px solid #ebeef5; + border-bottom: none; +} + +.search-term { + background: #fff; + padding: 0 15px; + border-left: 1px solid #ebeef5; + border-right: 1px solid #ebeef5; +} // table -.has-gutter{ - tr{ - th{ +.has-gutter { + tr { + th { background-color: #fafafa; } } } -.el-table--striped{ - .el-table__body{ - tr.el-table__row--striped{ - td{ + +.el-table--striped { + .el-table__body { + tr.el-table__row--striped { + td { background: #fff!important; } } } -} -.el-table th, .el-table tr{ +} + +.el-table th, +.el-table tr { background-color: #fafafa; } -.el-pagination{ + +.el-pagination { .btn-prev, - .btn-next{ + .btn-next { border: 1px solid #ddd; border-radius: 4px; } - .el-pager{ - - - li{ + .el-pager { + li { color: #666; font-size: 12px; margin: 0 5px; border: 1px solid #ddd; border-radius: 4px; } - } + } } - - // el-form -.el-form{ +.el-form { background-color: #fff; padding: 10px 0; } -.el-row{ + +.el-row { padding: 10px 0; - .el-col>label{ - - line-height: 30px; - text-align: right; - width: 80%; - padding-right: 15px; - display: inline-block; - + .el-col>label { + line-height: 30px; + text-align: right; + width: 80%; + padding-right: 15px; + display: inline-block; } - - .line{ + .line { line-height: 30px; text-align: center; } } + // edit_container -.edit_container{ +.edit_container { background-color: #fff; padding: 15px; .el-button { margin: 15px 0; } } -.edit{ + +.edit { background-color: #fff; - padding: 15px; + padding: 15px; .el-button { margin: 15px 0; } } + // upload-demo .upload-demo, -.upload{ +.upload { background-color: #fff; - padding: 15px; - .el-upload-list__item-status-label{ + padding: 15px; + .el-upload-list__item-status-label { right: 0; left: 120px; } - .el-upload__tip{ + .el-upload__tip { margin: 10px 0; - } + } } // system -.system{ +.system { padding: 15px; - .el-input__inner{ + .el-input__inner { width: 80%; } } // 导航 #app { - .el-container{ + .el-container { position: relative; height: 100%; width: 100%; - } .el-container.mobile.openside { position: fixed; top: 0; } - .hideside{ - .aside{ + .hideside { + .aside { width: 54px!important; } } - .el-aside{ + .el-aside { -webkit-transition: width .2s; transition: width .2s; width: 220px; @@ -759,66 +754,57 @@ li { z-index: 1001; overflow: hidden; } - - .mobile.hideside{ - .el-aside{ + .mobile.hideside { + .el-aside { // pointer-events: none; -webkit-transition-duration: .2s; transition-duration: .2s; - -webkit-transform: translate3d(-210px,0,0); - transform: translate3d(-220px,0,0); + -webkit-transform: translate3d(-210px, 0, 0); + transform: translate3d(-220px, 0, 0); } - } - - .mobile{ - .el-aside{ + .mobile { + .el-aside { -webkit-transition: -webkit-transform .28s; transition: -webkit-transform .28s; transition: transform .28s; - transition: transform .28s,-webkit-transform .28s; + transition: transform .28s, -webkit-transform .28s; width: 210px!important } } - - - .el-container{ + .el-container { position: relative; height: 100%; width: 100%; - .el-aside{ + .el-aside { // transition: none; - .aside { + .aside { background: #000; - .el-menu{ + .el-menu { border-right: none; } } } } - - .main-cont.el-main{ + .main-cont.el-main { min-height: 100%; -webkit-transition: margin-left .28s; transition: margin-left .28s; margin-left: 220px; position: relative; } - - - .hideside{ - .main-cont.el-main{ + .hideside { + .main-cont.el-main { margin-left: 54px; } } - .mobile { - .main-cont.el-main{ + .mobile { + .main-cont.el-main { margin-left: 0px; } - } - .openside.mobile{ - .shadowBg{ + .openside.mobile { + .shadowBg { background: #000; opacity: .3; width: 100%; @@ -829,22 +815,39 @@ li { left: 0; } } - } -.el-menu--vertical{ - .el-menu{ + +.el-menu .el-menu--inline { + background: #2c3b41; +} + +.el-submenu .el-submenu { + background-color: #000408 !important; +} + +.aside .el-scrollbar .el-scrollbar__view .el-submenu__title:hover { + background-color: #000408 !important; +} + +.el-submenu { + .aside .el-scrollbar .el-scrollbar__view .el-submenu__title:hover { + background-color: #000408 !important; + } +} + +.el-menu--vertical { + .el-menu { margin-left: -8px; - background-color:rgb(48,65,86); - .el-menu-item{ - background-color:rgb(48,65,86); + background-color: rgb(48, 65, 86); + .el-menu-item { + background-color: rgb(48, 65, 86); } - .el-menu-item:focus, - .el-menu-item:hover{ + .el-menu-item:focus, + .el-menu-item:hover { background-color: #263445; color: #fff; } } } -// 导航***** - +// 导航***** \ No newline at end of file diff --git a/web/src/view/superAdmin/api/api.vue b/web/src/view/superAdmin/api/api.vue index 6cdc0b03..29ebc6f8 100644 --- a/web/src/view/superAdmin/api/api.vue +++ b/web/src/view/superAdmin/api/api.vue @@ -259,7 +259,7 @@ export default { if (res.code == 0) { this.$message({ type: 'success', - message: '添加成功', + message: '编辑成功', showClose: true }) } diff --git a/web/src/view/superAdmin/menu/menu.vue b/web/src/view/superAdmin/menu/menu.vue index 38998fe3..7c742f0e 100644 --- a/web/src/view/superAdmin/menu/menu.vue +++ b/web/src/view/superAdmin/menu/menu.vue @@ -225,14 +225,9 @@ export default { if (res.code == 0) { this.$message({ type: 'success', - message: '添加成功!' + message: this.isEdit?'编辑成功':'添加成功!' }) this.getTableData() - } else { - this.$message({ - type: 'error', - message: '添加失败!' - }) } this.initForm() this.dialogFormVisible = false diff --git a/web/src/view/superAdmin/user/user.vue b/web/src/view/superAdmin/user/user.vue index 8e0613cc..7d5be00a 100644 --- a/web/src/view/superAdmin/user/user.vue +++ b/web/src/view/superAdmin/user/user.vue @@ -30,6 +30,21 @@ + + + // 获取列表内容封装在mixins内部 getTableData方法 初始化已封装完成 const path = process.env.VUE_APP_BASE_API -import { getUserList, setUserAuthority, register } from '@/api/user' +import { getUserList, setUserAuthority, register, deleteUser } from '@/api/user' import { getAuthorityList } from '@/api/authority' import infoList from '@/components/mixins/infoList' import { mapGetters } from 'vuex' @@ -127,6 +142,13 @@ export default { ...mapGetters('user', ['token']) }, methods: { + async deleteUser(row){ + const res = await deleteUser({id:row.ID}) + if(res.code == 0){ + this.getTableData() + row.visible = false + } + }, getAuthorityList(AuthorityData){ AuthorityData.map(item=>{ this.authOptions.push({