修复设备采购状态图无法顺利依据流程变化的问题
This commit is contained in:
parent
80f174e9a4
commit
9933ad7206
|
@ -194,6 +194,12 @@ export interface EquipmentResp {
|
||||||
inventoryBasis?: string
|
inventoryBasis?: string
|
||||||
/** 动态记录 */
|
/** 动态记录 */
|
||||||
dynamicRecord?: string
|
dynamicRecord?: string
|
||||||
|
|
||||||
|
/** 采购状态 */
|
||||||
|
procurementStatus?: string
|
||||||
|
|
||||||
|
/** 审批状态 */
|
||||||
|
approvalStatus?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,6 +300,17 @@ export enum BusinessType {
|
||||||
RETURN = 'RETURN'
|
RETURN = 'RETURN'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备采购状态枚举
|
||||||
|
*/
|
||||||
|
export enum ProcurementStatus {
|
||||||
|
NOT_STARTED = 'NOT_STARTED',
|
||||||
|
PENDING_APPROVAL = 'PENDING_APPROVAL',
|
||||||
|
APPROVED = 'APPROVED',
|
||||||
|
REJECTED = 'REJECTED',
|
||||||
|
COMPLETED = 'COMPLETED'
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备审批列表查询请求
|
* 设备审批列表查询请求
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -237,6 +237,7 @@ const rules = {
|
||||||
// 监听设备数据变化,填充表单
|
// 监听设备数据变化,填充表单
|
||||||
watch(() => props.equipmentData, (newData) => {
|
watch(() => props.equipmentData, (newData) => {
|
||||||
if (newData) {
|
if (newData) {
|
||||||
|
console.log('采购申请弹窗 - 接收到设备数据:', newData)
|
||||||
// 填充设备数据到表单
|
// 填充设备数据到表单
|
||||||
Object.assign(formData, {
|
Object.assign(formData, {
|
||||||
equipmentId: newData.equipmentId || '', // 添加设备ID
|
equipmentId: newData.equipmentId || '', // 添加设备ID
|
||||||
|
@ -254,6 +255,7 @@ watch(() => props.equipmentData, (newData) => {
|
||||||
technicalRequirements: '',
|
technicalRequirements: '',
|
||||||
businessJustification: ''
|
businessJustification: ''
|
||||||
})
|
})
|
||||||
|
console.log('采购申请弹窗 - 填充后的表单数据:', formData)
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
|
@ -291,10 +293,18 @@ const handleSubmit = async () => {
|
||||||
|
|
||||||
// 调试信息:打印提交的数据
|
// 调试信息:打印提交的数据
|
||||||
console.log('提交的表单数据:', submitData)
|
console.log('提交的表单数据:', submitData)
|
||||||
|
console.log('设备ID:', submitData.equipmentId)
|
||||||
|
console.log('设备名称:', submitData.equipmentName)
|
||||||
console.log('applyReason 值:', submitData.applyReason)
|
console.log('applyReason 值:', submitData.applyReason)
|
||||||
console.log('applyReason 类型:', typeof submitData.applyReason)
|
console.log('applyReason 类型:', typeof submitData.applyReason)
|
||||||
console.log('applyReason 长度:', submitData.applyReason?.length)
|
console.log('applyReason 长度:', submitData.applyReason?.length)
|
||||||
|
|
||||||
|
// 确保设备ID存在
|
||||||
|
if (!submitData.equipmentId) {
|
||||||
|
Message.error('设备ID不能为空,请检查设备数据')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
await equipmentApprovalApi.submitProcurementApplication(submitData)
|
await equipmentApprovalApi.submitProcurementApplication(submitData)
|
||||||
|
|
||||||
// 添加采购申请通知
|
// 添加采购申请通知
|
||||||
|
|
|
@ -128,6 +128,17 @@
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- 采购状态 -->
|
||||||
|
<template #procurementStatus="{ record }">
|
||||||
|
<a-tag
|
||||||
|
v-if="record.procurementStatus && record.procurementStatus !== 'NOT_STARTED'"
|
||||||
|
:color="getProcurementStatusColor(record.procurementStatus)"
|
||||||
|
>
|
||||||
|
{{ getProcurementStatusText(record.procurementStatus) }}
|
||||||
|
</a-tag>
|
||||||
|
<a-tag v-else color="gray">未开始</a-tag>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- 位置状态 -->
|
<!-- 位置状态 -->
|
||||||
<template #locationStatus="{ record }">
|
<template #locationStatus="{ record }">
|
||||||
<a-tag :color="getLocationStatusColor(record.locationStatus)">
|
<a-tag :color="getLocationStatusColor(record.locationStatus)">
|
||||||
|
@ -175,7 +186,7 @@
|
||||||
<a-button type="text" size="small" @click="handleEdit(record)">
|
<a-button type="text" size="small" @click="handleEdit(record)">
|
||||||
编辑
|
编辑
|
||||||
</a-button>
|
</a-button>
|
||||||
<!-- 申请采购按钮 -->
|
<!-- 申请采购按钮 - 只在特定状态下显示 -->
|
||||||
<a-button
|
<a-button
|
||||||
v-if="canApplyProcurement(record)"
|
v-if="canApplyProcurement(record)"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
@ -184,12 +195,20 @@
|
||||||
>
|
>
|
||||||
申请采购
|
申请采购
|
||||||
</a-button>
|
</a-button>
|
||||||
|
<!-- 显示采购状态 - 优先显示采购状态 -->
|
||||||
|
<a-tag
|
||||||
|
v-if="record.procurementStatus && record.procurementStatus !== 'NOT_STARTED'"
|
||||||
|
:color="getProcurementStatusColor(record.procurementStatus)"
|
||||||
|
>
|
||||||
|
{{ getProcurementStatusText(record.procurementStatus) }}
|
||||||
|
</a-tag>
|
||||||
<!-- 显示审批状态 -->
|
<!-- 显示审批状态 -->
|
||||||
<a-tag v-if="record.approvalStatus" :color="getApprovalStatusColor(record.approvalStatus)">
|
<a-tag v-if="record.approvalStatus" :color="getApprovalStatusColor(record.approvalStatus)">
|
||||||
{{ getApprovalStatusText(record.approvalStatus) }}
|
{{ getApprovalStatusText(record.approvalStatus) }}
|
||||||
</a-tag>
|
</a-tag>
|
||||||
|
<!-- 删除按钮 -->
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
content="确定要删除这条采购记录吗?"
|
content="确定要删除这条记录吗?"
|
||||||
@ok="handleDelete(record)"
|
@ok="handleDelete(record)"
|
||||||
>
|
>
|
||||||
<a-button type="text" size="small" status="danger">
|
<a-button type="text" size="small" status="danger">
|
||||||
|
@ -345,6 +364,14 @@ const columns = [
|
||||||
slotName: 'equipmentStatus',
|
slotName: 'equipmentStatus',
|
||||||
width: 120,
|
width: 120,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '采购状态',
|
||||||
|
dataIndex: 'procurementStatus',
|
||||||
|
key: 'procurementStatus',
|
||||||
|
slotName: 'procurementStatus',
|
||||||
|
width: 120,
|
||||||
|
fixed: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '位置状态',
|
title: '位置状态',
|
||||||
dataIndex: 'locationStatus',
|
dataIndex: 'locationStatus',
|
||||||
|
@ -403,6 +430,30 @@ const getEquipmentStatusText = (status: string) => {
|
||||||
return textMap[status] || '未知'
|
return textMap[status] || '未知'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取采购状态颜色
|
||||||
|
const getProcurementStatusColor = (status: string) => {
|
||||||
|
const colorMap: Record<string, string> = {
|
||||||
|
NOT_STARTED: 'gray',
|
||||||
|
PENDING_APPROVAL: 'blue',
|
||||||
|
APPROVED: 'green',
|
||||||
|
REJECTED: 'red',
|
||||||
|
COMPLETED: 'purple',
|
||||||
|
}
|
||||||
|
return colorMap[status] || 'blue'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取采购状态文本
|
||||||
|
const getProcurementStatusText = (status: string) => {
|
||||||
|
const textMap: Record<string, string> = {
|
||||||
|
NOT_STARTED: '未开始',
|
||||||
|
PENDING_APPROVAL: '待审批',
|
||||||
|
APPROVED: '已通过',
|
||||||
|
REJECTED: '已拒绝',
|
||||||
|
COMPLETED: '已完成',
|
||||||
|
}
|
||||||
|
return textMap[status] || '未知'
|
||||||
|
}
|
||||||
|
|
||||||
// 获取位置状态颜色
|
// 获取位置状态颜色
|
||||||
const getLocationStatusColor = (status: string) => {
|
const getLocationStatusColor = (status: string) => {
|
||||||
const colorMap: Record<string, string> = {
|
const colorMap: Record<string, string> = {
|
||||||
|
@ -530,6 +581,7 @@ const transformBackendData = (data: any[]): EquipmentResp[] => {
|
||||||
totalPrice: item.totalPrice,
|
totalPrice: item.totalPrice,
|
||||||
inventoryBasis: item.inventoryBasis,
|
inventoryBasis: item.inventoryBasis,
|
||||||
dynamicRecord: item.dynamicRecord,
|
dynamicRecord: item.dynamicRecord,
|
||||||
|
procurementStatus: item.procurementStatus,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,6 +624,10 @@ const loadData = async (searchParams?: EquipmentListReq) => {
|
||||||
if (dataList.length > 0) {
|
if (dataList.length > 0) {
|
||||||
const transformedData = transformBackendData(dataList)
|
const transformedData = transformBackendData(dataList)
|
||||||
console.log('转换后的数据:', transformedData)
|
console.log('转换后的数据:', transformedData)
|
||||||
|
// 调试采购状态字段
|
||||||
|
transformedData.forEach((item, index) => {
|
||||||
|
console.log(`设备 ${index + 1} - 名称: ${item.equipmentName}, 采购状态: ${item.procurementStatus}`)
|
||||||
|
})
|
||||||
tableData.value = transformedData
|
tableData.value = transformedData
|
||||||
} else {
|
} else {
|
||||||
tableData.value = []
|
tableData.value = []
|
||||||
|
@ -662,9 +718,15 @@ const handleModalSuccess = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 采购申请成功回调
|
// 采购申请成功回调
|
||||||
const handleApplicationSuccess = () => {
|
const handleApplicationSuccess = async () => {
|
||||||
applicationModalVisible.value = false
|
applicationModalVisible.value = false
|
||||||
loadData(currentSearchParams.value)
|
console.log('采购申请成功,准备刷新数据...')
|
||||||
|
// 延迟刷新数据,确保后端状态更新完成
|
||||||
|
setTimeout(async () => {
|
||||||
|
console.log('开始刷新数据...')
|
||||||
|
await loadData(currentSearchParams.value)
|
||||||
|
message.success('采购申请已提交,请等待审批')
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新数据
|
// 刷新数据
|
||||||
|
@ -714,8 +776,12 @@ const getTotalAmount = () => {
|
||||||
|
|
||||||
// 检查是否可以申请采购
|
// 检查是否可以申请采购
|
||||||
const canApplyProcurement = (record: EquipmentResp) => {
|
const canApplyProcurement = (record: EquipmentResp) => {
|
||||||
// 检查是否有审批状态,如果没有或者状态为待申请,则可以申请
|
// 根据采购状态判断是否可以申请采购
|
||||||
return !record.approvalStatus || record.approvalStatus === 'PENDING_APPLICATION'
|
// 只有未开始、已拒绝、已完成的设备可以重新申请采购
|
||||||
|
const allowedStatuses = ['NOT_STARTED', 'REJECTED', 'COMPLETED', null, undefined]
|
||||||
|
const canApply = allowedStatuses.includes(record.procurementStatus)
|
||||||
|
console.log(`设备 ${record.equipmentName} 采购状态: ${record.procurementStatus}, 可申请: ${canApply}`)
|
||||||
|
return canApply
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取审批状态颜色
|
// 获取审批状态颜色
|
||||||
|
|
Loading…
Reference in New Issue