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
5a438c3f
Commit
5a438c3f
authored
Mar 27, 2026
by
qinjianhui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 将创建入库单抽取为组件
parent
c9cc32d2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
0 deletions
+181
-0
src/views/warehouse/components/ReceiptProductDialog.vue
+0
-0
src/views/warehouse/hooks/useReceiptProductDialog.ts
+181
-0
src/views/warehouse/receiptDoc.vue
+0
-0
No files found.
src/views/warehouse/components/ReceiptProductDialog.vue
0 → 100644
View file @
5a438c3f
This diff is collapsed.
Click to expand it.
src/views/warehouse/hooks/useReceiptProductDialog.ts
0 → 100644
View file @
5a438c3f
import
{
computed
,
ref
,
type
Ref
}
from
'vue'
import
BigNumber
from
'bignumber.js'
import
{
ElMessage
}
from
'element-plus'
import
{
getBySkuAndUserMarkApi
}
from
'@/api/warehouse'
import
type
{
InterProductList
,
InterWarehouseDetail
,
InterskuList
,
}
from
'@/types/api/warehouse'
interface
UserMark
{
userId
:
number
userMark
:
string
userName
:
string
}
interface
UseReceiptProductDialogOptions
{
editForm
:
Ref
<
InterWarehouseDetail
>
otherPurchaseData
:
Ref
<
InterProductList
[]
>
userMark
:
Ref
<
number
>
batchUserMark
:
Ref
<
number
>
importUserMark
:
Ref
<
number
>
selectSku
:
Ref
<
string
>
userMarkList
:
Ref
<
UserMark
[]
>
}
export
function
useReceiptProductDialog
(
options
:
UseReceiptProductDialogOptions
)
{
const
{
editForm
,
otherPurchaseData
,
userMark
,
batchUserMark
,
importUserMark
,
selectSku
,
userMarkList
,
}
=
options
const
skuData
=
ref
<
InterskuList
[]
>
([])
const
setCostPrice
=
(
item
:
InterProductList
)
=>
{
if
(
item
.
costPrice
!==
0
&&
!
item
.
costPrice
)
{
ElMessage
.
warning
(
'商品成本价为空,请完善商品成本价'
)
return
}
const
buyStored
=
item
.
buyStored
??
0
const
costPrice
=
item
.
costPrice
??
0
const
amount
=
new
BigNumber
(
buyStored
).
multipliedBy
(
costPrice
).
toFixed
(
2
)
item
.
totalPrice
=
Number
(
amount
)
}
const
getUserMarkText
=
(
customerId
:
number
,
mode
:
'query'
|
'create'
=
'query'
,
):
string
|
null
=>
{
const
item
=
userMarkList
.
value
.
find
((
e
)
=>
e
.
userId
===
customerId
)
if
(
customerId
===
0
)
{
return
mode
===
'query'
?
null
:
''
}
return
item
?.
userMark
||
null
}
const
batchAddCommodity
=
async
(
sku
:
string
,
type
:
'1'
|
'2'
|
'3'
,
):
Promise
<
InterskuList
[]
>
=>
{
if
(
!
editForm
.
value
.
warehouseId
)
{
ElMessage
.
error
(
'请选择仓库'
)
return
[]
}
try
{
let
userValue
:
number
=
0
if
(
type
===
'1'
)
{
userValue
=
userMark
.
value
}
else
if
(
type
===
'2'
)
{
userValue
=
batchUserMark
.
value
}
else
if
(
type
===
'3'
)
{
userValue
=
importUserMark
.
value
}
const
user
=
getUserMarkText
(
userValue
,
'query'
)
const
res
=
await
getBySkuAndUserMarkApi
(
editForm
.
value
.
warehouseId
,
sku
,
user
)
const
arr
:
InterskuList
[]
=
res
.
data
||
[]
const
ids
:
Record
<
string
,
boolean
>
=
{}
for
(
const
item
of
otherPurchaseData
.
value
)
{
if
(
item
.
warehouseSku
!==
undefined
)
{
ids
[
item
.
warehouseSku
]
=
true
}
}
return
arr
.
filter
((
currentItem
:
InterskuList
)
=>
{
return
currentItem
.
sku
===
undefined
||
!
ids
[
currentItem
.
sku
]
})
}
catch
(
e
)
{
console
.
error
(
e
)
return
[]
}
}
const
selectbySku
=
async
()
=>
{
if
(
!
editForm
.
value
.
warehouseId
)
return
ElMessage
.
error
(
'请选择仓库'
)
try
{
const
user
=
getUserMarkText
(
userMark
.
value
,
'query'
)
const
res
=
await
getBySkuAndUserMarkApi
(
editForm
.
value
.
warehouseId
,
selectSku
.
value
,
user
,
)
skuData
.
value
=
res
.
data
||
[]
}
catch
(
e
)
{
console
.
error
(
e
)
}
}
const
skudblclick
=
(
val
:
InterskuList
)
=>
{
const
{
locationCode
=
''
,
costPrice
=
null
,
productNo
=
''
,
warehouseSku
=
''
,
productName
=
''
,
skuImage
=
''
,
locationId
=
null
,
currencyName
=
''
,
currencyCode
=
null
,
}
=
val
||
{}
const
lastItem
=
otherPurchaseData
.
value
[
otherPurchaseData
.
value
.
length
-
1
]
||
null
if
(
lastItem
&&
lastItem
.
currencyName
)
{
if
(
!
currencyName
||
currencyName
!==
lastItem
.
currencyName
)
{
ElMessage
.
error
(
'添加的商品币种需一致'
)
return
}
}
const
item
=
userMarkList
.
value
.
find
((
e
)
=>
e
.
userId
===
userMark
.
value
)
otherPurchaseData
.
value
=
[
...
JSON
.
parse
(
JSON
.
stringify
(
otherPurchaseData
.
value
)),
{
skuImage
,
warehouseSku
,
customerId
:
userMark
.
value
!==
0
?
userMark
.
value
:
null
,
customerName
:
userMark
.
value
!==
0
?
item
?.
userName
||
''
:
null
,
userMark
:
userMark
.
value
!==
0
?
item
?.
userMark
:
null
,
skuName
:
productName
,
productNo
,
locationCode
:
locationCode
??
''
,
locationId
:
locationId
??
null
,
costPrice
,
buyStored
:
null
,
totalPrice
:
null
,
currencyName
,
currencyCode
,
},
]
const
skuSet
=
new
Set
(
otherPurchaseData
.
value
.
map
((
item
:
InterProductList
)
=>
item
.
warehouseSku
),
)
skuData
.
value
=
skuData
.
value
.
filter
((
item
:
InterskuList
)
=>
!
skuSet
.
has
(
item
.
sku
))
}
const
filterSkuData
=
computed
(()
=>
{
const
skuList
=
otherPurchaseData
.
value
.
map
((
el
)
=>
el
.
warehouseSku
)
const
item
=
userMarkList
.
value
.
find
((
u
)
=>
u
.
userId
===
userMark
.
value
)
return
skuData
.
value
.
filter
((
el
)
=>
!
skuList
.
includes
(
el
.
warehouseSku
))
.
map
((
e
)
=>
{
return
{
...
e
,
userMark
:
userMark
.
value
===
0
?
''
:
item
?.
userMark
,
}
})
})
return
{
skuData
,
setCostPrice
,
batchAddCommodity
,
selectbySku
,
skudblclick
,
filterSkuData
,
}
}
src/views/warehouse/receiptDoc.vue
View file @
5a438c3f
This diff is collapsed.
Click to expand it.
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