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
22a5a2d2
Commit
22a5a2d2
authored
Jun 11, 2025
by
wuqian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
出库单完成
parent
c5abe4eb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
70 deletions
+125
-70
src/types/api/warehouse.ts
+3
-0
src/views/warehouse/issueDoc.vue
+89
-60
src/views/warehouse/receiptDoc.vue
+30
-7
src/views/warehouse/warning.vue
+3
-3
No files found.
src/types/api/warehouse.ts
View file @
22a5a2d2
...
@@ -5,6 +5,8 @@ export interface warehouseSearchForm {
...
@@ -5,6 +5,8 @@ export interface warehouseSearchForm {
billStatus
?:
string
billStatus
?:
string
createTimeEnd
?:
string
createTimeEnd
?:
string
createTimeStart
?:
string
createTimeStart
?:
string
startTime
?:
string
endTime
?:
string
inNo
?:
string
inNo
?:
string
outNo
?:
string
outNo
?:
string
warehouseSku
?:
string
warehouseSku
?:
string
...
@@ -106,6 +108,7 @@ export interface InterskuList {
...
@@ -106,6 +108,7 @@ export interface InterskuList {
price
?:
number
|
null
//出库单的
price
?:
number
|
null
//出库单的
usableInventory
?:
number
|
null
usableInventory
?:
number
|
null
warehouseSku
?:
string
warehouseSku
?:
string
remark
?:
string
|
null
}
}
export
interface
ILocation
{
export
interface
ILocation
{
id
?:
number
id
?:
number
...
...
src/views/warehouse/issueDoc.vue
View file @
22a5a2d2
...
@@ -817,7 +817,7 @@ import {
...
@@ -817,7 +817,7 @@ import {
factoryWarehouseInventoryPrint
,
factoryWarehouseInventoryPrint
,
OutRecordBatchCheckPrintApi
,
OutRecordBatchCheckPrintApi
,
}
from
'@/api/warehouse'
}
from
'@/api/warehouse'
import
{
filePath
}
from
'@/api/axios
.ts
'
import
{
filePath
}
from
'@/api/axios'
import
BigNumber
from
'bignumber.js'
import
BigNumber
from
'bignumber.js'
import
{
ref
,
onMounted
,
watch
,
nextTick
}
from
'vue'
import
{
ref
,
onMounted
,
watch
,
nextTick
}
from
'vue'
import
'element-plus/dist/index.css'
import
'element-plus/dist/index.css'
...
@@ -966,7 +966,7 @@ const rules = {
...
@@ -966,7 +966,7 @@ const rules = {
warehouseId
:
[{
required
:
true
,
message
:
'请选择仓库'
,
trigger
:
'change'
}
],
warehouseId
:
[{
required
:
true
,
message
:
'请选择仓库'
,
trigger
:
'change'
}
],
}
}
const
isAllExport
=
()
=>
{
const
isAllExport
=
()
=>
{
if
(
exportForm
.
value
.
resource
==
=
2
)
{
if
(
exportForm
.
value
.
resource
==
'2'
)
{
ElMessage
.
warning
(
'最多支持5000条!'
)
ElMessage
.
warning
(
'最多支持5000条!'
)
}
}
}
}
...
@@ -994,7 +994,7 @@ const {
...
@@ -994,7 +994,7 @@ const {
}
,
}
,
page
,
page
,
pageSize
,
pageSize
,
).
then
((
res
)
=>
res
.
data
)
as
never
,
).
then
((
res
)
=>
res
.
data
),
}
)
}
)
const
setCostPrice
=
(
item
:
InterProductList
)
=>
{
const
setCostPrice
=
(
item
:
InterProductList
)
=>
{
...
@@ -1097,9 +1097,10 @@ const batchAddCommodity = async (sku: string): Promise<InterskuList[]> => {
...
@@ -1097,9 +1097,10 @@ const batchAddCommodity = async (sku: string): Promise<InterskuList[]> => {
}
}
}
}
interface
InterImportData
{
interface
InterImportData
{
warehouseSku
:
string
warehouseSku
:
string
;
remark
?:
string
|
null
remark
?:
string
|
null
;
[
key
:
string
]:
unknown
buyStored
?:
string
|
number
|
null
|
object
;
// 扩大 buyStored 类型,以兼容原始数据
[
propName
:
string
]:
string
|
number
|
boolean
|
undefined
|
unknown
}
}
// 前端导入Excel
// 前端导入Excel
const
excelFieldMap
:
Record
<
string
,
keyof
InterImportData
>
=
{
const
excelFieldMap
:
Record
<
string
,
keyof
InterImportData
>
=
{
...
@@ -1118,71 +1119,95 @@ const handleLocalImport = async ({
...
@@ -1118,71 +1119,95 @@ const handleLocalImport = async ({
data
,
data
,
}
:
{
}
:
{
path
:
string
path
:
string
data
:
InterImportData
[]
data
:
Record
<
string
,
any
>
[]
}
)
=>
{
}
)
=>
{
// 1. 将原始导入数据映射到 InterImportData[]
// 1. 将原始导入数据映射到 InterImportData[]
const
importedData
:
InterImportData
[]
=
data
const
importedData
:
InterImportData
[]
=
data
.
map
(
item
=>
{
.
map
((
item
)
=>
{
const
obj
:
InterImportData
=
{
warehouseSku
:
''
}
;
const
obj
:
InterImportData
=
{
warehouseSku
:
''
}
Object
.
keys
(
excelFieldMap
).
forEach
(
excelKey
=>
{
Object
.
keys
(
excelFieldMap
).
forEach
((
excelKey
)
=>
{
const
field
=
excelFieldMap
[
excelKey
];
const
field
=
excelFieldMap
[
excelKey
]
const
value
=
item
[
excelKey
];
const
value
=
item
[
excelKey
]
// 根据目标字段进行可能的类型转换或处理
if
(
field
===
'warehouseSku'
)
{
if
(
field
===
'warehouseSku'
)
{
obj
[
field
]
=
typeof
value
===
'string'
?
value
:
String
(
value
??
''
)
// 转换为字符串,处理 null/undefined
obj
[
field
]
=
typeof
value
===
'string'
?
value
:
String
(
value
??
''
);
}
else
if
(
field
===
'remark'
)
{
}
else
if
(
field
===
'remark'
)
{
obj
[
field
]
=
obj
[
field
]
=
typeof
value
===
'string'
?
value
:
(
value
===
null
||
value
===
undefined
?
null
:
String
(
value
));
typeof
value
===
'string'
}
else
if
(
field
===
'buyStored'
)
{
?
value
// 处理 buyStored: 确保它是一个数字、数字字符串,否则设置为 null
:
value
===
null
||
value
===
undefined
if
(
typeof
value
===
'number'
)
{
?
null
obj
[
field
]
=
String
(
value
);
// 将数字转换为字符串
:
String
(
value
)
// 备注可以是 string | null
}
else
if
(
typeof
value
===
'string'
&&
!
isNaN
(
Number
(
value
)))
{
obj
[
field
]
=
value
;
// 保持有效的数字字符串
}
else
{
// 如果不是数字或有效的数字字符串,则设置为 null
obj
[
field
]
=
null
;
}
}
else
{
}
else
{
// 处理其他字段
obj
[
field
]
=
value
;
obj
[
field
]
=
value
}
}
}
)
}
);
return
obj
return
obj
;
}
)
}
).
filter
(
item
=>
item
.
warehouseSku
);
.
filter
((
item
)
=>
item
.
warehouseSku
)
// 过滤掉没有 SKU 的行
if
(
importedData
.
length
===
0
)
{
if
(
importedData
.
length
===
0
)
{
ElMessage
.
warning
(
'导入数据中没有有效的商品SKU'
)
ElMessage
.
warning
(
'导入数据中没有有效的商品SKU'
);
importDialogVisible
.
value
=
false
importDialogVisible
.
value
=
false
;
return
return
;
}
}
// 2. 提取导入的 SKU 列表
// 2. 提取导入的 SKU 列表
const
importedSkus
=
importedData
.
map
((
item
)
=>
item
.
warehouseSku
).
join
(
','
)
const
importedSkus
=
importedData
.
map
(
item
=>
item
.
warehouseSku
).
join
(
','
);
// 3. 调用 batchAddCommodity 获取商品的完整信息并过滤掉已有的 SKU
// 3. 调用 batchAddCommodity 获取商品的完整信息并过滤掉已有的 SKU
const
filteredSkusList
=
await
batchAddCommodity
(
importedSkus
)
// 使用 await 等待结果
const
filteredSkusList
=
await
batchAddCommodity
(
importedSkus
);
if
(
filteredSkusList
.
length
===
0
)
{
if
(
filteredSkusList
.
length
===
0
)
{
ElMessage
.
warning
(
'导入的商品SKU已存在或无效'
)
ElMessage
.
warning
(
'导入的商品SKU已存在或无效'
);
importedFileUrl
.
value
=
path
importedFileUrl
.
value
=
path
;
importDialogVisible
.
value
=
false
importDialogVisible
.
value
=
false
;
return
return
;
}
}
// 4. 将备注信息合并到获取到的商品列表中
// 4. 将备注信息合并到获取到的商品列表中
const
mergedProductList
=
filteredSkusList
.
map
((
skuItem
)
=>
{
const
mergedProductList
=
filteredSkusList
.
map
(
skuItem
=>
{
// 在导入数据中找到匹配的备注信息
const
importedItem
=
importedData
.
find
(
item
=>
item
.
warehouseSku
===
skuItem
.
warehouseSku
);
const
importedItem
=
importedData
.
find
(
(
item
)
=>
item
.
warehouseSku
===
skuItem
.
warehouseSku
,
let
outCountValueForBigNumber
:
string
|
number
=
'0'
;
// 初始化为安全默认值
)
return
{
if
(
importedItem
?.
buyStored
!==
null
&&
importedItem
?.
buyStored
!==
undefined
)
{
skuImage
:
skuItem
.
image
,
if
(
typeof
importedItem
.
buyStored
===
'string'
&&
!
isNaN
(
Number
(
importedItem
.
buyStored
)))
{
warehouseSku
:
skuItem
.
warehouseSku
,
outCountValueForBigNumber
=
importedItem
.
buyStored
;
skuName
:
skuItem
.
skuName
,
}
else
if
(
typeof
importedItem
.
buyStored
===
'number'
)
{
productNo
:
skuItem
.
productNumber
,
outCountValueForBigNumber
=
importedItem
.
buyStored
;
locationCode
:
skuItem
.
locationCode
??
''
,
}
else
{
locationId
:
skuItem
.
locationId
??
null
,
// 如果是对象或其他意外类型,则默认为 '0'
costPrice
:
skuItem
.
price
,
outCountValueForBigNumber
=
'0'
;
outCount
:
null
,
// 出库数量初始为 null
}
totalPrice
:
null
,
}
usableInventory
:
skuItem
.
usableInventory
,
inventoryId
:
skuItem
.
id
,
const
calculatedOutCount
=
new
BigNumber
(
outCountValueForBigNumber
).
toNumber
();
remark
:
importedItem
?.
remark
??
null
,
}
as
InterProductList
// 明确类型
return
{
}
)
skuImage
:
skuItem
.
image
,
warehouseSku
:
skuItem
.
warehouseSku
,
skuName
:
skuItem
.
skuName
,
productNo
:
skuItem
.
productNumber
,
locationCode
:
skuItem
.
locationCode
??
''
,
locationId
:
skuItem
.
locationId
??
null
,
costPrice
:
skuItem
.
price
,
outCount
:
calculatedOutCount
,
totalPrice
:
new
BigNumber
(
calculatedOutCount
).
multipliedBy
(
skuItem
.
price
??
0
).
toNumber
(),
usableInventory
:
skuItem
.
usableInventory
,
inventoryId
:
skuItem
.
id
,
remark
:
importedItem
?.
remark
??
skuItem
.
remark
??
null
,
}
as
InterProductList
;
}
);
// 5. 更新 otherPurchaseData
// 5. 更新 otherPurchaseData
otherPurchaseData
.
value
=
[...
otherPurchaseData
.
value
,
...
mergedProductList
]
otherPurchaseData
.
value
=
[...
otherPurchaseData
.
value
,
...
mergedProductList
];
importedFileUrl
.
value
=
path
importedFileUrl
.
value
=
path
importDialogVisible
.
value
=
false
importDialogVisible
.
value
=
false
}
}
...
@@ -1198,14 +1223,18 @@ const submitExportForm = async () => {
...
@@ -1198,14 +1223,18 @@ const submitExportForm = async () => {
if
(
exportForm
.
value
.
resource
===
''
)
{
if
(
exportForm
.
value
.
resource
===
''
)
{
return
ElMessage
.
error
(
'请选择导出类型'
)
return
ElMessage
.
error
(
'请选择导出类型'
)
}
}
let
purchaseIds
=
[]
let
purchaseIds
:
number
[]
=
[]
let
exportTotal
:
number
|
undefined
=
undefined
let
exportTotal
:
number
|
undefined
=
undefined
const
params
:
AnyObject
=
{
}
const
params
:
AnyObject
=
{
}
const
resourceType
=
Number
(
exportForm
.
value
.
resource
)
const
resourceType
=
Number
(
exportForm
.
value
.
resource
)
if
(
resourceType
===
0
)
{
if
(
resourceType
===
0
)
{
purchaseIds
=
tableData
.
value
.
map
((
el
:
InterWarehousePage
)
=>
el
.
id
)
purchaseIds
=
(
tableData
.
value
as
InterWarehousePage
[]).
map
(
(
el
:
InterWarehousePage
)
=>
Number
(
el
.
id
),
)
}
else
if
(
resourceType
===
1
)
{
}
else
if
(
resourceType
===
1
)
{
purchaseIds
=
selections
.
value
.
map
((
el
:
InterWarehousePage
)
=>
el
.
id
)
purchaseIds
=
selections
.
value
.
map
((
el
:
InterWarehousePage
)
=>
Number
(
el
.
id
),
)
}
else
if
(
resourceType
===
2
)
{
}
else
if
(
resourceType
===
2
)
{
purchaseIds
=
[]
purchaseIds
=
[]
exportTotal
=
total
.
value
exportTotal
=
total
.
value
...
...
src/views/warehouse/receiptDoc.vue
View file @
22a5a2d2
...
@@ -1001,7 +1001,7 @@ const rules = {
...
@@ -1001,7 +1001,7 @@ const rules = {
warehouseId
:
[{
required
:
true
,
message
:
'请选择仓库'
,
trigger
:
'change'
}
],
warehouseId
:
[{
required
:
true
,
message
:
'请选择仓库'
,
trigger
:
'change'
}
],
}
}
const
isAllExport
=
()
=>
{
const
isAllExport
=
()
=>
{
if
(
exportForm
.
value
.
resource
==
=
2
)
{
if
(
exportForm
.
value
.
resource
==
'2'
)
{
ElMessage
.
warning
(
'最多支持5000条!'
)
ElMessage
.
warning
(
'最多支持5000条!'
)
}
}
}
}
...
@@ -1160,11 +1160,33 @@ const handleLocalImport = async ({
...
@@ -1160,11 +1160,33 @@ const handleLocalImport = async ({
Object
.
keys
(
excelFieldMap
).
forEach
((
excelKey
)
=>
{
Object
.
keys
(
excelFieldMap
).
forEach
((
excelKey
)
=>
{
const
field
=
excelFieldMap
[
excelKey
]
const
field
=
excelFieldMap
[
excelKey
]
const
value
=
item
[
excelKey
]
const
value
=
item
[
excelKey
]
obj
[
field
]
=
value
if
(
field
===
'warehouseSku'
)
{
obj
[
field
]
=
typeof
value
===
'string'
?
value
:
String
(
value
??
''
)
}
else
if
(
field
===
'remark'
)
{
obj
[
field
]
=
typeof
value
===
'string'
?
value
:
value
===
null
||
value
===
undefined
?
null
:
String
(
value
)
}
else
if
(
field
===
'buyStored'
)
{
// 确保 value 是一个有效的数字或数字字符串,否则设置为 null
if
(
typeof
value
===
'number'
||
(
typeof
value
===
'string'
&&
!
isNaN
(
Number
(
value
)))
)
{
obj
[
field
]
=
String
(
value
)
// 转换为字符串
}
else
{
obj
[
field
]
=
null
// 无效值设置为 null
}
}
else
{
obj
[
field
]
=
value
}
}
)
}
)
return
obj
return
obj
}
)
}
)
.
filter
((
item
)
=>
item
.
warehouseSku
)
// 过滤掉没有 SKU 的行
.
filter
((
item
)
=>
item
.
warehouseSku
)
if
(
importedData
.
length
===
0
)
{
if
(
importedData
.
length
===
0
)
{
ElMessage
.
warning
(
'导入数据中没有有效的商品SKU'
)
ElMessage
.
warning
(
'导入数据中没有有效的商品SKU'
)
importDialogVisible
.
value
=
false
importDialogVisible
.
value
=
false
...
@@ -1186,9 +1208,6 @@ const handleLocalImport = async ({
...
@@ -1186,9 +1208,6 @@ const handleLocalImport = async ({
const
importedItem
=
importedData
.
find
(
const
importedItem
=
importedData
.
find
(
(
item
)
=>
item
.
warehouseSku
===
skuItem
.
sku
,
(
item
)
=>
item
.
warehouseSku
===
skuItem
.
sku
,
)
)
const
amount
=
new
BigNumber
(
importedItem
?.
buyStored
)
.
multipliedBy
(
skuItem
.
factoryPrice
)
.
toFixed
(
2
)
return
{
return
{
skuImage
:
skuItem
.
image
,
skuImage
:
skuItem
.
image
,
warehouseSku
:
skuItem
.
sku
,
warehouseSku
:
skuItem
.
sku
,
...
@@ -1198,7 +1217,11 @@ const handleLocalImport = async ({
...
@@ -1198,7 +1217,11 @@ const handleLocalImport = async ({
locationId
:
skuItem
.
locationId
??
null
,
locationId
:
skuItem
.
locationId
??
null
,
costPrice
:
skuItem
.
factoryPrice
,
costPrice
:
skuItem
.
factoryPrice
,
buyStored
:
importedItem
?.
buyStored
??
null
,
buyStored
:
importedItem
?.
buyStored
??
null
,
totalPrice
:
Number
(
amount
),
totalPrice
:
new
BigNumber
(
(
importedItem
?.
buyStored
??
0
)
as
number
|
string
,
)
.
multipliedBy
(
skuItem
.
price
??
0
)
.
toNumber
(),
usableInventory
:
skuItem
.
usableInventory
,
usableInventory
:
skuItem
.
usableInventory
,
remark
:
importedItem
?.
remark
??
null
,
remark
:
importedItem
?.
remark
??
null
,
}
as
InterProductList
// 明确类型
}
as
InterProductList
// 明确类型
...
...
src/views/warehouse/warning.vue
View file @
22a5a2d2
...
@@ -112,14 +112,14 @@ const submitExportForm = async () => {
...
@@ -112,14 +112,14 @@ const submitExportForm = async () => {
return
ElMessage
.
error
(
'请选择导出类型'
)
return
ElMessage
.
error
(
'请选择导出类型'
)
}
}
exportLoading
.
value
=
true
exportLoading
.
value
=
true
let
purchaseIds
=
[]
let
purchaseIds
:
number
[]
=
[]
let
exportTotal
:
number
|
undefined
=
undefined
let
exportTotal
:
number
|
undefined
=
undefined
const
params
:
AnyObject
=
{}
const
params
:
AnyObject
=
{}
const
resourceType
=
Number
(
exportForm
.
value
.
resource
)
const
resourceType
=
Number
(
exportForm
.
value
.
resource
)
if
(
resourceType
===
0
)
{
if
(
resourceType
===
0
)
{
purchaseIds
=
leftData
.
value
.
map
((
el
:
WarehouseWarning
)
=>
el
.
id
)
purchaseIds
=
leftData
.
value
.
map
((
el
:
WarehouseWarning
)
=>
Number
(
el
.
id
)
)
}
else
if
(
resourceType
===
1
)
{
}
else
if
(
resourceType
===
1
)
{
purchaseIds
=
selections
.
value
.
map
((
el
:
WarehouseWarning
)
=>
el
.
id
)
purchaseIds
=
selections
.
value
.
map
((
el
:
WarehouseWarning
)
=>
Number
(
el
.
id
)
)
}
else
if
(
resourceType
===
2
)
{
}
else
if
(
resourceType
===
2
)
{
purchaseIds
=
[]
purchaseIds
=
[]
exportTotal
=
pagination
.
value
.
total
exportTotal
=
pagination
.
value
.
total
...
...
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