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
fe2bcfc6
Commit
fe2bcfc6
authored
Jun 05, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(table): support custom update on row editing
在表格进入行编辑状态时,在某一列数据发生修改时,允许获取或同步修改其它列的当前编辑数据。 close #646
parent
808012b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
EditableCell.vue
...components/Table/src/components/editable/EditableCell.vue
+4
-0
index.ts
src/components/Table/src/components/editable/index.ts
+2
-1
EditRowTable.vue
src/views/demo/table/EditRowTable.vue
+13
-1
No files found.
src/components/Table/src/components/editable/EditableCell.vue
View file @
fe2bcfc6
...
...
@@ -282,6 +282,10 @@
initCbs
(
'
validCbs
'
,
handleSubmiRule
);
initCbs
(
'
cancelCbs
'
,
handleCancel
);
if
(
props
.
column
.
dataIndex
)
{
if
(
!
props
.
record
.
editValueRefs
)
props
.
record
.
editValueRefs
=
{};
props
.
record
.
editValueRefs
[
props
.
column
.
dataIndex
]
=
currentValueRef
;
}
/* eslint-disable */
props
.
record
.
onCancelEdit
=
()
=>
{
isArray
(
props
.
record
?.
cancelCbs
)
&&
props
.
record
?.
cancelCbs
.
forEach
((
fn
)
=>
fn
());
...
...
src/components/Table/src/components/editable/index.ts
View file @
fe2bcfc6
import
type
{
BasicColumn
}
from
'
/@/components/Table/src/types/table
'
;
import
{
h
}
from
'
vue
'
;
import
{
h
,
Ref
}
from
'
vue
'
;
import
EditableCell
from
'
./EditableCell.vue
'
;
...
...
@@ -50,5 +50,6 @@ export type EditRecordRow<T = Recordable> = Partial<
submitCbs
:
Fn
[];
cancelCbs
:
Fn
[];
validCbs
:
Fn
[];
editValueRefs
:
Recordable
<
Ref
>
;
}
&
T
>
;
src/views/demo/table/EditRowTable.vue
View file @
fe2bcfc6
<
template
>
<div
class=
"p-4"
>
<BasicTable
@
register=
"registerTable"
>
<BasicTable
@
register=
"registerTable"
@
edit-change=
"onEditChange"
>
<template
#action
="
{ record, column }">
<TableAction
:actions=
"createActions(record, column)"
/>
</
template
>
...
...
@@ -145,6 +145,9 @@
const
[
registerTable
]
=
useTable
({
title
:
'
可编辑行示例
'
,
titleHelpMessage
:
[
'
本例中修改[数字输入框]这一列时,同一行的[远程下拉]列的当前编辑数据也会同步发生改变
'
,
],
api
:
demoListApi
,
columns
:
columns
,
showIndexColumn
:
false
,
...
...
@@ -198,10 +201,19 @@
];
}
function
onEditChange
({
column
,
value
,
record
})
{
// 本例
if
(
column
.
dataIndex
===
'
id
'
)
{
record
.
editValueRefs
.
name4
.
value
=
`
${
value
}
`
;
}
console
.
log
(
column
,
value
,
record
);
}
return
{
registerTable
,
handleEdit
,
createActions
,
onEditChange
,
};
},
});
...
...
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