Commit 20d0eefb by qinjianhui

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

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