feat: 实现PDMS查看当前模型功能并统一状态管理

- 扩展PDMS API服务添加getCurrentModel方法,调用真实API接口
- 修改PDMS模型查看器使用props接收真实API数据
- 统一CAD状态管理,所有软件使用setCurrentProjectName方法
- 修复DashboardView中PdmsModelViewer缺失modelData传递问题
- 确保数据传递层级正确,避免undefined访问错误

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sladro 2025-09-18 19:21:28 +08:00
parent 46c85cf9a2
commit 707a673b5b
5 changed files with 52 additions and 53 deletions

View File

@ -143,23 +143,21 @@ const handleOpenModel = async () => {
if (connectedCAD.id === 'creo') {
const result = await creoApi.getCurrentModel()
if (result.success) {
cadStore.currentProjectName = result.data.data.fileName
cadStore.setCurrentProjectName(result.data.data.fileName)
emit('show-model-viewer', result.data)
}
} else if (connectedCAD.id === 'revit') {
const result = await revitApi.getCurrentModel()
if (result.success) {
cadStore.currentProjectName = result.data.data.project.name
cadStore.setCurrentProjectName(result.data.data.project.name)
emit('show-model-viewer', result.data.data)
}
} else if (connectedCAD.id === 'pdms') {
// PDMS
emit('show-model-viewer', {
data: {
software: 'pdms',
connected: true
}
})
const result = await pdmsApi.getCurrentModel()
if (result.success) {
cadStore.setCurrentProjectName(result.data.data.ProjectInfo.ProjectName)
emit('show-model-viewer', result.data.data)
}
}
} else {
// - 使ElementPlus
@ -180,7 +178,7 @@ const handleOpenModel = async () => {
//
const modelResult = await creoApi.getCurrentModel()
if (modelResult.success) {
cadStore.currentProjectName = modelResult.data.data.fileName
cadStore.setCurrentProjectName(modelResult.data.data.fileName)
emit('show-model-viewer', modelResult.data)
}
}

View File

@ -11,7 +11,7 @@
<h2>PDMS 工厂设计分析中心</h2>
<p>当前项目{{ projectData.ProjectName }}</p>
<span class="project-status-badge connected">
{{ projectData.ModelLoaded ? '模型已加载' : '模型未加载' }}
{{ modelLoaded ? '模型已加载' : '模型未加载' }}
</span>
</div>
</div>
@ -39,22 +39,22 @@
<div class="pdms-stats-grid">
<div class="pdms-stat-card">
<h4><i class="fas fa-cubes"></i> 总元素数</h4>
<div class="stat-number">{{ modelStats.TotalElements.toLocaleString() }}</div>
<div class="stat-number">{{ (modelStats.TotalElements || 0).toLocaleString() }}</div>
<div class="stat-label">工厂模型总元素</div>
</div>
<div class="pdms-stat-card">
<h4><i class="fas fa-layer-group"></i> 区域数量</h4>
<div class="stat-number">{{ modelStats.ZoneCount }}</div>
<div class="stat-number">{{ modelStats.ZoneCount || 0 }}</div>
<div class="stat-label">设计区域总数</div>
</div>
<div class="pdms-stat-card">
<h4><i class="fas fa-play-circle"></i> 活跃区域</h4>
<div class="stat-number">{{ modelStats.ActiveZones.length }}</div>
<div class="stat-number">{{ (modelStats.ActiveZones || []).length }}</div>
<div class="stat-label">当前活跃区域</div>
</div>
<div class="pdms-stat-card">
<h4><i class="fas fa-th-list"></i> 元素类型</h4>
<div class="stat-number">{{ Object.keys(modelStats.ElementCounts).length }}</div>
<div class="stat-number">{{ Object.keys(modelStats.ElementCounts || {}).length }}</div>
<div class="stat-label">不同元素类型</div>
</div>
</div>
@ -64,7 +64,7 @@
<!-- 左侧元素类型分布 -->
<div class="pdms-elements-breakdown">
<h4><i class="fas fa-chart-pie"></i> 元素类型分布</h4>
<div class="pdms-element-item" v-for="(count, type) in modelStats.ElementCounts" :key="type">
<div class="pdms-element-item" v-for="(count, type) in (modelStats.ElementCounts || {})" :key="type">
<div class="pdms-element-name">
<div class="pdms-element-icon" :class="getElementClass(type)">
<i :class="getElementIcon(type)"></i>
@ -80,11 +80,11 @@
<h4><i class="fas fa-map-marked-alt"></i> 区域管理</h4>
<div class="zone-summary">
<span class="zone-label">总区域: </span>
<strong>{{ modelStats.ZoneCount }}</strong>
<strong>{{ modelStats.ZoneCount || 0 }}</strong>
<span class="zone-label active-label">活跃区域: </span>
<strong class="active-count">{{ modelStats.ActiveZones.length }}</strong>
<strong class="active-count">{{ (modelStats.ActiveZones || []).length }}</strong>
</div>
<div class="pdms-zone-item active" v-for="zone in modelStats.ActiveZones" :key="zone">
<div class="pdms-zone-item active" v-for="zone in (modelStats.ActiveZones || [])" :key="zone">
<i class="fas fa-check-circle"></i>
<span>{{ zone }}</span>
</div>
@ -135,40 +135,22 @@
</template>
<script setup>
import { computed } from 'vue'
import { ElNotification } from 'element-plus'
// PDMS
const projectData = {
ProjectName: 'PETROCHEMICAL_PLANT_2024',
MdsName: 'MAINDB_PETROCHEMICAL',
PdmsVersion: '12.1.SP5',
ModelLoaded: true
}
const modelStats = {
TotalElements: 156789,
ZoneCount: 24,
ActiveZones: ['ZONE_A01_REACTOR', 'ZONE_B02_DISTILL', 'ZONE_C03_STORAGE', 'ZONE_D04_UTILITY'],
ElementCounts: {
'PIPE': 45623,
'ELBO': 12847,
'VALVE': 8934,
'FITTING': 15672,
'EQUIPMENT': 2156,
'STRUCTURE': 18945,
'TEE': 6789,
'REDUCER': 3421,
'FLANGE': 9876,
'PUMP': 234,
'TANK': 89
//
const props = defineProps({
modelData: {
type: Object,
required: true
}
}
})
const sessionData = {
UserName: 'engineering_admin',
StartTime: '2024-09-17T08:30:00Z',
DurationMinutes: 145
}
// API
const projectData = computed(() => props.modelData?.ProjectInfo || {})
const modelStats = computed(() => props.modelData?.ModelStatistics || {})
const sessionData = computed(() => props.modelData?.SessionInfo || {})
const modelLoaded = computed(() => props.modelData?.ModelLoaded || false)
// PDMS
const elementTypeIcons = {

View File

@ -1,8 +1,6 @@
import apiClient from './apiClient'
import { buildApiUrl } from '@/config/cad'
const SOFTWARE_TYPE = "pdms"
class PdmsApiService {
constructor() {
this.softwareName = 'pdms'
@ -22,6 +20,21 @@ class PdmsApiService {
}
})
}
/**
* 获取当前模型状态
* @returns {Promise<{success: boolean, data?: any, error?: string}>}
*/
async getCurrentModel() {
const url = buildApiUrl(this.softwareName, 'status')
return await apiClient.get(url, {
operationContext: {
software: 'PDMS',
operation: '获取当前模型'
}
})
}
}
export const pdmsApi = new PdmsApiService()

View File

@ -85,6 +85,11 @@ export const useCADStore = defineStore('cad', () => {
}
}
// 设置当前项目名称
const setCurrentProjectName = (projectName) => {
currentProjectName.value = projectName
}
return {
// 状态
@ -97,6 +102,7 @@ export const useCADStore = defineStore('cad', () => {
getCADConnection,
cadSupportsFeature,
setCADConnection,
setCADConnecting
setCADConnecting,
setCurrentProjectName
}
})

View File

@ -91,7 +91,7 @@
<!-- 模型查看页面 -->
<div v-if="currentPage === PAGE_TYPES.MODEL_VIEWER && showModelViewer" class="page-content">
<CreoModelViewer v-if="currentConnectedSoftware === 'creo'" :model-data="currentModelData" />
<PdmsModelViewer v-else-if="currentConnectedSoftware === 'pdms'" />
<PdmsModelViewer v-else-if="currentConnectedSoftware === 'pdms'" :model-data="currentModelData" />
<RevitModelViewer v-else-if="currentConnectedSoftware === 'revit'" :model-data="currentModelData" />
<CreoModelViewer v-else :model-data="currentModelData" />
</div>