<template>
|
<div class="audit-record-container">
|
<div class="label">审批记录</div>
|
<el-steps direction="vertical" :active="displayedSteps.length">
|
<el-step v-for="step in displayedSteps" :key="step.status" :title="step.title" :description="`${step.person || ''}\n${step.time || ''}`" />
|
</el-steps>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, watch } from 'vue'
|
import { gdSupplyDemandAuditListApi } from '@/views/orderView/orderDataManage/supplyAdd/supplyAddApi'
|
|
const props = defineProps({
|
demandId: {
|
type: [String, Number],
|
required: true
|
}
|
})
|
const detailDemandStatus = inject('detailDemandStatus')
|
const reasonForRejection = inject('reasonForRejection')
|
|
// 步骤条数据
|
const displayedSteps = ref([])
|
|
// 监听 demandId 变化
|
watch(() => props.demandId, (newVal) => {
|
if (newVal) {
|
loadAuditRecords(newVal)
|
}
|
}, { immediate: true })
|
|
// 加载审核记录
|
function loadAuditRecords(demandId) {
|
gdSupplyDemandAuditListApi({ demandId }).then(res => {
|
const auditRecords = res?.data?.data ?? []
|
|
// 按创建时间排序(最新的在最后)
|
const sortedRecords = [...auditRecords].sort((a, b) => new Date(a.createTime) - new Date(b.createTime))
|
|
// 构建步骤数据
|
const steps = []
|
|
// 添加需求申请步骤
|
steps.push({
|
status: '0',
|
title: '需求申请',
|
person: sortedRecords.find(r => r.auditStatus === '0')?.userName || '',
|
time: sortedRecords.find(r => r.auditStatus === '0')?.createTime || ''
|
})
|
|
// 添加审核通过步骤(如果有)
|
const approvedRecord = sortedRecords.find(r => r.auditStatus === '1')
|
if (approvedRecord) {
|
steps.push({
|
status: '1',
|
title: '审核通过',
|
person: approvedRecord.userName || '',
|
time: approvedRecord.createTime || ''
|
})
|
}
|
|
// 添加拒绝申请步骤(如果有)
|
const rejectedRecord = sortedRecords.find(r => r.auditStatus === '2')
|
if (rejectedRecord) {
|
steps.push({
|
status: '2',
|
title: '拒绝申请',
|
person: rejectedRecord.userName || '',
|
time: rejectedRecord.createTime || ''
|
})
|
// 查找拒绝原因
|
reasonForRejection.value = rejectedRecord.auditOpinion || ''
|
}
|
|
displayedSteps.value = steps
|
}).catch(error => {
|
console.error('加载审核记录失败:', error)
|
// 重置步骤数据
|
displayedSteps.value = []
|
reasonForRejection.value = ''
|
})
|
}
|
|
defineExpose({
|
loadAuditRecords
|
})
|
</script>
|
|
<style scoped lang="scss">
|
.audit-record-container {
|
height: 95%;
|
.label {
|
font-weight: 500;
|
margin-bottom: 8px;
|
color: #333;
|
}
|
}
|
|
/* 步骤条样式 */
|
:deep(.el-steps) {
|
align-items: flex-start;
|
}
|
|
:deep(.el-step) {
|
// margin-bottom: 20px;
|
}
|
|
:deep(.el-step__title) {
|
font-size: 14px;
|
font-weight: 500;
|
}
|
|
:deep(.el-step__description) {
|
font-size: 13px;
|
color: #666;
|
white-space: pre-wrap;
|
line-height: 1.4;
|
}
|
</style>
|