fix:模具出入库bug修复

main
黄伟杰 2 days ago
parent a049c54d7d
commit 152838e14b

@ -1,49 +1,49 @@
import request from '@/config/axios'
// 模具管理-领模申请 VO
export interface MoldGetVO {
id: number // ID
orderId: number // 领模单号
code: string // 模具编码
name: string // 模具名称
state: string // 状态
person: string // 领模人
deviceId: number // 设备id
deviceName: string // 设备名称
getTime: Date // 领取时间
principal: string // 库管员
remark: string // 备注
}
// 模具管理-领模申请 API
export const MoldGetApi = {
// 查询模具管理-领模申请分页
getMoldGetPage: async (params: any) => {
return await request.get({ url: `/mes/mold-get/page`, params })
},
// 查询模具管理-领模申请详情
getMoldGet: async (id: number) => {
return await request.get({ url: `/mes/mold-get/get?id=` + id })
},
// 新增模具管理-领模申请
createMoldGet: async (data: MoldGetVO) => {
return await request.post({ url: `/mes/mold-get/create`, data })
},
// 修改模具管理-领模申请
updateMoldGet: async (data: MoldGetVO) => {
return await request.put({ url: `/mes/mold-get/update`, data })
},
// 删除模具管理-领模申请
deleteMoldGet: async (id: number) => {
return await request.delete({ url: `/mes/mold-get/delete?id=` + id })
},
// 导出模具管理-领模申请 Excel
exportMoldGet: async (params) => {
return await request.download({ url: `/mes/mold-get/export-excel`, params })
},
}
import request from '@/config/axios'
// 模具管理-领模申请 VO
export interface MoldGetVO {
id: number // ID
orderId: number // 领模单号
code: string // 模具编码
name: string // 模具名称
state: string // 状态
person: string // 领模人
deviceId: number // 设备id
deviceName: string // 设备名称
getTime: Date // 领取时间
principal: string // 库管员
remark: string // 备注
}
// 模具管理-领模申请 API
export const MoldGetApi = {
// 查询模具管理-领模申请分页
getMoldGetPage: async (params: any) => {
return await request.get({ url: `/mes/mold-get/page`, params })
},
// 查询模具管理-领模申请详情
getMoldGet: async (id: number) => {
return await request.get({ url: `/mes/mold-get/get?id=` + id })
},
// 新增模具管理-领模申请
createMoldGet: async (data: MoldGetVO) => {
return await request.post({ url: `/mes/mold-get/create`, data })
},
// 修改模具管理-领模申请
updateMoldGet: async (data: MoldGetVO) => {
return await request.put({ url: `/mes/mold-get/update`, data })
},
// 删除模具管理-领模申请
deleteMoldGet: async (id: number) => {
return await request.delete({ url: `/mes/mold-get/delete?id=` + id })
},
// 导出模具管理-领模申请 Excel
exportMoldGet: async (params) => {
return await request.download({ url: `/mes/mold-get/export-excel`, params })
},
}

@ -1,47 +1,47 @@
import request from '@/config/axios'
// 模具管理-模具入库 VO
export interface MoldReturnVO {
id: number // ID
orderId: number // 领模单号
code: string // 模具编码
name: string // 模具名称
state: string // 状态
person: string // 归还人
returnTime: Date // 入库时间
principal: string // 库管员
remark: string // 备注
}
// 模具管理-模具入库 API
export const MoldReturnApi = {
// 查询模具管理-模具入库分页
getMoldReturnPage: async (params: any) => {
return await request.get({ url: `/mes/mold-return/page`, params })
},
// 查询模具管理-模具入库详情
getMoldReturn: async (id: number) => {
return await request.get({ url: `/mes/mold-return/get?id=` + id })
},
// 新增模具管理-模具入库
createMoldReturn: async (data: MoldReturnVO) => {
return await request.post({ url: `/mes/mold-return/create`, data })
},
// 修改模具管理-模具入库
updateMoldReturn: async (data: MoldReturnVO) => {
return await request.put({ url: `/mes/mold-return/update`, data })
},
// 删除模具管理-模具入库
deleteMoldReturn: async (id: number) => {
return await request.delete({ url: `/mes/mold-return/delete?id=` + id })
},
// 导出模具管理-模具入库 Excel
exportMoldReturn: async (params) => {
return await request.download({ url: `/mes/mold-return/export-excel`, params })
},
}
import request from '@/config/axios'
// 模具管理-模具入库 VO
export interface MoldReturnVO {
id: number // ID
orderId: number // 领模单号
code: string // 模具编码
name: string // 模具名称
state: string // 状态
person: string // 归还人
returnTime: Date // 入库时间
principal: string // 库管员
remark: string // 备注
}
// 模具管理-模具入库 API
export const MoldReturnApi = {
// 查询模具管理-模具入库分页
getMoldReturnPage: async (params: any) => {
return await request.get({ url: `/mes/mold-return/page`, params })
},
// 查询模具管理-模具入库详情
getMoldReturn: async (id: number) => {
return await request.get({ url: `/mes/mold-return/get?id=` + id })
},
// 新增模具管理-模具入库
createMoldReturn: async (data: MoldReturnVO) => {
return await request.post({ url: `/mes/mold-return/create`, data })
},
// 修改模具管理-模具入库
updateMoldReturn: async (data: MoldReturnVO) => {
return await request.put({ url: `/mes/mold-return/update`, data })
},
// 删除模具管理-模具入库
deleteMoldReturn: async (id: number) => {
return await request.delete({ url: `/mes/mold-return/delete?id=` + id })
},
// 导出模具管理-模具入库 Excel
exportMoldReturn: async (params) => {
return await request.download({ url: `/mes/mold-return/export-excel`, params })
},
}

@ -93,7 +93,13 @@
<ContentWrap>
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
<el-tab-pane :label="t('MoldManagement.MoldGet.moldGroupListTitle')" name="item">
<el-table :data="formData.items || []" :stripe="true" :show-overflow-tooltip="true" row-key="id">
<StockOutItemFormComp
v-if="!disabled"
ref="itemFormRef"
:items="formData.items"
:disabled="disabled"
/>
<el-table v-else :data="formData.items || []" :stripe="true" :show-overflow-tooltip="true" row-key="id">
<el-table-column type="expand" width="48">
<template #default="{ row: itemRow }">
<div class="p-12px">
@ -144,7 +150,7 @@
</template>
<script setup lang="ts">
import { StockOutApi, StockOutVO } from '@/api/erp/stock/out'
import {DICT_TYPE, getBoolDictOptions, getStrDictOptions} from "@/utils/dict";
import { DICT_TYPE } from '@/utils/dict'
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
@ -155,11 +161,40 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
const warehouseList = ref<WarehouseVO[]>([]) //
interface MoldGetItem {
id?: number
moldSetId?: number
productId?: number
warehouseId?: number
moldSetName?: string
productBarCode?: string
count?: number
remark?: string
moldList?: any[]
[key: string]: any
}
interface MoldGetFormData {
id?: number
no?: string
customerId?: number
outTime?: number | string
remark?: string
outType?: string
fileUrl: string
items: MoldGetItem[]
warehouseId?: number
[key: string]: any
}
const StockOutItemFormComp = defineAsyncComponent(() => import('./components/StockOutItemForm.vue') as any)
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update - detail -
const formData = ref({
const formData = ref<MoldGetFormData>({
id: undefined,
no: undefined,
customerId: undefined,
outTime: undefined,
remark: undefined,
@ -190,6 +225,7 @@ const options = [
]
/** 子表的表单 */
const subTabsName = ref('item')
const itemFormRef = ref()
const ensureWarehouseId = () => {
if (formData.value.warehouseId !== undefined && formData.value.warehouseId !== null) return
@ -199,6 +235,32 @@ const ensureWarehouseId = () => {
const getTodayTimestamp = () => new Date().setHours(0, 0, 0, 0)
const getSelectedItemRows = (): any[] => {
const selectedRows = itemFormRef.value?.selectedRows
if (Array.isArray(selectedRows)) return selectedRows
if (Array.isArray(selectedRows?.value)) return selectedRows.value
return []
}
const buildSubmitItems = (rows: any[]): MoldGetItem[] => {
const existingItemMap = new Map(
(formData.value.items || []).map((item) => [item.productId ?? item.id, item])
)
return rows.map((row: any) => {
const existing = existingItemMap.get(row.id) || {}
return {
...existing,
moldSetId: existing.moldSetId ?? row.id,
productId: row.id,
warehouseId: formData.value.warehouseId,
moldSetName: existing.moldSetName ?? row.name,
productBarCode: existing.productBarCode ?? row.code,
count: existing.count ?? row.childMoldCount ?? 1
}
})
}
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogTitle.value = t('action.' + type)
@ -234,6 +296,12 @@ const emit = defineEmits(['success', 'closed']) // 定义 success 和 closed 事
const submitForm = async () => {
//
await formRef.value.validate()
const selectedRows = getSelectedItemRows()
if (!selectedRows.length) {
message.warning('请选择模具组')
return
}
formData.value.items = buildSubmitItems(selectedRows)
//
formLoading.value = true
try {
@ -258,12 +326,13 @@ const resetForm = () => {
formRef.value?.resetFields()
formData.value = {
id: undefined,
no: undefined,
customerId: undefined,
outTime: getTodayTimestamp(),
remark: undefined,
fileUrl: undefined,
fileUrl: '',
items: [],
outType: "模具出库",
outType: '模具出库',
warehouseId: undefined
}
}

@ -93,7 +93,13 @@
<ContentWrap>
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
<el-tab-pane :label="t('MoldManagement.MoldReturn.moldGroupListTitle')" name="item">
<el-table :data="formData.items || []" :stripe="true" :show-overflow-tooltip="true" row-key="id">
<StockInItemFormComp
v-if="!disabled"
ref="itemFormRef"
:items="formData.items"
:disabled="disabled"
/>
<el-table v-else :data="formData.items || []" :stripe="true" :show-overflow-tooltip="true" row-key="id">
<el-table-column type="expand" width="48">
<template #default="{ row: itemRow }">
<div class="p-12px">
@ -155,11 +161,40 @@ const { t } = useI18n() // 国际化
const message = useMessage() //
const warehouseList = ref<WarehouseVO[]>([]) //
interface MoldReturnItem {
id?: number
moldSetId?: number
productId?: number
warehouseId?: number
moldSetName?: string
productBarCode?: string
count?: number
remark?: string
moldList?: any[]
[key: string]: any
}
interface MoldReturnFormData {
id?: number
no?: string
customerId?: number
inTime?: number | string
remark?: string
inType?: string
fileUrl: string
items: MoldReturnItem[]
warehouseId?: number
[key: string]: any
}
const StockInItemFormComp = defineAsyncComponent(() => import('./components/StockInItemForm.vue') as any)
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update - detail -
const formData = ref({
const formData = ref<MoldReturnFormData>({
id: undefined,
no: undefined,
customerId: undefined,
inTime: undefined,
remark: undefined,
@ -190,6 +225,7 @@ const options = [
]
/** 子表的表单 */
const subTabsName = ref('item')
const itemFormRef = ref()
const ensureWarehouseId = () => {
if (formData.value.warehouseId !== undefined && formData.value.warehouseId !== null) return
@ -199,6 +235,32 @@ const ensureWarehouseId = () => {
const getTodayTimestamp = () => new Date().setHours(0, 0, 0, 0)
const getSelectedItemRows = (): any[] => {
const selectedRows = itemFormRef.value?.selectedRows
if (Array.isArray(selectedRows)) return selectedRows
if (Array.isArray(selectedRows?.value)) return selectedRows.value
return []
}
const buildSubmitItems = (rows: any[]): MoldReturnItem[] => {
const existingItemMap = new Map(
(formData.value.items || []).map((item) => [item.productId ?? item.id, item])
)
return rows.map((row: any) => {
const existing = existingItemMap.get(row.id) || {}
return {
...existing,
moldSetId: existing.moldSetId ?? row.id,
productId: row.id,
warehouseId: formData.value.warehouseId,
moldSetName: existing.moldSetName ?? row.name,
productBarCode: existing.productBarCode ?? row.code,
count: existing.count ?? row.childMoldCount ?? 1
}
})
}
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogTitle.value = t('action.' + type)
@ -234,10 +296,16 @@ const emit = defineEmits(['success', 'closed']) // 定义 success 和 closed 事
const submitForm = async () => {
//
await formRef.value.validate()
const selectedRows = getSelectedItemRows()
if (!selectedRows.length) {
message.warning('请选择模具组')
return
}
formData.value.items = buildSubmitItems(selectedRows)
//
formLoading.value = true
try {
const data = formData.value as unknown as StockInVO
const data = formData.value as unknown as StockInVO
if (formType.value === 'create') {
await StockInApi.createStockIn(data)
message.success(t('common.createSuccess'))
@ -258,12 +326,13 @@ const resetForm = () => {
formRef.value?.resetFields()
formData.value = {
id: undefined,
no: undefined,
customerId: undefined,
inTime: getTodayTimestamp(),
remark: undefined,
fileUrl: undefined,
fileUrl: '',
items: [],
inType: "模具入库",
inType: '模具入库',
warehouseId: undefined
}
}

Loading…
Cancel
Save