Skip to content

Commit

Permalink
steedos-board组件在同一个组件内变更字段顺序时,组件value值未实时更新
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlianghui committed Oct 23, 2023
1 parent 806a75d commit 013c146
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ export function MultipleContainers(props) {
Object.keys(items) as UniqueIdentifier[]
);

const handleChange = async () => {
const handleChange = async (newItems? : any) => {
if (!amisDispatchEvent || !amisOnChange)
return
const value = items;
const value = newItems || items;

// 支持 amis OnEvent.change
const rendererEvent = await amisDispatchEvent(
Expand Down Expand Up @@ -493,26 +493,31 @@ export function MultipleContainers(props) {

const overContainer = findContainer(overId);

let newItems = items;

if (overContainer) {
const activeIndex = items[activeContainer].indexOf(active.id);
const overIndex = items[overContainer].indexOf(overId);

if (activeIndex !== overIndex) {
setItems((items) => ({
...items,
[overContainer]: arrayMove(
items[overContainer],
activeIndex,
overIndex
),
}));
setItems((items) => {
newItems = {
...items,
[overContainer]: arrayMove(
items[overContainer],
activeIndex,
overIndex
),
}
return newItems;
});
}
}

setActiveId(null);

// console.log('拖动结束2,更新form value')
handleChange()
handleChange(newItems)
}}
cancelDrop={cancelDrop}
onDragCancel={onDragCancel}
Expand Down

0 comments on commit 013c146

Please sign in to comment.