feat: 快速回库
This commit is contained in:
parent
41729665b5
commit
2e3f33b46e
|
|
@ -98,6 +98,12 @@
|
|||
text type="success" size="small"
|
||||
@click="openMockCallback(task)"
|
||||
>模拟回调</el-button>
|
||||
<el-button
|
||||
v-if="!isMonitorMode && canReturnToWarehouse(task)"
|
||||
text type="warning" size="small"
|
||||
:loading="returningTaskCode === task.code"
|
||||
@click="handleReturnToWarehouse(task)"
|
||||
>回库</el-button>
|
||||
<el-button v-if="!isMonitorMode" text type="danger" size="small" @click="handleDeleteTask(task)">
|
||||
删除
|
||||
</el-button>
|
||||
|
|
@ -337,6 +343,14 @@
|
|||
<el-icon color="#67c23a"><VideoPlay /></el-icon>
|
||||
<span>模拟回调</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="actionTask && canReturnToWarehouse(actionTask)"
|
||||
class="m-action-item"
|
||||
@click="taskActionDrawerVisible = false; handleReturnToWarehouse(actionTask!)"
|
||||
>
|
||||
<el-icon color="#e6a23c"><House /></el-icon>
|
||||
<span>回库</span>
|
||||
</div>
|
||||
<div class="m-action-item" @click="taskActionDrawerVisible = false; openStatusPicker()">
|
||||
<el-icon color="#409eff"><Switch /></el-icon>
|
||||
<span>变更状态</span>
|
||||
|
|
@ -447,7 +461,7 @@ defineOptions({ name: 'TaskChainDetail' })
|
|||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ArrowLeft, MoreFilled, VideoPlay, Switch, Delete } from '@element-plus/icons-vue'
|
||||
import { ArrowLeft, MoreFilled, VideoPlay, Switch, Delete, House } from '@element-plus/icons-vue'
|
||||
import { useDevice } from '@/composables/useDevice'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { chainStatusMap, getChainStatusTag } from '@/constants/chainStatus'
|
||||
|
|
@ -457,6 +471,7 @@ import {
|
|||
callbackScenarioMap, sendMockCallback,
|
||||
type CallbackScenario, type TaskChainDetailVO, type TaskVO,
|
||||
} from '@/api/task'
|
||||
import { generateRelease } from '@/api/generate'
|
||||
|
||||
const { isMobile } = useDevice()
|
||||
const userStore = useUserStore()
|
||||
|
|
@ -465,6 +480,7 @@ const route = useRoute()
|
|||
const loading = ref(false)
|
||||
const executing = ref(false)
|
||||
const canceling = ref(false)
|
||||
const returningTaskCode = ref<string | null>(null)
|
||||
const chain = ref<TaskChainDetailVO | null>(null)
|
||||
const tasks = ref<TaskVO[]>([])
|
||||
const statusOptions = taskStatusOptions
|
||||
|
|
@ -478,6 +494,55 @@ function canExecuteNext(status: string) {
|
|||
return status === 'IN_PROGRESS' || status === 'CREATED' || status === 'READY'
|
||||
}
|
||||
|
||||
/** TP/HJ 前缀映射回库库区;与任务生成-释放信号约定一致 */
|
||||
function resolveReturnWarehouseTargetCode(container: string | undefined | null): string | null {
|
||||
const c = container?.trim().toUpperCase()
|
||||
if (!c) return null
|
||||
if (c.startsWith('TP')) return 'WH01-3-2'
|
||||
if (c.startsWith('HJ')) return 'WH01-3-3'
|
||||
return null
|
||||
}
|
||||
|
||||
function canReturnToWarehouse(task: TaskVO): boolean {
|
||||
if (task.type !== 'HK_STATION_RELEASE' || task.status !== 'WAITING_RELEASE') return false
|
||||
if (!chain.value?.warehouse || !task.sourceContainer?.trim()) return false
|
||||
return resolveReturnWarehouseTargetCode(task.sourceContainer) != null
|
||||
}
|
||||
|
||||
async function handleReturnToWarehouse(task: TaskVO) {
|
||||
const wh = chain.value?.warehouse
|
||||
if (!wh) return
|
||||
const targetCode = resolveReturnWarehouseTargetCode(task.sourceContainer)
|
||||
if (!targetCode) {
|
||||
ElMessage.warning('仅支持容器号以 TP、HJ 开头时回库')
|
||||
return
|
||||
}
|
||||
const taskChainCode = task.chainCode || chain.value?.code
|
||||
if (!taskChainCode) {
|
||||
ElMessage.warning('缺少任务链编号')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认发送回库释放信号?目标库区:${targetCode},容器:${task.sourceContainer}`,
|
||||
'回库',
|
||||
{ type: 'warning' },
|
||||
)
|
||||
returningTaskCode.value = task.code
|
||||
await generateRelease({
|
||||
warehouse: wh,
|
||||
taskChainCode,
|
||||
container: task.sourceContainer,
|
||||
targetType: 'AREA',
|
||||
targetCode,
|
||||
})
|
||||
ElMessage.success('回库释放信号已发送')
|
||||
await loadData()
|
||||
} catch { /* cancelled */ } finally {
|
||||
returningTaskCode.value = null
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 移动端子任务操作 ====================
|
||||
const taskActionDrawerVisible = ref(false)
|
||||
const statusPickerVisible = ref(false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue