Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-qa
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-qa
Commits
c94a8ae9
提交
c94a8ae9
authored
8月 30, 2022
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 优化权限
上级
9f2be835
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
61 行增加
和
17 行删除
+61
-17
main.js
src/main.js
+2
-2
PaperQuestions.vue
src/modules/paper/components/PaperQuestions.vue
+12
-9
Detail.vue
src/modules/paper/views/Detail.vue
+9
-1
List.vue
src/modules/paper/views/List.vue
+13
-3
Update.vue
src/modules/paper/views/Update.vue
+2
-2
permission.js
src/utils/permission.js
+23
-0
没有找到文件。
src/main.js
浏览文件 @
c94a8ae9
...
...
@@ -3,7 +3,7 @@ import App from './App.vue'
import
router
from
'./router'
import
store
from
'./store'
import
modules
from
'./modules'
import
directives
from
'@/utils/directives
'
import
{
permissionDirective
}
from
'@/utils/permission
'
// 公共css
import
'./assets/css/base.css'
...
...
@@ -22,7 +22,7 @@ Vue.component('AppCard', AppCard)
Vue
.
component
(
'AppList'
,
AppList
)
// 注册指令
Vue
.
use
(
directives
)
Vue
.
directive
(
'permission'
,
{
inserted
:
permissionDirective
,
update
:
permissionDirective
}
)
// 注册模块
modules
({
router
,
store
})
...
...
src/modules/paper/components/PaperQuestions.vue
浏览文件 @
c94a8ae9
...
...
@@ -7,23 +7,19 @@
<template
#
header-aside
>
<!-- 选题组卷 -->
<template
v-if=
"data.paper_type === 1"
>
<el-button
type=
"primary"
@
click=
"showSelectQuestion"
v-permission=
"'paper_setu_rules'"
>
添加试题
</el-button
>
<el-button
type=
"primary"
@
click=
"showSelectQuestion"
v-if=
"hasUpdate"
>
添加试题
</el-button>
<el-button
type=
"primary"
:disabled=
"!multipleSelection.length"
@
click=
"handleRemove"
>
删除选中试题
</el-button
>
</
template
>
<!-- 自动组卷 -->
<
template
v-if=
"data.paper_type === 2"
>
<el-button
type=
"primary"
@
click=
"handleAutoPaper"
v-
permission=
"'paper_setu_rules'
"
>
自动组卷
</el-button>
<el-button
type=
"primary"
@
click=
"handleAutoPaper"
v-
if=
"hasUpdate
"
>
自动组卷
</el-button>
</
template
>
<!-- 自由组卷 -->
<
template
v-if=
"data.paper_type === 3"
>
<el-button
type=
"primary"
@
click=
"handleAutoPaper"
v-permission=
"'paper_setu_rules'"
>
自动组卷
</el-button>
<el-button
type=
"primary"
@
click=
"paperVisible = true"
v-permission=
"'paper_setu_rules'"
>
添加试题
</el-button
>
<el-button
type=
"primary"
@
click=
"handleAutoPaper"
v-if=
"hasUpdate"
>
自动组卷
</el-button>
<el-button
type=
"primary"
@
click=
"paperVisible = true"
v-if=
"hasUpdate"
>
添加试题
</el-button>
<el-button
type=
"primary"
:disabled=
"!multipleSelection.length"
@
click=
"handleRemove"
>
删除选中试题
</el-button
>
...
...
@@ -61,7 +57,7 @@
</
template
>
<
template
#
footer
>
<template
v-if=
"hasSelection"
>
<el-button
type=
"primary"
@
click=
"handleSubmit"
v-
permission=
"'paper_setu_rules'
"
>
保存试卷
</el-button>
<el-button
type=
"primary"
@
click=
"handleSubmit"
v-
if=
"hasUpdate
"
>
保存试卷
</el-button>
</
template
>
</template>
</question-num>
...
...
@@ -98,6 +94,8 @@ import AddPaper from './AddPaper.vue'
import
AutomaticPaper
from
'./AutomaticPaper.vue'
import
OnceAutomaticPaper
from
'./OnceAutomaticPaper.vue'
import
{
updatePaperRules
}
from
'../api.js'
import
{
checkPermission
}
from
'@/utils/permission'
export
default
{
props
:
{
data
:
{
type
:
Object
,
default
:
()
=>
({})
}
...
...
@@ -146,6 +144,11 @@ export default {
// 是否可选
hasSelection
()
{
return
[
1
,
3
].
includes
(
this
.
data
.
paper_type
)
},
hasUpdate
()
{
return
this
.
data
.
permission
===
1
?
checkPermission
(
'paper_setu_rules'
)
:
checkPermission
(
'paper_setu_rules'
)
&&
checkPermission
(
'button_question_permission_public'
)
}
},
methods
:
{
...
...
src/modules/paper/views/Detail.vue
浏览文件 @
c94a8ae9
...
...
@@ -3,7 +3,7 @@
<!-- 试卷描述 -->
<app-card
title=
"试卷信息"
>
<template
#
header-aside
>
<el-button
type=
"primary"
@
click=
"handleUpdate"
v-
permission=
"'paper_update'
"
>
编辑试卷
</el-button>
<el-button
type=
"primary"
@
click=
"handleUpdate"
v-
if=
"hasUpdate
"
>
编辑试卷
</el-button>
</
template
>
<el-descriptions
:column=
"2"
class=
"descriptionsCon"
>
<el-descriptions-item
label=
"试卷名称"
>
{{ detail.paper_title }}
</el-descriptions-item>
...
...
@@ -32,6 +32,7 @@
import
PaperQuestions
from
'../components/PaperQuestions.vue'
import
{
getPaper
}
from
'../api.js'
import
{
paperType
}
from
'@/utils/dictionary'
import
{
checkPermission
}
from
'@/utils/permission'
export
default
{
props
:
{
id
:
{
type
:
String
}
},
...
...
@@ -42,6 +43,13 @@ export default {
detail
:
{
paper_category
:
{},
questions
:
[]
}
}
},
computed
:
{
hasUpdate
()
{
return
this
.
detail
.
permission
===
1
?
checkPermission
(
'paper_update'
)
:
checkPermission
(
'paper_update'
)
&&
checkPermission
(
'button_question_permission_public'
)
}
},
beforeMount
()
{
this
.
getDetail
()
// 获取试题分类,组卷的时候用,只请求一次
...
...
src/modules/paper/views/List.vue
浏览文件 @
c94a8ae9
...
...
@@ -27,13 +27,13 @@
></question-type-treeselect>
</
template
>
<
template
v-slot:table-x=
"{ row }"
>
<router-link
:to=
"
{ name: 'editPaper', params: { id: row.id } }" target="_blank" v-
permission="'paper_update'
">
<router-link
:to=
"
{ name: 'editPaper', params: { id: row.id } }" target="_blank" v-
if="hasUpdate
">
<el-button
type=
"text"
>
编辑
</el-button>
</router-link>
<router-link
:to=
"
{ name: 'viewPaper', params: { id: row.id } }" target="_blank" v-permission="'paper_detail'">
<el-button
type=
"text"
>
查看详情
</el-button>
</router-link>
<el-button
type=
"text"
@
click=
"handleDelete(row)"
v-
permission=
"'paper_batch_delete'
"
>
删除
</el-button>
<el-button
type=
"text"
@
click=
"handleDelete(row)"
v-
if=
"hasDelete
"
>
删除
</el-button>
</
template
>
</app-list>
</app-card>
...
...
@@ -43,7 +43,7 @@
import
{
getPaperList
,
batchDeletePaper
}
from
'../api'
import
QuestionTypeTreeselect
from
'@/components/base/QuestionTypeTreeselect.vue'
import
{
paperType
,
paperTypeList
}
from
'@/utils/dictionary'
import
{
checkPermission
}
from
'@/utils/permission'
export
default
{
components
:
{
QuestionTypeTreeselect
},
data
()
{
...
...
@@ -130,6 +130,16 @@ export default {
{
label
:
'操作'
,
slots
:
'table-x'
,
align
:
'right'
,
width
:
150
}
]
}
},
hasUpdate
()
{
return
this
.
permission
===
1
?
checkPermission
(
'paper_update'
)
:
checkPermission
(
'paper_update'
)
&&
checkPermission
(
'button_question_permission_public'
)
},
hasDelete
()
{
return
this
.
permission
===
1
?
checkPermission
(
'paper_batch_delete'
)
:
checkPermission
(
'paper_batch_delete'
)
&&
checkPermission
(
'button_question_permission_public'
)
}
},
methods
:
{
...
...
src/modules/paper/views/Update.vue
浏览文件 @
c94a8ae9
...
...
@@ -160,11 +160,11 @@ export default {
callback
()
}
}
const
permission
=
parseInt
(
this
.
$route
.
query
.
permission
)
||
1
//
const permission = parseInt(this.$route.query.permission) || 1
return
{
paperTypeList
,
form
:
{
permission
,
permission
:
1
,
paper_title
:
''
,
// 试卷名称
paper_uses
:
1
,
// 试卷用途
paper_labels
:
''
,
// 标签
...
...
src/utils/permission.js
0 → 100644
浏览文件 @
c94a8ae9
import
store
from
'@/store'
// 判断是否有权限
export
function
checkPermission
(
value
)
{
if
(
!
value
)
return
const
permissions
=
store
.
state
.
permissions
||
[]
console
.
log
(
JSON
.
stringify
(
permissions
))
if
(
Array
.
isArray
(
value
))
{
return
permissions
.
some
(
item
=>
value
.
includes
(
item
.
tag
))
}
else
{
return
!!
permissions
.
find
(
item
=>
item
.
tag
===
value
)
}
}
// 权限指令
export
function
permissionDirective
(
el
,
binding
)
{
const
{
value
}
=
binding
if
(
!
value
)
return
console
.
log
(
value
)
if
(
!
checkPermission
(
value
))
{
el
.
parentNode
&&
el
.
parentNode
.
removeChild
(
el
)
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论