Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
456a6614
提交
456a6614
authored
10月 14, 2021
作者:
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(table): `deleteTableDataRecord` not work
上级
59028867
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
13 行删除
+33
-13
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+2
-0
useDataSource.ts
src/components/Table/src/hooks/useDataSource.ts
+28
-10
useTable.ts
src/components/Table/src/hooks/useTable.ts
+2
-2
table.ts
src/components/Table/src/types/table.ts
+1
-1
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
456a6614
...
...
@@ -12,12 +12,14 @@
-
修复
`useTable`
与
`BasicTable`
实例的
`reload`
方法
`await`
表现不一致的问题
-
修复
`clickToRowSelect`
会无视行选择框 disabled 状态的问题
-
修复
`BasicTable`
在某些情况下,分页会被重置的问题
-
修改
`deleteTableDataRecord`
方法
-
**BasicModal**
-
修复点击遮罩、按下
`Esc`
键都不能关闭
`Modal`
的问题
-
修复点击关闭按钮、最大化按钮旁边的空白区域也会导致
`Modal`
关闭的问题
-
**BasicTree**
修复节点插槽不起作用的问题
-
**CodeEditor**
修复可能会造成的
`Build`
失败的问题
-
**BasicForm**
修复自定义 FormItem 组件的内容宽度可能超出范围的问题
-
**ApiTreeSelect**
修复
`params`
变化未能触发重新请求 api 数据的问题
-
**其它**
-
修复多标签在某些情况下关闭页签不会跳转路由的问题
-
修复部分组件可能会造成热更新异常的问题
...
...
src/components/Table/src/hooks/useDataSource.ts
浏览文件 @
456a6614
...
...
@@ -160,21 +160,39 @@ export function useDataSource(
}
}
function
deleteTableDataRecord
(
r
ecord
:
Recordable
|
Recordable
[]):
Recordable
|
undefined
{
function
deleteTableDataRecord
(
r
owKey
:
string
|
number
|
string
[]
|
number
[])
{
if
(
!
dataSourceRef
.
value
||
dataSourceRef
.
value
.
length
==
0
)
return
;
const
records
=
!
Array
.
isArray
(
record
)
?
[
record
]
:
record
;
const
recordIndex
=
records
.
map
((
item
)
=>
dataSourceRef
.
value
.
findIndex
((
s
)
=>
s
.
key
===
item
.
key
))
// 取序号
.
filter
((
item
)
=>
item
!==
undefined
)
.
sort
((
a
,
b
)
=>
b
-
a
);
// 从大到小排序
for
(
const
index
of
recordIndex
)
{
unref
(
dataSourceRef
).
splice
(
index
,
1
);
unref
(
propsRef
).
dataSource
?.
splice
(
index
,
1
);
const
rowKeyName
=
unref
(
getRowKey
);
if
(
!
rowKeyName
)
return
;
const
rowKeys
=
!
Array
.
isArray
(
rowKey
)
?
[
rowKey
]
:
rowKey
;
for
(
const
key
of
rowKeys
)
{
let
index
:
number
|
undefined
=
dataSourceRef
.
value
.
findIndex
((
row
)
=>
{
let
targetKeyName
:
string
;
if
(
typeof
rowKeyName
===
'function'
)
{
targetKeyName
=
rowKeyName
(
row
);
}
else
{
targetKeyName
=
rowKeyName
as
string
;
}
return
row
[
targetKeyName
]
===
key
;
});
if
(
index
>=
0
)
{
dataSourceRef
.
value
.
splice
(
index
,
1
);
}
index
=
unref
(
propsRef
).
dataSource
?.
findIndex
((
row
)
=>
{
let
targetKeyName
:
string
;
if
(
typeof
rowKeyName
===
'function'
)
{
targetKeyName
=
rowKeyName
(
row
);
}
else
{
targetKeyName
=
rowKeyName
as
string
;
}
return
row
[
targetKeyName
]
===
key
;
});
if
(
typeof
index
!==
'undefined'
&&
index
!==
-
1
)
unref
(
propsRef
).
dataSource
?.
splice
(
index
,
1
);
}
setPagination
({
total
:
unref
(
propsRef
).
dataSource
?.
length
,
});
return
unref
(
propsRef
).
dataSource
;
}
function
insertTableDataRecord
(
record
:
Recordable
,
index
:
number
):
Recordable
|
undefined
{
...
...
src/components/Table/src/hooks/useTable.ts
浏览文件 @
456a6614
...
...
@@ -122,8 +122,8 @@ export function useTable(tableProps?: Props): [
updateTableData
:
(
index
:
number
,
key
:
string
,
value
:
any
)
=>
{
return
getTableInstance
().
updateTableData
(
index
,
key
,
value
);
},
deleteTableDataRecord
:
(
r
ecord
:
Recordable
|
Recordable
[])
=>
{
return
getTableInstance
().
deleteTableDataRecord
(
r
ecord
);
deleteTableDataRecord
:
(
r
owKey
:
string
|
number
|
string
[]
|
number
[])
=>
{
return
getTableInstance
().
deleteTableDataRecord
(
r
owKey
);
},
insertTableDataRecord
:
(
record
:
Recordable
|
Recordable
[],
index
?:
number
)
=>
{
return
getTableInstance
().
insertTableDataRecord
(
record
,
index
);
...
...
src/components/Table/src/types/table.ts
浏览文件 @
456a6614
...
...
@@ -95,7 +95,7 @@ export interface TableActionType {
setPagination
:
(
info
:
Partial
<
PaginationProps
>
)
=>
void
;
setTableData
:
<
T
=
Recordable
>
(
values
:
T
[])
=>
void
;
updateTableDataRecord
:
(
rowKey
:
string
|
number
,
record
:
Recordable
)
=>
Recordable
|
void
;
deleteTableDataRecord
:
(
r
ecord
:
Recordable
|
Recordable
[])
=>
Recordable
|
void
;
deleteTableDataRecord
:
(
r
owKey
:
string
|
number
|
string
[]
|
number
[])
=>
void
;
insertTableDataRecord
:
(
record
:
Recordable
,
index
?:
number
)
=>
Recordable
|
void
;
findTableDataRecord
:
(
rowKey
:
string
|
number
)
=>
Recordable
|
void
;
getColumns
:
(
opt
?:
GetColumnsParams
)
=>
BasicColumn
[];
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论