吉安感知网项目-前端
shuishen
6 days ago 6e88705bd5b443a259b24c17c8a299765d059d96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<template>
  <div class="audit-record-container">
    <el-timeline class="gd-timeline">
      <el-timeline-item
        v-for="(step, index) in displayedSteps"
        :key="step.status"
        :icon="Check"
        :type="index === displayedSteps.length - 1 ? 'success' : 'info'"
        :timestamp="step.time"
      >
        <div class="item-content">
          <div class="flowName">{{ step.title }}</div>
          <div >{{ step.person }}</div>
        </div>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>
 
<script setup>
import { ref, watch } from 'vue'
import { Check } from '@element-plus/icons-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 {
width:100%;
    // height: 95%;
 
}
 
/* 时间线样式 */
:deep(.gd-timeline) {
 padding-left: 90px;
}
 
:deep(.el-timeline-item) {
  padding-bottom: 20px;
  .item-content {
     position: relative;
            .flowName {
                width: 80px;
                position: absolute;
                left: -120px;
                top: 0px;
            }
  }
}
 
:deep(.el-timeline-item__timestamp) {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}
</style>