Commit ea325cfe by qinjianhui

Merge branch 'fix_1001802' into 'dev'

Fix 1001802

See merge request !254
parents 62deaf48 26a1bab1
...@@ -572,6 +572,14 @@ watch(visible, async (value: boolean) => { ...@@ -572,6 +572,14 @@ watch(visible, async (value: boolean) => {
sortingAreaId.value = hit.id sortingAreaId.value = hit.id
warehouseId.value = hit.warehouseId warehouseId.value = hit.warehouseId
isAutoPrint.value = hit.autoPrint isAutoPrint.value = hit.autoPrint
} else {
const defaultArea =
sortingAreaList.value.find(
(item) => item.defaultWarehouse === 1 && item.areaCode === 'AREA_0',
) || sortingAreaList.value[0]
sortingAreaId.value = defaultArea.id
warehouseId.value = defaultArea.warehouseId
isAutoPrint.value = defaultArea.autoPrint || false
} }
} else { } else {
/* 先找一次,确认本地值是否存在于列表 */ /* 先找一次,确认本地值是否存在于列表 */
...@@ -634,7 +642,8 @@ watch( ...@@ -634,7 +642,8 @@ watch(
if (item?.data) { if (item?.data) {
renderItemBox(true) renderItemBox(true)
} else { } else {
if (boxIndex.value === podBoxIndex.value) { // 0 号箱为单件,不在播种墙列表中,不应清空当前单件数据
if (boxIndex.value === podBoxIndex.value && boxIndex.value !== 0) {
podOrderDetailsData.value = {} podOrderDetailsData.value = {}
boxIndex.value = null boxIndex.value = null
} }
...@@ -668,6 +677,7 @@ watch( ...@@ -668,6 +677,7 @@ watch(
const podBoxIndex = computed(() => orderStore.podBoxIndex) const podBoxIndex = computed(() => orderStore.podBoxIndex)
let renderLock = false let renderLock = false
let pickFinishedAlertToken = 0
const renderItemBox = (bool: boolean) => { const renderItemBox = (bool: boolean) => {
if ( if (
...@@ -969,21 +979,36 @@ const getPackingData = async (code: string) => { ...@@ -969,21 +979,36 @@ const getPackingData = async (code: string) => {
boxIndex.value = box as number boxIndex.value = box as number
if (boxIndex.value == 0) { if (boxIndex.value == 0) {
podOrderDetailsData.value = data as OrderData const orderData = data as OrderData
orderData.productList?.forEach((el) => {
if (!el.previewImgs || !el.previewImgs.length) {
if (
el.productMark === 'custom_normal' ||
el.productMark === 'normal'
) {
el.previewImgs = [{ url: el.variantImage || '' }]
} else {
el.previewImgs = el.imageAry
? JSON.parse(el.imageAry)
: [{ url: el.variantImage }]
}
}
})
podOrderDetailsData.value = orderData
podOrderDetailsData.value.fromUser = userStore.user?.id podOrderDetailsData.value.fromUser = userStore.user?.id
if (podOrderDetailsData.value.productList?.length) {
const list = podOrderDetailsData.value.productList const list = podOrderDetailsData.value.productList
if (list?.length) {
await nextTick()
tableRef.value?.setCurrentRow(list[0])
coverImage.value = list[0].previewImgs?.[0]?.url || ''
for (const product of list) { for (const product of list) {
if (product.count === product.purchaseNumber) { if (product.count === product.purchaseNumber) {
product.power = true product.power = true
print(data as OrderData, false, () => { print(orderData, false, () => {
renderLock = false renderLock = false
}) })
} }
} }
nextTick(() => {
tableRef.value?.setCurrentRow(list[0])
})
} }
} }
} catch (error) { } catch (error) {
...@@ -1131,6 +1156,8 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => { ...@@ -1131,6 +1156,8 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => {
} }
return item return item
}) })
// 当 boxIndex.value 为 0 时,不更新列表数据,防止单件数据丢失
if (boxIndex.value !== 0) {
const currentBox = boxIndex.value const currentBox = boxIndex.value
const currentBoxItem = currentBox const currentBoxItem = currentBox
? boxList.find((item) => item.box === currentBox && item.data) ? boxList.find((item) => item.box === currentBox && item.data)
...@@ -1142,7 +1169,10 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => { ...@@ -1142,7 +1169,10 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => {
podOrderDetailsData.value?.productList?.forEach((el) => { podOrderDetailsData.value?.productList?.forEach((el) => {
if (!el.previewImgs) { if (!el.previewImgs) {
if (el.productMark === 'custom_normal' || el.productMark === 'normal') { if (
el.productMark === 'custom_normal' ||
el.productMark === 'normal'
) {
el.previewImgs = [{ url: el.variantImage || '' }] el.previewImgs = [{ url: el.variantImage || '' }]
} else { } else {
el.previewImgs = el.imageAry el.previewImgs = el.imageAry
...@@ -1153,7 +1183,8 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => { ...@@ -1153,7 +1183,8 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => {
}) })
if (type !== 'scan') { if (type !== 'scan') {
coverImage.value = coverImage.value =
podOrderDetailsData.value?.productList?.[0]?.previewImgs?.[0].url || '' podOrderDetailsData.value?.productList?.[0]?.previewImgs?.[0].url ||
''
} }
if ( if (
...@@ -1163,6 +1194,7 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => { ...@@ -1163,6 +1194,7 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => {
) { ) {
podOrderDetailsData.value.printResult = 'notPrintSuccess' podOrderDetailsData.value.printResult = 'notPrintSuccess'
} }
}
const pickFinished = boxList.filter((item) => { const pickFinished = boxList.filter((item) => {
return item.data?.productList?.every((product) => product.power) return item.data?.productList?.every((product) => product.power)
}) })
...@@ -1175,6 +1207,10 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => { ...@@ -1175,6 +1207,10 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => {
// 切换箱子至验货完成的箱子 // 切换箱子至验货完成的箱子
boxChange.value = true boxChange.value = true
boxIndex.value = boxs[0] as number boxIndex.value = boxs[0] as number
const token = ++pickFinishedAlertToken
if (token > 1) {
ElMessageBox.close()
}
try { try {
await ElMessageBox.alert( await ElMessageBox.alert(
`检测到${boxs.join(',')}号箱验货完成,请及时处理`, `检测到${boxs.join(',')}号箱验货完成,请及时处理`,
...@@ -1183,8 +1219,10 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => { ...@@ -1183,8 +1219,10 @@ const initOrderDetailBox = async (type: 'scan' | 'manual' = 'manual') => {
confirmButtonText: '确定', confirmButtonText: '确定',
}, },
) )
if (token !== pickFinishedAlertToken) return
productionOrderRef.value.focus() productionOrderRef.value.focus()
} catch (error) { } catch (error) {
if (token !== pickFinishedAlertToken) return
productionOrderRef.value.focus() productionOrderRef.value.focus()
console.error(error) console.error(error)
} }
...@@ -1387,6 +1425,7 @@ const print = (data: OrderData, forcePrint = false, callback?: () => void) => { ...@@ -1387,6 +1425,7 @@ const print = (data: OrderData, forcePrint = false, callback?: () => void) => {
} else { } else {
;(podOrderDetailsData.value as OrderData).printResult = 'printFail' ;(podOrderDetailsData.value as OrderData).printResult = 'printFail'
} }
return
} }
const factoryNo = userStore.user?.factory.id const factoryNo = userStore.user?.factory.id
if (!factoryNo) return if (!factoryNo) return
...@@ -1556,13 +1595,6 @@ const getSortingAreaList = async () => { ...@@ -1556,13 +1595,6 @@ const getSortingAreaList = async () => {
const res = await getSortingRuleListApi({}) const res = await getSortingRuleListApi({})
if (res.code !== 200) return if (res.code !== 200) return
sortingAreaList.value = res.data.records sortingAreaList.value = res.data.records
const defaultArea =
sortingAreaList.value.find(
(item) => item.defaultWarehouse === 1 && item.areaCode === 'AREA_0',
) || sortingAreaList.value[0]
sortingAreaId.value = defaultArea.id
warehouseId.value = defaultArea.warehouseId
isAutoPrint.value = defaultArea.autoPrint || false
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment