Commit 20b5f95f by qinjianhui

Merge branch 'dev_new_order_intercept' into 'dev'

Dev new order intercept

See merge request !209
parents 7bb0575c ba2110e0
......@@ -2,6 +2,7 @@ import axios from './axios'
import type { BasePaginationData, BaseRespData } from '@/types/api'
import type { CancelOrderProcessStateGroupMap } from '@/types/api/cancelOrderProcess'
import type { operateOrderListData } from '@/types/api/factoryOrderNew'
import { InterskuList } from '@/types/api/warehouse'
function normalizePodOrderQueryPayload(
data: Record<string, unknown>,
......@@ -20,7 +21,7 @@ function normalizePodOrderQueryPayload(
export function getCancelOrderProcessStateGroupMapApi() {
return axios.get<never, BaseRespData<CancelOrderProcessStateGroupMap>>(
'factory/podOrderOperationForReclaim/findStateGroupMap',
'factory/podOrderOperation/find-state-group-map',
)
}
......@@ -32,13 +33,13 @@ export function getCancelOrderProcessListApi(
) {
const body = normalizePodOrderQueryPayload({ ...data })
return axios.post<never, BasePaginationData<operateOrderListData>>(
'factory/podOrderOperationForReclaim/list_page',
'factory/podOrderOperation/list-page',
{ ...body, currentPage, pageSize, alreadyInStock },
)
}
export function getOperationInfoByNoApi(operationNo: string) {
return axios.get<never, BaseRespData<operateOrderListData>>(
`factory/podOrderOperationForReclaim/getByOperationNo?operationNo=${operationNo}`,
`factory/podOrderOperation/get-by-operation-no?operationNo=${operationNo}`,
)
}
export function completeDeliveryByCancelOrderProcessApi(data: {
......@@ -47,7 +48,14 @@ export function completeDeliveryByCancelOrderProcessApi(data: {
warehouseId: number
}) {
return axios.post<never, BaseRespData<never>>(
'factory/podOrderOperationForReclaim/storeAfterScan',
'factory/podOrderOperation/store-after-scan',
data,
)
}
export function getBySkuAndUserMarkAndInboundTypeApi(operationNo: string[]) {
return axios.post<never, BaseRespData<InterskuList[]>>(
'factory/podOrderOperation/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,
......
......@@ -151,11 +151,11 @@ const menu: MenuItem[] = [
id: 12,
label: '工厂订单(NEW)',
},
// {
// index: '/order/cancel-order-process',
// id: 13,
// label: '取消后订单处理',
// },
{
index: '/order/cancel-order-process',
id: 13,
label: '取消后订单处理',
},
],
},
{
......
......@@ -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
......
......@@ -327,6 +327,7 @@
</div>
<FastProduction
v-model:detail-visible="detailVisible"
:dialog-title="dialogTitle"
:is-new-order="true"
:detail-data="detailData"
:fast-key="fastKey"
......@@ -385,6 +386,7 @@ import {
getCancelOrderProcessStateGroupMapApi,
getOperationInfoByNoApi,
completeDeliveryByCancelOrderProcessApi,
getBySkuAndUserMarkAndInboundTypeApi,
} from '@/api/cancelOrderProcess'
import type { CardLayoutListFetcher } from '@/types/api/factoryOrderNew'
import LogisticsWaySelect from '@/views/logistics/components/LogisticsWaySelect'
......@@ -393,7 +395,6 @@ import ProductTypeFilter from '../factoryOrderNew/component/ProductTypeFilter.vu
import { CaretBottom, CaretTop } from '@element-plus/icons-vue'
import { normalizeProductMarkListForQuery } from '../factoryOrderNew/utils/productMarkQuery'
import FastProduction from '../components/FastProduction.vue'
import { ResultInfoDataItem } from '@/types/api/order/common'
import { ElButton } from 'element-plus'
import ReceiptProductDialog from '@/views/warehouse/components/ReceiptProductDialog.vue'
import { useValue } from '@/utils/hooks/useValue'
......@@ -412,6 +413,7 @@ import {
warehouseInfoGetAll,
} from '@/api/warehouse'
import type { CancelOrderProcessStateGroupMap } from '@/types/api/cancelOrderProcess'
import BigNumber from 'bignumber.js'
const cardLayoutRef = ref()
......@@ -545,23 +547,14 @@ const completeOperationById = (_: number[], detail: Record<string, unknown>) =>
warehouseId: detail.warehouseId as number,
inboundType: fastInboundType.value,
})
const handleFastProductionSuccess = (data: ResultInfoDataItem[]) => {
const result = data[0]
if (!result.status) {
ElMessageBox.alert(
`操作单号 ${result.factoryOrderNumber} ${result.message}`,
'提示',
{
type: 'error',
},
)
return
}
const handleFastProductionSuccess = () => {
ElMessage.success('入库成功')
}
const fastClose = () => {
detailVisible.value = false
if (fastKey.value === 'detail') return
search()
loadOrderStatusCounts()
}
const {
userMarkList,
......@@ -614,7 +607,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
......@@ -622,6 +618,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,
......@@ -630,8 +636,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,
......@@ -641,20 +647,40 @@ function mapInterskuToProduct(val: InterskuList): InterProductList {
}
const handleEmbryoInStock = async () => {
if (cardSelectList.value.length !== 0) {
handleEmbryoInStockByCard()
handleEmbryoInStockByCard('embryoInStock')
} else {
handleEmbryoInFastStock(0)
}
}
const dialogTitle = computed(() => {
return fastKey.value === 'fastReceipt'
? fastInboundType.value === 1
? '生产完成-快捷入库'
: '胚衣-快捷入库'
: '查看详情'
})
const handleEmbryoInFastStock = (inboundType: number) => {
fastInboundType.value = inboundType
fastKey.value = 'fastReceipt'
detailVisible.value = true
detailData.value = {}
}
const handleEmbryoInStockByCard = async () => {
const firstWid = cardSelectList.value[0].warehouseId
if (cardSelectList.value.some((r) => r.warehouseId !== firstWid)) {
const handleEmbryoInStockByCard = async (
type: 'completeProduction' | 'embryoInStock',
) => {
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()
......@@ -674,8 +700,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
......@@ -685,11 +710,16 @@ const handleEmbryoInStockByCard = async () => {
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const skus = cardSelectList.value.map((r) => r.thirdSkuCode as string)
const res = await getBySkuAndUserMarkApi(firstWid, skus.join(','), null)
const skus = operationList.map((r) => r.thirdSkuCode as string)
const res =
type === 'embryoInStock'
? await getBySkuAndUserMarkApi(firstWid, skus.join(','), null)
: 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()
......@@ -758,7 +788,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
......@@ -780,17 +820,31 @@ 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()
} catch (e) {
console.error(e)
} finally {
......@@ -800,11 +854,7 @@ const handleReceiptSave = async () => {
const handleProductionCompleteInStock = () => {
// 客户定制的单子不能操作生产完成入库,提示:客户定制商品,不能入库!
if (cardSelectList.value.length !== 0) {
if (cardSelectList.value.some((r) => r.inboundType === 2)) {
ElMessage.error('客户定制商品,不能入库!')
return
}
handleEmbryoInStockByCard()
handleEmbryoInStockByCard('completeProduction')
} else {
handleEmbryoInFastStock(1)
}
......
......@@ -323,7 +323,7 @@ const title = computed(() => {
if (props.fastKey === 'fastProduction') {
return '快捷生产'
} else if (props.fastKey === 'fastReceipt') {
return '快捷入库'
return props.dialogTitle
} else {
return '查看详情'
}
......@@ -388,18 +388,13 @@ const props = withDefaults(
downloadApi?: (
ids: number[],
) => Promise<{ code?: number; message?: string }>
/** 打开弹框时「自动完成上一单」的初始勾选;默认 false,与原有 podCN 快捷生产一致 */
defaultAutoSure?: boolean
/** 为 true 时展示「操作单号」一行,数据字段为 `operationNo`(不影响 podCN 默认) */
showOperationNoRow?: boolean
/** 查询无数据时的提示 */
notFoundMessage?: string
/** 未生产完成提醒里对单号的称呼,如「生产单号」「操作单号」 */
pendingOrderLabel?: string
/** 未扫码时的提示 */
pleaseScanTip?: string
/** 扫码输入为空时音频/提示文案 */
searchInputAudioTip?: string
dialogTitle?: string
}>(),
{
type: 0,
......@@ -420,6 +415,7 @@ const props = withDefaults(
completeApi: (ids: number[], detailData: Record<string, unknown>) =>
productionQueryApi(ids[0], Number(detailData.podJomallOrderCnId || -1)),
downloadApi: (ids: number[]) => downloadMaterialApi(ids),
dialogTitle: '',
},
)
const emit = defineEmits(['update:detailVisible', 'close', 'onSuccess'])
......@@ -553,7 +549,7 @@ const confirmQuery = (len: HistoryDataItem[], i: number) => {
TrackingNumber.value = el.orderNumber
await trackCodeInput()
await setData(el.orderNumber)
ElMessage.success('生产完成')
ElMessage.success(`${props.fastKey === 'fastProduction' ? '生产完成' : '入库完成'}`)
if (len[i + 1]) {
confirmQuery(len, i + 1)
}
......@@ -580,7 +576,7 @@ const changeStatus = async () => {
if (!detail.value || Object.keys(detail.value).length <= 1) {
return ElMessage.warning(props.pleaseScanTip)
}
showConfirm('确定生产完成?', {
showConfirm(`确定${props.fastKey === 'fastProduction' ? '生产完成' : '入库完成'}?`, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
......
......@@ -1796,13 +1796,13 @@ const operationOrderColumns = [
key: 'imageAry',
prop: 'imageAry',
label: '商品图片',
minWidth: 100,
minWidth: 180,
align: 'center',
render: (row: operateOrderListData) => {
const list = parseOperationOrderImageAry(row.imageAry)
if (!list.length) {
return (
<div>
<div style="display:flex;gap:4px;">
<el-image
src={row.variantImage}
style="width:50px;height:50px"
......
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