✨ feat(mes): 添加产品收货单及行相关功能和数据结构
新增产品收货单及行的相关数据对象、请求和响应 VO,以及对应的服务和控制器接口。实现了产品收货单的创建、更新、删除和查询功能,支持与物料、仓库等模块的关联,提升了系统的可扩展性和可维护性。pull/871/MERGE
parent
248635e3d7
commit
c1a0c63ba6
|
|
@ -300,4 +300,5 @@ export enum DICT_TYPE {
|
||||||
MES_WM_QUALITY_STATUS = 'mes_wm_quality_status', // MES 质量状态
|
MES_WM_QUALITY_STATUS = 'mes_wm_quality_status', // MES 质量状态
|
||||||
MES_WM_RETURN_ISSUE_STATUS = 'mes_wm_return_issue_status', // MES 生产退料单状态
|
MES_WM_RETURN_ISSUE_STATUS = 'mes_wm_return_issue_status', // MES 生产退料单状态
|
||||||
MES_WM_RETURN_ISSUE_TYPE = 'mes_wm_return_issue_type', // MES 退料类型
|
MES_WM_RETURN_ISSUE_TYPE = 'mes_wm_return_issue_type', // MES 退料类型
|
||||||
|
MES_WM_PRODUCT_RECPT_STATUS = 'mes_wm_product_recpt_status', // MES 成品入库单状态
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
<!-- 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="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 { WmProductRecptDetailApi, WmProductRecptDetailVO } from '@/api/mes/wm/productrecpt/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: 'ProductRecptDetailForm' })
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
recptId: 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('')
|
||||||
|
const currentLineId = ref<number>()
|
||||||
|
const formRef = ref()
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined as number | undefined,
|
||||||
|
lineId: undefined as number | undefined,
|
||||||
|
recptId: undefined as number | undefined,
|
||||||
|
itemId: undefined as number | undefined,
|
||||||
|
quantity: undefined as number | 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 WmProductRecptDetailApi.getProductRecptDetail(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,
|
||||||
|
recptId: props.recptId,
|
||||||
|
lineId: currentLineId.value
|
||||||
|
} as unknown as WmProductRecptDetailVO
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await WmProductRecptDetailApi.createProductRecptDetail(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await WmProductRecptDetailApi.updateProductRecptDetail(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,
|
||||||
|
recptId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
locationId: undefined,
|
||||||
|
areaId: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
<!-- MES 产品入库单明细列表(展开行内嵌子组件) -->
|
||||||
|
<template>
|
||||||
|
<div class="pl-60px pr-20px py-10px">
|
||||||
|
<el-table v-loading="loading" :data="list" border size="small">
|
||||||
|
<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="areaName" min-width="100" />
|
||||||
|
<el-table-column label="数量" align="center" prop="quantity" width="100" />
|
||||||
|
<el-table-column
|
||||||
|
v-if="props.formType === 'stock'"
|
||||||
|
label="操作"
|
||||||
|
align="center"
|
||||||
|
width="120"
|
||||||
|
fixed="right"
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { WmProductRecptDetailApi, WmProductRecptDetailVO } from '@/api/mes/wm/productrecpt/detail'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ProductRecptDetailList' })
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
recptId: number
|
||||||
|
lineId: number
|
||||||
|
itemId: number
|
||||||
|
formType: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits(['edit-detail'])
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const list = ref<WmProductRecptDetailVO[]>([])
|
||||||
|
|
||||||
|
/** 查询明细列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
list.value = await WmProductRecptDetailApi.getProductRecptDetailListByLineId(props.lineId)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ getList })
|
||||||
|
|
||||||
|
/** 删除上架明细 */
|
||||||
|
const handleDelete = async (detailId: number) => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await WmProductRecptDetailApi.deleteProductRecptDetail(detailId)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化:延迟加载,展开时才触发 */
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,209 @@
|
||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="110px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="入库单编号" prop="code">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.code"
|
||||||
|
placeholder="请输入入库单编号"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
>
|
||||||
|
<template #append>
|
||||||
|
<el-button @click="generateCode" :disabled="formType !== 'create'">
|
||||||
|
生成
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="入库单名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.name"
|
||||||
|
placeholder="请输入入库单名称"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="入库日期" prop="receiptDate">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="formData.receiptDate"
|
||||||
|
type="date"
|
||||||
|
value-format="x"
|
||||||
|
placeholder="请选择入库日期"
|
||||||
|
class="!w-1/1"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="生产工单" prop="workOrderId">
|
||||||
|
<ProWorkOrderSelect v-model="formData.workOrderId" :disabled="isHeaderReadonly" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<!-- TODO @AI:MdItemSelect 都是 readonly,通过 ProWorkOrderSelect 选择后,设置下; -->
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="产品物料" prop="itemId">
|
||||||
|
<MdItemSelect v-model="formData.itemId" :disabled="isHeaderReadonly" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.remark"
|
||||||
|
type="textarea"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
:disabled="isHeaderReadonly"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<!-- 非新建模式展示行项目信息(收货物料) -->
|
||||||
|
<template v-if="formData.id">
|
||||||
|
<el-divider content-position="center">物料信息</el-divider>
|
||||||
|
<ProductRecptLineList :recpt-id="formData.id" :form-type="formType" />
|
||||||
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<el-button v-if="isUpdate" @click="submitForm" type="primary" :disabled="formLoading">
|
||||||
|
确 定
|
||||||
|
</el-button>
|
||||||
|
<el-button v-if="isStock" @click="handleStock" type="primary" :disabled="formLoading">
|
||||||
|
执行上架
|
||||||
|
</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { generateRandomStr } from '@/utils'
|
||||||
|
import { WmProductRecptApi, WmProductRecptVO } from '@/api/mes/wm/productrecpt'
|
||||||
|
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
|
import ProWorkOrderSelect from '@/views/mes/pro/workorder/components/ProWorkOrderSelect.vue'
|
||||||
|
import ProductRecptLineList from './ProductRecptLineList.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ProductRecptForm' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const formLoading = ref(false)
|
||||||
|
const formType = ref<string>('create')
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined as number | undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
workOrderId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
receiptDate: undefined,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
// TODO @AI:name;必填
|
||||||
|
code: [{ required: true, message: '入库单编号不能为空', trigger: 'blur' }],
|
||||||
|
receiptDate: [{ required: true, message: '入库日期不能为空', trigger: 'change' }],
|
||||||
|
// TODO @AI:workOrderId 可选;
|
||||||
|
workOrderId: [{ required: true, message: '生产工单不能为空', trigger: 'change' }],
|
||||||
|
// TODO @AI:去掉 itemId 必填;
|
||||||
|
itemId: [{ required: true, message: '产品物料不能为空', trigger: 'change' }]
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
const isUpdate = computed(() => ['create', 'update'].includes(formType.value))
|
||||||
|
const isStock = computed(() => formType.value === 'stock')
|
||||||
|
const isHeaderReadonly = computed(() => ['stock', 'detail'].includes(formType.value))
|
||||||
|
const dialogTitle = computed(() => {
|
||||||
|
const titles = {
|
||||||
|
create: '新增产品入库单',
|
||||||
|
update: '编辑产品入库单',
|
||||||
|
stock: '执行上架',
|
||||||
|
detail: '产品入库单详情'
|
||||||
|
}
|
||||||
|
return titles[formType.value] || formType.value
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 生成入库单编号 */
|
||||||
|
const generateCode = () => {
|
||||||
|
formData.value.code = 'PR' + generateRandomStr(10)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 打开弹窗 */
|
||||||
|
const open = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await WmProductRecptApi.getProductRecpt(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open })
|
||||||
|
|
||||||
|
/** 提交表单(create/update 模式) */
|
||||||
|
const emit = defineEmits(['success'])
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = formData.value as unknown as WmProductRecptVO
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
const res = await WmProductRecptApi.createProductRecpt(data)
|
||||||
|
message.success('新增成功')
|
||||||
|
formData.value.id = res
|
||||||
|
formType.value = 'update'
|
||||||
|
} else {
|
||||||
|
await WmProductRecptApi.updateProductRecpt(data)
|
||||||
|
message.success('修改成功')
|
||||||
|
}
|
||||||
|
emit('success')
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行上架 */
|
||||||
|
const handleStock = async () => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认执行上架?')
|
||||||
|
formLoading.value = true
|
||||||
|
await WmProductRecptApi.stockProductRecpt(formData.value.id!)
|
||||||
|
message.success('上架成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit('success')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
workOrderId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
receiptDate: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,277 @@
|
||||||
|
<!-- MES 产品入库单行列表子组件 -->
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-button v-if="isUpdate" type="primary" plain @click="openForm('create')" class="mb-10px">
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 添加物料
|
||||||
|
</el-button>
|
||||||
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
border
|
||||||
|
:row-key="(row: any) => row.id"
|
||||||
|
>
|
||||||
|
<el-table-column type="expand">
|
||||||
|
<template #default="scope">
|
||||||
|
<ProductRecptDetailList
|
||||||
|
:ref="(el: any) => setDetailListRef(scope.row.id, el)"
|
||||||
|
:recpt-id="props.recptId"
|
||||||
|
:line-id="scope.row.id"
|
||||||
|
:item-id="scope.row.itemId"
|
||||||
|
:form-type="props.formType"
|
||||||
|
@edit-detail="
|
||||||
|
(detailId: number) =>
|
||||||
|
openDetailForm('update', scope.row.id, scope.row.itemId, detailId)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="物料编码" align="center" prop="itemCode" min-width="120" />
|
||||||
|
<el-table-column label="物料名称" align="center" prop="itemName" min-width="140" />
|
||||||
|
<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="quantity" width="100" />
|
||||||
|
<el-table-column label="批次号" align="center" prop="batchCode" min-width="120" />
|
||||||
|
<el-table-column
|
||||||
|
v-if="isUpdate || isStock"
|
||||||
|
label="操作"
|
||||||
|
align="center"
|
||||||
|
width="160"
|
||||||
|
fixed="right"
|
||||||
|
>
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button v-if="isUpdate" link type="primary" @click="openForm('update', scope.row.id)">
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button v-if="isUpdate" link type="danger" @click="handleDelete(scope.row.id)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<el-button v-if="isStock" link type="success" @click="handleStock(scope.row.id)">
|
||||||
|
上架
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 添加/编辑行弹窗 -->
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="960px">
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="110px"
|
||||||
|
v-loading="formLoading"
|
||||||
|
>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="物料" prop="itemId">
|
||||||
|
<MdItemSelect
|
||||||
|
v-model="formData.itemId"
|
||||||
|
placeholder="请选择物料"
|
||||||
|
class="!w-1/1"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<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-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-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
|
<!-- 上架明细添加/编辑弹窗 -->
|
||||||
|
<ProductRecptDetailForm
|
||||||
|
ref="detailFormRef"
|
||||||
|
:recpt-id="props.recptId"
|
||||||
|
@success="onDetailFormSuccess"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { WmProductRecptLineApi, WmProductRecptLineVO } from '@/api/mes/wm/productrecpt/line'
|
||||||
|
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
|
import ProductRecptDetailList from './ProductRecptDetailList.vue'
|
||||||
|
import ProductRecptDetailForm from './ProductRecptDetailForm.vue'
|
||||||
|
|
||||||
|
defineOptions({ name: 'ProductRecptLineList' })
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
recptId: number
|
||||||
|
formType: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
|
const isUpdate = computed(() => ['create', 'update'].includes(props.formType))
|
||||||
|
const isStock = computed(() => props.formType === 'stock')
|
||||||
|
|
||||||
|
// ==================== 列表 ====================
|
||||||
|
const loading = ref(false)
|
||||||
|
const list = ref<WmProductRecptLineVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
recptId: undefined as number | undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 查询行列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
queryParams.recptId = props.recptId
|
||||||
|
const data = await WmProductRecptLineApi.getProductRecptLinePage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await WmProductRecptLineApi.deleteProductRecptLine(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,
|
||||||
|
recptId: undefined as number | undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
batchId: undefined,
|
||||||
|
batchCode: undefined,
|
||||||
|
remark: undefined
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
itemId: [{ required: true, message: '物料不能为空', trigger: 'change' }],
|
||||||
|
quantity: [{ required: true, message: '入库数量不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
/** 打开表单弹窗 */
|
||||||
|
const openForm = async (type: string, id?: number) => {
|
||||||
|
dialogVisible.value = true
|
||||||
|
dialogTitle.value = type === 'create' ? '添加物料入库单行' : '修改物料入库单行'
|
||||||
|
lineFormType.value = type
|
||||||
|
resetForm()
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
formData.value = await WmProductRecptLineApi.getProductRecptLine(id)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const submitForm = async () => {
|
||||||
|
await formRef.value.validate()
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = { ...formData.value, recptId: props.recptId } as unknown as WmProductRecptLineVO
|
||||||
|
if (lineFormType.value === 'create') {
|
||||||
|
await WmProductRecptLineApi.createProductRecptLine(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await WmProductRecptLineApi.updateProductRecptLine(data)
|
||||||
|
message.success(t('common.updateSuccess'))
|
||||||
|
}
|
||||||
|
dialogVisible.value = false
|
||||||
|
await getList()
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
recptId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
quantity: undefined,
|
||||||
|
batchId: undefined,
|
||||||
|
batchCode: undefined,
|
||||||
|
remark: undefined
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 展开行:上架明细 ====================
|
||||||
|
const detailListRefs = ref<Record<number, InstanceType<typeof ProductRecptDetailList>>>({})
|
||||||
|
|
||||||
|
/** 缓存子组件 ref */
|
||||||
|
const setDetailListRef = (lineId: number, el: any) => {
|
||||||
|
if (el) {
|
||||||
|
detailListRefs.value[lineId] = el
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 上架明细表单(LineList 层级持有) ====================
|
||||||
|
const detailFormRef = ref()
|
||||||
|
|
||||||
|
/** 上架:直接打开明细创建表单 */
|
||||||
|
const handleStock = (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>
|
||||||
|
|
@ -0,0 +1,293 @@
|
||||||
|
<template>
|
||||||
|
<ContentWrap>
|
||||||
|
<el-form
|
||||||
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="100px"
|
||||||
|
>
|
||||||
|
<el-form-item label="入库单编号" prop="code">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.code"
|
||||||
|
placeholder="请输入入库单编号"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入库单名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入入库单名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="生产工单" prop="workOrderId">
|
||||||
|
<ProWorkOrderSelect v-model="queryParams.workOrderId" class="!w-240px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品物料" prop="itemId">
|
||||||
|
<MdItemSelect v-model="queryParams.itemId" class="!w-240px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.MES_WM_PRODUCT_RECPT_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入库日期" prop="receiptDate">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.receiptDate"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
type="daterange"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="openForm('create')"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ContentWrap>
|
||||||
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||||
|
<el-table-column label="入库单编号" align="center" prop="code" min-width="160" />
|
||||||
|
<el-table-column label="入库单名称" align="center" prop="name" min-width="150" />
|
||||||
|
<el-table-column label="生产工单" align="center" prop="workOrderCode" min-width="120" />
|
||||||
|
<!-- TODO @AI:itemName -> itemCode -->
|
||||||
|
<el-table-column label="产品物料" align="center" prop="itemName" min-width="120" />
|
||||||
|
<el-table-column
|
||||||
|
label="入库日期"
|
||||||
|
align="center"
|
||||||
|
prop="receiptDate"
|
||||||
|
:formatter="dateFormatter2"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="单据状态" align="center" prop="status" min-width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.MES_WM_PRODUCT_RECPT_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" width="240" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<!-- 草稿:编辑、提交、删除 -->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:update']"
|
||||||
|
v-if="scope.row.status === MesWmProductRecptStatusEnum.PREPARE"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="warning"
|
||||||
|
@click="handleSubmit(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:update']"
|
||||||
|
v-if="scope.row.status === MesWmProductRecptStatusEnum.PREPARE"
|
||||||
|
>
|
||||||
|
提交
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:delete']"
|
||||||
|
v-if="scope.row.status === MesWmProductRecptStatusEnum.PREPARE"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<!-- 待上架:执行上架、取消 -->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="success"
|
||||||
|
@click="openForm('stock', scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:update']"
|
||||||
|
v-if="scope.row.status === MesWmProductRecptStatusEnum.APPROVING"
|
||||||
|
>
|
||||||
|
执行上架
|
||||||
|
</el-button>
|
||||||
|
<!-- 待入库:执行入库、取消 -->
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="handleExecute(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:execute']"
|
||||||
|
v-if="scope.row.status === MesWmProductRecptStatusEnum.APPROVED"
|
||||||
|
>
|
||||||
|
执行入库
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleCancel(scope.row.id)"
|
||||||
|
v-hasPermi="['mes:wm-product-recpt:update']"
|
||||||
|
v-if="
|
||||||
|
[MesWmProductRecptStatusEnum.APPROVING, MesWmProductRecptStatusEnum.APPROVED].includes(
|
||||||
|
scope.row.status
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<ProductRecptForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { dateFormatter2 } from '@/utils/formatTime'
|
||||||
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { WmProductRecptApi, WmProductRecptVO } from '@/api/mes/wm/productrecpt'
|
||||||
|
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||||
|
import ProWorkOrderSelect from '@/views/mes/pro/workorder/components/ProWorkOrderSelect.vue'
|
||||||
|
import ProductRecptForm from './ProductRecptForm.vue'
|
||||||
|
import { MesWmProductRecptStatusEnum } from '@/views/mes/utils/constants'
|
||||||
|
|
||||||
|
defineOptions({ name: 'MesWmProductRecpt' })
|
||||||
|
|
||||||
|
const message = useMessage()
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
const loading = ref(true)
|
||||||
|
const list = ref<WmProductRecptVO[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
const exportLoading = ref(false)
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
code: undefined,
|
||||||
|
name: undefined,
|
||||||
|
workOrderId: undefined,
|
||||||
|
itemId: undefined,
|
||||||
|
status: undefined,
|
||||||
|
receiptDate: undefined
|
||||||
|
})
|
||||||
|
const queryFormRef = ref()
|
||||||
|
const formRef = ref()
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await WmProductRecptApi.getProductRecptPage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加/修改操作 */
|
||||||
|
const openForm = (type: string, id?: number) => {
|
||||||
|
formRef.value.open(type, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交按钮操作 */
|
||||||
|
const handleSubmit = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认提交该产品入库单?')
|
||||||
|
await WmProductRecptApi.submitProductRecpt(id)
|
||||||
|
message.success('提交成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行入库 */
|
||||||
|
const handleExecute = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认执行入库?执行后将更新库存台账。')
|
||||||
|
await WmProductRecptApi.executeProductRecpt(id)
|
||||||
|
message.success('入库成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消 */
|
||||||
|
const handleCancel = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.confirm('确认取消该产品入库单?取消后不可恢复。')
|
||||||
|
await WmProductRecptApi.cancelProductRecpt(id)
|
||||||
|
message.success('取消成功')
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await WmProductRecptApi.deleteProductRecpt(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
await message.exportConfirm()
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await WmProductRecptApi.exportProductRecpt(queryParams)
|
||||||
|
download.excel(data, '产品入库单.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue