Skip to content

Commit 813d3bb

Browse files
committed
fix(view): permission
1 parent 59cbf79 commit 813d3bb

File tree

5 files changed

+115
-159
lines changed

5 files changed

+115
-159
lines changed

admin/src/api/permission.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import request from '@/utils/request'
2+
3+
export function getList(params) {
4+
// return request.get('/api/permissions', params)
5+
return request({
6+
url: '/api/permissions',
7+
method: 'get',
8+
params
9+
})
10+
}
11+
12+
export function getRole() {
13+
return request.get('/api/permissions/create')
14+
}
15+
16+
export function postAdd(params) {
17+
return request.post('/api/permissions', params)
18+
}
19+
20+
export function edit(id) {
21+
return request.get('/api/permissions/' + id)
22+
}
23+
24+
export function postEdit(id, params) {
25+
return request.patch('/api/permissions/' + id, params)
26+
}
27+
28+
export function deleteAct(id) {
29+
return request.delete('/api/permissions/' + id)
30+
}
31+
32+
/**
33+
* 搜索 permissions
34+
* @param params
35+
*/
36+
export function search(params) {
37+
return request({
38+
url: '/api/permissions_search',
39+
method: 'get',
40+
params
41+
})
42+
}
43+
44+
export function startTask(params) {
45+
return request({
46+
url: '/api/start_task',
47+
method: 'post',
48+
params
49+
})
50+
}

admin/src/router/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export const constantRouterMap = [
173173
},
174174

175175
{
176-
path: '/user',
176+
path: 'user',
177177
component: Layout,
178178
redirect: '/user',
179179
name: '权限',
@@ -189,19 +189,19 @@ export const constantRouterMap = [
189189
component: () => import('@/views/user/index'),
190190
meta: { title: '用户列表', icon: 'user' }
191191
},
192-
{ path: 'permission/add', name: 'AddPermission', component: () => import('@/views/permission/add'), hidden: true },
193-
{ path: 'permission/edit/:id', name: 'EditPermission', component: () => import('@/views/permission/edit'), hidden: true },
192+
{ path: '/permission/add', name: 'AddPermission', component: () => import('@/views/permission/add'), hidden: true },
193+
{ path: '/permission/edit/:id', name: 'EditPermission', component: () => import('@/views/permission/edit'), hidden: true },
194194
{
195-
path: 'permission',
195+
path: '/permission',
196196
name: '权限列表',
197197
component: () => import('@/views/permission/index'),
198198
meta: { title: '权限列表', icon: 'permission' }
199199
},
200200

201-
{ path: 'role/add', name: 'AddRole', component: () => import('@/views/role/add'), hidden: true },
202-
{ path: 'role/edit/:id', name: 'EditRole', component: () => import('@/views/role/edit'), hidden: true },
201+
{ path: '/role/add', name: 'AddRole', component: () => import('@/views/role/add'), hidden: true },
202+
{ path: '/role/edit/:id', name: 'EditRole', component: () => import('@/views/role/edit'), hidden: true },
203203
{
204-
path: 'role',
204+
path: '/role',
205205
name: '角色管理',
206206
component: () => import('@/views/role/index'),
207207
meta: { title: '角色管理', icon: 'role' }

admin/src/views/permission/add.vue

Lines changed: 35 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,21 @@
11
<template>
22
<div class="app-container">
3-
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
4-
<el-form-item label="接口名称" prop="name">
5-
<el-input v-model="form.name"/>
3+
<el-form ref="form" :model="form" :rules="rules" label-width="220px">
4+
<el-form-item label="权限名称" prop="name">
5+
<el-col :span="10">
6+
<el-input v-model="form.name"/>
7+
</el-col>
8+
<el-col :span="14"/>
69
</el-form-item>
7-
<el-form-item label="接口地址" prop="url">
8-
<el-input v-model="form.url"/>
9-
</el-form-item>
10-
<el-form-item label="接口参数" prop="param">
11-
<el-input v-model="form.param"/>
12-
<span>(多个参数请用英文 , 分割;如: realname,mobile,idcard)</span>
13-
</el-form-item>
14-
<el-form-item label="结果集 result" prop="result">
15-
<el-input v-model="form.result"/>
16-
<span>(多个参数请用英文 , 分割;如: res,msg)</span>
17-
</el-form-item>
18-
<el-form-item label="是否处理" prop="is_need">
19-
<el-switch v-model="form.is_need"/>
20-
<br>
21-
<span>(开启后,输出的 Excel 最后一栏将根据 result 字段 res 1 展示一致 2 不一致)</span>
22-
</el-form-item>
23-
<el-form-item label="网址" prop="website">
24-
<el-input v-model="form.website"/>
25-
</el-form-item>
26-
<el-form-item label="请求方式" prop="method">
27-
<!--<el-input v-model="form.method"/>-->
28-
<el-select v-model="form.method" placeholder="请选择接口" value-key="name">
29-
<el-option key="1" label="get" value="get">
30-
<span style="float: left; color: #8492a6; font-size: 13px">get</span>
31-
</el-option>
32-
<el-option key="2" label="post" value="post">
33-
<span style="float: left; color: #8492a6; font-size: 13px">post</span>
34-
</el-option>
35-
</el-select>
36-
</el-form-item>
37-
<el-form-item label="是否启用">
38-
<el-switch v-model="form.state"/>
10+
11+
<el-form-item label="新增权限赋值角色" prop="roles">
12+
<template>
13+
<el-checkbox-group v-model="form.checkedRoles" @change="handleCheckedRolesChange">
14+
<el-checkbox v-for="role in form.roles" :label="role.id" :key="role.id">{{ role.name }}</el-checkbox>
15+
</el-checkbox-group>
16+
</template>
3917
</el-form-item>
18+
4019
<el-form-item>
4120
<el-button type="primary" @click="onSubmit('form')">提交</el-button>
4221
<el-button @click="resetForm('form')">重置</el-button>
@@ -46,43 +25,43 @@
4625
</template>
4726

4827
<script>
49-
import { postAdd } from '@/api/api_param'
28+
29+
import { postAdd, getRole } from '@/api/permission'
5030
5131
export default {
5232
data() {
5333
return {
5434
form: {
5535
name: '',
56-
url: '',
57-
param: '',
58-
result: '',
59-
is_need: false,
60-
state: true,
61-
website: '',
62-
method: 'get',
36+
checkedRoles: [],
37+
roles: [],
38+
isIndeterminate: true,
6339
loading: false
6440
},
6541
rules: {
6642
name: [
6743
{ required: true, message: '请输入名称', trigger: 'blur' }
68-
],
69-
url: [
70-
{ required: true, message: '请输入接口地址', trigger: 'blur' }
71-
],
72-
param: [
73-
{ required: true, message: '请输入接口参数', trigger: 'blur' }
74-
],
75-
result: [
76-
{ required: true, message: '请输入结果集 result', trigger: 'blur' }
77-
],
78-
is_need: [
79-
{ required: true, message: '请选择是否处理', trigger: 'blur' }
8044
]
8145
},
82-
redirect: '/api_param/index'
46+
redirect: '/permission'
8347
}
8448
},
49+
created() {
50+
this.fetchData()
51+
},
8552
methods: {
53+
fetchData() {
54+
this.listLoading = true
55+
getRole().then(response => {
56+
console.log(response.data)
57+
this.form.roles = response.data.roles
58+
this.listLoading = false
59+
})
60+
},
61+
handleCheckedRolesChange(value) {
62+
const checkedCount = value.length
63+
this.isIndeterminate = checkedCount > 0 && checkedCount < this.form.roles.length
64+
},
8665
onSubmit(form) {
8766
console.log(this.form)
8867
this.$refs[form].validate((valid) => {
@@ -126,4 +105,3 @@ export default {
126105
text-align: center;
127106
}
128107
</style>
129-

admin/src/views/permission/edit.vue

Lines changed: 15 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
11
<template>
22
<div class="app-container">
3-
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
4-
<el-form-item label="接口名称" prop="name">
5-
<el-input v-model="form.name"/>
6-
</el-form-item>
7-
<el-form-item label="接口地址" prop="url">
8-
<el-input v-model="form.url"/>
9-
</el-form-item>
10-
<el-form-item label="接口参数" prop="param">
11-
<el-input v-model="form.param"/>
12-
<span>(多个参数请用英文 , 分割;如: realname,mobile,idcard)</span>
13-
</el-form-item>
14-
<el-form-item label="结果集 result" prop="result">
15-
<el-input v-model="form.result"/>
16-
<span>(多个参数请用英文 , 分割;如: res,msg)</span>
17-
</el-form-item>
18-
<el-form-item label="是否处理" prop="is_need">
19-
<el-switch v-model="form.is_need"/>
20-
</el-form-item>
21-
<el-form-item label="网址" prop="website">
22-
<el-input v-model="form.website"/>
23-
</el-form-item>
24-
<el-form-item label="请求方式" prop="method">
25-
<!--<el-input v-model="form.method"/>-->
26-
<el-select v-model="form.method" placeholder="请选择接口" value-key="name">
27-
<el-option key="1" label="get" value="get">
28-
<span style="float: left; color: #8492a6; font-size: 13px">get</span>
29-
</el-option>
30-
<el-option key="2" label="post" value="post">
31-
<span style="float: left; color: #8492a6; font-size: 13px">post</span>
32-
</el-option>
33-
</el-select>
34-
</el-form-item>
35-
<el-form-item label="是否启用">
36-
<el-switch v-model="form.state"/>
3+
<el-form ref="form" :model="form" :rules="rules" label-width="220px">
4+
<el-form-item label="权限名称" prop="name">
5+
<el-col :span="10">
6+
<el-input v-model="form.name"/>
7+
</el-col>
8+
<el-col :span="14"/>
379
</el-form-item>
10+
3811
<el-form-item>
3912
<el-button type="primary" @click="onSubmit('form')">提交</el-button>
4013
<el-button @click="resetForm('form')">重置</el-button>
@@ -44,40 +17,22 @@
4417
</template>
4518

4619
<script>
47-
import { edit, postEdit } from '@/api/api_param'
20+
21+
import { postEdit, edit } from '@/api/permission'
4822
4923
export default {
5024
data() {
5125
return {
5226
form: {
5327
name: '',
54-
url: '',
55-
param: '',
56-
result: '',
57-
is_need: false,
58-
state: true,
59-
website: '',
60-
method: 'get',
6128
loading: false
6229
},
6330
rules: {
6431
name: [
6532
{ required: true, message: '请输入名称', trigger: 'blur' }
66-
],
67-
url: [
68-
{ required: true, message: '请输入接口地址', trigger: 'blur' }
69-
],
70-
param: [
71-
{ required: true, message: '请输入接口参数', trigger: 'blur' }
72-
],
73-
result: [
74-
{ required: true, message: '请输入结果集 result', trigger: 'blur' }
75-
],
76-
is_need: [
77-
{ required: true, message: '请选择是否处理', trigger: 'blur' }
7833
]
7934
},
80-
redirect: '/api_param/index'
35+
redirect: '/permission'
8136
}
8237
},
8338
created() {
@@ -86,21 +41,21 @@ export default {
8641
},
8742
methods: {
8843
getData(id) {
89-
// this.id = this.$route.params.id
9044
edit(id).then(response => {
91-
// console.log(response)
9245
this.loading = false
9346
if (response.code === 200) {
9447
this.form = response.data
95-
this.form.is_need = (response.data.is_need === 1)
96-
this.form.state = (response.data.state === 1)
9748
} else {
9849
this.$message.error(response.reason)
9950
}
10051
})
10152
},
53+
handleCheckedRolesChange(value) {
54+
const checkedCount = value.length
55+
this.isIndeterminate = checkedCount > 0 && checkedCount < this.form.roles.length
56+
},
10257
onSubmit(form) {
103-
console.log(this.form)
58+
// console.log(this.form)
10459
this.$refs[form].validate((valid) => {
10560
if (valid) {
10661
this.loading = true
@@ -142,4 +97,3 @@ export default {
14297
text-align: center;
14398
}
14499
</style>
145-

0 commit comments

Comments
 (0)