feat: add manual WCS dispatch action

This commit is contained in:
zgw
2026-07-16 11:05:16 +08:00
parent 4641bddcea
commit 10ce28f8ac
5 changed files with 202 additions and 19 deletions

View File

@@ -109,15 +109,19 @@
>手动完成</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-upload2"
size="mini"
:disabled="single"
@click="handlePushWcs"
v-hasPermi="['out:job:edit']"
>推送WCS</el-button>
<el-tooltip content="手动下发 WCS" placement="top">
<span>
<el-button
type="primary"
plain
icon="el-icon-s-promotion"
size="mini"
:disabled="single || !canPushWcs(selectedRows[0])"
@click="handlePushWcs"
v-hasPermi="['out:job:pushWcs']"
>手动下发 WCS</el-button>
</span>
</el-tooltip>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@@ -154,6 +158,29 @@
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="WCS状态" align="center" prop="dispatchStatus" width="112">
<template slot-scope="scope">
<el-tag :type="dispatchStatusType(scope.row.dispatchStatus)" size="mini" effect="plain">
{{ dispatchStatusLabel(scope.row.dispatchStatus) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="自动重试" align="center" prop="autoRetryCount" width="88">
<template slot-scope="scope">{{ scope.row.autoRetryCount || 0 }}</template>
</el-table-column>
<el-table-column label="最后下发错误" align="left" prop="lastDispatchError" min-width="160">
<template slot-scope="scope">
<el-tooltip
v-if="scope.row.lastDispatchError"
:content="scope.row.lastDispatchError"
placement="top"
effect="dark"
>
<span class="dispatch-error">{{ scope.row.lastDispatchError }}</span>
</el-tooltip>
<span v-else class="dispatch-empty">-</span>
</template>
</el-table-column>
<el-table-column label="开始时间" align="center" prop="startTime" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
@@ -239,6 +266,8 @@ export default {
loading: true,
// 选中数组
ids: [],
// 当前选中行
selectedRows: [],
// 非单个禁用
single: true,
// 显示搜索条件
@@ -290,6 +319,8 @@ export default {
this.jobList = response.rows
this.total = response.total
this.loading = false
}).catch(() => {
this.loading = false
})
},
/** 搜索按钮操作 */
@@ -313,6 +344,7 @@ export default {
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.jobId)
this.selectedRows = selection
this.single = selection.length !== 1
},
/** 手动作废按钮操作 */
@@ -337,14 +369,59 @@ export default {
},
/** 推送 WCS 按钮操作 */
handlePushWcs() {
const jobId = this.ids[0]
this.$modal.confirm('是否确认推送选中的出库作业到WCS?').then(() => {
return pushJobToWcs(jobId)
}).then(() => {
this.$modal.msgSuccess("推送成功")
const row = this.selectedRows[0]
if (!this.canPushWcs(row)) {
this.$modal.msgWarning('当前作业状态不允许手动下发 WCS')
return
}
const autoRetries = Number(row.autoRetryCount || 0)
const manualRetries = Number(row.manualRetryCount || 0)
const lastError = row.lastDispatchError || '无'
const message = `确认手动下发作业 ${row.jobId} 到 WCS?自动重试 ${autoRetries} 次,人工下发 ${manualRetries} 次;最后错误:${lastError}`
this.$modal.confirm(message).then(() => {
return pushJobToWcs(row.jobId)
}).then(response => {
const resultMessage = response.msg || 'WCS手动下发请求已处理'
if (resultMessage.includes('下发成功')) {
this.$modal.msgSuccess(resultMessage)
} else {
this.$modal.msgWarning(resultMessage)
}
this.getList()
}).catch(() => {})
},
canPushWcs(row) {
if (!row || String(row.status) !== '1') {
return false
}
return ['PENDING', 'RETRY_WAIT', 'EXHAUSTED', 'BLOCKED']
.includes(this.normalizeDispatchStatus(row.dispatchStatus))
},
normalizeDispatchStatus(status) {
return status || 'PENDING'
},
dispatchStatusLabel(status) {
const labels = {
PENDING: '待下发',
SENDING: '下发中',
BLOCKED: '通道阻挡',
RETRY_WAIT: '等待重试',
SUCCESS: '已下发',
EXHAUSTED: '重试耗尽'
}
return labels[this.normalizeDispatchStatus(status)] || status || '待下发'
},
dispatchStatusType(status) {
const types = {
PENDING: 'info',
SENDING: 'warning',
BLOCKED: 'warning',
RETRY_WAIT: 'warning',
SUCCESS: 'success',
EXHAUSTED: 'danger'
}
return types[this.normalizeDispatchStatus(status)] || 'info'
},
/** 点击主作业行 —— 联动刷新子作业 */
handleRowClick(row) {
this.currentJob = row
@@ -368,3 +445,19 @@ export default {
}
}
</script>
<style scoped>
.dispatch-error {
display: inline-block;
max-width: 100%;
overflow: hidden;
color: #f56c6c;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: middle;
}
.dispatch-empty {
color: #c0c4cc;
}
</style>