Commit 20d0eefb by qinjianhui

fix: 升成完成入库接口联调

parent b9e42c95
......@@ -21,7 +21,7 @@ function normalizePodOrderQueryPayload(
export function getCancelOrderProcessStateGroupMapApi() {
return axios.get<never, BaseRespData<CancelOrderProcessStateGroupMap>>(
'factory/podOrderOperationForReclaim/findStateGroupMap',
'factory/podOrderOperationForReclaim/find-state-group-map',
)
}
......@@ -33,13 +33,13 @@ export function getCancelOrderProcessListApi(
) {
const body = normalizePodOrderQueryPayload({ ...data })
return axios.post<never, BasePaginationData<operateOrderListData>>(
'factory/podOrderOperationForReclaim/list_page',
'factory/podOrderOperationForReclaim/list-page',
{ ...body, currentPage, pageSize, alreadyInStock },
)
}
export function getOperationInfoByNoApi(operationNo: string) {
return axios.get<never, BaseRespData<operateOrderListData>>(
`factory/podOrderOperationForReclaim/getByOperationNo?operationNo=${operationNo}`,
`factory/podOrderOperationForReclaim/get-by-operation-no?operationNo=${operationNo}`,
)
}
export function completeDeliveryByCancelOrderProcessApi(data: {
......@@ -48,14 +48,14 @@ export function completeDeliveryByCancelOrderProcessApi(data: {
warehouseId: number
}) {
return axios.post<never, BaseRespData<never>>(
'factory/podOrderOperationForReclaim/storeAfterScan',
'factory/podOrderOperationForReclaim/store-after-scan',
data,
)
}
export function getBySkuAndUserMarkAndInboundTypeApi(operationNo: string[]) {
return axios.post<never, BaseRespData<InterskuList[]>>(
'factory/podOrderOperationForReclaim/getProductByOperationNo',
'factory/podOrderOperationForReclaim/get-product-by-operation-no',
operationNo,
)
}
......@@ -394,7 +394,7 @@ export function rejectInRecordApi({
)
}
export function addInRecordApi(form: InterWarehouseDetail) {
return axios.post<never, BaseRespData<never>>(
return axios.post<never, BaseRespData<unknown>>(
'factory/warehouseInRecord/add',
{
...form,
......
......@@ -123,6 +123,8 @@ export interface InterskuList {
remark?: string | null
currencyName?: string | null
currencyCode?: string | null
buyStored?: number | null
totalPrice?: number | null
}
export interface ILocation {
id?: number
......
......@@ -385,7 +385,7 @@ import {
getCancelOrderProcessStateGroupMapApi,
getOperationInfoByNoApi,
completeDeliveryByCancelOrderProcessApi,
getBySkuAndUserMarkAndInboundTypeApi
getBySkuAndUserMarkAndInboundTypeApi,
} from '@/api/cancelOrderProcess'
import type { CardLayoutListFetcher } from '@/types/api/factoryOrderNew'
import LogisticsWaySelect from '@/views/logistics/components/LogisticsWaySelect'
......@@ -413,6 +413,7 @@ import {
warehouseInfoGetAll,
} from '@/api/warehouse'
import type { CancelOrderProcessStateGroupMap } from '@/types/api/cancelOrderProcess'
import BigNumber from 'bignumber.js'
const cardLayoutRef = ref()
......@@ -616,7 +617,10 @@ const { skuData, setCostPrice, filterSkuData } = useReceiptProductDialog({
selectSku: receiptSelectSku,
userMarkList: receiptUserMarkList,
})
function mapInterskuToProduct(val: InterskuList): InterProductList {
function mapInterskuToProduct(
val: InterskuList,
type: 'completeProduction' | 'embryoInStock',
): InterProductList {
const warehouseSku = val.warehouseSku || val.sku || ''
const skuNameVal = val.skuName || val.productName || ''
let customerId: number | null = null
......@@ -624,6 +628,16 @@ function mapInterskuToProduct(val: InterskuList): InterProductList {
const n = Number(val.customerId)
if (!Number.isNaN(n)) customerId = n
}
if (type === 'embryoInStock') {
const operationList = cardSelectList.value.filter(
(r) => r.thirdSkuCode === val.warehouseSku,
)
val.buyStored = operationList ? operationList.length : 0
}
const amount = new BigNumber(val.buyStored ?? 0)
.multipliedBy(val.costPrice ?? 0)
.toFixed(2)
val.totalPrice = Number(amount) as number
return {
skuImage: val.skuImage || val.image || '',
warehouseSku,
......@@ -632,8 +646,8 @@ function mapInterskuToProduct(val: InterskuList): InterProductList {
locationCode: val.locationCode ?? '',
locationId: val.locationId ?? null,
costPrice: val.costPrice ?? null,
buyStored: null,
totalPrice: null,
buyStored: val.buyStored ?? null,
totalPrice: val.totalPrice ?? null,
currencyName: val.currencyName ?? null,
currencyCode: val.currencyCode ?? null,
customerId,
......@@ -657,8 +671,19 @@ const handleEmbryoInFastStock = (inboundType: number) => {
const handleEmbryoInStockByCard = async (
type: 'completeProduction' | 'embryoInStock',
) => {
const firstWid = cardSelectList.value[0].warehouseId
if (cardSelectList.value.some((r) => r.warehouseId !== firstWid)) {
let operationList
if (type === 'completeProduction') {
operationList = cardSelectList.value.filter((r) => r.inboundType !== 2)
if (operationList.length === 0) {
ElMessage.error('客户定制商品,不能入库!')
return
}
} else {
operationList = cardSelectList.value
}
fastInboundType.value = type === 'completeProduction' ? 1 : 0
const firstWid = operationList[0].warehouseId
if (operationList.some((r) => r.warehouseId !== firstWid)) {
return ElMessage.error('请选择相同仓库的库存SKU!')
}
resetReceiptEditForm()
......@@ -678,8 +703,7 @@ const handleEmbryoInStockByCard = async (
}
}
receiptEditForm.value.warehouseId = firstWid
receiptEditForm.value.warehouseName = cardSelectList.value[0]
.warehouseName as string
receiptEditForm.value.warehouseName = operationList[0].warehouseName as string
const wh = warehouseList.value.find((w) => w.id == firstWid)
if (wh) {
receiptEditForm.value.warehouseName = wh.name
......@@ -689,14 +713,16 @@ const handleEmbryoInStockByCard = async (
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const skus = cardSelectList.value.map((r) => r.thirdSkuCode as string)
const skus = operationList.map((r) => r.thirdSkuCode as string)
const res =
type === 'embryoInStock'
? await getBySkuAndUserMarkApi(firstWid, skus.join(','), null)
: await getBySkuAndUserMarkAndInboundTypeApi(cardSelectList.value.map((r) => r.operationNo as string))
: await getBySkuAndUserMarkAndInboundTypeApi(
operationList.map((r) => r.operationNo as string),
)
if (res.code !== 200) return
otherPurchaseData.value = res.data.map((item: InterskuList) =>
mapInterskuToProduct(item),
mapInterskuToProduct(item, type),
)
await fetchReceiptLocationList('')
const listRes = await warehouseInfoGetAll()
......@@ -765,7 +791,17 @@ const handleReceiptSave = async () => {
} catch {
return
}
const arr = otherPurchaseData.value
const arr = otherPurchaseData.value.map((item) => {
const operationForReclaimList = cardSelectList.value.filter((r) =>
fastInboundType.value === 1
? `${r.userMark}${r.variantSku}` === item.warehouseSku
: r.thirdSkuCode === item.warehouseSku,
)
return {
...item,
operationForReclaimList: operationForReclaimList,
}
})
if (arr.length === 0) {
ElMessage.error('请至少选择一条数据')
return
......@@ -787,16 +823,28 @@ const handleReceiptSave = async () => {
}
}
const params = {
forNewProduct: fastInboundType.value === 1,
...receiptEditForm.value,
productList: otherPurchaseData.value,
productList: arr,
}
const loading = ElLoading.service({
text: '保存中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
await addInRecordApi(params)
ElMessage.success('保存成功')
const res = await addInRecordApi(params)
if (res.code !== 200) return
if (res.data && Array.isArray(res.data) && res.data.length > 0) {
ElMessageBox.alert(
`操作单号: ${res.data.map((e: number) => e).join(',')}入库失败`,
'提示',
{
type: 'error',
},
)
} else {
ElMessage.success('保存成功')
}
receiptDialogVisible.value = false
search()
loadOrderStatusCounts()
......@@ -809,10 +857,6 @@ const handleReceiptSave = async () => {
const handleProductionCompleteInStock = () => {
// 客户定制的单子不能操作生产完成入库,提示:客户定制商品,不能入库!
if (cardSelectList.value.length !== 0) {
if (cardSelectList.value.some((r) => r.inboundType === 2)) {
ElMessage.error('您选择的操作单包含客户定制商品,不能入库!')
return
}
handleEmbryoInStockByCard('completeProduction')
} else {
handleEmbryoInFastStock(1)
......
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