Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
6afee415
提交
6afee415
authored
4月 26, 2021
作者:
zuihou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(table): Table operation columns support permission codes
上级
8b2e0f66
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
25 行删除
+38
-25
TableAction.vue
src/components/Table/src/components/TableAction.vue
+35
-25
tableAction.ts
src/components/Table/src/types/tableAction.ts
+3
-0
没有找到文件。
src/components/Table/src/components/TableAction.vue
浏览文件 @
6afee415
...
@@ -25,16 +25,17 @@
...
@@ -25,16 +25,17 @@
</template>
</template>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
,
PropType
,
computed
,
toRaw
}
from
'vue'
;
import
{
defineComponent
,
PropType
,
computed
,
toRaw
}
from
'vue'
;
import
{
MoreOutlined
}
from
'@ant-design/icons-vue'
;
import
{
MoreOutlined
}
from
'@ant-design/icons-vue'
;
import
{
Divider
}
from
'ant-design-vue'
;
import
Icon
from
'/@/components/Icon/index'
;
import
Icon
from
'/@/components/Icon/index'
;
import
{
ActionItem
,
TableActionType
}
from
'/@/components/Table'
;
import
{
ActionItem
,
TableActionType
}
from
'/@/components/Table'
;
import
{
PopConfirmButton
}
from
'/@/components/Button'
;
import
{
PopConfirmButton
}
from
'/@/components/Button'
;
import
{
Divider
}
from
'ant-design-vue'
;
import
{
Dropdown
}
from
'/@/components/Dropdown'
;
import
{
Dropdown
}
from
'/@/components/Dropdown'
;
import
{
useDesign
}
from
'/@/hooks/web/useDesign'
;
import
{
useDesign
}
from
'/@/hooks/web/useDesign'
;
import
{
useTableContext
}
from
'../hooks/useTableContext'
;
import
{
useTableContext
}
from
'../hooks/useTableContext'
;
import
{
usePermission
}
from
'/@/hooks/web/usePermission'
;
import
{
propTypes
}
from
'/@/utils/propTypes'
;
import
{
propTypes
}
from
'/@/utils/propTypes'
;
import
{
ACTION_COLUMN_FLAG
}
from
'../const'
;
import
{
ACTION_COLUMN_FLAG
}
from
'../const'
;
...
@@ -61,33 +62,42 @@
...
@@ -61,33 +62,42 @@
table
=
useTableContext
();
table
=
useTableContext
();
}
}
const
{
hasPermission
}
=
usePermission
();
const
getActions
=
computed
(()
=>
{
const
getActions
=
computed
(()
=>
{
return
(
toRaw
(
props
.
actions
)
||
[]).
map
((
action
)
=>
{
return
(
toRaw
(
props
.
actions
)
||
[])
const
{
popConfirm
}
=
action
;
.
filter
((
action
)
=>
{
return
{
return
hasPermission
(
action
.
auth
);
type
:
'link'
,
})
size
:
'small'
,
.
map
((
action
)
=>
{
...
action
,
const
{
popConfirm
}
=
action
;
...(
popConfirm
||
{}),
return
{
onConfirm
:
popConfirm
?.
confirm
,
type
:
'link'
,
onCancel
:
popConfirm
?.
cancel
,
size
:
'small'
,
enable
:
!!
popConfirm
,
...
action
,
};
...(
popConfirm
||
{}),
});
onConfirm
:
popConfirm
?.
confirm
,
onCancel
:
popConfirm
?.
cancel
,
enable
:
!!
popConfirm
,
};
});
});
});
const
getDropdownList
=
computed
(()
=>
{
const
getDropdownList
=
computed
(()
=>
{
return
(
toRaw
(
props
.
dropDownActions
)
||
[]).
map
((
action
,
index
)
=>
{
return
(
toRaw
(
props
.
dropDownActions
)
||
[])
const
{
label
,
popConfirm
}
=
action
;
.
filter
((
action
)
=>
{
return
{
return
hasPermission
(
action
.
auth
);
...
action
,
})
...
popConfirm
,
.
map
((
action
,
index
)
=>
{
onConfirm
:
popConfirm
?.
confirm
,
const
{
label
,
popConfirm
}
=
action
;
onCancel
:
popConfirm
?.
cancel
,
return
{
text
:
label
,
...
action
,
divider
:
index
<
props
.
dropDownActions
.
length
-
1
?
props
.
divider
:
false
,
...
popConfirm
,
};
onConfirm
:
popConfirm
?.
confirm
,
});
onCancel
:
popConfirm
?.
cancel
,
text
:
label
,
divider
:
index
<
props
.
dropDownActions
.
length
-
1
?
props
.
divider
:
false
,
};
});
});
});
const
getAlign
=
computed
(()
=>
{
const
getAlign
=
computed
(()
=>
{
...
...
src/components/Table/src/types/tableAction.ts
浏览文件 @
6afee415
import
{
ButtonProps
}
from
'ant-design-vue/es/button/buttonTypes'
;
import
{
ButtonProps
}
from
'ant-design-vue/es/button/buttonTypes'
;
import
{
RoleEnum
}
from
'/@/enums/roleEnum'
;
export
interface
ActionItem
extends
ButtonProps
{
export
interface
ActionItem
extends
ButtonProps
{
onClick
?:
Fn
;
onClick
?:
Fn
;
label
:
string
;
label
:
string
;
...
@@ -7,6 +8,8 @@ export interface ActionItem extends ButtonProps {
...
@@ -7,6 +8,8 @@ export interface ActionItem extends ButtonProps {
popConfirm
?:
PopConfirm
;
popConfirm
?:
PopConfirm
;
disabled
?:
boolean
;
disabled
?:
boolean
;
divider
?:
boolean
;
divider
?:
boolean
;
// Permission code
auth
?:
RoleEnum
|
RoleEnum
[]
|
string
|
string
[];
}
}
export
interface
PopConfirm
{
export
interface
PopConfirm
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论