Commit 0a3ddae3 by qinjianhui

feat: 快捷生产

parent 8ae09219
...@@ -393,3 +393,12 @@ export function completeDeliveryApi(ids: (number | string)[]) { ...@@ -393,3 +393,12 @@ export function completeDeliveryApi(ids: (number | string)[]) {
}[]> }[]>
>('factory/podOrderOperation/completeDelivery', ids) >('factory/podOrderOperation/completeDelivery', ids)
} }
export function getByOperationNoLogApi(operationNo: string) {
return axios.get<never, BaseRespData<operateOrderListData>>(
'factory/podOrderOperation/getByOperationNoLog',
{
params: { operationNo },
},
)
}
...@@ -703,7 +703,7 @@ ...@@ -703,7 +703,7 @@
/> />
<!-- 到派单、配货中子状态 --> <!-- 到派单、配货中子状态 -->
<div :key="status" v-if="isCardLayout" class="card-content"> <div v-if="isCardLayout" :key="status" class="card-content">
<CardLayout <CardLayout
ref="cardLayoutRef" ref="cardLayoutRef"
:status="status" :status="status"
...@@ -817,6 +817,18 @@ ...@@ -817,6 +817,18 @@
@refresh-table="refreshCurrentView" @refresh-table="refreshCurrentView"
/> />
<WeightDialog ref="weightDialogRef" @update-list="refreshCurrentView" /> <WeightDialog ref="weightDialogRef" @update-list="refreshCurrentView" />
<FastProduction
v-model:detail-visible="detailVisible"
:detail-data="detailData"
:fast-key="fastKey"
history-storage-key="historyFactoryOrderNewData"
tracking-placeholder="扫描枪输入操作单号,录入下一单本单自动生产完成,最后一单扫两次完成生产"
:query-api="getOperationByNo"
:complete-api="completeOperationById"
:download-api="downloadOperationById"
@on-success="handleFastProductionSuccess"
@close="fastClose"
/>
<ArrangeDialog <ArrangeDialog
ref="arrangeDialogRef" ref="arrangeDialogRef"
...@@ -894,6 +906,7 @@ import { ...@@ -894,6 +906,7 @@ import {
syncReceiverAddress, syncReceiverAddress,
updateRemarkApi, updateRemarkApi,
completeDeliveryApi, completeDeliveryApi,
getByOperationNoLogApi,
} from '@/api/factoryOrderNew' } from '@/api/factoryOrderNew'
import { import {
getListCraftApi, getListCraftApi,
...@@ -926,6 +939,7 @@ import OperateDetailsDialog from './component/OperateDetailsDialog.vue' ...@@ -926,6 +939,7 @@ import OperateDetailsDialog from './component/OperateDetailsDialog.vue'
import CreateLogisticDialog from '@/views/order/podCN/components/CreateLogisticDialog.vue' import CreateLogisticDialog from '@/views/order/podCN/components/CreateLogisticDialog.vue'
import UpdateCustomDeclarationInfoDialog from '@/views/order/podCN/components/UpdateCustomDeclarationInfoDialog.vue' import UpdateCustomDeclarationInfoDialog from '@/views/order/podCN/components/UpdateCustomDeclarationInfoDialog.vue'
import WeightDialog from '@/views/order/podCN/components/WeightDialog.vue' import WeightDialog from '@/views/order/podCN/components/WeightDialog.vue'
import FastProduction from '@/views/order/podCN/FastProduction.vue'
import PodMakeOrder from '@/views/order/podUs/PodMakeOrder.vue' import PodMakeOrder from '@/views/order/podUs/PodMakeOrder.vue'
const cardLayoutStatuses = [ const cardLayoutStatuses = [
...@@ -1494,6 +1508,9 @@ const arrangeDialogRef = ref<InstanceType<typeof ArrangeDialog>>() ...@@ -1494,6 +1508,9 @@ const arrangeDialogRef = ref<InstanceType<typeof ArrangeDialog>>()
const createLogisticDialogRef = ref() const createLogisticDialogRef = ref()
const updateCustomsDialogVisible = ref(false) const updateCustomsDialogVisible = ref(false)
const weightDialogRef = ref() const weightDialogRef = ref()
const detailVisible = ref(false)
const fastKey = ref('')
const detailData = ref<Record<string, unknown>>({})
const getSelectedIds = (): (number | string)[] => { const getSelectedIds = (): (number | string)[] => {
if (isCardLayout.value) return cardSelectList.value.map((item) => item.id) if (isCardLayout.value) return cardSelectList.value.map((item) => item.id)
return selectedRowIds.value return selectedRowIds.value
...@@ -2165,9 +2182,21 @@ const handleReplenishFail = () => { ...@@ -2165,9 +2182,21 @@ const handleReplenishFail = () => {
if (!ensureSelection()) return if (!ensureSelection()) return
ElMessage.info('补胚失败功能待集成') ElMessage.info('补胚失败功能待集成')
} }
const getOperationByNo = (operationNo: string) =>
getByOperationNoLogApi(operationNo) as Promise<{ data?: unknown }>
const completeOperationById = (ids: number[]) => completeDeliveryApi(ids)
const downloadOperationById = (ids: number[]) => downloadOperationMaterialApi(ids)
const handleFastProductionSuccess = () => {
refreshCurrentView({ isRefreshTree: true })
}
const fastClose = () => {
detailVisible.value = false
refreshCurrentView({ isRefreshTree: true })
}
const handleQuickProduction = () => { const handleQuickProduction = () => {
if (!ensureSelection()) return detailVisible.value = true
ElMessage.info('快捷生产功能待集成') fastKey.value = 'fastProduction'
detailData.value = {}
} }
const handleSinglePrint = () => { const handleSinglePrint = () => {
if (!ensureSelection()) return if (!ensureSelection()) return
......
...@@ -211,7 +211,7 @@ import { ...@@ -211,7 +211,7 @@ import {
import { cardImages, PodOrderRes } from '@/types/api/podCnOrder' import { cardImages, PodOrderRes } from '@/types/api/podCnOrder'
import { showConfirm } from '@/utils/ui' import { showConfirm } from '@/utils/ui'
import { filePath } from '@/api/axios' import { filePath } from '@/api/axios'
import { ref, watch, defineProps, defineEmits } from 'vue' import { ref, watch } from 'vue'
interface HistoryDataItem { interface HistoryDataItem {
orderNumber: string orderNumber: string
finished: boolean finished: boolean
...@@ -251,41 +251,108 @@ const audios = { ...@@ -251,41 +251,108 @@ const audios = {
).href, ).href,
} }
const TrackingNumber = ref('') const TrackingNumber = ref('')
const props = defineProps({ const props = withDefaults(
type: { defineProps<{
default: 0, type?: number
type: Number, detailVisible?: boolean
detailData?: Record<string, unknown> | null
fastKey?: string
historyStorageKey?: string
trackingPlaceholder?: string
queryApi?: (orderNumber: string) => Promise<{ data?: unknown }>
completeApi?: (ids: number[], detail: Record<string, unknown>) => Promise<unknown>
downloadApi?: (ids: number[]) => Promise<{ code?: number; message?: string }>
}>(),
{
type: 0,
detailVisible: false,
detailData: null,
fastKey: '',
historyStorageKey: 'historyCnData',
trackingPlaceholder:
'扫描枪输入生产单号,录入下一单本单自动生产完成,最后一单扫两次完成生产',
queryApi: (orderNumber: string) => getSubOrderBySubOrderNumber(orderNumber),
completeApi: (ids: number[], detailData: Record<string, unknown>) =>
productionQueryApi(
ids[0],
Number(detailData.podJomallOrderCnId || -1),
),
downloadApi: (ids: number[]) => downloadMaterialApi(ids),
}, },
detailVisible: { )
default: false,
type: Boolean,
},
detailData: {
default: null,
type: Object,
},
fastKey: {
default: '',
type: String,
},
})
const emit = defineEmits(['update:detailVisible', 'close', 'onSuccess']) const emit = defineEmits(['update:detailVisible', 'close', 'onSuccess'])
const parseImages = (value: unknown): cardImages[] => {
if (!value) return []
if (Array.isArray(value)) {
return value
.filter((item) => !!item?.url)
.map((item, index) => ({
title: String(item?.title || ''),
url: String(item?.url || ''),
sort: Number(item?.sort ?? index + 1),
id: item?.id,
}))
}
if (typeof value === 'string') {
const source = value.trim()
if (!source) return []
if (source.startsWith('http')) {
return source.split(',').map((url, index) => ({
title: '',
url: url.trim(),
sort: index + 1,
}))
}
try {
const parsed = JSON.parse(source)
if (Array.isArray(parsed)) {
return parsed
.filter((item) => !!item?.url)
.map((item, index) => ({
title: String(item?.title || ''),
url: String(item?.url || ''),
sort: Number(item?.sort ?? index + 1),
id: item?.id,
}))
}
} catch (_e) {
return []
}
}
return []
}
const normalizeDetail = (value: unknown): PodOrderRes => {
const raw = (value || {}) as Record<string, unknown>
const d = JSON.parse(JSON.stringify(raw)) as Record<string, unknown>
if (typeof d.note === 'string') {
try {
d.note = JSON.parse(d.note)
} catch (_e) {
d.note = []
}
}
if (!Array.isArray(d.note)) d.note = []
const imageSource = d.imageAry || d.designImages || d.imgList
d.imgList = parseImages(imageSource)
return d as unknown as PodOrderRes
}
watch( watch(
() => props.detailVisible, () => props.detailVisible,
(newVal: boolean) => { (newVal: boolean) => {
dialogVisible.value = newVal dialogVisible.value = newVal
detail.value = { id: -1, podJomallOrderCnId: -1, imgList: [] } detail.value = { id: -1, podJomallOrderCnId: -1, imgList: [] }
if (newVal) { if (newVal) {
const history = localStorage.getItem('historyCnData') const history = localStorage.getItem(props.historyStorageKey)
historyData.value = history ? JSON.parse(history) : [] historyData.value = history ? JSON.parse(history) : []
const len = historyData.value const len = historyData.value
if (len.length > 0 && props.fastKey === 'fastProduction') { if (len.length > 0 && props.fastKey === 'fastProduction') {
confirmQuery(len, 0) confirmQuery(len, 0)
} }
placeholderText.value = placeholderText.value = props.trackingPlaceholder
'扫描枪输入生产单号,录入下一单本单自动生产完成,最后一单扫两次完成生产'
trackingNumberRef.value && trackingNumberRef.value.focus() trackingNumberRef.value && trackingNumberRef.value.focus()
...@@ -304,18 +371,7 @@ watch( ...@@ -304,18 +371,7 @@ watch(
imgList: [], imgList: [],
} }
if (newVal && Object.keys(newVal).length > 0) { if (newVal && Object.keys(newVal).length > 0) {
const d = JSON.parse(JSON.stringify(newVal)) detail.value = normalizeDetail(newVal)
if (d.note) {
d.note = JSON.parse(d.note)
} else {
d.note = []
}
if (d.imageAry) {
d.imgList = d.imageAry
} else {
d.imgList = []
}
detail.value = d
} }
}, },
{ deep: true }, { deep: true },
...@@ -342,7 +398,10 @@ const confirmQuery = (len: HistoryDataItem[], i: number) => { ...@@ -342,7 +398,10 @@ const confirmQuery = (len: HistoryDataItem[], i: number) => {
) )
if (index >= 0) { if (index >= 0) {
historyData.value.splice(index, 1) historyData.value.splice(index, 1)
localStorage.setItem('historyCnData', JSON.stringify(historyData.value)) localStorage.setItem(
props.historyStorageKey,
JSON.stringify(historyData.value),
)
} }
if (len[i + 1]) { if (len[i + 1]) {
confirmQuery(len, i + 1) confirmQuery(len, i + 1)
...@@ -367,8 +426,7 @@ const setData = async (orderNumber: string) => { ...@@ -367,8 +426,7 @@ const setData = async (orderNumber: string) => {
if (!detail.value || detail.value?.id === -1) return if (!detail.value || detail.value?.id === -1) return
try { try {
const id = detail.value.id const id = detail.value.id
const podJomallOrderCnId = detail.value.podJomallOrderCnId await props.completeApi([id], detail.value as unknown as Record<string, unknown>)
await productionQueryApi(id, podJomallOrderCnId)
if (orderNumber) { if (orderNumber) {
const index = historyData.value.findIndex( const index = historyData.value.findIndex(
...@@ -377,7 +435,10 @@ const setData = async (orderNumber: string) => { ...@@ -377,7 +435,10 @@ const setData = async (orderNumber: string) => {
if (index >= 0) { if (index >= 0) {
// 扫单完成删除 // 扫单完成删除
historyData.value.splice(index, 1) historyData.value.splice(index, 1)
localStorage.setItem('historCnData', JSON.stringify(historyData.value)) localStorage.setItem(
props.historyStorageKey,
JSON.stringify(historyData.value),
)
} }
} }
emit('onSuccess') emit('onSuccess')
...@@ -418,7 +479,7 @@ const download = async () => { ...@@ -418,7 +479,7 @@ const download = async () => {
const id = detail.value.id const id = detail.value.id
if (id !== undefined) { if (id !== undefined) {
try { try {
const res = await downloadMaterialApi([id]) const res = await props.downloadApi([id])
if (res.code !== 200) return if (res.code !== 200) return
// window.open(filePath + res.message) // window.open(filePath + res.message)
const a = document.createElement('a') const a = document.createElement('a')
...@@ -484,7 +545,7 @@ const trackCodeInput = async () => { ...@@ -484,7 +545,7 @@ const trackCodeInput = async () => {
orderNumber: TrackingNumber.value, orderNumber: TrackingNumber.value,
finished: false, finished: false,
}) })
localStorage.setItem('historyCnData', JSON.stringify(historyData.value)) localStorage.setItem(props.historyStorageKey, JSON.stringify(historyData.value))
} }
const orderNumber = TrackingNumber.value const orderNumber = TrackingNumber.value
...@@ -496,23 +557,11 @@ const trackCodeInput = async () => { ...@@ -496,23 +557,11 @@ const trackCodeInput = async () => {
} }
try { try {
const res = await getSubOrderBySubOrderNumber(orderNumber) const res = await props.queryApi(orderNumber)
if (!res.data) { if (!res.data) {
return ElMessage.error('生产单不存在') return ElMessage.error('生产单不存在')
} }
const d = JSON.parse(JSON.stringify(res.data)) detail.value = normalizeDetail(res.data)
if (d.note) {
d.note = JSON.parse(d.note)
} else {
d.note = []
}
if (d.imageAry) {
d.imgList = JSON.parse(d.imageAry)
} else {
d.imgList = []
}
detail.value = d
if (isDownloadImage.value) { if (isDownloadImage.value) {
download() download()
......
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