<template>
|
<div class="split-package">
|
<el-alert
|
title="拆包操作将把选中的物料包分成两个包,系统会自动生成新条码"
|
type="info"
|
:closable="false"
|
class="split-alert"
|
/>
|
|
<!-- 原物料信息展示 -->
|
<el-card header="原物料信息" class="original-info">
|
<el-descriptions :column="2" border>
|
<el-descriptions-item label="旧条码">
|
<el-text type="primary">{{ lockInfo.MaterielCode }}</el-text>
|
</el-descriptions-item>
|
<el-descriptions-item label="物料名称">
|
{{ lockInfo.MaterielName }}
|
</el-descriptions-item>
|
<el-descriptions-item label="批次号">
|
{{ lockInfo.BatchNo }}
|
</el-descriptions-item>
|
<el-descriptions-item label="托盘编号">
|
{{ lockInfo.PalletCode }}
|
</el-descriptions-item>
|
<el-descriptions-item label="库位编号">
|
{{ lockInfo.LocationCode }}
|
</el-descriptions-item>
|
<el-descriptions-item label="任务号">
|
{{ taskNo }}
|
</el-descriptions-item>
|
<el-descriptions-item label="分配数量">
|
<el-text type="info">{{ lockInfo.AssignQuantity }}</el-text>
|
</el-descriptions-item>
|
<el-descriptions-item label="已拣数量">
|
<el-text type="warning">{{ lockInfo.PickedQty }}</el-text>
|
</el-descriptions-item>
|
<el-descriptions-item label="可拆包数量">
|
<el-text type="success">{{ availableQuantity }}</el-text>
|
</el-descriptions-item>
|
</el-descriptions>
|
</el-card>
|
|
<!-- 拆包信息输入 -->
|
<el-card header="拆包信息" class="split-info">
|
<el-form :model="splitForm" label-width="120px">
|
<el-form-item label="拆包数量" required>
|
<el-input-number
|
v-model="splitForm.splitQuantity"
|
:min="1"
|
:max="availableQuantity"
|
:precision="2"
|
placeholder="请输入拆包数量"
|
style="width: 200px"
|
/>
|
<div class="form-tips">
|
可拆包数量: {{ availableQuantity }} {{ lockInfo.Unit }}
|
</div>
|
</el-form-item>
|
|
<el-form-item label="新条码" v-if="newBarcode">
|
<el-text type="success">{{ newBarcode }}</el-text>
|
<div class="form-tips">系统自动生成的新条码</div>
|
</el-form-item>
|
</el-form>
|
</el-card>
|
|
<div class="action-buttons">
|
<el-button
|
type="primary"
|
@click="handleConfirm"
|
:loading="confirmLoading"
|
:disabled="!splitForm.splitQuantity"
|
>
|
确认拆包
|
</el-button>
|
<el-button @click="$emit('close')">取消</el-button>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, reactive, computed } from 'vue'
|
import { ElMessage } from 'element-plus'
|
|
const props = defineProps({
|
lockInfo: {
|
type: Object,
|
required: true
|
}
|
})
|
|
const emit = defineEmits(['confirm', 'close'])
|
|
const splitForm = reactive({
|
splitQuantity: 1
|
})
|
|
const confirmLoading = ref(false)
|
const newBarcode = ref('')
|
const taskNo = ref(`SPLIT_${Date.now()}`)
|
|
// 计算可拆包数量
|
const availableQuantity = computed(() => {
|
return props.lockInfo.AssignQuantity - props.lockInfo.PickedQty
|
})
|
|
const handleConfirm = async () => {
|
if (!splitForm.splitQuantity || splitForm.splitQuantity <= 0) {
|
ElMessage.warning('请输入有效的拆包数量')
|
return
|
}
|
|
if (splitForm.splitQuantity >= availableQuantity.value) {
|
ElMessage.warning('拆包数量必须小于可拆包数量')
|
return
|
}
|
|
confirmLoading.value = true
|
|
try {
|
const request = {
|
lockInfoId: props.lockInfo.Id,
|
taskNo: taskNo.value,
|
splitQuantity: splitForm.splitQuantity
|
}
|
|
const result = await $http.post('/api/outbound/splitPackage', request)
|
|
if (result.success) {
|
newBarcode.value = result.data?.newBarcode || '生成成功'
|
ElMessage.success(`拆包操作成功!新条码: ${newBarcode.value}`)
|
|
// 延迟关闭,让用户看到新条码
|
setTimeout(() => {
|
emit('confirm')
|
}, 2000)
|
} else {
|
ElMessage.error(result.message)
|
}
|
} catch (error) {
|
ElMessage.error('拆包操作失败')
|
} finally {
|
confirmLoading.value = false
|
}
|
}
|
</script>
|
|
<style scoped>
|
.split-package {
|
max-height: 70vh;
|
overflow-y: auto;
|
}
|
|
.split-alert {
|
margin-bottom: 16px;
|
}
|
|
.original-info {
|
margin-bottom: 16px;
|
}
|
|
.split-info {
|
margin-bottom: 16px;
|
}
|
|
.form-tips {
|
font-size: 12px;
|
color: #909399;
|
margin-top: 4px;
|
}
|
|
.action-buttons {
|
text-align: center;
|
margin-top: 20px;
|
}
|
</style>
|