Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
6afee415
Commit
6afee415
authored
Apr 26, 2021
by
zuihou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(table): Table operation columns support permission codes
parent
8b2e0f66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
25 deletions
+38
-25
TableAction.vue
src/components/Table/src/components/TableAction.vue
+35
-25
tableAction.ts
src/components/Table/src/types/tableAction.ts
+3
-0
No files found.
src/components/Table/src/components/TableAction.vue
View file @
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
View file @
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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment