fix:修改bug
This commit is contained in:
parent
82499cf1fa
commit
f280a779b3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -134,7 +134,7 @@
|
||||
<div class="node-user">
|
||||
{{ node.userName || '--' }}
|
||||
<span class="node-time">
|
||||
{{ formatTime(node.time) }}
|
||||
{{ formatTime(node.operateTime) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -209,7 +209,9 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
changeTable: [],
|
||||
progress: [],
|
||||
progress: [], // 保留用于兼容
|
||||
flowNodes: [], // 审批流程节点数据
|
||||
progressDetailData: {}, // 审批流程详情数据
|
||||
detailOption: '',
|
||||
flowStatus: '',
|
||||
changeTableTotal: 0,
|
||||
@ -232,6 +234,16 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
progressDetail() {
|
||||
// 优先使用从接口获取的数据,如果没有则使用默认值
|
||||
if (this.progressDetailData && Object.keys(this.progressDetailData).length > 0) {
|
||||
return {
|
||||
progressTitle: this.progressDetailData.progressTitle || '',
|
||||
contentName: this.progressDetailData.contentName || '',
|
||||
templateVersion: this.progressDetailData.templateVersion || '',
|
||||
explanation: this.progressDetailData.explanation || '',
|
||||
description: this.progressDetailData.explanation || this.progressDetailData.description || ''
|
||||
}
|
||||
}
|
||||
const defaultDetail = {
|
||||
approvalNumber: '',
|
||||
modelName: '',
|
||||
@ -265,22 +277,92 @@ export default {
|
||||
nodes.push({
|
||||
title: '提交申请',
|
||||
userName: this.detail.username,
|
||||
time: this.detail.createdTime,
|
||||
operateTime: this.detail.createdTime,
|
||||
result: 'INITIATE',
|
||||
status: 'INITIATE',
|
||||
opinion: this.initiateNode.opinion || this.initiateNode.remark || this.initiateNode.comment || null
|
||||
})
|
||||
}
|
||||
|
||||
// 添加所有审批节点
|
||||
if (this.progress && this.progress.length > 0) {
|
||||
// 使用 flowNodes 数据构建审批流程节点
|
||||
if (this.flowNodes && this.flowNodes.length > 0) {
|
||||
// 按照 nodeOrder 排序
|
||||
const sortedNodes = [...this.flowNodes].sort((a, b) => {
|
||||
const orderA = a.nodeOrder !== undefined && a.nodeOrder !== null ? Number(a.nodeOrder) : 0
|
||||
const orderB = b.nodeOrder !== undefined && b.nodeOrder !== null ? Number(b.nodeOrder) : 0
|
||||
return orderA - orderB
|
||||
})
|
||||
|
||||
// 查找是否有 REJECT 节点
|
||||
const rejectIndex = sortedNodes.findIndex((node) => node.result === 'REJECT')
|
||||
|
||||
let processedNodes = sortedNodes
|
||||
if (rejectIndex !== -1) {
|
||||
// 如果有 REJECT 节点,删除该节点后面的所有节点
|
||||
processedNodes = sortedNodes.slice(0, rejectIndex + 1)
|
||||
} else {
|
||||
// 如果没有 REJECT,将第一个 result 是"待审批"的节点改为 APPROVING
|
||||
const stayIndex = processedNodes.findIndex((node) => node.result === '待审批')
|
||||
if (stayIndex !== -1) {
|
||||
processedNodes = processedNodes.map((node, index) => {
|
||||
if (index === stayIndex) {
|
||||
return {
|
||||
...node,
|
||||
result: 'APPROVING'
|
||||
}
|
||||
}
|
||||
return node
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 转换为时间线节点格式
|
||||
processedNodes.forEach((node) => {
|
||||
let result = 'APPROVING'
|
||||
let status = 'APPROVING'
|
||||
|
||||
if (node.result) {
|
||||
if (node.result === 'REJECT') {
|
||||
result = 'REJECT'
|
||||
status = 'REJECT'
|
||||
} else if (node.result === 'APPROVING') {
|
||||
result = 'APPROVING'
|
||||
status = 'APPROVING'
|
||||
} else if (node.result === 'PASS') {
|
||||
result = 'PASS'
|
||||
status = 'PASS'
|
||||
} else if (node.result === '待审批') {
|
||||
result = 'STAY'
|
||||
status = 'STAY'
|
||||
}
|
||||
}
|
||||
|
||||
// 处理审批意见:如果有 opinions 数组,取第一个;否则为空
|
||||
const opinion = node.opinions && Array.isArray(node.opinions) && node.opinions.length > 0
|
||||
? node.opinions[0]
|
||||
: null
|
||||
|
||||
// 处理用户名:优先使用 todoUserName(已处理人),如果没有则使用 undoUserName(待处理人)
|
||||
const userName = node.todoUserName || node.undoUserName || '--'
|
||||
|
||||
nodes.push({
|
||||
title: node.node || '审批节点',
|
||||
userName: userName,
|
||||
operateTime: node.approvalTime || '',
|
||||
result: result,
|
||||
status: status,
|
||||
opinion: opinion
|
||||
})
|
||||
})
|
||||
} else if (this.progress && this.progress.length > 0) {
|
||||
// 兼容旧逻辑:如果没有 flowNodes,则使用原来的 progress 数据
|
||||
this.progress.forEach((stage) => {
|
||||
if (stage.steps && stage.steps.length > 0) {
|
||||
stage.steps.forEach((step) => {
|
||||
nodes.push({
|
||||
title: stage.title || '审批节点',
|
||||
userName: step.userName,
|
||||
time: step.approvalTime || step.handleTime || step.createTime,
|
||||
operateTime: step.approvalTime || step.handleTime || step.createTime,
|
||||
result: step.result || step.status,
|
||||
status: step.result || step.status,
|
||||
opinion: step.opinion || step.remark || step.comment || null
|
||||
@ -375,6 +457,9 @@ export default {
|
||||
return classMap[result] || 'status-default'
|
||||
},
|
||||
getApprovalSpet() {
|
||||
if (!this.detail || !this.detail.flowId) {
|
||||
return
|
||||
}
|
||||
const request = {
|
||||
...api.GET_PPROVAL_ALL,
|
||||
params: {
|
||||
@ -383,15 +468,28 @@ export default {
|
||||
},
|
||||
disableSuccessMsg: true
|
||||
}
|
||||
this.$request(request).asyncThen((resp) => {
|
||||
this.$request(request)
|
||||
.asyncThen((resp) => {
|
||||
console.log('审批流程数据:', resp)
|
||||
this.flowStatus = resp.data?.flowStatus
|
||||
// 处理说明信息
|
||||
this.detailOption = resp.data?.explanation || resp.data?.description || ''
|
||||
|
||||
let list = []
|
||||
const data = resp.data || resp
|
||||
// 保存流程状态
|
||||
this.flowStatus = data.flowStatus || ''
|
||||
// 保存流程详情
|
||||
this.progressDetailData = {
|
||||
explanation: data.explanation || '',
|
||||
flowStatus: data.flowStatus || '',
|
||||
progressTitle: data.progressTitle || '',
|
||||
templateVersion: data.templateVersion || '',
|
||||
contentName: data.contentName || ''
|
||||
}
|
||||
// 处理说明信息
|
||||
this.detailOption = data.explanation || data.description || ''
|
||||
// 保存流程节点
|
||||
this.flowNodes = data.flowNodes || []
|
||||
|
||||
// 兼容旧逻辑:如果没有 flowNodes,尝试使用旧的节点结构
|
||||
if (!this.flowNodes || this.flowNodes.length === 0) {
|
||||
let list = []
|
||||
// 处理校对节点
|
||||
if (data.proofreadNodes && Array.isArray(data.proofreadNodes) && data.proofreadNodes.length > 0) {
|
||||
const steps = data.proofreadNodes
|
||||
@ -447,7 +545,13 @@ export default {
|
||||
}
|
||||
|
||||
this.progress = list
|
||||
console.log('处理后的流程数据:', this.progress)
|
||||
console.log('处理后的流程数据(兼容模式):', this.progress)
|
||||
}
|
||||
})
|
||||
.asyncErrorCatch((err) => {
|
||||
console.error('获取审批流程数据失败:', err)
|
||||
this.flowNodes = []
|
||||
this.progressDetailData = {}
|
||||
})
|
||||
},
|
||||
getApprovalChange() {
|
||||
|
||||
@ -1286,6 +1286,12 @@ export default {
|
||||
// 如果选中的是父节点,检查该section的数据是否属于该父节点
|
||||
if (nodeInfo.isParent) {
|
||||
const sectionData = data[sectionName] || []
|
||||
// 如果 sectionName 等于子系统名称,说明这是零部件名称为 "/" 的分组
|
||||
// 这种情况下,sectionName 就是子系统名称,所以直接匹配
|
||||
if (sectionName === nodeInfo.label) {
|
||||
hasMatch = true
|
||||
} else {
|
||||
// 否则检查该section的数据是否属于该父节点
|
||||
const hasDataInSubsystem = sectionData.some(
|
||||
(param) => param.subsystemName === nodeInfo.label
|
||||
)
|
||||
@ -1294,6 +1300,7 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
return hasMatch
|
||||
},
|
||||
|
||||
@ -1127,7 +1127,6 @@ export default {
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
return data.map((node) => formatNode(node))
|
||||
},
|
||||
// 处理部门选择变化
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user