Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
啊嘞嘞EC
vue-vben-admin
提交
456a6614
V
vue-vben-admin
项目概览
啊嘞嘞EC
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
456a6614
编写于
10月 14, 2021
作者:
无
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(table): `deleteTableDataRecord` not work
上级
59028867
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
13 deletion
+33
-13
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+2
-0
src/components/Table/src/hooks/useDataSource.ts
src/components/Table/src/hooks/useDataSource.ts
+28
-10
src/components/Table/src/hooks/useTable.ts
src/components/Table/src/hooks/useTable.ts
+2
-2
src/components/Table/src/types/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
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录