diff --git a/QMPlusServer/controller/api/authority.go b/QMPlusServer/controller/api/authority.go index a5d212e2..1554bdf6 100644 --- a/QMPlusServer/controller/api/authority.go +++ b/QMPlusServer/controller/api/authority.go @@ -5,10 +5,11 @@ import ( "github.com/gin-gonic/gin" "main/controller/servers" "main/model/dbModel" + "main/model/modelInterface" ) type CreateAuthorityPatams struct { - AuthorityId uint `json:"authorityId"` + AuthorityId string `json:"authorityId"` AuthorityName string `json:"authorityName"` } @@ -22,7 +23,7 @@ type CreateAuthorityPatams struct { // @Router /authority/createAuthority [post] func CreateAuthority(c *gin.Context) { var auth dbModel.Authority - _ = c.BindJSON(&auth) + _ = c.ShouldBind(&auth) err, authBack := auth.CreateAuthority() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{ @@ -58,3 +59,27 @@ func DeleteAuthority(c *gin.Context) { servers.ReportFormat(c, true, "删除成功", gin.H{}) } } + +// @Tags authority +// @Summary 分页获取角色列表 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body modelInterface.PageInfo true "分页获取用户列表" +// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /authority/getAuthorityList [post] +func GetAuthorityList(c *gin.Context){ + var pageInfo modelInterface.PageInfo + _ = c.BindJSON(&pageInfo) + err, list, total := new(dbModel.Authority).GetInfoList(pageInfo) + if err != nil { + servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{}) + } else { + servers.ReportFormat(c, true, "获取数据成功", gin.H{ + "authList": list, + "total": total, + "page": pageInfo.Page, + "pageSize": pageInfo.PageSize, + }) + } +} \ No newline at end of file diff --git a/QMPlusServer/model/dbModel/authority.go b/QMPlusServer/model/dbModel/authority.go index 009dab8c..083e7cef 100644 --- a/QMPlusServer/model/dbModel/authority.go +++ b/QMPlusServer/model/dbModel/authority.go @@ -3,12 +3,14 @@ package dbModel import ( "github.com/jinzhu/gorm" "github.com/pkg/errors" + "main/controller/servers" "main/init/qmsql" + "main/model/modelInterface" ) type Authority struct { gorm.Model `json:"-"` - AuthorityId uint `json:"authorityId" gorm:"not null;unique"` + AuthorityId string `json:"authorityId" gorm:"not null;unique"` AuthorityName string `json:"authorityName"` } @@ -28,3 +30,18 @@ func (a *Authority) DeleteAuthority() (err error) { } return err } + + + +// 分页获取数据 需要分页实现这个接口即可 +func (a *Authority) GetInfoList(info modelInterface.PageInfo) (err error, list interface{}, total int) { + // 封装分页方法 调用即可 传入 当前的结构体和分页信息 + err, db, total := servers.PagingServer(a, info) + if err != nil { + return + } else { + var authority []Authority + err = db.Find(&authority).Error + return err, authority, total + } +} \ No newline at end of file diff --git a/QMPlusServer/router/authority.go b/QMPlusServer/router/authority.go index 39254b26..48c0b627 100644 --- a/QMPlusServer/router/authority.go +++ b/QMPlusServer/router/authority.go @@ -11,5 +11,6 @@ func InitAuthorityRouter(Router *gin.Engine) { { AuthorityRouter.POST("createAuthority", api.CreateAuthority) AuthorityRouter.POST("deleteAuthority", api.DeleteAuthority) + AuthorityRouter.POST("getAuthorityList",api.GetAuthorityList) } } diff --git a/QMPlusVuePage/package-lock.json b/QMPlusVuePage/package-lock.json index 63eb6472..95a7e43f 100644 --- a/QMPlusVuePage/package-lock.json +++ b/QMPlusVuePage/package-lock.json @@ -11678,6 +11678,11 @@ "integrity": "sha1-HuO8mhbsv1EYvjNLsV+cRvgvWCU=", "dev": true }, + "vuescroll": { + "version": "4.14.4", + "resolved": "https://registry.npmjs.org/vuescroll/-/vuescroll-4.14.4.tgz", + "integrity": "sha512-v+QYnoZLr1Eo93CekHOyF54e5c1Mu9s+k3G6Qaw/vRL20j1hnS/mMejW2pn60nuFinqKdXb9MghjJP4jKrc8+w==" + }, "vuex": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.1.tgz", diff --git a/QMPlusVuePage/package.json b/QMPlusVuePage/package.json index e104f11f..9c1ed705 100644 --- a/QMPlusVuePage/package.json +++ b/QMPlusVuePage/package.json @@ -18,6 +18,7 @@ "vue": "^2.6.10", "vue-particle-line": "^0.1.4", "vue-router": "^3.1.3", + "vuescroll": "^4.14.4", "vuex": "^3.1.1", "vuex-persist": "^2.1.0" }, diff --git a/QMPlusVuePage/src/App.vue b/QMPlusVuePage/src/App.vue index 7fbd56c5..4347e36f 100644 --- a/QMPlusVuePage/src/App.vue +++ b/QMPlusVuePage/src/App.vue @@ -18,6 +18,9 @@ export default { diff --git a/QMPlusVuePage/src/api/authority.js b/QMPlusVuePage/src/api/authority.js new file mode 100644 index 00000000..fa3b6538 --- /dev/null +++ b/QMPlusVuePage/src/api/authority.js @@ -0,0 +1,47 @@ +import service from '@/utils/request' + +// @Summary 用户登录 +// @Produce application/json +// @Param { +// page int +// pageSize int +// } +// @Router /authority/getAuthorityList [post] +export const getAuthorityList = (data) => { + return service({ + url: "/authority/getAuthorityList", + method: 'post', + data + }) +} + + +// @Summary 删除角色 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body {authorityId uint} true "删除角色" +// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /authority/deleteAuthority [post] +export const deleteAuthority = (data) => { + return service({ + url: "/authority/deleteAuthority", + method: 'post', + data + }) +} + +// @Summary 创建角色 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data body api.CreateAuthorityPatams true "创建角色" +// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}" +// @Router /authority/createAuthority [post] +export const createAuthority = (data) => { + return service({ + url: "/authority/createAuthority", + method: 'post', + data + }) +} \ No newline at end of file diff --git a/QMPlusVuePage/src/main.js b/QMPlusVuePage/src/main.js index c213a3e4..c898a5e4 100644 --- a/QMPlusVuePage/src/main.js +++ b/QMPlusVuePage/src/main.js @@ -16,6 +16,9 @@ import '@/permission' import { store } from '@/store/index' Vue.config.productionTip = false + +import Bus from '@/utils/bus.js' +Vue.use(Bus) new Vue({ render: h => h(App), router, diff --git a/QMPlusVuePage/src/store/module/user.js b/QMPlusVuePage/src/store/module/user.js index a94baa0f..d0851883 100644 --- a/QMPlusVuePage/src/store/module/user.js +++ b/QMPlusVuePage/src/store/module/user.js @@ -45,7 +45,7 @@ export const user = { if (redirect) { router.push({ path: redirect }) } else { - router.push({ path: '/layout/dashboard' }) + router.push({ name: 'dashboard' }) } } } catch (err) { diff --git a/QMPlusVuePage/src/style/base.scss b/QMPlusVuePage/src/style/base.scss new file mode 100644 index 00000000..d9415a55 --- /dev/null +++ b/QMPlusVuePage/src/style/base.scss @@ -0,0 +1,35 @@ +.clearflex { + *zoom: 1; +} + +.clearflex:after { + content: ''; + display: block; + height: 0; + visibility: hidden; + clear: both; +} + +.fl-left { + float: left; +} + +.fl-right { + float: right; +} + +.left-mg-xs { + margin-left: 6px; +} + +.left-mg-sm { + margin-left: 10px; +} + +.left-mg-md { + margin-left: 14px; +} + +.left-mg-lg { + margin-left: 18px; +} \ No newline at end of file diff --git a/QMPlusVuePage/src/utils/asyncRouter.js b/QMPlusVuePage/src/utils/asyncRouter.js index fbefeb05..dfaa4e41 100644 --- a/QMPlusVuePage/src/utils/asyncRouter.js +++ b/QMPlusVuePage/src/utils/asyncRouter.js @@ -1,7 +1,11 @@ const _import = require('./_import') //获取组件的方法 export const asyncRouterHandle = (asyncRouter) => { asyncRouter.map(item => { - item.component = _import(item.component) + if (item.component) { + item.component = _import(item.component) + } else { + delete item['component'] + } if (item.children) { asyncRouterHandle(item.children) } diff --git a/QMPlusVuePage/src/utils/bus.js b/QMPlusVuePage/src/utils/bus.js new file mode 100644 index 00000000..4e49e218 --- /dev/null +++ b/QMPlusVuePage/src/utils/bus.js @@ -0,0 +1,18 @@ +const install = (Vue) => { + const Bus = new Vue({ + methods: { + emit(event, ...args) { + this.$emit(event, ...args) + }, + on(event, cb) { + this.$on(event, cb) + }, + off(event, cb) { + this.$off(event, cb) + } + }, + }) + Vue.prototype.$bus = Bus +} + +export default install \ No newline at end of file diff --git a/QMPlusVuePage/src/view/dashbord/index.vue b/QMPlusVuePage/src/view/dashbord/index.vue index 4a94bda4..607a062a 100644 --- a/QMPlusVuePage/src/view/dashbord/index.vue +++ b/QMPlusVuePage/src/view/dashbord/index.vue @@ -1,16 +1,33 @@ \ No newline at end of file diff --git a/QMPlusVuePage/src/view/layout/aside/asideComponent/asyncSubmenu.vue b/QMPlusVuePage/src/view/layout/aside/asideComponent/asyncSubmenu.vue index 0ac6a539..dea43c83 100644 --- a/QMPlusVuePage/src/view/layout/aside/asideComponent/asyncSubmenu.vue +++ b/QMPlusVuePage/src/view/layout/aside/asideComponent/asyncSubmenu.vue @@ -1,7 +1,7 @@