Commit 79f80b97 by wusiyi

feat: 工厂订单new添加配货分拣功能 #1005762

parent cb0342fe
......@@ -713,7 +713,7 @@ export function updateConfighApi(data: { id: number; enable: boolean }) {
}
// 配货分拣 列表
export function getSortingRuleListApi(data: { warehouseId: number }) {
export function getSortingRuleListApi(data?: { warehouseId?: number }) {
return axios.post<never, BasePaginationData<SortingList>>(
'allocation-sorting-rule/list_page',
data,
......
......@@ -263,9 +263,10 @@ export function getPodBoxListApi(
url: string,
factoryNo: number | string | undefined,
warehouseId: number | string,
sortingAreaId?: number | string,
) {
return axios.get<never, BaseRespData<PodMakeOrderData[]>>(url, {
params: { factoryNo, warehouseId },
params: { factoryNo, warehouseId, packingId: sortingAreaId },
})
}
......@@ -276,9 +277,10 @@ export function submitInspectionApi(
},
boxIndex: number | null,
warehouseId: number | string,
sortingAreaId?: number | string,
) {
return axios.post<never, BaseRespData<never>>(
`${url}?box=${boxIndex}&warehouseId=${warehouseId}`,
`${url}?box=${boxIndex}&warehouseId=${warehouseId}&packingId=${sortingAreaId}`,
params,
)
}
......@@ -287,18 +289,20 @@ export function clearBoxApi(
factoryNo: number,
box: number | null,
warehouseId: number | string,
sortingAreaId?: number | string,
) {
return axios.get<never, BaseRespData<never>>(url, {
params: { factoryNo, box, warehouseId },
params: { factoryNo, box, warehouseId, packingId: sortingAreaId },
})
}
export function clearAllBoxApi(
url: string,
warehouseId: string | number,
factoryNo: string | number | undefined,
sortingAreaId?: number | string,
) {
return axios.get<never, BaseRespData<never>>(url, {
params: { warehouseId, factoryNo },
params: { warehouseId, factoryNo, packingId: sortingAreaId },
})
}
export function updateRemarkApi(id: number, content: string) {
......
......@@ -302,7 +302,7 @@ export interface SortingList {
areaCode: string
warehouseId: number
warehouseName: string
autoPrint: 0 | 1
autoPrint: boolean
}
// 配货分拣 详情
......
......@@ -4,6 +4,9 @@ export interface PodMakeOrderData {
fromUser?: number | string
box?: number
addDate?: string
packingId?: number | string
factoryNo?: number | string
autoPrint?: boolean
}
export interface OrderData {
......
......@@ -31,8 +31,11 @@
/>
<div class="text-xs">配货分拣</div>
<el-divider direction="vertical" />
<div v-if="!isEnableSorting">关闭时,直接使用配货打单功能配货</div>
<div v-else>
<div v-if="!isEnableSorting" class="info">
关闭时,直接使用配货打单功能配货
</div>
<div v-else class="info">
开启时,支持设置分拣规则,根据分拣规则分配配货区,使用配货分拣功能配货。
</div>
</div>
......@@ -296,6 +299,10 @@ onMounted(async () => {
font-size: 14px;
color: #555;
font-weight: 500;
.info {
font-size: 12px;
color: #999;
}
}
.sorting-content {
......
......@@ -581,7 +581,7 @@
>
</span>
<span v-if="status === 'IN_PRODUCTION' && isEnableSorting" class="item">
<ElButton type="primary" @click="handleSeedingWall"
<ElButton type="primary" @click="handleSeedingWall('sort')"
>配货分拣</ElButton
>
</span>
......@@ -592,7 +592,7 @@
"
class="item"
>
<ElButton type="success" @click="handleSeedingWall"
<ElButton type="success" @click="handleSeedingWall('print')"
>配货打单</ElButton
>
</span>
......@@ -1050,9 +1050,15 @@
v-model="podOrderVisible"
:print-order="printOrder"
:warehouse-list="warehouseList"
:title="wallType === 'print' ? '配货打单' : '配货分拣'"
:is-new-order="true"
ws-open-code="STARTORDERNEWPOD"
ws-close-code="ENDORDERNEWPOD"
:wall-type="wallType"
:ws-open-code="
wallType === 'print' ? 'STARTORDERNEWPOD' : 'STARTORDERNEWPODTOP'
"
:ws-close-code="
wallType === 'print' ? 'ENDORDERNEWPOD' : 'ENDORDERNEWPODTOP'
"
init-url="factory/podOrderPacking/local/getPodBoxOrderDetails"
@set-printer="handlePrinterChange"
@set-warehouse-id="handleWarehouseIdChange"
......@@ -2471,8 +2477,16 @@ const handlePrinterChange = (value: string) => {
sheetPrinter.value = value
localStorage.setItem('sheetPrinter', JSON.stringify(value))
}
const handleWarehouseIdChange = (value: string) => {
localStorage.setItem('localNewWarehouseId', JSON.stringify(value))
const handleWarehouseIdChange = (
value:
| string
| { warehouseId: string | number; sortingAreaId: string | number },
) => {
if (wallType.value === 'print') {
localStorage.setItem('localNewWarehouseId', JSON.stringify(value))
} else if (wallType.value === 'sort') {
localStorage.setItem('localSortingAreaId', JSON.stringify(value))
}
}
const mapOrderParamListToSubmitItems = (
orderParamList: { id: number; dataVersion?: number }[],
......@@ -2493,7 +2507,9 @@ const getPrintLogisticLabelFactory = (id?: number) =>
getfaceSimplexFileApi([id ?? 0])
const { getCLodop } = useLodop()
const handleSeedingWall = () => {
const wallType = ref<'print' | 'sort'>('print')
const handleSeedingWall = (type: 'print' | 'sort') => {
wallType.value = type
const lodop = getCLodop(null, null)
if (!lodop) return
sheetPrinter.value = lodop.GET_PRINTER_NAME(0)
......
......@@ -13,7 +13,7 @@
>
<template #header>
<div class="title">
<span>{{ isNewOrder ? '配货打单' : '播种墙配货' }}</span>
<span>{{ props.title }}</span>
<span v-if="socketConnect === 'online'" class="online">[在线]</span>
<span v-else class="offline">[离线]</span>
<ElButton
......@@ -47,6 +47,21 @@
</div>
<div class="form-item">
<ElSelect
v-if="props.wallType === 'sort'"
v-model="sortingAreaId"
placeholder="请选择配货区"
style="width: 200px"
@change="handleSortingAreaChange"
>
<ElOption
v-for="item in sortingAreaList"
:key="item.id"
:label="item.areaName + ' - ' + item.warehouseName"
:value="item.id"
/>
</ElSelect>
<ElSelect
v-else
v-model="warehouseId"
placeholder="请选择仓库"
style="width: 200px"
......@@ -65,7 +80,11 @@
ref="productionOrderRef"
v-model="productionOrder"
:placeholder="
props.isNewOrder ? '请输入操作单号' : '请输入生产单号'
props.wallType === 'us'
? '请输入生产单号'
: props.wallType === 'sort'
? '请输入操作单号/生产单号'
: '请输入操作单号'
"
clearable
style="width: 100%"
......@@ -124,14 +143,14 @@
>
<template #image="{ row }">
<div
style="display: flex; flex-wrap: nowrap"
v-if="row.previewImgs?.length"
style="display: flex; flex-wrap: nowrap"
>
<div
v-for="img in row.previewImgs"
:key="img"
@click.stop="handleCurrentChange(img.url)"
style="cursor: pointer; margin-right: 5px; flex: 1"
@click.stop="handleCurrentChange(img.url)"
>
<img v-if="img.url" :src="img.url" alt="" />
</div>
......@@ -147,124 +166,145 @@
</TableView>
</div>
</div>
<div class="middle-content">
<div class="box-top">
<div class="box-top-item" v-if="boxIndex !== 0">
<span class="box-top-item-box-index">
{{ boxIndex }}
</span>
<div class="right-panel">
<div v-if="props.wallType === 'sort'" class="sorting-area-content">
{{
(sortingAreaList.find((item) => item.id === sortingAreaId)
?.areaName || '') +
' - ' +
(sortingAreaList.find((item) => item.id === sortingAreaId)
?.warehouseName || '')
}}
</div>
<div class="flex right-panel-body">
<div class="middle-content">
<div class="box-top">
<div v-if="boxIndex !== 0" class="box-top-item">
<span class="box-top-item-box-index">
{{ boxIndex }}
</span>
<span class="box-top-item-box-index-text">号箱</span>
<span class="box-top-item-box-index-text">号箱</span>
<span style="font-size: 30px">放入第</span>
<div
class="box-top-item-box-index-number"
:style="{
color:
podOrderDetailsData?.pickingNumber ===
podOrderDetailsData?.purchaseNumber
? 'rgb(0, 255, 0)'
: '',
}"
>
{{ podOrderDetailsData?.pickingNumber }}
<span style="font-size: 30px">放入第</span>
<div
class="box-top-item-box-index-number"
:style="{
color:
podOrderDetailsData?.pickingNumber ===
podOrderDetailsData?.purchaseNumber
? 'rgb(0, 255, 0)'
: '',
}"
>
{{ podOrderDetailsData?.pickingNumber }}
</div>
<span
v-if="
podOrderDetailsData?.pickingNumber != null &&
podOrderDetailsData?.purchaseNumber != null &&
podOrderDetailsData.pickingNumber ===
podOrderDetailsData.purchaseNumber
"
style="font-size: 30px"
>件已配齐</span
>
<span v-else style="font-size: 30px">件商品</span>
</div>
<div v-else class="box-top-item-box-index-text">
单件商品<span style="color: rgb(0, 255, 0)">(配齐)</span
>,不占用播种墙
</div>
<div class="box-top-item-status">
<span
v-if="
isAutoPrint &&
podOrderDetailsData?.pickingNumber &&
podOrderDetailsData?.purchaseNumber &&
podOrderDetailsData?.pickingNumber ===
podOrderDetailsData?.purchaseNumber
"
>
<span v-if="podOrderDetailsData?.printResult">
面单{{
renderPrintResult(podOrderDetailsData?.printResult)
}}
</span>
<span v-else>面单打印中。。。</span>
</span>
<span v-else>验货中。。。</span>
</div>
<div class="box-top-item-btn">
<ElButton
type="primary"
@click="
podOrderDetailsData && print(podOrderDetailsData, true)
"
>手动打印</ElButton
>
<ElButton
v-if="wallType === 'us'"
type="primary"
@click="printNormal"
>普货拣货
</ElButton>
<ElButton type="success" @click="handlePrintFinish"
>打单完成</ElButton
>
<ElButton
:disabled="boxIndex === 0"
type="danger"
@click="handleClearBox"
>清空箱子</ElButton
>
</div>
<div
v-if="
podOrderDetailsData?.productList?.length &&
podOrderDetailsData?.productList?.length > 1
"
class="multiple-title"
>
<span class="multiple-title-text"></span>
</div>
</div>
<div class="order-image">
<img :src="coverImage" alt="" />
</div>
<span
v-if="
podOrderDetailsData?.pickingNumber != null &&
podOrderDetailsData?.purchaseNumber != null &&
podOrderDetailsData.pickingNumber ===
podOrderDetailsData.purchaseNumber
"
style="font-size: 30px"
>件已配齐</span
>
<span v-else style="font-size: 30px">件商品</span>
</div>
<div v-else class="box-top-item-box-index-text">
单件商品<span style="color: rgb(0, 255, 0)">(配齐)</span
>,不占用播种墙
</div>
<div class="box-top-item-status">
<span
v-if="
podOrderDetailsData?.pickingNumber &&
podOrderDetailsData?.purchaseNumber &&
podOrderDetailsData?.pickingNumber ===
podOrderDetailsData?.purchaseNumber
"
>
<span v-if="podOrderDetailsData?.printResult">
面单{{ renderPrintResult(podOrderDetailsData?.printResult) }}
</span>
<span v-else>面单打印中。。。</span>
</span>
<span v-else>验货中。。。</span>
</div>
<div class="box-top-item-btn">
<ElButton
type="primary"
@click="podOrderDetailsData && print(podOrderDetailsData, true)"
>手动打印</ElButton
>
<ElButton v-if="!isNewOrder" type="primary" @click="printNormal"
>普货拣货
</ElButton>
<ElButton type="success" @click="handlePrintFinish"
>打单完成</ElButton
>
<ElButton
:disabled="boxIndex === 0"
type="danger"
@click="handleClearBox"
>清空箱子</ElButton
>
</div>
<div
v-if="
podOrderDetailsData?.productList?.length &&
podOrderDetailsData?.productList?.length > 1
"
class="multiple-title"
>
<span class="multiple-title-text"></span>
</div>
</div>
<div class="order-image">
<img :src="coverImage" alt="" />
</div>
</div>
<div class="right-content">
<div class="box-list">
<div
v-for="(item, index) in podBoxList"
:key="item.box"
class="box-list-item"
:class="{
active: item.box && boxIndex == item.box,
isNull: !item.data,
}"
@click="handleBoxClick(item)"
>
<span style="font-weight: bold" :title="index + 1 + '号箱'">
{{ index + 1 }}
</span>
<div class="right-content">
<div class="box-list">
<div
v-for="(item, index) in podBoxList"
:key="item.box"
class="box-list-item"
:class="{
active: item.box && boxIndex == item.box,
isNull: !item.data,
}"
@click="handleBoxClick(item)"
>
<span style="font-weight: bold" :title="index + 1 + '号箱'">
{{ index + 1 }}
</span>
<span v-if="item.data?.pickingNumber" class="number">
{{ item.data?.pickingNumber }}/{{ item.data.purchaseNumber }}
</span>
<div
v-if="
item.data &&
item.data.productList?.some(
(e) =>
e.productMark === 'custom_normal' ||
e.productMark === 'normal',
)
"
class="cb-product-mark"
>
<div class="red-circle"></div>
<span v-if="item.data?.pickingNumber" class="number">
{{ item.data?.pickingNumber }}/{{ item.data.purchaseNumber }}
</span>
<div
v-if="
item.data &&
item.data.productList?.some(
(e) =>
e.productMark === 'custom_normal' ||
e.productMark === 'normal',
)
"
class="cb-product-mark"
>
<div class="red-circle"></div>
</div>
</div>
</div>
</div>
</div>
......@@ -292,6 +332,7 @@ import {
submitInspectionApi,
printNormalPickPdfApi,
} from '@/api/podUsOrder'
import { getSortingRuleListApi } from '@/api/order'
import useUserStore from '@/store/user'
import { Check, Refresh } from '@element-plus/icons-vue'
import socket from '@/utils/websocket'
......@@ -299,6 +340,7 @@ import { WarehouseListData } from '@/types/index'
import { filePath } from '@/api/axios.ts'
import { ElButton, ElIcon, ElTag } from 'element-plus'
import { BaseRespData } from '@/types/api'
import type { SortingList } from '@/types/api/order'
const { getCLodop } = useLodop()
......@@ -311,12 +353,16 @@ const props = withDefaults(
wsOpenCode?: string
wsCloseCode?: string
initUrl?: string
wallType?: 'print' | 'sort' | 'us'
title?: string
}>(),
{
isNewOrder: false,
wsOpenCode: 'STARTORDER',
wsCloseCode: 'ENDORDER',
initUrl: 'factory/podJomallOrderUs/local/getPodBoxOrderDetails',
wallType: 'us',
title: '播种墙配货',
},
)
const emit = defineEmits([
......@@ -402,14 +448,14 @@ const podOrderDetailsColumns = computed(() => [
align: 'center',
},
{
label: props.isNewOrder ? '操作单号' : '生产单号',
prop: props.isNewOrder ? 'operationNos' : 'podJomallUsNo',
width: props.isNewOrder ? 180 : 150,
label: props.wallType === 'us' ? '生产单号' : '操作单号',
prop: props.wallType === 'us' ? 'podJomallUsNo' : 'operationNos',
width: props.wallType === 'us' ? 150 : 180,
align: 'center',
render: (row: ProductList) => {
return (
<div>
{props.isNewOrder &&
{props.wallType !== 'us' &&
row.operationNos?.split(',').map((item) => {
const { operationNo, status, statusText } = parseOperationNo(item)
const { type, style } = operationStatusTagMap[status] || {}
......@@ -428,7 +474,7 @@ const podOrderDetailsColumns = computed(() => [
</div>
)
})}
{!props.isNewOrder && row.podJomallUsNo}
{props.wallType === 'us' && row.podJomallUsNo}
</div>
)
},
......@@ -490,14 +536,43 @@ watch(visible, async (value: boolean) => {
if (value) {
podOrderDetailsData.value = {}
currentCode = ''
const localRaw = props.isNewOrder
? localStorage.getItem('localNewWarehouseId')
: localStorage.getItem('locaclWarehouseId')
const localId = localRaw ? JSON.parse(localRaw) : ''
/* 先找一次,确认本地值是否存在于列表 */
const hit = props.warehouseList.find((w) => w.id == localId)
warehouseId.value = hit ? localId : props.warehouseList[0]?.id
_warehouseId.value = hit ? localId : props.warehouseList[0]?.id
if (props.wallType === 'sort') {
await getSortingAreaList()
}
let localRaw = ''
switch (props.wallType) {
case 'us':
localRaw = localStorage.getItem('locaclWarehouseId') || ''
break
case 'print':
localRaw = localStorage.getItem('localNewWarehouseId') || ''
break
case 'sort':
localRaw = localStorage.getItem('localSortingAreaId') || ''
break
}
const localData = localRaw ? JSON.parse(localRaw) : ''
// 配货分拣 存仓库+配货区
if (props.wallType === 'sort') {
const localSortingAreaId = localData.sortingAreaId
const localWarehouseId = localData.warehouseId
const hit = sortingAreaList.value.find(
(item) =>
item.id === localSortingAreaId &&
item.warehouseId === localWarehouseId,
)
if (hit) {
sortingAreaId.value = hit.id
warehouseId.value = hit.warehouseId
isAutoPrint.value = hit.autoPrint
}
} else {
/* 先找一次,确认本地值是否存在于列表 */
const hit = props.warehouseList.find((w) => w.id == localData)
warehouseId.value = hit ? localData : props.warehouseList[0]?.id
_warehouseId.value = hit ? localData : props.warehouseList[0]?.id
}
if (userStore.user?.factory.id) {
try {
......@@ -512,6 +587,8 @@ watch(visible, async (value: boolean) => {
code: props.wsOpenCode,
factoryNo: userStore.user?.factory.id,
warehouseId: warehouseId.value,
packingId:
props.wallType === 'sort' ? sortingAreaId.value : undefined,
})
} catch (error) {
console.error(error)
......@@ -519,6 +596,7 @@ watch(visible, async (value: boolean) => {
}
initOrderDetailBox()
initPrintDevice()
const locaclPrinter = localStorage.getItem('sheetPrinter')
if (locaclPrinter) sheetPrinter.value = JSON.parse(locaclPrinter)
emit('set-printer', sheetPrinter.value)
......@@ -528,6 +606,7 @@ watch(visible, async (value: boolean) => {
code: props.wsCloseCode,
factoryNo: userStore.user?.factory.id,
warehouseId: warehouseId.value,
packingId: sortingAreaId.value,
})
socket.close()
}
......@@ -535,7 +614,6 @@ watch(visible, async (value: boolean) => {
})
watch(boxIndex, (value: number | null) => {
// if (value) {
console.log('boxIndex11111', value)
const bool = !boxChange.value
boxChange.value = false
......@@ -597,7 +675,6 @@ const renderItemBox = (bool: boolean) => {
renderLock = true
let boxItem = podBoxList.value?.find((item) => item.box === boxIndex.value)
console.log(boxItem, 'boxItem')
if (!boxItem) boxItem = { data: { productList: [] } }
const { data } = boxItem
data?.productList?.forEach((el) => {
......@@ -658,8 +735,22 @@ const renderItemBox = (bool: boolean) => {
if (productList.every((item) => item.power)) {
if (userStore.user?.id !== boxItem.fromUser) return
// 配货分拣 非自动打单的配货区: 不打印 不打单完成; 自动打单的配货区: 打印后打单完成
if (props.wallType === 'sort' && !isAutoPrint.value) {
renderLock = false
return
}
print(data, false, () => {
if (props.wallType === 'sort' && isAutoPrint.value) {
submitInspection(() => {
getPackingData(currentCode)
renderLock = false
return
})
}
renderLock = false
return
})
} else {
renderLock = false
......@@ -669,7 +760,12 @@ const messageChange = (data: WebSocketMessage) => {
if (!data) return
const { code, ...more } = data
if (code === 'POD_PRINT_ORDER' || code === 'FACTORY_POD_ORDER_PRINT_ORDER') {
// 扫码进箱
if (
code === 'POD_PRINT_ORDER' ||
code === 'FACTORY_POD_ORDER_PRINT_ORDER' ||
code === 'FACTORY_POD_ORDER_TOP_PRINT_ORDER'
) {
try {
if (typeof more.txt === 'string') {
console.log(
......@@ -684,15 +780,17 @@ const messageChange = (data: WebSocketMessage) => {
console.log('WebSocketMessage', more)
setPodBoxList(more)
} else if (
}
// 清空箱子
else if (
code === 'POD_BOX_FLUSH' ||
code === 'FACTORY_POD_ORDER_BOX_FLUSH'
code === 'FACTORY_POD_ORDER_BOX_FLUSH' ||
code === 'FACTORY_POD_ORDER_TOP_BOX_FLUSH'
) {
initOrderDetailBox()
}
}
const setPodBoxList = (data: WebSocketMessage) => {
console.log(data, 'datatatata')
const obj = data.txt
if (obj && typeof obj === 'string') {
const parsedData = JSON.parse(obj)
......@@ -753,7 +851,12 @@ const handleSearch = () => {
* printIng 打印中
* notPrintSuccess 未能获取打印状态
*/
if (podOrderDetailsData.value?.printResult === 'printSuccess') {
// 配货分拣 自动打单(无需校验是否打单成功)
if (
props.wallType !== 'sort' &&
podOrderDetailsData.value?.printResult === 'printSuccess'
) {
submitInspection(() => {
getPackingData(code)
})
......@@ -781,23 +884,38 @@ const getPackingData = async (code: string) => {
productionOrder.value = ''
return
}
if (!warehouseId.value) {
if (props.wallType !== 'sort' && !warehouseId.value) {
return ElMessage.warning('请选择仓库')
}
const url = props.isNewOrder
? 'factory/podOrderPacking/local/putPackingSafe'
: 'factory/podJomallOrderUs/local/putPackingSafe'
let url = ''
switch (props.wallType) {
case 'us':
url = 'factory/podJomallOrderUs/local/putPackingSafe'
break
case 'print':
url = 'factory/podOrderPacking/local/putPackingSafe'
break
case 'sort':
url = 'factory/podOrderPacking/top/putPackingSafe'
break
}
let params = {}
if (props.isNewOrder) {
if (props.wallType === 'us') {
params = {
podOperationNo: code,
podJomallUsNo: code,
box: boxIndex.value,
factoryNo,
warehouseId: warehouseId.value,
}
} else if (props.wallType === 'sort') {
params = {
podOperationNo: code,
box: boxIndex.value,
factoryNo,
}
} else {
params = {
podJomallUsNo: code,
podOperationNo: code,
box: boxIndex.value,
factoryNo,
warehouseId: warehouseId.value,
......@@ -811,12 +929,22 @@ const getPackingData = async (code: string) => {
productionOrder.value = ''
return
}
const { box, data } = res.data
console.log('box', box)
const { box, data, packingId, factoryNo: respFactoryNo } = res.data
// if (box) {
// 配货分拣 扫码
if (props.wallType === 'sort') {
const area = sortingAreaList.value.find((item) => item.id == packingId)
const areaChanged =
sortingAreaId.value != packingId ||
(!!area && warehouseId.value != area.warehouseId)
syncSortingArea(packingId as number, respFactoryNo ?? factoryNo)
if (areaChanged) {
await initOrderDetailBox()
}
}
boxChange.value = true
boxIndex.value = box as number
// }
if (boxIndex.value == 0) {
podOrderDetailsData.value = data as OrderData
podOrderDetailsData.value.fromUser = userStore.user?.id
......@@ -835,11 +963,6 @@ const getPackingData = async (code: string) => {
})
}
}
// renderItemBox(true)
console.log('podBoxList', podBoxList.value)
// }
} catch (error) {
const err = error as BaseRespData<{
inventory: number
......@@ -847,7 +970,7 @@ const getPackingData = async (code: string) => {
availableInventory: number
thirdSkuCode?: string
}>
if (props.isNewOrder && err?.code === 301) {
if (props.wallType === 'print' && err?.code === 301) {
loading.close()
await ElMessageBox.alert(
`${err.data?.thirdSkuCode}库存不足,无法进入生产!请联系仓库管理人员核对库存。<br/>
......@@ -873,17 +996,19 @@ const submitInspection = async (callback: () => void) => {
return
}
try {
const url = props.isNewOrder
? 'factory/podOrderPacking/podPrintOrderComplete'
: 'factory/podJomallOrderUs/podPrintOrderComplete'
const url =
props.wallType === 'us'
? 'factory/podJomallOrderUs/podPrintOrderComplete'
: 'factory/podOrderPacking/podPrintOrderComplete'
let params = {}
if (props.isNewOrder) {
if (props.wallType === 'us') {
params = {
orderParamList: [{ id: podOrderDetailsData.value?.id }],
orderId: podOrderDetailsData.value?.id,
}
} else {
params = {
orderId: podOrderDetailsData.value?.id,
orderParamList: [{ id: podOrderDetailsData.value?.id }],
}
}
const res = await submitInspectionApi(
......@@ -891,6 +1016,7 @@ const submitInspection = async (callback: () => void) => {
params,
boxIndex.value,
warehouseId.value,
sortingAreaId.value,
)
if (res.code !== 200) return
ElMessage.warning(res.message)
......@@ -912,7 +1038,7 @@ const initOrderDetailBox = async () => {
if (!factoryNo) {
return
}
if (!warehouseId.value) {
if (props.wallType !== 'sort' && !warehouseId.value) {
return ElMessage.warning('请选择仓库')
}
const loading = ElLoading.service({
......@@ -922,11 +1048,17 @@ const initOrderDetailBox = async () => {
})
try {
const url = props.initUrl
const res = await getPodBoxListApi(url, factoryNo, warehouseId.value)
const res = await getPodBoxListApi(
url,
factoryNo,
warehouseId.value,
sortingAreaId.value,
)
if (res.code !== 200) {
ElMessage.warning(res.message)
return
}
orderStore.setPodBoxList({
url,
boxList: res.data,
......@@ -956,9 +1088,14 @@ const initOrderDetailBox = async () => {
}
return item
})
podOrderDetailsData.value =
boxList.find((item) => item.data)?.data || undefined
boxIndex.value = boxList.find((item) => item.data)?.box || null
const currentBox = boxIndex.value
const currentBoxItem = currentBox
? boxList.find((item) => item.box === currentBox && item.data)
: undefined
const fallbackItem = boxList.find((item) => item.data)
const targetItem = currentBoxItem || fallbackItem
podOrderDetailsData.value = targetItem?.data || undefined
boxIndex.value = targetItem?.box || null
podOrderDetailsData.value?.productList?.forEach((el) => {
if (!el.previewImgs) {
......@@ -986,6 +1123,11 @@ const initOrderDetailBox = async () => {
})
const boxs = pickFinished.map((item) => item.box)
if (boxs.length > 0) {
if (props.wallType === 'sort') {
console.log(podOrderDetailsData, 'boxspodOrderDetailsData')
return
}
nextTick(async () => {
try {
await ElMessageBox.alert(
......@@ -1046,7 +1188,8 @@ const nextStep = async (callback: () => void) => {
if (
everyPicked &&
(podOrderDetailsData.value?.printResult === 'printSuccess' ||
podOrderDetailsData.value?.printResult === 'notPrintSuccess')
podOrderDetailsData.value?.printResult === 'notPrintSuccess') &&
props.wallType !== 'sort'
) {
try {
await ElMessageBox.alert(
......@@ -1101,14 +1244,17 @@ const handleClearBox = async () => {
}
try {
const url = props.isNewOrder
? 'factory/podOrderPacking/local/delPodBoxOrderDetailsByBox'
: 'factory/podJomallOrderUs/local/delPodBoxOrderDetailsByBox'
const url =
props.wallType === 'us'
? 'factory/podJomallOrderUs/local/delPodBoxOrderDetailsByBox'
: 'factory/podOrderPacking/local/delPodBoxOrderDetailsByBox'
const res = await clearBoxApi(
url,
factoryNo,
boxIndex.value || null,
warehouseId.value,
sortingAreaId.value,
)
if (res.code !== 200) {
ElMessage.warning(res.message)
......@@ -1219,13 +1365,15 @@ const clearAllBox = async () => {
return
}
try {
const url = props.isNewOrder
? 'factory/podOrderPacking/local/delPodBoxOrderDetails'
: 'factory/podJomallOrderUs/local/delPodBoxOrderDetails'
const url =
props.wallType === 'us'
? 'factory/podJomallOrderUs/local/delPodBoxOrderDetails'
: 'factory/podOrderPacking/local/delPodBoxOrderDetails'
const res = await clearAllBoxApi(
url,
warehouseId.value,
userStore.user?.factory.id,
sortingAreaId.value,
)
if (res.code !== 200) return
productionOrderRef.value.focus()
......@@ -1249,6 +1397,47 @@ const handleCurrentChange = (url: string) => {
}
const warehouseId = ref<string | number>('')
const _warehouseId = ref<string | number>('')
const sortingAreaList = ref<SortingList[]>([])
const sortingAreaId = ref<number | string>('')
const isAutoPrint = ref<boolean>(false) // 当前配货区是否自动打单
// 配货分拣 更新配货区
const syncSortingArea = (
packingId: number | string,
factoryNo: number | string,
) => {
const currentArea = sortingAreaList.value.find((item) => item.id == packingId)
if (!currentArea) return
if (
sortingAreaId.value == packingId &&
warehouseId.value == currentArea.warehouseId
) {
return
}
warehouseId.value = currentArea.warehouseId
sortingAreaId.value = packingId
isAutoPrint.value = currentArea.autoPrint
socket.send({
code: props.wsOpenCode,
factoryNo,
warehouseId: warehouseId.value,
packingId: sortingAreaId.value,
})
}
// 配货分拣 手动切换配货区
const handleSortingAreaChange = (
value: string | number,
factoryNo?: number | string,
) => {
const no = factoryNo ?? userStore.user?.factory.id
if (!no) return
syncSortingArea(value, no)
emit('set-warehouseId', {
warehouseId: warehouseId.value,
sortingAreaId: sortingAreaId.value,
})
initOrderDetailBox()
}
// 手动切换仓库
const handleWarehouseChange = (value: string | number) => {
if (!value) return
if (_warehouseId.value !== warehouseId.value) {
......@@ -1309,12 +1498,23 @@ const reconnectWebSocket = async () => {
code: props.wsOpenCode,
factoryNo: userStore.user?.factory.id,
warehouseId: warehouseId.value,
packingId: sortingAreaId.value,
})
} catch (error) {
console.error('WebSocket 重连失败:', error)
ElMessage.error('WebSocket 重连失败,请稍后重试')
}
}
// 配货分拣 获取配货区列表
const getSortingAreaList = async () => {
const res = await getSortingRuleListApi({})
if (res.code !== 200) return
sortingAreaList.value = res.data.records
sortingAreaId.value = res.data.records[0].id
warehouseId.value = res.data.records[0].warehouseId
isAutoPrint.value = res.data.records[0].autoPrint
}
</script>
<style scoped lang="scss">
......@@ -1354,6 +1554,30 @@ const reconnectWebSocket = async () => {
flex: 1;
overflow: hidden;
}
.right-panel {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
overflow: hidden;
}
.right-panel-body {
min-height: 0;
overflow: hidden;
}
.sorting-area-content {
border: 2px solid #666;
padding: 10px;
margin-bottom: 10px;
width: 100%;
height: 80px;
font-size: 35px;
color: red;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
}
.middle-content {
width: 500px;
display: flex;
......@@ -1443,7 +1667,7 @@ const reconnectWebSocket = async () => {
}
.order-image {
flex: 1;
overflow: hidden;
overflow: auto;
border: 1px solid #ddd;
background: #eee;
}
......
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