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
9dee038a
Commit
9dee038a
authored
Jul 01, 2026
by
qinjianhui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 查询SPU时,添加仓库筛选
parent
9ffc5cd7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
43 deletions
+119
-43
src/api/warehouse/warehouseRuleSetting.ts
+15
-10
src/types/api/warehouse/warehouseRuleSetting.ts
+4
-2
src/views/warehouse/warehouseRuleSetting/components/EditDialog.vue
+68
-28
src/views/warehouse/warehouseRuleSetting/hooks/useWarehouseRuleSettingTableColumns.tsx
+2
-2
src/views/warehouse/warehouseRuleSetting/index.vue
+30
-1
No files found.
src/api/warehouse/warehouseRuleSetting.ts
View file @
9dee038a
...
@@ -4,8 +4,8 @@ import {
...
@@ -4,8 +4,8 @@ import {
EditForm
,
EditForm
,
SearchForm
,
SearchForm
,
WarehouseRuleSettingData
,
WarehouseRuleSettingData
,
WarehouseRuleSpuItem
,
}
from
'@/types/api/warehouse/warehouseRuleSetting'
}
from
'@/types/api/warehouse/warehouseRuleSetting'
import
{
IgoodsType
}
from
'@/views/supply/supplierManagement/types'
export
function
getWarehouseRuleSettingListApi
(
export
function
getWarehouseRuleSettingListApi
(
data
:
SearchForm
,
data
:
SearchForm
,
...
@@ -18,27 +18,32 @@ export function getWarehouseRuleSettingListApi(
...
@@ -18,27 +18,32 @@ export function getWarehouseRuleSettingListApi(
)
)
}
}
export
function
getQuerySpuApi
(
warehouseSpu
:
string
)
{
export
function
getQuerySpuApi
(
warehouseSpu
:
string
,
warehouseId
:
number
|
undefined
)
{
return
axios
.
post
<
never
,
BaseRespData
<
IgoodsType
>>
(
return
axios
.
post
<
never
,
BaseRespData
<
WarehouseRuleSpuItem
>>
(
'/factory/sharedInventorySku/query-spu'
,
'/factory/sharedInventorySku/query-spu'
,
{
warehouseSpu
},
{
warehouseSpu
,
warehouseId
},
)
)
}
}
export
function
addSharedInventoryGroupApi
(
export
function
addSharedInventoryGroupApi
(
data
:
EditForm
)
{
data
:
EditForm
,
)
{
return
axios
.
post
<
never
,
BaseRespData
<
void
>>
(
return
axios
.
post
<
never
,
BaseRespData
<
void
>>
(
'/factory/sharedInventoryGroup/add'
,
'/factory/sharedInventoryGroup/add'
,
data
,
data
,
)
)
}
}
export
function
updateSharedInventoryGroupApi
(
export
function
updateSharedInventoryGroupApi
(
data
:
EditForm
)
{
data
:
EditForm
,
)
{
return
axios
.
post
<
never
,
BaseRespData
<
void
>>
(
return
axios
.
post
<
never
,
BaseRespData
<
void
>>
(
'/factory/sharedInventoryGroup/update'
,
'/factory/sharedInventoryGroup/update'
,
data
,
data
,
)
)
}
}
export
function
getWarehouseRuleSettingDetailApi
(
id
:
number
|
undefined
)
{
return
axios
.
get
<
never
,
BaseRespData
<
EditForm
>>
(
`/factory/sharedInventoryGroup/get`
,
{
params
:
{
id
},
},
)
}
src/types/api/warehouse/warehouseRuleSetting.ts
View file @
9dee038a
...
@@ -20,14 +20,16 @@ export interface WarehouseRuleSpuItem {
...
@@ -20,14 +20,16 @@ export interface WarehouseRuleSpuItem {
sortOrder
?:
number
sortOrder
?:
number
warehouseSku
?:
string
warehouseSku
?:
string
warehouseSpu
?:
string
warehouseSpu
?:
string
productName
?:
string
skuImage
?:
string
imgUrl
?:
string
skuName
?:
string
warehouseId
?:
number
}
}
export
interface
EditForm
{
export
interface
EditForm
{
id
?:
number
id
?:
number
groupName
?:
string
groupName
?:
string
status
?:
boolean
status
?:
boolean
warehouseId
?:
number
spuList
?:
WarehouseRuleSpuItem
[]
spuList
?:
WarehouseRuleSpuItem
[]
skuList
?:
WarehouseRuleSpuItem
[]
skuList
?:
WarehouseRuleSpuItem
[]
}
}
src/views/warehouse/warehouseRuleSetting/components/EditDialog.vue
View file @
9dee038a
...
@@ -37,6 +37,19 @@
...
@@ -37,6 +37,19 @@
<div
class=
"section-title"
>
组内SPU清单
</div>
<div
class=
"section-title"
>
组内SPU清单
</div>
<div
class=
"spu-search-bar"
>
<div
class=
"spu-search-bar"
>
<ElSelect
v-model=
"editForm.warehouseId"
placeholder=
"请选择仓库"
style=
"width: 160px"
clearable
>
<ElOption
v-for=
"item in warehouseList"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
/>
</ElSelect>
<ElInput
<ElInput
v-model=
"spuSearchKeyword"
v-model=
"spuSearchKeyword"
clearable
clearable
...
@@ -61,7 +74,7 @@
...
@@ -61,7 +74,7 @@
size=
"small"
size=
"small"
>
>
<
template
#
spuImage=
"{ row }"
>
<
template
#
spuImage=
"{ row }"
>
<ImageView
:src=
"row.
imgUrl
"
width=
"40px"
height=
"40px"
/>
<ImageView
:src=
"row.
skuImage
"
width=
"40px"
height=
"40px"
/>
</
template
>
</
template
>
<
template
#
operation=
"{ row }"
>
<
template
#
operation=
"{ row }"
>
<ElButton
<ElButton
...
@@ -100,7 +113,7 @@
...
@@ -100,7 +113,7 @@
</span>
</span>
</
template
>
</
template
>
<
template
#
spuImage=
"{ row }"
>
<
template
#
spuImage=
"{ row }"
>
<ImageView
:src=
"row.
imgUrl
"
width=
"40px"
height=
"40px"
/>
<ImageView
:src=
"row.
skuImage
"
width=
"40px"
height=
"40px"
/>
</
template
>
</
template
>
<
template
#
operation=
"{ index }"
>
<
template
#
operation=
"{ index }"
>
<ElButton
link
type=
"danger"
@
click=
"handleRemoveSpu(index)"
>
<ElButton
link
type=
"danger"
@
click=
"handleRemoveSpu(index)"
>
...
@@ -132,14 +145,21 @@ import {
...
@@ -132,14 +145,21 @@ import {
}
from
'@/types/api/warehouse/warehouseRuleSetting'
}
from
'@/types/api/warehouse/warehouseRuleSetting'
import
{
Plus
,
Warning
}
from
'@element-plus/icons-vue'
import
{
Plus
,
Warning
}
from
'@element-plus/icons-vue'
import
{
useWarehouseRuleSettingTableColumns
}
from
'../hooks/useWarehouseRuleSettingTableColumns'
import
{
useWarehouseRuleSettingTableColumns
}
from
'../hooks/useWarehouseRuleSettingTableColumns'
import
{
WarehouseListData
}
from
'@/types'
const
emit
=
defineEmits
<
{
const
emit
=
defineEmits
<
{
(
e
:
'update:visible'
,
value
:
boolean
):
void
(
e
:
'update:visible'
,
value
:
boolean
):
void
(
e
:
'saveSuccess'
):
void
(
e
:
'saveSuccess'
):
void
}
>
()
}
>
()
const
props
=
defineProps
<
{
const
props
=
withDefaults
(
visible
:
boolean
defineProps
<
{
}
>
()
visible
:
boolean
warehouseList
:
WarehouseListData
[]
}
>
(),
{
warehouseList
:
()
=>
[],
},
)
const
dialogVisible
=
computed
({
const
dialogVisible
=
computed
({
get
()
{
get
()
{
return
props
.
visible
return
props
.
visible
...
@@ -148,12 +168,12 @@ const dialogVisible = computed({
...
@@ -148,12 +168,12 @@ const dialogVisible = computed({
emit
(
'update:visible'
,
value
)
emit
(
'update:visible'
,
value
)
},
},
})
})
const
createDefaultForm
=
():
EditForm
=>
({
const
createDefaultForm
=
():
EditForm
=>
({
id
:
undefined
,
id
:
undefined
,
groupName
:
''
,
groupName
:
''
,
status
:
true
,
status
:
true
,
spuList
:
[],
spuList
:
[],
warehouseId
:
props
.
warehouseList
[
0
]?.
id
,
})
})
const
editForm
=
ref
<
EditForm
>
(
createDefaultForm
())
const
editForm
=
ref
<
EditForm
>
(
createDefaultForm
())
...
@@ -163,10 +183,43 @@ const spuSearchResultList = ref<WarehouseRuleSpuItem[]>([])
...
@@ -163,10 +183,43 @@ const spuSearchResultList = ref<WarehouseRuleSpuItem[]>([])
const
popoverVisible
=
ref
(
false
)
const
popoverVisible
=
ref
(
false
)
const
dragIndex
=
ref
<
number
|
null
>
(
null
)
const
dragIndex
=
ref
<
number
|
null
>
(
null
)
watch
(
()
=>
props
.
visible
,
(
visible
)
=>
{
if
(
visible
&&
props
.
warehouseList
.
length
)
{
editForm
.
value
.
warehouseId
=
props
.
warehouseList
[
0
].
id
}
},
)
const
{
spuTableColumns
,
spuSearchTableColumns
}
=
const
{
spuTableColumns
,
spuSearchTableColumns
}
=
useWarehouseRuleSettingTableColumns
()
useWarehouseRuleSettingTableColumns
()
const
resetFields
=
()
=>
{
editForm
.
value
=
createDefaultForm
()
const
updateSortNo
=
(
list
:
WarehouseRuleSpuItem
[])
=>
{
return
list
.
map
((
item
,
index
)
=>
({
...
item
,
sortOrder
:
index
+
1
,
}))
}
const
resetFields
=
(
data
?:
EditForm
)
=>
{
if
(
data
)
{
const
spuList
=
data
.
spuList
??
data
.
skuList
??
[]
editForm
.
value
=
{
id
:
data
.
id
,
groupName
:
data
.
groupName
??
''
,
status
:
typeof
data
.
status
===
'boolean'
?
data
.
status
:
data
.
status
===
1
,
spuList
:
updateSortNo
(
spuList
.
map
((
item
)
=>
({
...
item
,
warehouseSpu
:
item
.
warehouseSpu
??
item
.
warehouseSku
,
})),
),
}
}
else
{
editForm
.
value
=
createDefaultForm
()
}
spuSearchKeyword
.
value
=
''
spuSearchKeyword
.
value
=
''
spuSearchResultList
.
value
=
[]
spuSearchResultList
.
value
=
[]
popoverVisible
.
value
=
false
popoverVisible
.
value
=
false
...
@@ -176,13 +229,6 @@ const resetFields = () => {
...
@@ -176,13 +229,6 @@ const resetFields = () => {
})
})
}
}
const
updateSortNo
=
(
list
:
WarehouseRuleSpuItem
[])
=>
{
return
list
.
map
((
item
,
index
)
=>
({
...
item
,
sortOrder
:
index
+
1
,
}))
}
const
handleDragStart
=
(
index
:
number
)
=>
{
const
handleDragStart
=
(
index
:
number
)
=>
{
dragIndex
.
value
=
index
dragIndex
.
value
=
index
}
}
...
@@ -211,20 +257,13 @@ const handleSearchSpu = async () => {
...
@@ -211,20 +257,13 @@ const handleSearchSpu = async () => {
background
:
'rgba(0, 0, 0, 0.7)'
,
background
:
'rgba(0, 0, 0, 0.7)'
,
})
})
try
{
try
{
const
res
=
await
getQuerySpuApi
(
keyword
)
const
res
=
await
getQuerySpuApi
(
keyword
,
editForm
.
value
.
warehouseId
)
if
(
res
.
code
!==
200
)
{
if
(
res
.
code
!==
200
)
{
popoverVisible
.
value
=
false
popoverVisible
.
value
=
false
spuSearchKeyword
.
value
=
''
spuSearchKeyword
.
value
=
''
return
return
}
}
spuSearchResultList
.
value
=
[
spuSearchResultList
.
value
=
[
res
.
data
]
{
warehouseSpu
:
res
.
data
.
sku
,
imgUrl
:
res
.
data
.
imgUrl
,
productName
:
res
.
data
.
name
,
id
:
Number
(
res
.
data
.
id
)
??
undefined
,
},
]
if
(
spuSearchResultList
.
value
.
length
===
0
)
{
if
(
spuSearchResultList
.
value
.
length
===
0
)
{
ElMessageBox
.
alert
(
'未查询到SPU数据'
,
'提示'
,
{
ElMessageBox
.
alert
(
'未查询到SPU数据'
,
'提示'
,
{
type
:
'warning'
,
type
:
'warning'
,
...
@@ -255,8 +294,9 @@ const handleAddSpu = (row: WarehouseRuleSpuItem) => {
...
@@ -255,8 +294,9 @@ const handleAddSpu = (row: WarehouseRuleSpuItem) => {
...(
editForm
.
value
.
spuList
??
[]),
...(
editForm
.
value
.
spuList
??
[]),
{
{
warehouseSpu
:
row
.
warehouseSpu
,
warehouseSpu
:
row
.
warehouseSpu
,
productName
:
row
.
productName
,
skuName
:
row
.
skuName
,
imgUrl
:
row
.
imgUrl
,
skuImage
:
row
.
skuImage
,
warehouseId
:
row
.
warehouseId
,
},
},
])
])
spuSearchResultList
.
value
=
spuSearchResultList
.
value
.
filter
(
spuSearchResultList
.
value
=
spuSearchResultList
.
value
.
filter
(
...
@@ -304,6 +344,7 @@ const handleSave = async () => {
...
@@ -304,6 +344,7 @@ const handleSave = async () => {
skuList
:
editForm
.
value
.
spuList
.
map
((
item
)
=>
({
skuList
:
editForm
.
value
.
spuList
.
map
((
item
)
=>
({
warehouseSpu
:
item
.
warehouseSpu
!
,
warehouseSpu
:
item
.
warehouseSpu
!
,
sortOrder
:
item
.
sortOrder
!
,
sortOrder
:
item
.
sortOrder
!
,
warehouseId
:
item
.
warehouseId
!
,
})),
})),
})
})
if
(
res
.
code
!==
200
)
{
if
(
res
.
code
!==
200
)
{
...
@@ -371,7 +412,6 @@ defineExpose({
...
@@ -371,7 +412,6 @@ defineExpose({
.dialog-footer
{
.dialog-footer
{
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
justify-content
:
center
;
gap
:
10px
;
}
}
.popover-table
{
.popover-table
{
...
...
src/views/warehouse/warehouseRuleSetting/hooks/useWarehouseRuleSettingTableColumns.tsx
View file @
9dee038a
...
@@ -94,7 +94,7 @@ export function useWarehouseRuleSettingTableColumns(
...
@@ -94,7 +94,7 @@ export function useWarehouseRuleSettingTableColumns(
},
},
{
{
label
:
'商品名称'
,
label
:
'商品名称'
,
prop
:
'
product
Name'
,
prop
:
'
sku
Name'
,
minWidth
:
160
,
minWidth
:
160
,
align
:
'left'
,
align
:
'left'
,
},
},
...
@@ -120,7 +120,7 @@ export function useWarehouseRuleSettingTableColumns(
...
@@ -120,7 +120,7 @@ export function useWarehouseRuleSettingTableColumns(
},
},
{
{
label
:
'商品名称'
,
label
:
'商品名称'
,
prop
:
'
product
Name'
,
prop
:
'
sku
Name'
,
minWidth
:
160
,
minWidth
:
160
,
align
:
'left'
,
align
:
'left'
,
},
},
...
...
src/views/warehouse/warehouseRuleSetting/index.vue
View file @
9dee038a
...
@@ -101,11 +101,15 @@
...
@@ -101,11 +101,15 @@
<EditFormDialog
<EditFormDialog
ref=
"editFormRef"
ref=
"editFormRef"
v-model:visible=
"editDialogVisible"
v-model:visible=
"editDialogVisible"
:warehouse-list=
"warehouseList"
@
save-success=
"search"
@
save-success=
"search"
/>
/>
</
template
>
</
template
>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
getWarehouseRuleSettingListApi
}
from
'@/api/warehouse/warehouseRuleSetting'
import
{
getWarehouseRuleSettingListApi
,
getWarehouseRuleSettingDetailApi
,
}
from
'@/api/warehouse/warehouseRuleSetting'
import
{
import
{
SearchForm
,
SearchForm
,
WarehouseRuleSettingData
,
WarehouseRuleSettingData
,
...
@@ -115,6 +119,8 @@ import { useValue } from '@/utils/hooks/useValue'
...
@@ -115,6 +119,8 @@ import { useValue } from '@/utils/hooks/useValue'
import
{
ElDatePicker
,
ElFormItem
}
from
'element-plus'
import
{
ElDatePicker
,
ElFormItem
}
from
'element-plus'
import
{
useWarehouseRuleSettingTableColumns
}
from
'./hooks/useWarehouseRuleSettingTableColumns'
import
{
useWarehouseRuleSettingTableColumns
}
from
'./hooks/useWarehouseRuleSettingTableColumns'
import
EditFormDialog
from
'./components/EditDialog.vue'
import
EditFormDialog
from
'./components/EditDialog.vue'
import
{
WarehouseListData
}
from
'@/types'
import
{
loadWarehouseListApi
}
from
'@/api/common.ts'
const
[
searchForm
,
resetSearchForm
]
=
useValue
<
SearchForm
>
({
const
[
searchForm
,
resetSearchForm
]
=
useValue
<
SearchForm
>
({
createStartTime
:
''
,
createStartTime
:
''
,
createEndTime
:
''
,
createEndTime
:
''
,
...
@@ -126,6 +132,7 @@ const dateRange = ref([])
...
@@ -126,6 +132,7 @@ const dateRange = ref([])
const
currentStatus
=
ref
(
'sharedInventory'
)
const
currentStatus
=
ref
(
'sharedInventory'
)
const
editDialogVisible
=
ref
(
false
)
const
editDialogVisible
=
ref
(
false
)
const
editFormRef
=
ref
()
const
editFormRef
=
ref
()
const
warehouseList
=
ref
<
WarehouseListData
[]
>
([])
const
handleStatusClick
=
(
status
:
string
)
=>
{
const
handleStatusClick
=
(
status
:
string
)
=>
{
currentStatus
.
value
=
status
currentStatus
.
value
=
status
}
}
...
@@ -152,6 +159,20 @@ const handleSelectionChange = (selection: WarehouseRuleSettingData[]) => {
...
@@ -152,6 +159,20 @@ const handleSelectionChange = (selection: WarehouseRuleSettingData[]) => {
const
handleEdit
=
async
(
row
?:
WarehouseRuleSettingData
)
=>
{
const
handleEdit
=
async
(
row
?:
WarehouseRuleSettingData
)
=>
{
if
(
row
)
{
if
(
row
)
{
// 调用接口,获取数据
// 调用接口,获取数据
const
loading
=
ElLoading
.
service
({
fullscreen
:
true
,
text
:
'加载中...'
,
background
:
'rgba(0, 0, 0, 0.3)'
,
})
try
{
const
res
=
await
getWarehouseRuleSettingDetailApi
(
row
.
id
)
if
(
res
.
code
!==
200
)
return
editFormRef
.
value
.
resetFields
(
res
.
data
)
}
catch
(
error
)
{
console
.
error
(
error
)
}
finally
{
loading
.
close
()
}
}
else
{
}
else
{
await
editFormRef
.
value
.
resetFields
()
await
editFormRef
.
value
.
resetFields
()
}
}
...
@@ -161,6 +182,14 @@ const handleEdit = async (row?: WarehouseRuleSettingData) => {
...
@@ -161,6 +182,14 @@ const handleEdit = async (row?: WarehouseRuleSettingData) => {
const
{
columns
:
tableColumns
}
=
useWarehouseRuleSettingTableColumns
({
const
{
columns
:
tableColumns
}
=
useWarehouseRuleSettingTableColumns
({
onEdit
:
handleEdit
,
onEdit
:
handleEdit
,
})
})
const
loadWarehouseList
=
async
()
=>
{
const
res
=
await
loadWarehouseListApi
()
if
(
res
.
code
!==
200
)
return
warehouseList
.
value
=
res
.
data
||
[]
}
onMounted
(
async
()
=>
{
loadWarehouseList
()
})
</
script
>
</
script
>
<
style
scoped
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.status-container
{
.status-container
{
...
...
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