feat(mes): 更新领料出库单相关 API 接口及组件

重命名领料出库单和明细相关的 API 方法,增强代码可读性。新增领料出库明细表单组件,支持拣货明细的添加与编辑功能。同时,调整相关组件的逻辑以适应新的 API 结构。
pull/871/MERGE
YunaiV 2026-02-27 23:33:22 +08:00
parent bd27ddfc71
commit 5e2366ace0
10 changed files with 307 additions and 294 deletions

View File

@ -22,27 +22,27 @@ export interface WmProductionIssueDetailVO {
// MES 领料出库明细 API // MES 领料出库明细 API
export const WmProductionIssueDetailApi = { export const WmProductionIssueDetailApi = {
// 查询领料出库明细分页 // 查询领料出库明细分页
getDetailPage: async (params: any) => { getProductionIssueDetailPage: async (params: any) => {
return await request.get({ url: '/mes/wm/production-issue-detail/page', params }) return await request.get({ url: '/mes/wm/production-issue-detail/page', params })
}, },
// 查询领料出库明细详情 // 查询领料出库明细详情
getDetail: async (id: number) => { getProductionIssueDetail: async (id: number) => {
return await request.get({ url: '/mes/wm/production-issue-detail/get?id=' + id }) return await request.get({ url: '/mes/wm/production-issue-detail/get?id=' + id })
}, },
// 新增领料出库明细 // 新增领料出库明细
createDetail: async (data: WmProductionIssueDetailVO) => { createProductionIssueDetail: async (data: WmProductionIssueDetailVO) => {
return await request.post({ url: '/mes/wm/production-issue-detail/create', data }) return await request.post({ url: '/mes/wm/production-issue-detail/create', data })
}, },
// 修改领料出库明细 // 修改领料出库明细
updateDetail: async (data: WmProductionIssueDetailVO) => { updateProductionIssueDetail: async (data: WmProductionIssueDetailVO) => {
return await request.put({ url: '/mes/wm/production-issue-detail/update', data }) return await request.put({ url: '/mes/wm/production-issue-detail/update', data })
}, },
// 删除领料出库明细 // 删除领料出库明细
deleteDetail: async (id: number) => { deleteProductionIssueDetail: async (id: number) => {
return await request.delete({ url: '/mes/wm/production-issue-detail/delete?id=' + id }) return await request.delete({ url: '/mes/wm/production-issue-detail/delete?id=' + id })
} }
} }

View File

@ -11,7 +11,6 @@ export interface WmProductionIssueLineVO {
unitMeasureName?: string unitMeasureName?: string
quantity: number quantity: number
batchId?: number batchId?: number
batchCode?: string
remark?: string remark?: string
} }

View File

@ -11,34 +11,33 @@ export interface WmProductionIssueLineVO {
unitMeasureName?: string unitMeasureName?: string
quantity: number quantity: number
batchId?: number batchId?: number
batchCode?: string
remark?: string remark?: string
} }
// MES 领料出库单行 API // MES 领料出库单行 API
export const WmProductionIssueLineApi = { export const WmProductionIssueLineApi = {
// 查询领料出库单行分页 // 查询领料出库单行分页
getLinePage: async (params: any) => { getProductionIssueLinePage: async (params: any) => {
return await request.get({ url: '/mes/wm/production-issue-line/page', params }) return await request.get({ url: '/mes/wm/production-issue-line/page', params })
}, },
// 查询领料出库单行详情 // 查询领料出库单行详情
getLine: async (id: number) => { getProductionIssueLine: async (id: number) => {
return await request.get({ url: '/mes/wm/production-issue-line/get?id=' + id }) return await request.get({ url: '/mes/wm/production-issue-line/get?id=' + id })
}, },
// 新增领料出库单行 // 新增领料出库单行
createLine: async (data: WmProductionIssueLineVO) => { createProductionIssueLine: async (data: WmProductionIssueLineVO) => {
return await request.post({ url: '/mes/wm/production-issue-line/create', data }) return await request.post({ url: '/mes/wm/production-issue-line/create', data })
}, },
// 修改领料出库单行 // 修改领料出库单行
updateLine: async (data: WmProductionIssueLineVO) => { updateProductionIssueLine: async (data: WmProductionIssueLineVO) => {
return await request.put({ url: '/mes/wm/production-issue-line/update', data }) return await request.put({ url: '/mes/wm/production-issue-line/update', data })
}, },
// 删除领料出库单行 // 删除领料出库单行
deleteLine: async (id: number) => { deleteProductionIssueLine: async (id: number) => {
return await request.delete({ url: '/mes/wm/production-issue-line/delete?id=' + id }) return await request.delete({ url: '/mes/wm/production-issue-line/delete?id=' + id })
} }
} }

View File

@ -7,7 +7,7 @@
<el-table-column label="库位名称" align="center" prop="areaName" min-width="100" /> <el-table-column label="库位名称" align="center" prop="areaName" min-width="100" />
<el-table-column label="数量" align="center" prop="quantity" width="100" /> <el-table-column label="数量" align="center" prop="quantity" width="100" />
<el-table-column <el-table-column
v-if="props.formType === 'shelving'" v-if="props.formType === 'stock'"
label="操作" label="操作"
align="center" align="center"
width="120" width="120"

View File

@ -111,7 +111,7 @@ const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const formLoading = ref(false) // const formLoading = ref(false) //
const formType = ref<string>('create') // 表单的类型create / update / shelving / detail const formType = ref<string>('create') // 表单的类型create / update / stock / detail
const formData = ref({ const formData = ref({
id: undefined as number | undefined, id: undefined as number | undefined,
code: undefined, code: undefined,
@ -129,15 +129,14 @@ const formRules = reactive({
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
// TODO @AIformType 使 stock shelving
const isUpdate = computed(() => ['create', 'update'].includes(formType.value)) // const isUpdate = computed(() => ['create', 'update'].includes(formType.value)) //
const isStock = computed(() => formType.value === 'shelving') // const isStock = computed(() => formType.value === 'stock') //
const isHeaderReadonly = computed(() => ['shelving', 'detail'].includes(formType.value)) // const isHeaderReadonly = computed(() => ['stock', 'detail'].includes(formType.value)) //
const dialogTitle = computed(() => { const dialogTitle = computed(() => {
const titles = { const titles = {
create: '新增采购入库单', create: '新增采购入库单',
update: '编辑采购入库单', update: '编辑采购入库单',
shelving: '执行上架', stock: '执行上架',
detail: '采购入库单详情' detail: '采购入库单详情'
} }
return titles[formType.value] || formType.value return titles[formType.value] || formType.value

View File

@ -177,7 +177,7 @@ const { t } = useI18n() // 国际化
const message = useMessage() // const message = useMessage() //
const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) // const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) //
const isStock = computed(() => props.formType === 'shelving') // const isStock = computed(() => props.formType === 'stock') //
// ==================== ==================== // ==================== ====================
const loading = ref(false) // const loading = ref(false) //

View File

@ -126,7 +126,7 @@
<el-button <el-button
link link
type="success" type="success"
@click="openForm('shelving', scope.row.id)" @click="openForm('stock', scope.row.id)"
v-hasPermi="['mes:wm-item-receipt:update']" v-hasPermi="['mes:wm-item-receipt:update']"
v-if="scope.row.status === MesWmItemReceiptStatusEnum.APPROVING" v-if="scope.row.status === MesWmItemReceiptStatusEnum.APPROVING"
> >

View File

@ -0,0 +1,155 @@
<!-- MES 领料出库拣货明细表单弹窗 -->
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="600px">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="110px"
v-loading="formLoading"
>
<el-form-item label="物料" prop="itemId">
<MdItemSelect v-model="formData.itemId" disabled />
</el-form-item>
<el-form-item label="出库仓库" prop="warehouseId">
<WmWarehouseSelect v-model="formData.warehouseId" />
</el-form-item>
<el-form-item label="库区" prop="locationId" v-if="formData.warehouseId">
<WmWarehouseLocationSelect
v-model="formData.locationId"
:warehouse-id="formData.warehouseId"
/>
</el-form-item>
<el-form-item label="库位" prop="areaId" v-if="formData.locationId">
<WmWarehouseAreaSelect v-model="formData.areaId" :location-id="formData.locationId" />
</el-form-item>
<el-form-item label="批次号" prop="batchCode">
<el-input v-model="formData.batchCode" placeholder="请输入批次号" />
</el-form-item>
<el-form-item label="数量" prop="quantity">
<el-input-number
v-model="formData.quantity"
:precision="2"
:min="0"
controls-position="right"
class="!w-1/1"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import {
WmProductionIssueDetailApi,
WmProductionIssueDetailVO
} from '@/api/mes/wm/productionissue/detail'
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
import WmWarehouseSelect from '@/views/mes/wm/warehouse/components/WmWarehouseSelect.vue'
import WmWarehouseLocationSelect from '@/views/mes/wm/warehouse/components/WmWarehouseLocationSelect.vue'
import WmWarehouseAreaSelect from '@/views/mes/wm/warehouse/components/WmWarehouseAreaSelect.vue'
defineOptions({ name: 'ProductionIssueDetailForm' })
const props = defineProps<{
issueId: number
}>()
const emit = defineEmits(['success'])
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) //
const formType = ref('') // 表单的类型create / update
const currentLineId = ref<number>() // ID
const formRef = ref() // Ref
const formData = ref({
id: undefined as number | undefined,
lineId: undefined as number | undefined,
issueId: undefined as number | undefined,
itemId: undefined as number | undefined,
quantity: undefined as number | undefined,
batchCode: undefined as string | undefined,
warehouseId: undefined as number | undefined,
locationId: undefined as number | undefined,
areaId: undefined as number | undefined
})
const formRules = reactive({
itemId: [{ required: true, message: '物料不能为空', trigger: 'change' }],
warehouseId: [{ required: true, message: '出库仓库不能为空', trigger: 'change' }],
locationId: [{ required: true, message: '库区不能为空', trigger: 'change' }],
areaId: [{ required: true, message: '库位不能为空', trigger: 'change' }],
quantity: [{ required: true, message: '数量不能为空', trigger: 'blur' }]
})
/** 打开弹窗 */
const open = async (type: string, lineId: number, itemId?: number, detailId?: number) => {
dialogVisible.value = true
dialogTitle.value = type === 'create' ? '添加拣货明细' : '编辑拣货明细'
formType.value = type
currentLineId.value = lineId
resetForm()
//
if (detailId) {
formLoading.value = true
try {
formData.value = await WmProductionIssueDetailApi.getProductionIssueDetail(detailId)
} finally {
formLoading.value = false
}
} else if (itemId) {
formData.value.itemId = itemId
}
}
defineExpose({ open })
/** 提交表单 */
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = {
...formData.value,
issueId: props.issueId,
lineId: currentLineId.value
} as unknown as WmProductionIssueDetailVO
if (formType.value === 'create') {
await WmProductionIssueDetailApi.createProductionIssueDetail(data)
message.success(t('common.createSuccess'))
} else {
await WmProductionIssueDetailApi.updateProductionIssueDetail(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success', currentLineId.value)
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
lineId: undefined,
issueId: undefined,
itemId: undefined,
quantity: undefined,
batchCode: undefined,
warehouseId: undefined,
locationId: undefined,
areaId: undefined
}
formRef.value?.resetFields()
}
</script>

View File

@ -1,90 +1,36 @@
<!-- MES 领料出库明细列表展开行内嵌子组件 --> <!-- MES 领料出库拣货明细列表展开行内嵌子组件 -->
<template> <template>
<div class="pl-60px pr-20px py-10px"> <div class="pl-60px pr-20px py-10px">
<el-button
v-if="canPick"
type="primary"
size="small"
@click="handlePick"
class="mb-10px"
>
<Icon icon="ep:plus" class="mr-5px" /> 添加拣货
</el-button>
<el-table v-loading="loading" :data="list" border size="small"> <el-table v-loading="loading" :data="list" border size="small">
<el-table-column label="批次号" align="center" prop="batchCode" min-width="120" /> <el-table-column label="批次号" align="center" prop="batchCode" min-width="120" />
<el-table-column label="仓库" align="center" prop="warehouseName" min-width="100" /> <el-table-column label="仓库名称" align="center" prop="warehouseName" min-width="100" />
<el-table-column label="库区" align="center" prop="locationName" min-width="100" /> <el-table-column label="库区名称" align="center" prop="locationName" min-width="100" />
<el-table-column label="库位" align="center" prop="areaName" min-width="100" /> <el-table-column label="库位名称" align="center" prop="areaName" min-width="100" />
<el-table-column label="拣货数量" align="center" prop="quantity" width="100" /> <el-table-column label="数量" align="center" prop="quantity" width="100" />
<el-table-column <el-table-column
v-if="canPick" v-if="props.formType === 'stock'"
label="操作" label="操作"
align="center" align="center"
width="120" width="120"
fixed="right" fixed="right"
> >
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="emit('edit-detail', scope.row.id)">
编辑
</el-button>
<el-button link type="danger" @click="handleDelete(scope.row.id)"></el-button> <el-button link type="danger" @click="handleDelete(scope.row.id)"></el-button>
<!-- TODO @芋艿保留标签打印 -->
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 拣货对话框 -->
<el-dialog v-model="dialogVisible" title="添加拣货" width="600px">
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px">
<el-form-item label="库存位置" prop="materialStockId">
<el-input
v-model="formData.warehouseName"
placeholder="请选择库存位置"
readonly
@click="handleSelectStock"
class="cursor-pointer"
>
<template #append>
<el-button @click="handleSelectStock">
<Icon icon="ep:search" />
</el-button>
</template>
</el-input>
</el-form-item>
<el-form-item label="批次号">
<el-input v-model="formData.batchCode" disabled />
</el-form-item>
<el-form-item label="库区">
<el-input v-model="formData.locationName" disabled />
</el-form-item>
<el-form-item label="库位">
<el-input v-model="formData.areaName" disabled />
</el-form-item>
<el-form-item label="可用数量">
<el-input v-model="formData.availableQuantity" disabled />
</el-form-item>
<el-form-item label="拣货数量" prop="quantity">
<el-input-number
v-model="formData.quantity"
:min="0"
:max="formData.availableQuantity"
:precision="2"
class="!w-full"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleConfirm"></el-button>
</template>
</el-dialog>
<!-- 库存选择器 -->
<WmMaterialStockSelect ref="stockSelectRef" @select="handleStockSelected" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue' import {
import { WmProductionIssueDetailApi, WmProductionIssueDetailVO } from '@/api/mes/wm/productionissue/detail' WmProductionIssueDetailApi,
import WmMaterialStockSelect from '@/views/mes/wm/materialstock/components/WmMaterialStockSelect.vue' WmProductionIssueDetailVO
} from '@/api/mes/wm/productionissue/detail'
defineOptions({ name: 'ProductionIssueDetailList' }) defineOptions({ name: 'ProductionIssueDetailList' })
@ -97,45 +43,18 @@ const props = defineProps<{
const emit = defineEmits(['edit-detail']) const emit = defineEmits(['edit-detail'])
const { t } = useI18n() const { t } = useI18n() //
const message = useMessage() const message = useMessage() //
const loading = ref(false) const loading = ref(false) //
const list = ref<WmProductionIssueDetailVO[]>([]) const list = ref<WmProductionIssueDetailVO[]>([]) //
const dialogVisible = ref(false)
const formRef = ref()
const stockSelectRef = ref()
const canPick = computed(() => props.formType === 'stock') //
const formData = reactive<WmProductionIssueDetailVO & { availableQuantity?: number }>({
issueId: props.issueId,
lineId: props.lineId,
itemId: props.itemId,
materialStockId: 0,
quantity: 0,
batchId: undefined,
batchCode: '',
warehouseId: 0,
warehouseName: '',
locationId: undefined,
locationName: '',
areaId: undefined,
areaName: '',
remark: '',
availableQuantity: 0
})
const formRules = {
materialStockId: [{ required: true, message: '请选择库存位置', trigger: 'change' }],
quantity: [{ required: true, message: '请输入拣货数量', trigger: 'blur' }]
}
/** 查询明细列表 */ /** 查询明细列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
// TODO @AI list
try { try {
const data = await WmProductionIssueDetailApi.getDetailPage({ const data = await WmProductionIssueDetailApi.getProductionIssueDetailPage({
pageNo: 1, pageNo: 1,
pageSize: 100, pageSize: 100,
lineId: props.lineId lineId: props.lineId
@ -147,98 +66,18 @@ const getList = async () => {
} }
defineExpose({ getList }) defineExpose({ getList })
/** 添加拣货 */ /** 删除拣货明细 */
const handlePick = () => {
resetForm()
dialogVisible.value = true
}
/** 选择库存 */
const handleSelectStock = () => {
stockSelectRef.value.open(props.itemId)
}
/** 库存选择回调 */
const handleStockSelected = (stock: any) => {
formData.materialStockId = stock.materialStockId
formData.batchId = stock.batchId
formData.batchCode = stock.batchCode
formData.warehouseId = stock.warehouseId
formData.warehouseName = stock.warehouseName
formData.locationId = stock.locationId
formData.locationName = stock.locationName
formData.areaId = stock.areaId
formData.areaName = stock.areaName
formData.availableQuantity = stock.availableQuantity
}
/** 确认添加 */
const handleConfirm = async () => {
await formRef.value.validate()
try {
const data: WmProductionIssueDetailVO = {
issueId: props.issueId,
lineId: props.lineId,
itemId: props.itemId,
materialStockId: formData.materialStockId,
quantity: formData.quantity,
batchId: formData.batchId,
batchCode: formData.batchCode,
warehouseId: formData.warehouseId,
warehouseName: formData.warehouseName,
locationId: formData.locationId,
locationName: formData.locationName,
areaId: formData.areaId,
areaName: formData.areaName,
remark: formData.remark
}
await WmProductionIssueDetailApi.createDetail(data)
message.success('添加成功')
dialogVisible.value = false
await getList()
} catch {}
}
/** 删除明细 */
const handleDelete = async (detailId: number) => { const handleDelete = async (detailId: number) => {
try { try {
await message.delConfirm() await message.delConfirm()
await WmProductionIssueDetailApi.deleteDetail(detailId) await WmProductionIssueDetailApi.deleteProductionIssueDetail(detailId)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
await getList() await getList()
} catch {} } catch {}
} }
/** 重置表单 */
const resetForm = () => {
Object.assign(formData, {
issueId: props.issueId,
lineId: props.lineId,
itemId: props.itemId,
materialStockId: 0,
quantity: 0,
batchId: undefined,
batchCode: '',
warehouseId: 0,
warehouseName: '',
locationId: undefined,
locationName: '',
areaId: undefined,
areaName: '',
remark: '',
availableQuantity: 0
})
formRef.value?.clearValidate()
}
/** 初始化:延迟加载,展开时才触发 */ /** 初始化:延迟加载,展开时才触发 */
onMounted(() => { onMounted(() => {
getList() getList()
}) })
</script> </script>
<style scoped>
.cursor-pointer {
cursor: pointer;
}
</style>

View File

@ -32,21 +32,23 @@
<el-table-column label="规格型号" align="center" prop="specification" min-width="120" /> <el-table-column label="规格型号" align="center" prop="specification" min-width="120" />
<el-table-column label="单位" align="center" prop="unitMeasureName" width="80" /> <el-table-column label="单位" align="center" prop="unitMeasureName" width="80" />
<el-table-column label="领料数量" align="center" prop="quantity" width="100" /> <el-table-column label="领料数量" align="center" prop="quantity" width="100" />
<el-table-column label="批次号" align="center" prop="batchCode" min-width="120" />
<el-table-column <el-table-column
v-if="isUpdate" v-if="isUpdate || isStock"
label="操作" label="操作"
align="center" align="center"
width="160" width="160"
fixed="right" fixed="right"
> >
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="openForm('update', scope.row.id)"> <el-button v-if="isUpdate" link type="primary" @click="openForm('update', scope.row.id)">
编辑 编辑
</el-button> </el-button>
<el-button link type="danger" @click="handleDelete(scope.row.id)"> <el-button v-if="isUpdate" link type="danger" @click="handleDelete(scope.row.id)">
删除 删除
</el-button> </el-button>
<el-button v-if="isStock" link type="success" @click="handlePicking(scope.row.id)">
拣货
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -69,10 +71,10 @@
> >
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="物料" prop="itemId"> <el-form-item label="产品物料" prop="itemId">
<MdItemSelect <MdItemSelect
v-model="formData.itemId" v-model="formData.itemId"
placeholder="请选择物料" placeholder="请选择产品物料"
class="!w-1/1" class="!w-1/1"
@change="handleItemChange" @change="handleItemChange"
/> />
@ -89,11 +91,6 @@
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-form-item label="批次号" prop="batchCode">
<el-input v-model="formData.batchCode" placeholder="请输入批次号" />
</el-form-item>
</el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
@ -108,66 +105,53 @@
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
</template> </template>
</Dialog> </Dialog>
<!-- 拣货明细添加/编辑弹窗 -->
<ProductionIssueDetailForm
ref="detailFormRef"
:issue-id="props.issueId"
@success="onDetailFormSuccess"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, computed, onMounted } from 'vue' import {
import { WmProductionIssueLineApi, WmProductionIssueLineVO } from '@/api/mes/wm/productionissue/line' WmProductionIssueLineApi,
WmProductionIssueLineVO
} from '@/api/mes/wm/productionissue/line'
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue' import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
import ProductionIssueDetailList from './ProductionIssueDetailList.vue' import ProductionIssueDetailList from './ProductionIssueDetailList.vue'
import ProductionIssueDetailForm from './ProductionIssueDetailForm.vue'
defineOptions({ name: 'ProductionIssueLineList' }) defineOptions({ name: 'ProductionIssueLineList' })
const message = useMessage() const props = defineProps<{
issueId: number
formType: string
}>()
const props = defineProps({ const { t } = useI18n() //
issueId: { type: Number, required: true }, const message = useMessage() //
formType: { type: String, required: true }
})
const loading = ref(false) const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) //
const list = ref<WmProductionIssueLineVO[]>([]) const isStock = computed(() => props.formType === 'stock') //
const total = ref(0)
const dialogVisible = ref(false)
const dialogTitle = ref('')
const formLoading = ref(false)
const lineFormType = ref<string>('create')
const formRef = ref()
const detailListRefs = ref<Map<number, any>>(new Map())
// ==================== ====================
const loading = ref(false) //
const list = ref<WmProductionIssueLineVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
issueId: props.issueId issueId: undefined as number | undefined
}) })
const formData = ref<WmProductionIssueLineVO>({ /** 查询行列表 */
id: undefined,
issueId: props.issueId,
itemId: 0,
quantity: 0,
batchCode: undefined,
remark: undefined
})
const formRules = reactive({
itemId: [{ required: true, message: '请选择物料', trigger: 'change' }],
quantity: [{ required: true, message: '请输入领料数量', trigger: 'blur' }]
})
const isUpdate = computed(() => ['create', 'update'].includes(props.formType))
const setDetailListRef = (lineId: number, el: any) => {
if (el) {
detailListRefs.value.set(lineId, el)
}
}
/** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await WmProductionIssueLineApi.getLinePage(queryParams) queryParams.issueId = props.issueId
const data = await WmProductionIssueLineApi.getProductionIssueLinePage(queryParams)
list.value = data.list list.value = data.list
total.value = data.total total.value = data.total
} finally { } finally {
@ -175,17 +159,51 @@ const getList = async () => {
} }
} }
/** 删除 */
const handleDelete = async (id: number) => {
try {
await message.delConfirm()
await WmProductionIssueLineApi.deleteProductionIssueLine(id)
message.success(t('common.delSuccess'))
await getList()
} catch {}
}
// ==================== / ====================
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) //
const lineFormType = ref('') //
const formData = ref({
id: undefined,
issueId: undefined as number | undefined,
itemId: undefined,
quantity: undefined,
remark: undefined
})
const formRules = reactive({
itemId: [{ required: true, message: '物料不能为空', trigger: 'change' }],
quantity: [{ required: true, message: '领料数量不能为空', trigger: 'blur' }]
})
const formRef = ref() // Ref
/** 物料变化时,自动填充信息 */
const handleItemChange = (item: any) => {
if (item) {
formData.value.itemId = item.id
}
}
/** 打开表单弹窗 */ /** 打开表单弹窗 */
const openForm = async (type: string, id?: number) => { const openForm = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
dialogTitle.value = type === 'create' ? '添加物料' : '编辑物料' dialogTitle.value = type === 'create' ? '添加领料出库单行' : '修改领料出库单行'
lineFormType.value = type lineFormType.value = type
resetForm() resetForm()
// //
if (id) { if (id) {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await WmProductionIssueLineApi.getLine(id) formData.value = await WmProductionIssueLineApi.getProductionIssueLine(id)
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
@ -197,13 +215,13 @@ const submitForm = async () => {
await formRef.value.validate() await formRef.value.validate()
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value const data = { ...formData.value, issueId: props.issueId } as unknown as WmProductionIssueLineVO
if (lineFormType.value === 'create') { if (lineFormType.value === 'create') {
await WmProductionIssueLineApi.createLine(data) await WmProductionIssueLineApi.createProductionIssueLine(data)
message.success('新增成功') message.success(t('common.createSuccess'))
} else { } else {
await WmProductionIssueLineApi.updateLine(data) await WmProductionIssueLineApi.updateProductionIssueLine(data)
message.success('修改成功') message.success(t('common.updateSuccess'))
} }
dialogVisible.value = false dialogVisible.value = false
await getList() await getList()
@ -212,45 +230,49 @@ const submitForm = async () => {
} }
} }
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
await message.delConfirm()
await WmProductionIssueLineApi.deleteLine(id)
message.success('删除成功')
await getList()
} catch {}
}
/** 物料变化时,自动填充信息 */
const handleItemChange = (item: any) => {
if (item) {
formData.value.itemCode = item.code
formData.value.itemName = item.name
formData.value.specification = item.specification
formData.value.unitMeasureName = item.unitName
}
}
/** 打开明细表单弹窗 */
const openDetailForm = (type: string, lineId: number, itemId: number, detailId?: number) => {
// ProductionIssueDetailList
}
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
id: undefined, id: undefined,
issueId: props.issueId, issueId: undefined,
itemId: 0, itemId: undefined,
quantity: 0, quantity: undefined,
batchCode: undefined,
remark: undefined remark: undefined
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }
onMounted(() => { // ==================== ====================
getList() const detailListRefs = ref<Record<number, InstanceType<typeof ProductionIssueDetailList>>>({})
/** 缓存子组件 ref */
const setDetailListRef = (lineId: number, el: any) => {
if (el) {
detailListRefs.value[lineId] = el
}
}
// ==================== LineList ====================
const detailFormRef = ref()
/** 拣货:直接打开明细创建表单 */
const handlePicking = (lineId: number) => {
const row = list.value.find((r) => r.id === lineId)
openDetailForm('create', lineId, row?.itemId)
}
/** 打开拣货明细表单 */
const openDetailForm = (type: string, lineId: number, itemId?: number, detailId?: number) => {
detailFormRef.value.open(type, lineId, itemId, detailId)
}
/** 明细表单提交成功后,刷新已展开行的 DetailList */
const onDetailFormSuccess = (lineId: number) => {
detailListRefs.value[lineId]?.getList()
}
/** 初始化 */
onMounted(async () => {
await getList()
}) })
</script> </script>