Commit 02c6f082 authored by 武广's avatar 武广

fix: 修改分组不切换的问题

parent 67c49371
...@@ -40,10 +40,7 @@ const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del ...@@ -40,10 +40,7 @@ const DragTag = ({ text, id, index, changePosition, endChangePosition, edit, del
item.index = hoverIndex; // 将当前当前移动到Box的index赋值给当前拖动的box,不然会出现两个盒子疯狂抖动! item.index = hoverIndex; // 将当前当前移动到Box的index赋值给当前拖动的box,不然会出现两个盒子疯狂抖动!
}, },
drop: (item, monitor) => { drop: (item, monitor) => {
const dragIndex = item.index; endChangePosition(); // 调用传入的方法完成交换
const hoverIndex = index;
if (dragIndex === hoverIndex) return; // 如果回到自己的坑,那就什么都不做
endChangePosition(dragIndex, hoverIndex); // 调用传入的方法完成交换
}, },
}); });
......
...@@ -70,20 +70,16 @@ const GoodsGroup = options => { ...@@ -70,20 +70,16 @@ const GoodsGroup = options => {
}; };
// 更换位置 // 更换位置
const changePosition = async (dragIndex, hoverIndex) => { const changePosition = async (dIndex, hIndex) => {
const data = tags.slice(); const data = tags.slice();
const temp = data[dragIndex]; const temp = data[dIndex];
// 交换位置 // 交换位置
data[dragIndex] = data[hoverIndex]; data[dIndex] = data[hIndex];
data[hoverIndex] = temp; data[hIndex] = temp;
setTags(data); setTags(data);
}; };
const endChangePosition = async (dragIndex, hoverIndex) => { const endChangePosition = async () => {
const data = tags.slice(); const data = tags.slice();
const temp = data[dragIndex];
// 交换位置
data[dragIndex] = data[hoverIndex];
data[hoverIndex] = temp;
const storageRankList = data.map((item, i) => ({ const storageRankList = data.map((item, i) => ({
id: item.id, id: item.id,
priority: i + 1, priority: i + 1,
......
...@@ -22,7 +22,7 @@ const Takeaway = options => { ...@@ -22,7 +22,7 @@ const Takeaway = options => {
const [shopId, setShopId] = useState(0); const [shopId, setShopId] = useState(0);
const [groupId, setGroupId] = useState(0); const [groupId, setGroupId] = useState(0);
const [pageNo, setPageNo] = useState(1); const [pageNo, setPageNo] = useState(1);
const [pageSize, setPageSize] = useState(30); const [pageSize, setPageSize] = useState(50);
const [total, setTotal] = useState(0); const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [actionLoading, setActionLoading] = useState(false); const [actionLoading, setActionLoading] = useState(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment