Quellcode durchsuchen

添加按钮权限

daxiong.yang vor 7 Jahren
Ursprung
Commit
0a0e32a1b2

+ 1 - 1
src/api/modules/menu.js

3
import requestParam from '../requestParam'
3
import requestParam from '../requestParam'
4
import isInteger from 'lodash/isInteger'
4
import isInteger from 'lodash/isInteger'
5
5
6
// 获取导航菜单列表
6
// 获取导航菜单列表 / 权限
7
export function nav () {
7
export function nav () {
8
  return request({
8
  return request({
9
    url: requestUrl('/sys/menu/nav'),
9
    url: requestUrl('/sys/menu/nav'),

+ 3 - 0
src/main.js

8
import '@/element-ui'               // api: https://github.com/ElemeFE/element
8
import '@/element-ui'               // api: https://github.com/ElemeFE/element
9
import '@/iconfont'                 // api: http://www.iconfont.cn/
9
import '@/iconfont'                 // api: http://www.iconfont.cn/
10
import '@/assets/scss/index.scss'
10
import '@/assets/scss/index.scss'
11
import { isAuth } from '@/utils'
11
12
12
Vue.config.productionTip = false
13
Vue.config.productionTip = false
13
14
14
Vue.use(VueCookie)
15
Vue.use(VueCookie)
15
16
17
Vue.prototype.isAuth = isAuth // 挂载权限方法
18
16
/* eslint-disable no-new */
19
/* eslint-disable no-new */
17
new Vue({
20
new Vue({
18
  el: '#app',
21
  el: '#app',

+ 22 - 14
src/utils/index.js

1
/**
1
/**
2
 * 获取字符串字节长度
2
 * 是否有权限
3
 * @param {*} key
3
 */
4
 */
4
export function getStringLength (s) {
5
  return s.replace(/[\u4e00-\u9fa5\uff00-\uffff]/g, '**').length
6
}
7
8
/**
9
 * 获取路由名称, 根据url地址
10
 */
11
export function getRouteNameByUrl (url) {
12
  let val = /.*\/(.*)\.html/.exec(url)
13
  return val && val.length >= 1 ? val[1] : ''
5
export function isAuth (key) {
6
  return JSON.parse(sessionStorage.getItem('permissions') || '[]').indexOf(key) !== -1 || false
14
}
7
}
15
8
16
/**
9
/**
17
 * 树形数据转换
10
 * 树形数据转换
18
 * @param {*} data 数据
19
 * @param {*} id 标记
20
 * @param {*} pid 父级标记
11
 * @param {*} data
12
 * @param {*} id
13
 * @param {*} pid
21
 */
14
 */
22
export function treeDataTranslate (data, id, pid) {
15
export function treeDataTranslate (data, id, pid) {
23
  for (var i = 0; i < data.length; i++) {
16
  for (var i = 0; i < data.length; i++) {
33
  }
26
  }
34
  return data
27
  return data
35
}
28
}
29
30
/**
31
 * 获取字符串字节长度
32
 */
33
export function getStringLength (s) {
34
  return s.replace(/[\u4e00-\u9fa5\uff00-\uffff]/g, '**').length
35
}
36
37
/**
38
 * 获取路由名称, 根据url地址
39
 */
40
export function getRouteNameByUrl (url) {
41
  let val = /.*\/(.*)\.html/.exec(url)
42
  return val && val.length >= 1 ? val[1] : ''
43
}

+ 8 - 2
src/views/layout/sidebar.vue

82
        })
82
        })
83
        this.menuNavActive = menuNav.menuId + ''
83
        this.menuNavActive = menuNav.menuId + ''
84
      },
84
      },
85
      // 获取菜单导航列表
85
      // 获取菜单导航列表 / 权限
86
      getMenuNavList () {
86
      getMenuNavList () {
87
        return API.menu.nav().then(({data}) => {
87
        return API.menu.nav().then(({data}) => {
88
          this.UPDATE_MENU_NAV_LIST(data && data.code === 0 ? data.menuList : [])
88
          if (data && data.code === 0) {
89
            this.UPDATE_MENU_NAV_LIST(data.menuList)
90
            sessionStorage.setItem('permissions', JSON.stringify(data.permissions || '[]'))
91
          } else {
92
            this.UPDATE_MENU_NAV_LIST([])
93
            sessionStorage.setItem('permissions', '[]')
94
          }
89
        })
95
        })
90
      },
96
      },
91
      // 获取菜单导航, 根据路由名称
97
      // 获取菜单导航, 根据路由名称

+ 4 - 4
src/views/role/index.vue

6
      </el-form-item>
6
      </el-form-item>
7
      <el-form-item>
7
      <el-form-item>
8
        <el-button @click="getDataList()">查询</el-button>
8
        <el-button @click="getDataList()">查询</el-button>
9
        <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
10
        <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
9
        <el-button v-if="isAuth('sys:role:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
10
        <el-button v-if="isAuth('sys:role:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
11
      </el-form-item>
11
      </el-form-item>
12
    </el-form>
12
    </el-form>
13
    <el-table
13
    <el-table
55
        width="200"
55
        width="200"
56
        label="操作">
56
        label="操作">
57
        <template slot-scope="scope">
57
        <template slot-scope="scope">
58
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.roleId)">修改</el-button>
59
          <el-button type="text" size="small" @click="deleteHandle(scope.row.roleId)">删除</el-button>
58
          <el-button v-if="isAuth('sys:role:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.roleId)">修改</el-button>
59
          <el-button v-if="isAuth('sys:role:delete')" type="text" size="small" @click="deleteHandle(scope.row.roleId)">删除</el-button>
60
        </template>
60
        </template>
61
      </el-table-column>
61
      </el-table-column>
62
    </el-table>
62
    </el-table>

+ 11 - 11
src/views/schedule/index.vue

6
      </el-form-item>
6
      </el-form-item>
7
      <el-form-item>
7
      <el-form-item>
8
        <el-button @click="getDataList()">查询</el-button>
8
        <el-button @click="getDataList()">查询</el-button>
9
        <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
10
        <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
11
        <el-button type="danger" @click="pauseHandle()" :disabled="dataListSelections.length <= 0">批量暂停</el-button>
12
        <el-button type="danger" @click="resumeHandle()" :disabled="dataListSelections.length <= 0">批量恢复</el-button>
13
        <el-button type="danger" @click="runHandle()" :disabled="dataListSelections.length <= 0">批量立即执行</el-button>
14
        <el-button type="success" @click="logDialogVisible = true">日志列表</el-button>
9
        <el-button v-if="isAuth('sys:schedule:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
10
        <el-button v-if="isAuth('sys:schedule:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
11
        <el-button v-if="isAuth('sys:schedule:pause')" type="danger" @click="pauseHandle()" :disabled="dataListSelections.length <= 0">批量暂停</el-button>
12
        <el-button v-if="isAuth('sys:schedule:resume')" type="danger" @click="resumeHandle()" :disabled="dataListSelections.length <= 0">批量恢复</el-button>
13
        <el-button v-if="isAuth('sys:schedule:run')" type="danger" @click="runHandle()" :disabled="dataListSelections.length <= 0">批量立即执行</el-button>
14
        <el-button v-if="isAuth('sys:schedule:log')" type="success" @click="logDialogVisible = true">日志列表</el-button>
15
      </el-form-item>
15
      </el-form-item>
16
    </el-form>
16
    </el-form>
17
    <el-table
17
    <el-table
80
        width="200"
80
        width="200"
81
        label="操作">
81
        label="操作">
82
        <template slot-scope="scope">
82
        <template slot-scope="scope">
83
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.jobId)">修改</el-button>
84
          <el-button type="text" size="small" @click="deleteHandle(scope.row.jobId)">删除</el-button>
85
          <el-button type="text" size="small" @click="pauseHandle(scope.row.jobId)">暂停</el-button>
86
          <el-button type="text" size="small" @click="resumeHandle(scope.row.jobId)">恢复</el-button>
87
          <el-button type="text" size="small" @click="runHandle(scope.row.jobId)">立即执行</el-button>
83
          <el-button v-if="isAuth('sys:schedule:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.jobId)">修改</el-button>
84
          <el-button v-if="isAuth('sys:schedule:delete')" type="text" size="small" @click="deleteHandle(scope.row.jobId)">删除</el-button>
85
          <el-button v-if="isAuth('sys:schedule:pause')" type="text" size="small" @click="pauseHandle(scope.row.jobId)">暂停</el-button>
86
          <el-button v-if="isAuth('sys:schedule:resume')" type="text" size="small" @click="resumeHandle(scope.row.jobId)">恢复</el-button>
87
          <el-button v-if="isAuth('sys:schedule:run')" type="text" size="small" @click="runHandle(scope.row.jobId)">立即执行</el-button>
88
        </template>
88
        </template>
89
      </el-table-column>
89
      </el-table-column>
90
    </el-table>
90
    </el-table>

+ 4 - 4
src/views/user/index.vue

6
      </el-form-item>
6
      </el-form-item>
7
      <el-form-item>
7
      <el-form-item>
8
        <el-button @click="getDataList()">查询</el-button>
8
        <el-button @click="getDataList()">查询</el-button>
9
        <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
10
        <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
9
        <el-button v-if="isAuth('sys:user:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
10
        <el-button v-if="isAuth('sys:user:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
11
      </el-form-item>
11
      </el-form-item>
12
    </el-form>
12
    </el-form>
13
    <el-table
13
    <el-table
71
        width="200"
71
        width="200"
72
        label="操作">
72
        label="操作">
73
        <template slot-scope="scope">
73
        <template slot-scope="scope">
74
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.userId)">修改</el-button>
75
          <el-button type="text" size="small" @click="deleteHandle(scope.row.userId)">删除</el-button>
74
          <el-button v-if="isAuth('sys:user:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.userId)">修改</el-button>
75
          <el-button v-if="isAuth('sys:user:delete')" type="text" size="small" @click="deleteHandle(scope.row.userId)">删除</el-button>
76
        </template>
76
        </template>
77
      </el-table-column>
77
      </el-table-column>
78
    </el-table>
78
    </el-table>