✨ feat(mes): 更新领料出库单相关 API 接口及组件
重命名领料出库单和明细相关的 API 方法,增强代码可读性。新增领料出库明细表单组件,支持拣货明细的添加与编辑功能。同时,调整相关组件的逻辑以适应新的 API 结构。pull/871/MERGE
parent
bd27ddfc71
commit
5e2366ace0
|
|
@ -22,27 +22,27 @@ export interface WmProductionIssueDetailVO {
|
|||
// MES 领料出库明细 API
|
||||
export const WmProductionIssueDetailApi = {
|
||||
// 查询领料出库明细分页
|
||||
getDetailPage: async (params: any) => {
|
||||
getProductionIssueDetailPage: async (params: any) => {
|
||||
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 })
|
||||
},
|
||||
|
||||
// 新增领料出库明细
|
||||
createDetail: async (data: WmProductionIssueDetailVO) => {
|
||||
createProductionIssueDetail: async (data: WmProductionIssueDetailVO) => {
|
||||
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 })
|
||||
},
|
||||
|
||||
// 删除领料出库明细
|
||||
deleteDetail: async (id: number) => {
|
||||
deleteProductionIssueDetail: async (id: number) => {
|
||||
return await request.delete({ url: '/mes/wm/production-issue-detail/delete?id=' + id })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ export interface WmProductionIssueLineVO {
|
|||
unitMeasureName?: string
|
||||
quantity: number
|
||||
batchId?: number
|
||||
batchCode?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,34 +11,33 @@ export interface WmProductionIssueLineVO {
|
|||
unitMeasureName?: string
|
||||
quantity: number
|
||||
batchId?: number
|
||||
batchCode?: string
|
||||
remark?: string
|
||||
}
|
||||
|
||||
// MES 领料出库单行 API
|
||||
export const WmProductionIssueLineApi = {
|
||||
// 查询领料出库单行分页
|
||||
getLinePage: async (params: any) => {
|
||||
getProductionIssueLinePage: async (params: any) => {
|
||||
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 })
|
||||
},
|
||||
|
||||
// 新增领料出库单行
|
||||
createLine: async (data: WmProductionIssueLineVO) => {
|
||||
createProductionIssueLine: async (data: WmProductionIssueLineVO) => {
|
||||
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 })
|
||||
},
|
||||
|
||||
// 删除领料出库单行
|
||||
deleteLine: async (id: number) => {
|
||||
deleteProductionIssueLine: async (id: number) => {
|
||||
return await request.delete({ url: '/mes/wm/production-issue-line/delete?id=' + id })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<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 === 'shelving'"
|
||||
v-if="props.formType === 'stock'"
|
||||
label="操作"
|
||||
align="center"
|
||||
width="120"
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ const message = useMessage() // 消息弹窗
|
|||
|
||||
const dialogVisible = 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({
|
||||
id: undefined as number | undefined,
|
||||
code: undefined,
|
||||
|
|
@ -129,15 +129,14 @@ const formRules = reactive({
|
|||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
// TODO @AI:formType 还是使用 stock,而不是 shelving;
|
||||
const isUpdate = computed(() => ['create', 'update'].includes(formType.value)) // 是否为编辑模式
|
||||
const isStock = computed(() => formType.value === 'shelving') // 是否为上架模式
|
||||
const isHeaderReadonly = computed(() => ['shelving', 'detail'].includes(formType.value)) // 是否只读
|
||||
const isStock = computed(() => formType.value === 'stock') // 是否为上架模式
|
||||
const isHeaderReadonly = computed(() => ['stock', 'detail'].includes(formType.value)) // 是否只读
|
||||
const dialogTitle = computed(() => {
|
||||
const titles = {
|
||||
create: '新增采购入库单',
|
||||
update: '编辑采购入库单',
|
||||
shelving: '执行上架',
|
||||
stock: '执行上架',
|
||||
detail: '采购入库单详情'
|
||||
}
|
||||
return titles[formType.value] || formType.value
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ const { t } = useI18n() // 国际化
|
|||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const isUpdate = computed(() => ['create', 'update'].includes(props.formType)) // 是否为编辑模式
|
||||
const isStock = computed(() => props.formType === 'shelving') // 是否为上架模式
|
||||
const isStock = computed(() => props.formType === 'stock') // 是否为上架模式
|
||||
|
||||
// ==================== 列表 ====================
|
||||
const loading = ref(false) // 列表的加载中
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@
|
|||
<el-button
|
||||
link
|
||||
type="success"
|
||||
@click="openForm('shelving', scope.row.id)"
|
||||
@click="openForm('stock', scope.row.id)"
|
||||
v-hasPermi="['mes:wm-item-receipt:update']"
|
||||
v-if="scope.row.status === MesWmItemReceiptStatusEnum.APPROVING"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -1,90 +1,36 @@
|
|||
<!-- MES 领料出库明细列表(展开行内嵌子组件) -->
|
||||
<!-- MES 领料出库拣货明细列表(展开行内嵌子组件) -->
|
||||
<template>
|
||||
<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-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="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 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="canPick"
|
||||
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>
|
||||
<!-- TODO @芋艿:【保留】标签打印 -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</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>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { WmProductionIssueDetailApi, WmProductionIssueDetailVO } from '@/api/mes/wm/productionissue/detail'
|
||||
import WmMaterialStockSelect from '@/views/mes/wm/materialstock/components/WmMaterialStockSelect.vue'
|
||||
import {
|
||||
WmProductionIssueDetailApi,
|
||||
WmProductionIssueDetailVO
|
||||
} from '@/api/mes/wm/productionissue/detail'
|
||||
|
||||
defineOptions({ name: 'ProductionIssueDetailList' })
|
||||
|
||||
|
|
@ -97,45 +43,18 @@ const props = defineProps<{
|
|||
|
||||
const emit = defineEmits(['edit-detail'])
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const loading = ref(false)
|
||||
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 loading = ref(false) // 列表的加载中
|
||||
const list = ref<WmProductionIssueDetailVO[]>([]) // 明细列表
|
||||
|
||||
/** 查询明细列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
// TODO @AI:走 list 接口,不需要分页;检查下;
|
||||
try {
|
||||
const data = await WmProductionIssueDetailApi.getDetailPage({
|
||||
const data = await WmProductionIssueDetailApi.getProductionIssueDetailPage({
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
lineId: props.lineId
|
||||
|
|
@ -147,98 +66,18 @@ const getList = async () => {
|
|||
}
|
||||
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) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await WmProductionIssueDetailApi.deleteDetail(detailId)
|
||||
await WmProductionIssueDetailApi.deleteProductionIssueDetail(detailId)
|
||||
message.success(t('common.delSuccess'))
|
||||
await getList()
|
||||
} 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(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -32,21 +32,23 @@
|
|||
<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"
|
||||
v-if="isUpdate || isStock"
|
||||
label="操作"
|
||||
align="center"
|
||||
width="160"
|
||||
fixed="right"
|
||||
>
|
||||
<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 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 v-if="isStock" link type="success" @click="handlePicking(scope.row.id)">
|
||||
拣货
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -69,10 +71,10 @@
|
|||
>
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="物料" prop="itemId">
|
||||
<el-form-item label="产品物料" prop="itemId">
|
||||
<MdItemSelect
|
||||
v-model="formData.itemId"
|
||||
placeholder="请选择物料"
|
||||
placeholder="请选择产品物料"
|
||||
class="!w-1/1"
|
||||
@change="handleItemChange"
|
||||
/>
|
||||
|
|
@ -89,11 +91,6 @@
|
|||
/>
|
||||
</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">
|
||||
|
|
@ -108,66 +105,53 @@
|
|||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
|
||||
<!-- 拣货明细添加/编辑弹窗 -->
|
||||
<ProductionIssueDetailForm
|
||||
ref="detailFormRef"
|
||||
:issue-id="props.issueId"
|
||||
@success="onDetailFormSuccess"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { WmProductionIssueLineApi, WmProductionIssueLineVO } from '@/api/mes/wm/productionissue/line'
|
||||
import {
|
||||
WmProductionIssueLineApi,
|
||||
WmProductionIssueLineVO
|
||||
} from '@/api/mes/wm/productionissue/line'
|
||||
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||
import ProductionIssueDetailList from './ProductionIssueDetailList.vue'
|
||||
import ProductionIssueDetailForm from './ProductionIssueDetailForm.vue'
|
||||
|
||||
defineOptions({ name: 'ProductionIssueLineList' })
|
||||
|
||||
const message = useMessage()
|
||||
const props = defineProps<{
|
||||
issueId: number
|
||||
formType: string
|
||||
}>()
|
||||
|
||||
const props = defineProps({
|
||||
issueId: { type: Number, required: true },
|
||||
formType: { type: String, required: true }
|
||||
})
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref<WmProductionIssueLineVO[]>([])
|
||||
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 isUpdate = computed(() => ['create', 'update'].includes(props.formType)) // 是否为编辑模式
|
||||
const isStock = computed(() => props.formType === 'stock') // 是否为拣货模式
|
||||
|
||||
// ==================== 列表 ====================
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const list = ref<WmProductionIssueLineVO[]>([]) // 行列表
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
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 () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await WmProductionIssueLineApi.getLinePage(queryParams)
|
||||
queryParams.issueId = props.issueId
|
||||
const data = await WmProductionIssueLineApi.getProductionIssueLinePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} 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) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = type === 'create' ? '添加物料' : '编辑物料'
|
||||
dialogTitle.value = type === 'create' ? '添加领料出库单行' : '修改领料出库单行'
|
||||
lineFormType.value = type
|
||||
resetForm()
|
||||
// 修改/上架/详情时,加载数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await WmProductionIssueLineApi.getLine(id)
|
||||
formData.value = await WmProductionIssueLineApi.getProductionIssueLine(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
|
|
@ -197,13 +215,13 @@ const submitForm = async () => {
|
|||
await formRef.value.validate()
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value
|
||||
const data = { ...formData.value, issueId: props.issueId } as unknown as WmProductionIssueLineVO
|
||||
if (lineFormType.value === 'create') {
|
||||
await WmProductionIssueLineApi.createLine(data)
|
||||
message.success('新增成功')
|
||||
await WmProductionIssueLineApi.createProductionIssueLine(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await WmProductionIssueLineApi.updateLine(data)
|
||||
message.success('修改成功')
|
||||
await WmProductionIssueLineApi.updateProductionIssueLine(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
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 = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
issueId: props.issueId,
|
||||
itemId: 0,
|
||||
quantity: 0,
|
||||
batchCode: undefined,
|
||||
issueId: undefined,
|
||||
itemId: undefined,
|
||||
quantity: undefined,
|
||||
remark: undefined
|
||||
}
|
||||
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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue