Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
factory_front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinjianhui
factory_front
Commits
956d4d54
Commit
956d4d54
authored
Jul 01, 2026
by
qinjianhui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: enable drag-and-drop on entire SPU table rows
parent
319814a8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
15 deletions
+64
-15
src/views/warehouse/warehouseRuleSetting/components/EditDialog.vue
+64
-15
No files found.
src/views/warehouse/warehouseRuleSetting/components/EditDialog.vue
View file @
956d4d54
...
@@ -94,23 +94,22 @@
...
@@ -94,23 +94,22 @@
<el-icon
style=
"color: #409eff; font-size: 16px"
><Warning
/></el-icon
<el-icon
style=
"color: #409eff; font-size: 16px"
><Warning
/></el-icon
><span>
拖动SPU调整扣减顺序
</span>
><span>
拖动SPU调整扣减顺序
</span>
</div>
</div>
<div
class=
"spu-table-wrapper"
>
<div
class=
"spu-table-wrapper"
@
dragstart=
"handleRowDragStart"
@
dragover
.
prevent
@
drop=
"handleRowDrop"
@
dragend=
"handleRowDragEnd"
>
<TableView
<TableView
ref=
"spuTableRef"
:paginated-data=
"editForm.spuList ?? []"
:paginated-data=
"editForm.spuList ?? []"
:columns=
"spuTableColumns"
:columns=
"spuTableColumns"
row-key=
"warehouseSpu"
row-key=
"warehouseSpu"
size=
"small"
size=
"small"
>
>
<
template
#
sortNo=
"{ row, index }"
>
<
template
#
sortNo=
"{ row }"
>
<span
class=
"drag-handle"
draggable=
"true"
@
dragstart=
"handleDragStart(index)"
@
dragover
.
prevent
@
drop=
"handleDrop(index)"
>
{{
row
.
sortOrder
}}
{{
row
.
sortOrder
}}
</span>
</
template
>
</
template
>
<
template
#
spuImage=
"{ row }"
>
<
template
#
spuImage=
"{ row }"
>
<ImageView
:src=
"row.skuImage"
width=
"40px"
height=
"40px"
/>
<ImageView
:src=
"row.skuImage"
width=
"40px"
height=
"40px"
/>
...
@@ -182,6 +181,7 @@ const spuSearchKeyword = ref('')
...
@@ -182,6 +181,7 @@ const spuSearchKeyword = ref('')
const
spuSearchResultList
=
ref
<
WarehouseRuleSpuItem
[]
>
([])
const
spuSearchResultList
=
ref
<
WarehouseRuleSpuItem
[]
>
([])
const
popoverVisible
=
ref
(
false
)
const
popoverVisible
=
ref
(
false
)
const
dragIndex
=
ref
<
number
|
null
>
(
null
)
const
dragIndex
=
ref
<
number
|
null
>
(
null
)
const
spuTableRef
=
ref
()
watch
(
watch
(
()
=>
props
.
visible
,
()
=>
props
.
visible
,
...
@@ -189,6 +189,9 @@ watch(
...
@@ -189,6 +189,9 @@ watch(
if
(
visible
&&
props
.
warehouseList
.
length
)
{
if
(
visible
&&
props
.
warehouseList
.
length
)
{
editForm
.
value
.
warehouseId
=
props
.
warehouseList
[
0
].
id
editForm
.
value
.
warehouseId
=
props
.
warehouseList
[
0
].
id
}
}
if
(
visible
)
{
setupRowDrag
()
}
},
},
)
)
...
@@ -229,8 +232,52 @@ const resetFields = (data?: EditForm) => {
...
@@ -229,8 +232,52 @@ const resetFields = (data?: EditForm) => {
})
})
}
}
const
handleDragStart
=
(
index
:
number
)
=>
{
const
getRowIndexFromEvent
=
(
e
:
DragEvent
)
=>
{
const
row
=
(
e
.
target
as
HTMLElement
).
closest
(
'tr.el-table__row'
)
if
(
!
row
?.
parentElement
)
{
return
null
}
return
Array
.
from
(
row
.
parentElement
.
children
).
indexOf
(
row
)
}
const
setupRowDrag
=
()
=>
{
nextTick
(()
=>
{
const
tableEl
=
spuTableRef
.
value
?.
tableRef
?.
$el
as
HTMLElement
|
undefined
const
rows
=
tableEl
?.
querySelectorAll
(
'.el-table__body-wrapper tbody tr.el-table__row'
,
)
rows
?.
forEach
((
row
)
=>
{
row
.
setAttribute
(
'draggable'
,
'true'
)
})
})
}
watch
(()
=>
editForm
.
value
.
spuList
,
setupRowDrag
,
{
deep
:
true
})
const
handleRowDragStart
=
(
e
:
DragEvent
)
=>
{
const
target
=
e
.
target
as
HTMLElement
if
(
target
.
closest
(
'button, a, .el-button'
))
{
e
.
preventDefault
()
return
}
const
index
=
getRowIndexFromEvent
(
e
)
if
(
index
===
null
||
index
<
0
)
{
return
}
dragIndex
.
value
=
index
dragIndex
.
value
=
index
e
.
dataTransfer
!
.
effectAllowed
=
'move'
}
const
handleRowDrop
=
(
e
:
DragEvent
)
=>
{
const
index
=
getRowIndexFromEvent
(
e
)
if
(
index
===
null
||
index
<
0
)
{
return
}
handleDrop
(
index
)
}
const
handleRowDragEnd
=
()
=>
{
dragIndex
.
value
=
null
}
}
const
handleDrop
=
(
index
:
number
)
=>
{
const
handleDrop
=
(
index
:
number
)
=>
{
...
@@ -400,13 +447,15 @@ defineExpose({
...
@@ -400,13 +447,15 @@ defineExpose({
.spu-table-wrapper
{
.spu-table-wrapper
{
height
:
280px
;
height
:
280px
;
}
.drag-handle
{
:deep(tbody
tr.el-table__row)
{
display
:
inline-block
;
width
:
100%
;
cursor
:
move
;
cursor
:
move
;
user-select
:
none
;
user-select
:
none
;
}
:deep
(
img
)
{
-webkit-user-drag
:
none
;
}
}
}
.dialog-footer
{
.dialog-footer
{
...
...
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