feat(scrap): 报废作业页重构为「按单扫码执行」,对齐出库版式
create.vue 由「直接报废」页(492 行)重写为按单执行页:
· 顶部选择已批准申请单(scope=executable, status=1);
· 载入 items_json 为待执行清单,逐项显示批准数量与已扫数量;
· 扫码头按 (source_table, stock_id) 匹配批准明细,
不在单内或超批准量时红色 toast + 震动阻断,禁止入车;
· 支持 ?requestId= 深链直达;提交实扫 payload 到 execute 接口。
审批页的「执行报废」由弹窗盲执行改为跳转本页(router.push + query.requestId),
移除 executeVisible/confirmExecute 等已失效代码;路由标题改为「按单报废执行」。
executeScrapByRequest 增加 items 参数。
This commit is contained in:
@ -159,45 +159,18 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 按单报废执行 Dialog(严格按选单内容扣减) -->
|
||||
<el-dialog v-model="executeVisible" title="按单报废(确认扣减库存)" width="760px" destroy-on-close>
|
||||
<el-alert
|
||||
type="warning" :closable="false" show-icon
|
||||
title="确认后将严格按下列“选单明细”扣减对应库存行的可用数量并写入报废流水,不可撤销。"
|
||||
style="margin-bottom:12px;"
|
||||
/>
|
||||
<el-table :data="execItems" border size="small" max-height="340">
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column label="来源" width="90" align="center">
|
||||
<template #default="{ row: item }">
|
||||
<el-tag size="small">{{ sourceLabel(item.source_table) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="名称" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="spec_model" label="规格型号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="location" label="库位" width="110" />
|
||||
<el-table-column prop="batch_number" label="批次/序列号" width="130" />
|
||||
<el-table-column label="报废数量" width="100" align="center">
|
||||
<template #default="{ row: item }">
|
||||
<span style="color:#F56C6C;font-weight:bold;">{{ item.scrap_qty }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button @click="executeVisible = false">取消</el-button>
|
||||
<el-button type="warning" :loading="executing" @click="confirmExecute">确认执行报废</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Refresh, Warning } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getScrapApprovals, approveScrapRequest, executeScrapByRequest } from '@/api/scrap'
|
||||
import { getScrapApprovals, approveScrapRequest } from '@/api/scrap'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
// --- 状态 ---
|
||||
@ -216,11 +189,6 @@ const currentRejectRow = ref<any>(null)
|
||||
const rejectReason = ref('')
|
||||
const rejectLoading = ref(false)
|
||||
|
||||
// 执行 Dialog
|
||||
const executeVisible = ref(false)
|
||||
const executeRow = ref<any>(null)
|
||||
const execItems = ref<any[]>([])
|
||||
const executing = ref(false)
|
||||
|
||||
const userNameCache = ref<Record<number, string>>({})
|
||||
|
||||
@ -313,24 +281,9 @@ const confirmReject = async () => {
|
||||
} finally { rejectLoading.value = false }
|
||||
}
|
||||
|
||||
// --- 按单报废执行(严格按选单明细) ---
|
||||
// --- 按单报废执行:跳转到「按单报废执行」扫码页,由实扫明细驱动扣减 ---
|
||||
const openExecute = (row: any) => {
|
||||
executeRow.value = row
|
||||
execItems.value = row.items || []
|
||||
executeVisible.value = true
|
||||
}
|
||||
const confirmExecute = async () => {
|
||||
if (!executeRow.value) return
|
||||
executing.value = true
|
||||
try {
|
||||
await executeScrapByRequest(executeRow.value.id)
|
||||
ElMessage.success('已执行报废并扣减库存')
|
||||
executeVisible.value = false
|
||||
await fetchData()
|
||||
} catch (err: any) {
|
||||
// 拦截器已弹后端业务错误;无响应才算网络异常
|
||||
if (!err?.response) ElMessage.error('网络异常,请重试')
|
||||
} finally { executing.value = false }
|
||||
router.push({ path: '/scrap/create', query: { requestId: row.id } })
|
||||
}
|
||||
|
||||
onMounted(() => { fetchData() })
|
||||
|
||||
Reference in New Issue
Block a user