fix(wms/aps/requirement): 调整产需单状态与操作按钮逻辑,优化下发进度展示

1.  修正编辑和下发按钮的状态判断逻辑,移除状态3的相关校验
2.  更新产需单状态映射,将原状态2、3替换为已完成、生产中调整为正确的业务状态
3.  优化下发进度展示样式,拆分百分比显示并添加完成状态样式
4.  调整产需转化弹窗的加载逻辑,新增初始化加载状态
5.  简化下发、撤回的确认弹窗文案
This commit is contained in:
砂糖
2026-07-10 13:17:23 +08:00
parent 09d72e0f35
commit 7af7625967

View File

@@ -74,11 +74,11 @@
<span>产需单信息</span>
<div style="display:flex; gap:6px;">
<button class="header-btn"
:disabled="currentReq.scheduleStatus !== 0 && currentReq.scheduleStatus !== 3"
:disabled="currentReq.scheduleStatus !== 0"
@click="handleEdit(currentReq)">编辑</button>
<button v-if="currentReq.scheduleStatus === 0 || currentReq.scheduleStatus === 3" class="header-btn"
<button v-if="currentReq.scheduleStatus === 0" class="header-btn"
style="background:rgba(255,255,255,0.4);border-color:rgba(255,255,255,0.7);"
@click="handleDispatch">{{ currentReq.scheduleStatus === 3 ? '重新下发' : '下发' }}</button>
@click="handleDispatch">下发</button>
<button v-if="currentReq.scheduleStatus === 1" class="header-btn"
style="background:rgba(255,255,255,0.4);border-color:rgba(255,255,255,0.7);"
@click="handleRecall">撤回</button>
@@ -205,8 +205,10 @@
<div class="detail-card-header">
<span>排产明细{{ requirementDetailList.length }} 合计 {{ detailTotalWeight }} T</span>
<span style="display:flex;align-items:center;gap:8px;">
<span v-if="detailDispatchProgress.total > 0" style="font-size:12px;font-weight:400;opacity:0.9;">
已下发 {{ detailDispatchProgress.issued }} / {{ detailDispatchProgress.total }}{{ detailDispatchProgress.percent }}%
<span v-if="detailDispatchProgress.total > 0" class="dispatch-progress"
:class="{ 'dispatch-progress--done': detailDispatchProgress.percent === 100 }">
已下发 {{ detailDispatchProgress.issued }} / {{ detailDispatchProgress.total }}
<span class="dispatch-progress-pct">{{ detailDispatchProgress.percent }}%</span>
</span>
<button v-if="canEdit" class="header-btn" @click="handleDetailAdd">+ 新增</button>
</span>
@@ -431,9 +433,9 @@
v-for="rel in bindPreviewExistingRels"
:key="rel.scheduleId"
size="small"
:type="rel.scheduleStatus === 3 ? 'danger' : 'info'"
:type="rel.scheduleStatus === 2 ? 'success' : 'info'"
effect="plain"
:style="rel.scheduleStatus === 2 ? 'color:#555;border-color:#ccc;background:#f5f5f5;' : ''"
:style="rel.scheduleStatus === 0 ? 'color:#555;border-color:#ccc;background:#f5f5f5;' : ''"
>
{{ rel.scheduleNo }}
<span style="margin-left:4px; opacity:0.7;">{{ bindPreviewRelStatusMap[rel.scheduleStatus] || '' }}</span>
@@ -486,7 +488,7 @@
产需单号<strong>{{ convertReqNo }}</strong>
<span style="margin-left:16px;"> {{ convertDetailList.length }} 条明细</span>
</div>
<el-table :data="convertDetailList" border size="small" class="aps-table"
<el-table :data="convertDetailList" border size="small" class="aps-table" v-loading="convertInitLoading"
@selection-change="(val) => convertSelection = val">
<el-table-column type="selection" width="40" />
<el-table-column label="规格" prop="spec" min-width="100" />
@@ -580,8 +582,8 @@ export default {
pageNum: 1,
pageSize: 10
},
statusMap: { 0: '草稿', 1: '待审核', 2: '已下达', 3: '已退回' },
statusBadgeMap: { 0: 'gray', 1: 'blue', 2: 'green', 3: 'red' },
statusMap: { 0: '草稿', 1: '生产中', 2: '已完成' },
statusBadgeMap: { 0: 'gray', 1: 'blue', 2: 'green' },
// 绑定订单
bindDialogVisible: false,
@@ -598,7 +600,7 @@ export default {
// 当前预览订单已绑定的产需单列表
bindPreviewExistingRels: [],
// 产需单状态映射(用于展示绑定状态)
bindPreviewRelStatusMap: { 0: '草稿', 1: '待审核', 2: '已下达', 3: '已退回' },
bindPreviewRelStatusMap: { 0: '草稿', 1: '生产中', 2: '已完成' },
// 排产明细
detailLoading: false,
@@ -622,6 +624,7 @@ export default {
convertReqNo: '',
convertProgress: 0,
convertProgressShow: false,
convertInitLoading: false,
convertSelection: [],
processList: [],
@@ -639,7 +642,7 @@ export default {
},
computed: {
canEdit() {
return this.currentReq && (this.currentReq.scheduleStatus === 0 || this.currentReq.scheduleStatus === 3)
return this.currentReq && this.currentReq.scheduleStatus === 0
},
detailTotalWeight() {
return this.requirementDetailList.reduce((sum, item) => {
@@ -1062,7 +1065,7 @@ export default {
// ====== 下发 ======
handleDispatch() {
this.$confirm('确认下发该产需单吗?下发后将进入审核流程。', '提示', {
this.$confirm('确认下发该产需单吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
@@ -1081,7 +1084,7 @@ export default {
},
handleRecall() {
this.$confirm('确认撤回该产需单吗?撤回后将恢复为草稿状态。', '提示', {
this.$confirm('确认撤回该产需单吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
@@ -1101,22 +1104,24 @@ export default {
// ====== 产需转化 ======
openConvertDialogForReq(item) {
// 确保加载了该产需单的详情
// 先打开弹窗并显示 loading
this.convertReqNo = item.scheduleNo || ''
this.convertProgressShow = false
this.convertProgress = 0
this.convertDetailList = []
this.convertDialogVisible = true
this.convertInitLoading = true
const loadDetail = item.scheduleId === (this.currentReq && this.currentReq.scheduleId)
? Promise.resolve(this.currentReq)
: getRequirement(item.scheduleId)
// 同时加载工序列表和明细
Promise.all([
loadDetail,
listProcess({ pageNum: 1, pageSize: 1000 })
]).then(([res, processRes]) => {
const data = res.data || res
const detailList = (data.detailList || []).map(d => ({ ...d }))
// 构建工序查找表
const processRows = processRes.rows || []
const processMap = new Map()
processRows.forEach(p => {
@@ -1129,7 +1134,6 @@ export default {
.map(s => s.stepName).join(' → ')
: ''
}))
// 为已有 processId 的明细填充 _stepNames默认 scheduleDate 为今天
const today = this.getTodayStr()
detailList.forEach(d => {
if (!d.scheduleDate) {
@@ -1140,10 +1144,10 @@ export default {
}
})
this.convertDetailList = detailList
this.convertDialogVisible = true
}).catch(() => {
this.convertDetailList = []
this.convertDialogVisible = true
}).finally(() => {
this.convertInitLoading = false
})
},
@@ -1706,11 +1710,6 @@ export default {
background: #f6ffed;
color: #52c41a;
}
&.status-3 {
background: $aps-red-1;
color: $aps-red-2;
}
}
.aps-table {
@@ -1818,7 +1817,27 @@ export default {
padding: 16px 20px 0 20px;
}
.history-item:hover {
background: #fdecea;
.dispatch-progress {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 2px 10px;
border-radius: 12px;
font-size: 12px;
font-weight: 600;
background: #e6f7ff;
color: #1890ff;
border: 1px solid #91d5ff;
}
.dispatch-progress--done {
background: #f6ffed;
color: #52c41a;
border-color: #b7eb8f;
}
.dispatch-progress-pct {
font-size: 14px;
font-weight: 700;
}
</style>