✨ feat(mes): 添加外协发料单行及明细相关功能和请求响应 VO
parent
e6261273d4
commit
63f28ba4c3
|
|
@ -0,0 +1,45 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// MES 委外收货明细 VO
|
||||
export interface WmOutsourceReceiptDetailVO {
|
||||
id: number
|
||||
lineId: number
|
||||
receiptId: number
|
||||
itemId: number
|
||||
itemCode: string
|
||||
itemName: string
|
||||
batchCode: string
|
||||
quantity: number
|
||||
locationId: number
|
||||
locationName: string
|
||||
remark: string
|
||||
createTime: string
|
||||
}
|
||||
|
||||
// MES 委外收货明细 API
|
||||
export const WmOutsourceReceiptDetailApi = {
|
||||
// 查询委外收货明细列表(按行编号)
|
||||
getOutsourceReceiptDetailListByLineId: async (lineId: number) => {
|
||||
return await request.get({ url: '/mes/wm/outsource-receipt-detail/list-by-line', params: { lineId } })
|
||||
},
|
||||
|
||||
// 查询委外收货明细详情
|
||||
getOutsourceReceiptDetail: async (id: number) => {
|
||||
return await request.get({ url: '/mes/wm/outsource-receipt-detail/get?id=' + id })
|
||||
},
|
||||
|
||||
// 新增委外收货明细
|
||||
createOutsourceReceiptDetail: async (data: WmOutsourceReceiptDetailVO) => {
|
||||
return await request.post({ url: '/mes/wm/outsource-receipt-detail/create', data })
|
||||
},
|
||||
|
||||
// 修改委外收货明细
|
||||
updateOutsourceReceiptDetail: async (data: WmOutsourceReceiptDetailVO) => {
|
||||
return await request.put({ url: '/mes/wm/outsource-receipt-detail/update', data })
|
||||
},
|
||||
|
||||
// 删除委外收货明细
|
||||
deleteOutsourceReceiptDetail: async (id: number) => {
|
||||
return await request.delete({ url: '/mes/wm/outsource-receipt-detail/delete?id=' + id })
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// MES 委外收货单 VO
|
||||
export interface WmOutsourceReceiptVO {
|
||||
id: number
|
||||
code: string
|
||||
name: string
|
||||
vendorId: number
|
||||
vendorName: string
|
||||
warehouseId: number
|
||||
warehouseName: string
|
||||
receiptDate: string
|
||||
status: number
|
||||
remark: string
|
||||
createTime: string
|
||||
}
|
||||
|
||||
// MES 委外收货单明细 VO
|
||||
export interface WmOutsourceReceiptLineVO {
|
||||
id: number
|
||||
receiptId: number
|
||||
itemId: number
|
||||
itemCode: string
|
||||
itemName: string
|
||||
quantity: number
|
||||
unitId: number
|
||||
unitName: string
|
||||
remark: string
|
||||
}
|
||||
|
||||
// MES 委外收货单详情 VO
|
||||
export interface WmOutsourceReceiptDetailVO {
|
||||
id: number
|
||||
lineId: number
|
||||
batchCode: string
|
||||
quantity: number
|
||||
locationId: number
|
||||
locationName: string
|
||||
remark: string
|
||||
}
|
||||
|
||||
// MES 委外收货单 API
|
||||
export const WmOutsourceReceiptApi = {
|
||||
// 查询委外收货单分页
|
||||
getOutsourceReceiptPage: async (params: any) => {
|
||||
return await request.get({ url: '/mes/wm/outsource-receipt/page', params })
|
||||
},
|
||||
|
||||
// 查询委外收货单详情
|
||||
getOutsourceReceipt: async (id: number) => {
|
||||
return await request.get({ url: '/mes/wm/outsource-receipt/get?id=' + id })
|
||||
},
|
||||
|
||||
// 新增委外收货单
|
||||
createOutsourceReceipt: async (data: WmOutsourceReceiptVO) => {
|
||||
return await request.post({ url: '/mes/wm/outsource-receipt/create', data })
|
||||
},
|
||||
|
||||
// 修改委外收货单
|
||||
updateOutsourceReceipt: async (data: WmOutsourceReceiptVO) => {
|
||||
return await request.put({ url: '/mes/wm/outsource-receipt/update', data })
|
||||
},
|
||||
|
||||
// 删除委外收货单
|
||||
deleteOutsourceReceipt: async (id: number) => {
|
||||
return await request.delete({ url: '/mes/wm/outsource-receipt/delete?id=' + id })
|
||||
},
|
||||
|
||||
// 提交委外收货单
|
||||
submitOutsourceReceipt: async (id: number) => {
|
||||
return await request.put({ url: '/mes/wm/outsource-receipt/submit?id=' + id })
|
||||
},
|
||||
|
||||
// 审批委外收货单
|
||||
approveOutsourceReceipt: async (id: number) => {
|
||||
return await request.put({ url: '/mes/wm/outsource-receipt/approve?id=' + id })
|
||||
},
|
||||
|
||||
// 完成委外收货单
|
||||
finishOutsourceReceipt: async (id: number) => {
|
||||
return await request.put({ url: '/mes/wm/outsource-receipt/finish?id=' + id })
|
||||
},
|
||||
|
||||
// 取消委外收货单
|
||||
cancelOutsourceReceipt: async (id: number) => {
|
||||
return await request.put({ url: '/mes/wm/outsource-receipt/cancel?id=' + id })
|
||||
},
|
||||
|
||||
// 导出委外收货单 Excel
|
||||
exportOutsourceReceipt: async (params: any) => {
|
||||
return await request.download({ url: '/mes/wm/outsource-receipt/export-excel', params })
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// MES 委外收货单行 VO
|
||||
export interface WmOutsourceReceiptLineVO {
|
||||
id: number
|
||||
receiptId: number
|
||||
itemId: number
|
||||
itemCode: string
|
||||
itemName: string
|
||||
quantity: number
|
||||
unitId: number
|
||||
unitName: string
|
||||
remark: string
|
||||
createTime: string
|
||||
}
|
||||
|
||||
// MES 委外收货单行 API
|
||||
export const WmOutsourceReceiptLineApi = {
|
||||
// 查询委外收货单行分页
|
||||
getOutsourceReceiptLinePage: async (params: any) => {
|
||||
return await request.get({ url: '/mes/wm/outsource-receipt-line/page', params })
|
||||
},
|
||||
|
||||
// 查询委外收货单行详情
|
||||
getOutsourceReceiptLine: async (id: number) => {
|
||||
return await request.get({ url: '/mes/wm/outsource-receipt-line/get?id=' + id })
|
||||
},
|
||||
|
||||
// 新增委外收货单行
|
||||
createOutsourceReceiptLine: async (data: WmOutsourceReceiptLineVO) => {
|
||||
return await request.post({ url: '/mes/wm/outsource-receipt-line/create', data })
|
||||
},
|
||||
|
||||
// 修改委外收货单行
|
||||
updateOutsourceReceiptLine: async (data: WmOutsourceReceiptLineVO) => {
|
||||
return await request.put({ url: '/mes/wm/outsource-receipt-line/update', data })
|
||||
},
|
||||
|
||||
// 删除委外收货单行
|
||||
deleteOutsourceReceiptLine: async (id: number) => {
|
||||
return await request.delete({ url: '/mes/wm/outsource-receipt-line/delete?id=' + id })
|
||||
}
|
||||
}
|
||||
|
|
@ -236,6 +236,14 @@ export const MesWmProductionIssueStatusEnum = {
|
|||
CANCELED: MesOrderStatusConstants.CANCELLED
|
||||
}
|
||||
|
||||
/** MES 杂项入库单状态枚举 */
|
||||
export const MesWmMiscReceiptStatusEnum = {
|
||||
PREPARE: MesOrderStatusConstants.DRAFT,
|
||||
APPROVED: MesOrderStatusConstants.APPROVED,
|
||||
FINISHED: MesOrderStatusConstants.FINISHED,
|
||||
CANCELED: MesOrderStatusConstants.CANCELLED
|
||||
}
|
||||
|
||||
/** MES 供应商退货单状态枚举 */
|
||||
export const MesWmReturnVendorStatusEnum = {
|
||||
PREPARE: MesOrderStatusConstants.DRAFT,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,138 @@
|
|||
<!-- 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="batchCode">
|
||||
<el-input v-model="formData.batchCode" placeholder="请输入批次号" />
|
||||
</el-form-item>
|
||||
<!-- TODO @AI:参考别的 detail form;应该有 3 个 select; -->
|
||||
<el-form-item label="库位" prop="locationId">
|
||||
<MdLocationSelect v-model="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-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
|
||||
</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 { WmOutsourceReceiptDetailApi, WmOutsourceReceiptDetailVO } from '@/api/mes/wm/outsourcereceipt/detail'
|
||||
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||
import MdLocationSelect from '@/views/mes/md/location/components/MdLocationSelect.vue'
|
||||
|
||||
defineOptions({ name: 'OutsourceReceiptDetailForm' })
|
||||
|
||||
const props = defineProps<{
|
||||
receiptId: 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,
|
||||
receiptId: undefined as number | undefined,
|
||||
itemId: undefined as number | undefined,
|
||||
batchCode: undefined,
|
||||
quantity: undefined as number | undefined,
|
||||
locationId: undefined as number | undefined,
|
||||
remark: undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
itemId: [{ required: true, message: '物料不能为空', trigger: 'change' }],
|
||||
batchCode: [{ required: true, message: '批次号不能为空', trigger: 'blur' }],
|
||||
locationId: [{ 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 WmOutsourceReceiptDetailApi.getOutsourceReceiptDetail(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,
|
||||
receiptId: props.receiptId,
|
||||
lineId: currentLineId.value
|
||||
} as unknown as WmOutsourceReceiptDetailVO
|
||||
if (formType.value === 'create') {
|
||||
await WmOutsourceReceiptDetailApi.createOutsourceReceiptDetail(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await WmOutsourceReceiptDetailApi.updateOutsourceReceiptDetail(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,
|
||||
receiptId: undefined,
|
||||
itemId: undefined,
|
||||
batchCode: undefined,
|
||||
quantity: undefined,
|
||||
locationId: undefined,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<!-- MES 委外收货明细列表(展开行内嵌子组件) -->
|
||||
<template>
|
||||
<div class="pl-60px pr-20px py-10px">
|
||||
<el-button v-if="isUpdate" type="primary" plain size="small" @click="emit('edit-detail', undefined)" 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="locationName" min-width="100" />
|
||||
<el-table-column label="数量" align="center" prop="quantity" width="100" />
|
||||
<el-table-column
|
||||
v-if="isUpdate"
|
||||
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 { WmOutsourceReceiptDetailApi, WmOutsourceReceiptDetailVO } from '@/api/mes/wm/outsourcereceipt/detail'
|
||||
|
||||
defineOptions({ name: 'OutsourceReceiptDetailList' })
|
||||
|
||||
const props = defineProps<{
|
||||
receiptId: number
|
||||
lineId: number
|
||||
itemId: number
|
||||
formType: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['edit-detail'])
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
|
||||
const isUpdate = computed(() => ['create', 'update'].includes(props.formType))
|
||||
|
||||
const loading = ref(false)
|
||||
const list = ref<WmOutsourceReceiptDetailVO[]>([])
|
||||
|
||||
/** 查询明细列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
list.value = await WmOutsourceReceiptDetailApi.getOutsourceReceiptDetailListByLineId(props.lineId)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
defineExpose({ getList })
|
||||
|
||||
/** 删除收货明细 */
|
||||
const handleDelete = async (detailId: number) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await WmOutsourceReceiptDetailApi.deleteOutsourceReceiptDetail(detailId)
|
||||
message.success(t('common.delSuccess'))
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 初始化:延迟加载,展开时才触发 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
<template>
|
||||
<!-- TODO @AI:每行 3 个; -->
|
||||
<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>
|
||||
<!-- TODO @AI:外协工单;使用 workorder select; -->
|
||||
<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>
|
||||
<!-- TODO @AI:放到“日期”前面; -->
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="供应商" prop="vendorId">
|
||||
<MdVendorSelect v-model="formData.vendorId" :disabled="isHeaderReadonly" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- TODO @AI:去掉仓库 -->
|
||||
<el-col :span="8">
|
||||
<el-form-item label="仓库" prop="warehouseId">
|
||||
<MdWarehouseSelect v-model="formData.warehouseId" :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>
|
||||
<OutsourceReceiptLineList :receipt-id="formData.id" :form-type="formType" />
|
||||
</template>
|
||||
<template #footer>
|
||||
<el-button v-if="isUpdate" @click="submitForm" 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 { WmOutsourceReceiptApi, WmOutsourceReceiptVO } from '@/api/mes/wm/outsourcereceipt'
|
||||
import MdVendorSelect from '@/views/mes/md/vendor/components/MdVendorSelect.vue'
|
||||
import MdWarehouseSelect from '@/views/mes/md/warehouse/components/MdWarehouseSelect.vue'
|
||||
import OutsourceReceiptLineList from './OutsourceReceiptLineList.vue'
|
||||
|
||||
defineOptions({ name: 'OutsourceReceiptForm' })
|
||||
|
||||
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,
|
||||
vendorId: undefined,
|
||||
warehouseId: 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:供应商非必填;
|
||||
vendorId: [{ required: true, message: '供应商不能为空', trigger: 'change' }],
|
||||
// TODO @AI:warehouseId 没有这个字段!!!
|
||||
warehouseId: [{ required: true, message: '仓库不能为空', trigger: 'change' }]
|
||||
})
|
||||
const formRef = ref()
|
||||
|
||||
const isUpdate = computed(() => ['create', 'update'].includes(formType.value))
|
||||
const isHeaderReadonly = computed(() => ['detail'].includes(formType.value))
|
||||
const dialogTitle = computed(() => {
|
||||
const titles = {
|
||||
create: '新增委外收货单',
|
||||
update: '编辑委外收货单',
|
||||
detail: '委外收货单详情'
|
||||
}
|
||||
return titles[formType.value] || formType.value
|
||||
})
|
||||
|
||||
/** 生成收货单编号 */
|
||||
const generateCode = () => {
|
||||
formData.value.code = 'OR' + 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 WmOutsourceReceiptApi.getOutsourceReceipt(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success'])
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as WmOutsourceReceiptVO
|
||||
if (formType.value === 'create') {
|
||||
const res = await WmOutsourceReceiptApi.createOutsourceReceipt(data)
|
||||
message.success('新增成功')
|
||||
formData.value.id = res
|
||||
formType.value = 'update'
|
||||
} else {
|
||||
await WmOutsourceReceiptApi.updateOutsourceReceipt(data)
|
||||
message.success('修改成功')
|
||||
}
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
vendorId: undefined,
|
||||
warehouseId: undefined,
|
||||
receiptDate: undefined,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
<!-- 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">
|
||||
<OutsourceReceiptDetailList
|
||||
:ref="(el: any) => setDetailListRef(scope.row.id, el)"
|
||||
:receipt-id="props.receiptId"
|
||||
: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" />
|
||||
<!-- TODO @AI:规格型号; -->
|
||||
<el-table-column label="单位" align="center" prop="unitName" width="80" />
|
||||
<el-table-column label="收货数量" align="center" prop="quantity" width="100" />
|
||||
<!-- TODO @AI:批次号 -->
|
||||
<!-- TODO @AI:是否检验 -->
|
||||
<!-- TODO @AI:质量状态 -->
|
||||
<el-table-column
|
||||
v-if="isUpdate"
|
||||
label="操作"
|
||||
align="center"
|
||||
width="160"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="openForm('update', scope.row.id)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button link type="danger" @click="handleDelete(scope.row.id)">
|
||||
删除
|
||||
</el-button>
|
||||
<!-- TODO @芋艿:标签打印; -->
|
||||
</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-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>
|
||||
|
||||
<!-- 收货明细添加/编辑弹窗 -->
|
||||
<OutsourceReceiptDetailForm
|
||||
ref="detailFormRef"
|
||||
:receipt-id="props.receiptId"
|
||||
@success="onDetailFormSuccess"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { WmOutsourceReceiptLineApi, WmOutsourceReceiptLineVO } from '@/api/mes/wm/outsourcereceipt/line'
|
||||
import MdItemSelect from '@/views/mes/md/item/components/MdItemSelect.vue'
|
||||
import OutsourceReceiptDetailList from './OutsourceReceiptDetailList.vue'
|
||||
import OutsourceReceiptDetailForm from './OutsourceReceiptDetailForm.vue'
|
||||
|
||||
defineOptions({ name: 'OutsourceReceiptLineList' })
|
||||
|
||||
const props = defineProps<{
|
||||
receiptId: number
|
||||
formType: string
|
||||
}>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
|
||||
const isUpdate = computed(() => ['create', 'update'].includes(props.formType))
|
||||
|
||||
// ==================== 列表 ====================
|
||||
const loading = ref(false)
|
||||
const list = ref<WmOutsourceReceiptLineVO[]>([])
|
||||
const total = ref(0)
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
receiptId: undefined as number | undefined
|
||||
})
|
||||
|
||||
/** 查询行列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
queryParams.receiptId = props.receiptId
|
||||
const data = await WmOutsourceReceiptLineApi.getOutsourceReceiptLinePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await WmOutsourceReceiptLineApi.deleteOutsourceReceiptLine(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,
|
||||
receiptId: 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()
|
||||
|
||||
/** 打开表单弹窗 */
|
||||
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 WmOutsourceReceiptLineApi.getOutsourceReceiptLine(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = { ...formData.value, receiptId: props.receiptId } as unknown as WmOutsourceReceiptLineVO
|
||||
if (lineFormType.value === 'create') {
|
||||
await WmOutsourceReceiptLineApi.createOutsourceReceiptLine(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await WmOutsourceReceiptLineApi.updateOutsourceReceiptLine(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
await getList()
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
receiptId: undefined,
|
||||
itemId: undefined,
|
||||
quantity: undefined,
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
// ==================== 展开行:收货明细 ====================
|
||||
const detailListRefs = ref<Record<number, InstanceType<typeof OutsourceReceiptDetailList>>>({})
|
||||
|
||||
/** 缓存子组件 ref */
|
||||
const setDetailListRef = (lineId: number, el: any) => {
|
||||
if (el) {
|
||||
detailListRefs.value[lineId] = el
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 收货明细表单 ====================
|
||||
const detailFormRef = ref()
|
||||
|
||||
/** 打开收货明细表单 */
|
||||
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,292 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="100px"
|
||||
>
|
||||
<!-- TODO @AI:收货,改成入库;其它相关的也是;前后端都是; -->
|
||||
<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="vendorId">
|
||||
<MdVendorSelect v-model="queryParams.vendorId" class="!w-240px" />
|
||||
</el-form-item>
|
||||
<!-- TODO @AI:收货,改成发料 -->
|
||||
<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-outsource-receipt:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['mes:wm-outsource-receipt: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" />
|
||||
<!-- TODO @AI:生产工单号; -->
|
||||
<el-table-column label="供应商名称" align="center" prop="vendorName" 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">
|
||||
<!-- TODO @AI:数据库里的字典加下; -->
|
||||
<dict-tag :type="DICT_TYPE.MES_WM_OUTSOURCE_RECEIPT_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-outsource-receipt:update']"
|
||||
v-if="scope.row.status === MesWmOutsourceReceiptStatusEnum.PREPARE"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="warning"
|
||||
@click="handleSubmit(scope.row.id)"
|
||||
v-hasPermi="['mes:wm-outsource-receipt:update']"
|
||||
v-if="scope.row.status === MesWmOutsourceReceiptStatusEnum.PREPARE"
|
||||
>
|
||||
提交
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['mes:wm-outsource-receipt:delete']"
|
||||
v-if="scope.row.status === MesWmOutsourceReceiptStatusEnum.PREPARE"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<!-- TODO @AI:执行上架; -->
|
||||
<!-- 审批中:审批、取消 -->
|
||||
<el-button
|
||||
link
|
||||
type="success"
|
||||
@click="handleApprove(scope.row.id)"
|
||||
v-hasPermi="['mes:wm-outsource-receipt:update']"
|
||||
v-if="scope.row.status === MesWmOutsourceReceiptStatusEnum.APPROVING"
|
||||
>
|
||||
审批
|
||||
</el-button>
|
||||
<!-- TODO @AI:执行领料 -->
|
||||
<!-- 已审批:完成、取消 -->
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="handleFinish(scope.row.id)"
|
||||
v-hasPermi="['mes:wm-outsource-receipt:finish']"
|
||||
v-if="scope.row.status === MesWmOutsourceReceiptStatusEnum.APPROVED"
|
||||
>
|
||||
完成
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleCancel(scope.row.id)"
|
||||
v-hasPermi="['mes:wm-outsource-receipt:update']"
|
||||
v-if="
|
||||
[
|
||||
MesWmOutsourceReceiptStatusEnum.APPROVING,
|
||||
MesWmOutsourceReceiptStatusEnum.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>
|
||||
|
||||
<OutsourceReceiptForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
import download from '@/utils/download'
|
||||
import { WmOutsourceReceiptApi, WmOutsourceReceiptVO } from '@/api/mes/wm/outsourcereceipt'
|
||||
import MdVendorSelect from '@/views/mes/md/vendor/components/MdVendorSelect.vue'
|
||||
import OutsourceReceiptForm from './OutsourceReceiptForm.vue'
|
||||
import { MesWmOutsourceReceiptStatusEnum } from '@/views/mes/utils/constants'
|
||||
|
||||
defineOptions({ name: 'MesWmOutsourceReceipt' })
|
||||
|
||||
const message = useMessage()
|
||||
const { t } = useI18n()
|
||||
|
||||
const loading = ref(true)
|
||||
const list = ref<WmOutsourceReceiptVO[]>([])
|
||||
const total = ref(0)
|
||||
const exportLoading = ref(false)
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
vendorId: undefined,
|
||||
receiptDate: undefined
|
||||
})
|
||||
const queryFormRef = ref()
|
||||
const formRef = ref()
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await WmOutsourceReceiptApi.getOutsourceReceiptPage(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 WmOutsourceReceiptApi.submitOutsourceReceipt(id)
|
||||
message.success('提交成功')
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 审批 */
|
||||
const handleApprove = async (id: number) => {
|
||||
try {
|
||||
await message.confirm('确认审批该委外收货单?')
|
||||
await WmOutsourceReceiptApi.approveOutsourceReceipt(id)
|
||||
message.success('审批成功')
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 完成 */
|
||||
const handleFinish = async (id: number) => {
|
||||
try {
|
||||
await message.confirm('确认完成该委外收货单?完成后将更新库存台账。')
|
||||
await WmOutsourceReceiptApi.finishOutsourceReceipt(id)
|
||||
message.success('完成成功')
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 取消 */
|
||||
const handleCancel = async (id: number) => {
|
||||
try {
|
||||
await message.confirm('确认取消该委外收货单?取消后不可恢复。')
|
||||
await WmOutsourceReceiptApi.cancelOutsourceReceipt(id)
|
||||
message.success('取消成功')
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await WmOutsourceReceiptApi.deleteOutsourceReceipt(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await message.exportConfirm()
|
||||
exportLoading.value = true
|
||||
const data = await WmOutsourceReceiptApi.exportOutsourceReceipt(queryParams)
|
||||
download.excel(data, '委外收货单.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue