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
74d47424
Commit
74d47424
authored
Oct 25, 2020
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: the action column appears repeatedly in the table (#53)
parent
e1e9baa8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
26 deletions
+23
-26
BasicTable.vue
src/components/Table/src/BasicTable.vue
+8
-8
useColumns.ts
src/components/Table/src/hooks/useColumns.ts
+15
-18
No files found.
src/components/Table/src/BasicTable.vue
View file @
74d47424
...
...
@@ -190,6 +190,14 @@
return
!!
unref
(
getDataSourceRef
).
length
;
});
watch
(
()
=>
unref
(
getDataSourceRef
),
()
=>
{
handleSummary
();
},
{
immediate
:
true
}
);
function
getRowClassName
(
record
:
TableCustomRecord
<
any
>
,
index
:
number
)
{
const
{
striped
,
rowClassName
}
=
unref
(
getMergeProps
);
if
(
!
striped
)
return
;
...
...
@@ -242,14 +250,6 @@
}
}
watch
(
()
=>
unref
(
getDataSourceRef
),
()
=>
{
handleSummary
();
},
{
immediate
:
true
}
);
function
setProps
(
props
:
Partial
<
BasicTableProps
>
)
{
innerPropsRef
.
value
=
deepMerge
(
unref
(
innerPropsRef
)
||
{},
props
);
}
...
...
src/components/Table/src/hooks/useColumns.ts
View file @
74d47424
import
{
BasicColumn
,
BasicTableProps
}
from
'
../types/table
'
;
import
{
PaginationProps
}
from
'
../types/pagination
'
;
import
{
unref
,
ComputedRef
,
Ref
,
computed
,
watch
,
ref
}
from
'
vue
'
;
import
{
unref
,
ComputedRef
,
Ref
,
computed
,
watch
Effect
,
ref
,
toRaw
}
from
'
vue
'
;
import
{
isBoolean
,
isArray
,
isObject
}
from
'
/@/utils/is
'
;
import
{
PAGE_SIZE
}
from
'
../const
'
;
import
{
useProps
}
from
'
./useProps
'
;
...
...
@@ -10,20 +10,9 @@ export function useColumns(
getPaginationRef
:
ComputedRef
<
false
|
PaginationProps
>
)
{
const
{
propsRef
}
=
useProps
(
refProps
);
const
columnsRef
=
(
ref
(
unref
(
propsRef
).
columns
)
as
unknown
)
as
Ref
<
BasicColumn
[]
>
;
const
cacheColumnsRef
=
(
ref
(
unref
(
propsRef
).
columns
)
as
unknown
)
as
Ref
<
BasicColumn
[]
>
;
watch
(
()
=>
unref
(
propsRef
).
columns
,
(
columns
)
=>
{
columnsRef
.
value
=
columns
;
cacheColumnsRef
.
value
=
columns
;
},
{
immediate
:
true
,
}
);
const
getColumnsRef
=
computed
(()
=>
{
const
props
=
unref
(
propsRef
);
const
{
showIndexColumn
,
indexColumnProps
,
ellipsis
,
actionColumn
,
isTreeTable
}
=
props
;
...
...
@@ -81,16 +70,24 @@ export function useColumns(
}
if
(
actionColumn
)
{
const
hasIndex
=
columns
.
findIndex
((
column
)
=>
column
.
flag
===
'
ACTION
'
);
if
(
hasIndex
===
-
1
)
{
columns
.
push
({
...(
hasIndex
===
-
1
?
columns
[
hasIndex
]
:
{})
,
...
columns
[
hasIndex
]
,
fixed
:
'
right
'
,
...
actionColumn
,
flag
:
'
ACTION
'
,
});
}
}
return
columns
;
});
watchEffect
(()
=>
{
const
columns
=
toRaw
(
unref
(
propsRef
).
columns
);
columnsRef
.
value
=
columns
;
cacheColumnsRef
.
value
=
columns
;
});
function
setColumns
(
columns
:
BasicColumn
[]
|
string
[])
{
if
(
!
isArray
(
columns
))
return
;
...
...
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