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
28ba2892
Commit
28ba2892
authored
Sep 14, 2024
by
wuqian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
检索校验
parent
16e6395a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
40 deletions
+76
-40
src/types/api/order.ts
+7
-0
src/views/order/hook/useShipment.ts
+69
-40
No files found.
src/types/api/order.ts
View file @
28ba2892
...
...
@@ -263,3 +263,10 @@ export interface shopRemark {
resendNum
?:
number
|
undefined
|
null
remark
?:
string
|
undefined
|
null
}
export
interface
ICompareObjects
{
lanshouAddress
?:
string
lanshouName
?:
string
lanshouPhone
?:
string
lanshouPost
?:
string
lanshouRegion
?:
string
}
src/views/order/hook/useShipment.ts
View file @
28ba2892
...
...
@@ -4,6 +4,7 @@ import {
ProductList
,
ShipmentForm
,
ShipmentOrderRes
,
ICompareObjects
,
}
from
'@/types/api/order'
import
{
useValue
}
from
'@/utils/hooks/useValue'
import
{
nextTick
,
ref
}
from
'vue'
...
...
@@ -17,12 +18,14 @@ export default function useShipment(callback?: () => void) {
carriageAmount
:
''
,
namespace
:
''
,
})
const
firstResult
=
ref
<
ICompareObjects
|
null
>
(
null
)
const
shipmentFormRef
=
ref
()
const
productionOrderNumber
=
ref
(
''
)
const
shipmentVisible
=
ref
(
false
)
const
isLock
=
ref
(
false
)
const
inputRef
=
ref
()
const
currentRow
=
ref
<
ProductList
>
()
// const currentRow = ref<ProductList>()
const
currentRow
=
ref
<
ProductList
|
undefined
>
(
undefined
)
const
shipmentLoading
=
ref
(
false
)
const
shipmentOrderRef
=
ref
<
ShipmentType
>
()
const
searchShipmentByOrderNumber
=
async
()
=>
{
...
...
@@ -48,7 +51,6 @@ export default function useShipment(callback?: () => void) {
}
}
if
(
rowData
)
{
currentRow
.
value
=
rowData
const
unShipmentNum
=
(
rowData
.
num
||
0
)
-
...
...
@@ -92,45 +94,19 @@ export default function useShipment(callback?: () => void) {
shipmentLoading
.
value
=
true
const
res
=
await
getOrderBySubOrderNumber
(
code
)
if
(
res
.
data
)
{
const
code1
=
code
?.
split
(
'_'
)[
0
]
for
(
const
item
of
res
.
data
.
productList
||
[])
{
item
.
count
=
0
if
(
item
.
subOrderNumber
===
code1
)
{
item
.
count
=
(
item
.
num
||
0
)
-
((
item
.
shipmentNum
||
0
)
-
(
item
.
notPassNum
||
0
))
if
(
+
item
.
count
>
1
)
{
ElMessageBox
.
confirm
(
`该产品未发数为
${
item
.
count
}
件`
,
'重要提示'
,
{
confirmButtonText
:
'确定'
,
type
:
'warning'
,
},
).
catch
(()
=>
{})
}
currentRow
.
value
=
item
currentRow
.
value
.
orderNumber
=
res
.
data
.
orderNumber
if
(
firstResult
.
value
===
null
)
{
firstResult
.
value
=
res
.
data
canJoin
(
res
.
data
,
code
)
}
else
{
if
(
!
compareObjects
(
firstResult
.
value
,
res
.
data
))
{
ElMessageBox
.
confirm
(
'不能加入,地址信息不一致!'
,
'重要提示'
,
{
confirmButtonText
:
'确定'
,
type
:
'warning'
,
}).
catch
(()
=>
{})
}
else
{
canJoin
(
res
.
data
,
code
)
}
}
const
index
=
orderList
.
value
.
findIndex
(
(
item
)
=>
item
.
id
===
res
.
data
.
id
,
)
if
(
index
===
-
1
)
{
orderList
.
value
.
unshift
(
res
.
data
)
}
playAudio
(
'picking_search_success'
)
await
nextTick
()
if
(
shipmentOrderRef
.
value
)
{
const
rowEl
=
shipmentOrderRef
.
value
.
listRef
?.
querySelector
(
`div[data-id="
${
currentRow
.
value
?.
id
}
"]`,
)
if (!rowEl) return
rowEl.scrollIntoView()
}
}
inputRef
.
value
.
focus
()
productionOrderNumber
.
value
=
''
...
...
@@ -145,6 +121,55 @@ export default function useShipment(callback?: () => void) {
shipmentLoading
.
value
=
false
}
}
const
canJoin
=
async
(
data
:
any
,
code
:
string
)
=>
{
const
code1
=
code
?.
split
(
'_'
)[
0
]
for
(
const
item
of
data
.
productList
||
[])
{
item
.
count
=
0
if
(
item
.
subOrderNumber
===
code1
)
{
item
.
count
=
(
item
.
num
||
0
)
-
((
item
.
shipmentNum
||
0
)
-
(
item
.
notPassNum
||
0
))
if
(
+
item
.
count
>
1
)
{
ElMessageBox
.
confirm
(
`该产品未发数为
${
item
.
count
}
件`
,
'重要提示'
,
{
confirmButtonText
:
'确定'
,
type
:
'warning'
,
}).
catch
(()
=>
{})
}
currentRow
.
value
=
item
if
(
currentRow
.
value
)
{
currentRow
.
value
.
orderNumber
=
data
.
orderNumber
}
}
}
const
index
=
orderList
.
value
.
findIndex
((
item
)
=>
item
.
id
===
data
.
id
)
if
(
index
===
-
1
)
{
orderList
.
value
.
unshift
(
data
)
}
playAudio
(
'picking_search_success'
)
await
nextTick
()
if
(
shipmentOrderRef
.
value
)
{
const
rowEl
=
shipmentOrderRef
.
value
.
listRef
?.
querySelector
(
`div[data-id="
${
currentRow
.
value
?.
id
}
"]`,
)
if (!rowEl) return
rowEl.scrollIntoView()
}
}
const compareObjects = (
obj1: ICompareObjects,
obj2: ICompareObjects,
): boolean => {
const keysToCompare: (keyof ICompareObjects)[] = [
'lanshouAddress',
'lanshouName',
'lanshouPhone',
'lanshouPost',
'lanshouRegion',
]
return keysToCompare.every((key) => obj1[key] === obj2[key])
} //将后面的查询结果和第一次的结果进行比较,相同才能加入,反之不能
const saveShipment = async () => {
if (orderList.value.length === 0) {
return ElMessage({
...
...
@@ -200,6 +225,7 @@ export default function useShipment(callback?: () => void) {
const confirmDelivery = async () => {
shipmentVisible.value = true
productionOrderNumber.value = ''
firstResult.value = null //弹窗打开前先清空第一次的结果
resetOrderList()
resetShipmentForm()
}
...
...
@@ -217,7 +243,10 @@ export default function useShipment(callback?: () => void) {
*/
const playAudio = (key: string) => {
const audio = new Audio()
const audioPath = new URL(`../../../assets/audio/${key}.mp3`, import.meta.url).href
const audioPath = new URL(
`../../../assets/audio/${key}.mp3`,
import.meta.url,
).href
audio.src = audioPath
audio.play()
}
...
...
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