Commit 6d3b965d by wuqian

new-pod-cn

parent cc6f038d
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
WarehouseListData, WarehouseListData,
LogisticsData, LogisticsData,
ExportParams, ExportParams,
IconfirmSubmit
} from '@/types/api/podCnOrder' } from '@/types/api/podCnOrder'
import { InterceptStateGroupData } from '@/types/api/podUsOrder' import { InterceptStateGroupData } from '@/types/api/podUsOrder'
import axios from './axios' import axios from './axios'
...@@ -32,6 +33,24 @@ export function syncReceiverAddress(data: number[]) { ...@@ -32,6 +33,24 @@ export function syncReceiverAddress(data: number[]) {
data, data,
) )
} }
export function getPackingCnDataApi(
code: string,
factoryNo: number,
box: number | null,
warehouseId: number | string,
) {
return axios.get<never, BaseRespData<PodMakeOrderData>>(
'/factory/podJomallOrderCn/getPodBoxDetailsBySkuOrNo',
{
params: {
podJomallCnNo: code,
box,
factoryNo,
warehouseId,
},
},
)
}
export function refreshAddressApi(idList: number[]) { export function refreshAddressApi(idList: number[]) {
return axios.post<never, BaseRespData<never>>( return axios.post<never, BaseRespData<never>>(
'factory/podJomallOrderCn/syncReceiverAddress', 'factory/podJomallOrderCn/syncReceiverAddress',
...@@ -382,10 +401,10 @@ export function replenishmentSuccessApi(data: number[]) { ...@@ -382,10 +401,10 @@ export function replenishmentSuccessApi(data: number[]) {
) )
} }
//确认生产 //确认生产
export function confirmProductApi(orderIds: (string | number)[]) { export function confirmProductApi(data:IconfirmSubmit) {
return axios.post<never, BaseRespData<never>>( return axios.post<never, BaseRespData<never>>(
`factory/podJomallOrderCn/confirmProduct`, `factory/podJomallOrderCn/confirmProduct`,
orderIds, data,
) )
} }
export function toOutOfStockApi(ids: number[]) { export function toOutOfStockApi(ids: number[]) {
...@@ -450,6 +469,14 @@ export function batchDownloadRecomposingApi(params: { id: number }) { ...@@ -450,6 +469,14 @@ export function batchDownloadRecomposingApi(params: { id: number }) {
}, },
) )
} }
export function batchDownloadCnRecomposingApi(params: { id: number }) {
return axios.get<never, BaseRespData<never>>(
`factory/podBatchDownload/reCnComposingDesignImages`,
{
params,
},
)
}
// 生产完成 // 生产完成
export function updateToWaitShipmentApi(params: { export function updateToWaitShipmentApi(params: {
cnUpdateParams: Array<{ cnUpdateParams: Array<{
...@@ -515,7 +542,7 @@ export function updateSelfLogistics(params: { ...@@ -515,7 +542,7 @@ export function updateSelfLogistics(params: {
id?: string id?: string
}) { }) {
return axios.post<never, BaseRespData<never>>( return axios.post<never, BaseRespData<never>>(
'factory/podJomallOrderUs/updateSelfLogistics', 'factory/podJomallOrderCn/updateSelfLogistics',
params, params,
) )
} }
......
import { defineStore } from 'pinia'
import {
OrderData,
PodMakeOrderData,
ProductList,
} from '@/types/api/podMakeOrder'
import { getPodBoxListApi } from '@/api/podCnOrder'
export interface OrderStoreState {
podBoxList?: PodMakeOrderData[]
podBoxIndex?: number | null
socketConnect?: string
}
const useOrderStore = defineStore('order', {
state: () => {
return {
podBoxList: [],
podBoxIndex: null,
socketConnect: '',
} as OrderStoreState
},
actions: {
async setPodBoxList(content: {
boxList: PodMakeOrderData[] | OrderData | null
factoryNo: number | string
warehouseId: number | string
box?: number
data?: OrderData
}) {
const { factoryNo, warehouseId, boxList, box, data } = content
if (Array.isArray(boxList)) {
this.podBoxList = boxList
} else {
const index = this.podBoxList?.findIndex((item) => item.box === box)
if (index === -1) {
try {
const res = await getPodBoxListApi(factoryNo, warehouseId)
const boxList = res.data.map((item) => {
if (res.data) {
const productList = item?.data?.productList || []
const pickingNumber = productList.reduce(
(prev: number, item1: ProductList) => {
if (item1.count) {
return prev + item1.count
}
return prev
},
0,
)
if (item.data) {
item.data.pickingNumber = pickingNumber
}
}
return item
})
this.podBoxList = boxList
this.podBoxIndex = box
} catch (error) {
console.error(error)
}
} else if (box !== 0 && box !== undefined) {
const arr = this.podBoxList
if (arr) {
arr[box - 1] = {
box,
data: data || boxList || null,
}
}
this.podBoxList = arr
this.podBoxIndex = box
}
}
},
// 清空所有箱子
clearPodBoxList() {
this.podBoxList = []
},
// 设置当前箱子
setPodBox(box: number) {
this.podBoxIndex = box
},
// 清空当前箱子
clearPodBox() {
this.podBoxIndex = null
},
setSocketConnect(connect: string) {
this.socketConnect = connect
},
},
})
export default useOrderStore
...@@ -66,7 +66,6 @@ const useOrderStore = defineStore('order', { ...@@ -66,7 +66,6 @@ const useOrderStore = defineStore('order', {
data: data || boxList || null, data: data || boxList || null,
} }
} }
console.log('222arr1111', arr)
this.podBoxList = arr this.podBoxList = arr
this.podBoxIndex = box this.podBoxIndex = box
} }
......
...@@ -3,6 +3,11 @@ export interface Tab { ...@@ -3,6 +3,11 @@ export interface Tab {
statusName?: string statusName?: string
quantity?: number quantity?: number
} }
export interface IconfirmSubmit {
ids: string
warehouseId: number | null
warehouseName: string
}
export interface ExportParams extends SearchForm { export interface ExportParams extends SearchForm {
idList?: number[] idList?: number[]
exportAll: boolean exportAll: boolean
...@@ -32,6 +37,8 @@ export interface SearchForm { ...@@ -32,6 +37,8 @@ export interface SearchForm {
batchArrangeNumber?: string batchArrangeNumber?: string
craftCode?: string craftCode?: string
thirdStockSku?: string thirdStockSku?: string
exceptionHandling?: number | undefined
interceptStatus?: number | string
} }
export interface PodCnOrderListData { export interface PodCnOrderListData {
id: number id: number
...@@ -122,7 +129,9 @@ export interface ProductList { ...@@ -122,7 +129,9 @@ export interface ProductList {
isReplenishment?: boolean isReplenishment?: boolean
thirdSkuCode?: string | null thirdSkuCode?: string | null
supplierProductNo?: string | null supplierProductNo?: string | null
userMark?: string | null
replenishmentSumNum?: number | null replenishmentSumNum?: number | null
interceptStatus?: number | null
batchArrangeNumber?: string | null batchArrangeNumber?: string | null
} }
export interface cardImages { export interface cardImages {
......
...@@ -45,5 +45,6 @@ export interface ProductList { ...@@ -45,5 +45,6 @@ export interface ProductList {
power?: boolean power?: boolean
variantImage?: string variantImage?: string
podJomallUsNo?: string podJomallUsNo?: string
podJomallCnNo?: string
previewImgs?: { sort: string | number; title: string; url: string }[] previewImgs?: { sort: string | number; title: string; url: string }[]
} }
import { getWsUrl } from '../api/axios'
import useOrderStore from '../store/cnOrder'
interface NotificationOptions {
body: string
icon: string
data: string
requireInteraction: boolean
}
export interface WebSocketMessage {
code?: string
content?: string
type?: string
data?: unknown
[key: string]: string | unknown | undefined
}
interface InitOptions {
account: string
factoryNo: string
}
type MessageCallback = (
data: WebSocketMessage,
sendSystemMessage: (msg: string) => void,
) => void
type OpenCallback = () => void
function sendSystemMessage(msg: string): void {
if (window.Notification && Notification.permission === 'granted') {
const notificationOptions: NotificationOptions = {
body: msg,
icon: './favicon.ico',
data: 'I like peas.',
requireInteraction: true,
}
const n = new Notification('消息通知', notificationOptions)
n.onclick = (event: Event) => {
event.preventDefault()
window.open('/home', '_blank')
}
setTimeout(() => {
n.close()
}, 10000)
}
}
const showReconnectingMsg = (): void => {
ElMessageBox.alert('消息服务已断开,正在重新连接,请稍候', {
showClose: true,
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
}
class Im {
private socket: WebSocket | null = null
private _wsUrl: string = ''
// private userId: string = ''
private _onMessageCallback?: MessageCallback
private _onOpenCallback?: OpenCallback
private _heartbeatTimer: number | null = null
private _heartbeatTimeoutTimer: number | null = null
private _reconnectingTimer: number | null = null
private num: number = 0
constructor() {
this._onWsOpen = this._onWsOpen.bind(this)
this._onWsMessage = this._onWsMessage.bind(this)
this._onWsClose = this._onWsClose.bind(this)
this._onWsError = this._onWsError.bind(this)
}
private _onWsOpen(): void {
console.log('服务器连接成功')
localStorage.setItem('socket_connect', 'online')
this._onOpenCallback?.()
this._startHeartbeat()
}
private _onWsMessage(event: MessageEvent): void {
let data: WebSocketMessage = {}
if (typeof event.data === 'string') {
try {
data = JSON.parse(event.data)
} catch (error) {
data = {}
}
}
this._onHeartbeatMessage()
this._onMessageCallback?.(data, sendSystemMessage)
}
private _onWsClose(): void {
console.log('服务器关闭')
this._destroyWebSocket(true)
}
private _onWsError(): void {
console.log('连接出错')
this._destroyWebSocket(true)
}
private _sendHeartbeat(): void {
if (!this.socket) return
this.send({ code: 'HEALTH' })
if (this._heartbeatTimeoutTimer) {
window.clearTimeout(this._heartbeatTimeoutTimer)
}
this._heartbeatTimeoutTimer = window.setTimeout(() => {
this._destroyWebSocket(true)
}, 5 * 1000)
}
private _onHeartbeatMessage(): void {
console.log('心跳')
useOrderStore().setSocketConnect('online')
if (this._heartbeatTimeoutTimer) {
window.clearTimeout(this._heartbeatTimeoutTimer)
}
}
private _startHeartbeat(): void {
this._stopHeartbeat()
this._sendHeartbeat()
this._heartbeatTimer = window.setInterval(
() => this._sendHeartbeat(),
10 * 1000,
)
}
private _stopHeartbeat(): void {
if (this._heartbeatTimer) {
window.clearInterval(this._heartbeatTimer)
}
if (this._heartbeatTimeoutTimer) {
window.clearTimeout(this._heartbeatTimeoutTimer)
}
}
private _scheduleReconnect(): void {
if (!this.num) this.num = 0
this.num++
if (this.num > 5) {
ElMessageBox.alert('尝试重连消息服务失败,请刷新重试')
return
}
showReconnectingMsg()
this._reconnectingTimer = window.setTimeout(() => {
this._createWebSocket()
}, 2000)
}
private _destroyWebSocket(reconnect?: boolean): void {
if (!this.socket) return
this._stopHeartbeat()
if (this._reconnectingTimer) {
window.clearTimeout(this._reconnectingTimer)
}
this.socket.removeEventListener('open', this._onWsOpen)
this.socket.removeEventListener('message', this._onWsMessage)
this.socket.removeEventListener('close', this._onWsClose)
this.socket.removeEventListener('error', this._onWsError)
this.socket.close(1000)
this.socket = null
localStorage.removeItem('socket_connect')
useOrderStore().setSocketConnect('offline')
if (reconnect) this._scheduleReconnect()
}
private _createWebSocket(): void {
if (!this._wsUrl) return
const socket = new WebSocket(this._wsUrl)
socket.addEventListener('open', this._onWsOpen)
socket.addEventListener('message', this._onWsMessage)
socket.addEventListener('close', this._onWsClose)
socket.addEventListener('error', this._onWsError)
this.socket = socket
}
init(
options: InitOptions,
msgfunc?: MessageCallback,
openfunc?: OpenCallback,
): Promise<void> {
return new Promise((resolve, reject) => {
const { account, factoryNo } = options
const socket_connect = localStorage.getItem('socket_connect')
if (socket_connect === 'online') {
resolve()
return
}
if (!window.WebSocket) {
reject(new Error('WebSocket is not supported'))
return
}
this._onMessageCallback = msgfunc
this._onOpenCallback = () => {
openfunc?.()
resolve()
}
this._destroyWebSocket()
this._wsUrl = `${getWsUrl()}/ws/websocket/${factoryNo}/${account}`
this._createWebSocket()
})
}
send(options: WebSocketMessage): void {
this.socket?.send(JSON.stringify(options))
}
close(): void {
this._destroyWebSocket()
}
}
export default new Im()
...@@ -227,17 +227,18 @@ import { ...@@ -227,17 +227,18 @@ import {
PodMakeOrderData, PodMakeOrderData,
ProductList, ProductList,
} from '@/types/api/podMakeOrder' } from '@/types/api/podMakeOrder'
import useOrderStore from '@/store/order' import useOrderStore from '@/store/cnOrder'
import { import {
getPackingCnDataApi,
clearBoxApi, clearBoxApi,
clearAllBoxApi, clearAllBoxApi,
getPackingDataApi,
getPodBoxListApi, getPodBoxListApi,
submitInspectionApi, submitInspectionApi,
} from '@/api/podUsOrder' } from '@/api/podCnOrder'
import useUserStore from '@/store/user' import useUserStore from '@/store/user'
import { Check } from '@element-plus/icons-vue' import { Check } from '@element-plus/icons-vue'
import socket from '@/utils/websocket' import socket from '@/utils/cnWebsocket'
import { WarehouseListData } from '@/types/api/podUsOrder' import { WarehouseListData } from '@/types/api/podUsOrder'
const { getCLodop } = useLodop() const { getCLodop } = useLodop()
...@@ -272,7 +273,7 @@ const podOrderDetailsColumns = computed(() => [ ...@@ -272,7 +273,7 @@ const podOrderDetailsColumns = computed(() => [
}, },
{ {
label: '生产单号', label: '生产单号',
prop: 'podJomallUsNo', prop: 'podJomallCnNo',
width: 150, width: 150,
align: 'center', align: 'center',
}, },
...@@ -326,9 +327,17 @@ watch(visible, async (value: boolean) => { ...@@ -326,9 +327,17 @@ watch(visible, async (value: boolean) => {
if (value) { if (value) {
podOrderDetailsData.value = {} podOrderDetailsData.value = {}
currentCode = '' currentCode = ''
warehouseId.value = props.warehouseList[0].id // warehouseId.value = props.warehouseList[0].id
_warehouseId.value = props.warehouseList[0].id // _warehouseId.value = props.warehouseList[0].id
const locaclWarehouseId = sessionStorage.getItem('locaclCnWarehouseId')
// 设置仓库ID,优先使用本地存储的值,否则使用列表中的第一个仓库
warehouseId.value = locaclWarehouseId
? JSON.parse(locaclWarehouseId)
: props.warehouseList[0].id
_warehouseId.value = locaclWarehouseId
? JSON.parse(locaclWarehouseId)
: props.warehouseList[0].id
if (userStore.user?.factory.id) { if (userStore.user?.factory.id) {
try { try {
await socket.init( await socket.init(
...@@ -367,6 +376,7 @@ watch(boxIndex, (value: number | null) => { ...@@ -367,6 +376,7 @@ watch(boxIndex, (value: number | null) => {
if (value) { if (value) {
const bool = !boxChange.value const bool = !boxChange.value
boxChange.value = false boxChange.value = false
console.log('boxChange', bool, value)
renderItemBox(bool) renderItemBox(bool)
} }
}) })
...@@ -440,15 +450,14 @@ const renderItemBox = (bool: boolean) => { ...@@ -440,15 +450,14 @@ const renderItemBox = (bool: boolean) => {
if (currentCode) { if (currentCode) {
const parts = currentCode.split('_') const parts = currentCode.split('_')
currentCode = currentCode =
parts.length > 3 && parts[3].startsWith('USPSC') parts.length > 3 && parts[3].startsWith('CNPSC')
? parts[3] ? parts[3]
: parts.length > 1 : parts.length > 1
? parts[1] ? parts[1]
: parts[0] : parts[0]
for (const product of productList) { for (const product of productList) {
if (product.podJomallUsNo === currentCode) { if (product.podJomallCnNo === currentCode) {
coverImage.value = product.previewImgs?.[0]?.url || '' coverImage.value = product.previewImgs?.[0]?.url || ''
console.log(441, coverImage.value)
nextTick(() => { nextTick(() => {
tableRef.value?.setCurrentRow(product) tableRef.value?.setCurrentRow(product)
...@@ -460,7 +469,6 @@ const renderItemBox = (bool: boolean) => { ...@@ -460,7 +469,6 @@ const renderItemBox = (bool: boolean) => {
} }
podOrderDetailsData.value = data podOrderDetailsData.value = data
if (productList.every((item) => item.power)) { if (productList.every((item) => item.power)) {
print(data, false, () => { print(data, false, () => {
renderLock = false renderLock = false
...@@ -473,7 +481,7 @@ const messageChange = (data: WebSocketMessage) => { ...@@ -473,7 +481,7 @@ const messageChange = (data: WebSocketMessage) => {
if (!data) return if (!data) return
const { code, ...more } = data const { code, ...more } = data
if (code === 'POD_PRINT_ORDER') { if (code === 'FACTORY_POD_CN_PRINT_ORDER') {
try { try {
if (typeof more.txt === 'string') { if (typeof more.txt === 'string') {
console.log( console.log(
...@@ -571,7 +579,7 @@ const getPackingData = async (code: string) => { ...@@ -571,7 +579,7 @@ const getPackingData = async (code: string) => {
productionOrder.value = '' productionOrder.value = ''
return return
} }
const res = await getPackingDataApi( const res = await getPackingCnDataApi(
code, code,
factoryNo, factoryNo,
boxIndex.value, boxIndex.value,
...@@ -584,7 +592,6 @@ const getPackingData = async (code: string) => { ...@@ -584,7 +592,6 @@ const getPackingData = async (code: string) => {
return return
} }
const { box } = res.data const { box } = res.data
console.log('box', box)
if (box) { if (box) {
boxIndex.value = box boxIndex.value = box
...@@ -748,6 +755,7 @@ const handleClose = (done: () => void) => { ...@@ -748,6 +755,7 @@ const handleClose = (done: () => void) => {
}) })
} }
const onClose = () => { const onClose = () => {
// orderStore.clearPodBox()
emit('refresh') emit('refresh')
} }
// 下一步 // 下一步
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<el-dialog <el-dialog
title="处理结果" title="处理结果"
v-model="resultDialog" v-model="resultDialog"
width="600px" width="60%"
:close-on-click-modal="false" :close-on-click-modal="false"
@closed="closedFn" @closed="closedFn"
> >
...@@ -128,6 +128,7 @@ const copyAllCode = (field: string) => { ...@@ -128,6 +128,7 @@ const copyAllCode = (field: string) => {
function closedFn() { function closedFn() {
if (key === 'stockOut') return if (key === 'stockOut') return
emits('confirm', selectedList.value) emits('confirm', selectedList.value)
} }
// 监听弹窗状态 // 监听弹窗状态
......
<script setup lang="ts"> <script setup lang="ts">
import { defineModel } from 'vue' import { defineModel } from 'vue'
import { updateAddressApi } from '@/api/podUsOrder.ts' import { updateAddressApi } from '@/api/podCnOrder.ts'
import {AddressInfo} from '@/types/api/podUsOrder.ts' import {AddressInfo} from '@/types/api/podCnOrder.ts'
const emits = defineEmits(['success']) const emits = defineEmits(['success'])
defineProps<{ defineProps<{
......
...@@ -357,9 +357,17 @@ watch(visible, async (value: boolean) => { ...@@ -357,9 +357,17 @@ watch(visible, async (value: boolean) => {
if (value) { if (value) {
podOrderDetailsData.value = {} podOrderDetailsData.value = {}
currentCode = '' currentCode = ''
warehouseId.value = props.warehouseList[0].id // warehouseId.value = props.warehouseList[0].id
_warehouseId.value = props.warehouseList[0].id // _warehouseId.value = props.warehouseList[0].id
const locaclWarehouseId = localStorage.getItem('locaclWarehouseId')
// 设置仓库ID,优先使用本地存储的值,否则使用列表中的第一个仓库
warehouseId.value = locaclWarehouseId
? JSON.parse(locaclWarehouseId)
: props.warehouseList[0].id
_warehouseId.value = locaclWarehouseId
? JSON.parse(locaclWarehouseId)
: props.warehouseList[0].id
if (userStore.user?.factory.id) { if (userStore.user?.factory.id) {
try { try {
await socket.init( await socket.init(
...@@ -382,9 +390,9 @@ watch(visible, async (value: boolean) => { ...@@ -382,9 +390,9 @@ watch(visible, async (value: boolean) => {
initOrderDetailBox() initOrderDetailBox()
initPrintDevice() initPrintDevice()
const locaclPrinter = localStorage.getItem('sheetPrinter') const locaclPrinter = localStorage.getItem('sheetPrinter')
const locaclWarehouseId = localStorage.getItem('locaclWarehouseId') // const locaclWarehouseId = localStorage.getItem('locaclWarehouseId')
if (locaclPrinter) sheetPrinter.value = JSON.parse(locaclPrinter) if (locaclPrinter) sheetPrinter.value = JSON.parse(locaclPrinter)
if (locaclWarehouseId) warehouseId.value = JSON.parse(locaclWarehouseId) // if (locaclWarehouseId) warehouseId.value = JSON.parse(locaclWarehouseId)
} else { } else {
if (userStore.user?.factory.id) { if (userStore.user?.factory.id) {
socket.send({ socket.send({
......
...@@ -2014,6 +2014,7 @@ ...@@ -2014,6 +2014,7 @@
v-model="podOrderVisible" v-model="podOrderVisible"
:print-order="printOrder" :print-order="printOrder"
:warehouse-list="warehouseList" :warehouse-list="warehouseList"
:is-cn="false"
@set-printer="handlePrinterChange" @set-printer="handlePrinterChange"
@set-warehouseId="handleWarehouseIdChange" @set-warehouseId="handleWarehouseIdChange"
@refresh="onFastRefresh" @refresh="onFastRefresh"
......
...@@ -27,10 +27,10 @@ export default defineConfig({ ...@@ -27,10 +27,10 @@ export default defineConfig({
host: true, host: true,
proxy: { proxy: {
'/api': { '/api': {
target: 'http://10.168.31.130:8060', target: 'http://10.168.31.193:8060',
}, },
'/ws': { '/ws': {
target: 'ws://wkg.local.cn:8066', target: 'http://10.168.31.193:8060',
ws: true, ws: true,
changeOrigin: true, changeOrigin: true,
}, },
......
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