feat: 实现层级统计功能集成和层级删除配置页面

- 添加层级统计API端点配置和服务方法
- 集成getHierarchyStatistics API到层级删除配置页面
- 实现动态层级数据显示和组件数量统计
- 修复数据嵌套结构访问问题
- 调整层级显示从0-based改为1-based用户界面

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sladro 2025-09-18 09:59:24 +08:00
parent 98515ce0c6
commit a7decc6645
4 changed files with 66 additions and 11 deletions

View File

@ -146,6 +146,7 @@ const handleOperation = async () => {
- ✅ 信息面板实时日志显示和软件状态同步
- ✅ PDMS工厂设计模型查看器PdmsModelViewer
- ✅ Revit建筑设计模型查看器RevitModelViewer
- ✅ 层级统计功能完整集成getHierarchyStatistics API + 层级删除配置页面)
## 页面添加标准流程

View File

@ -28,16 +28,18 @@
<input type="number"
class="level-number-input"
id="deletion-level-input"
min="0"
:max="maxLevel"
v-model="selectedLevel">
min="1"
:max="maxLevel + 1"
v-model="displayLevel"
:disabled="loading">
<span>或选择:</span>
<select class="level-select"
id="deletion-level-select"
v-model="selectedLevel">
v-model="displayLevel"
:disabled="loading">
<option value="">-- 选择层级 --</option>
<option v-for="level in availableLevels" :key="level" :value="level">
层级 {{ level }} (25 个组件)
<option v-for="level in availableLevels" :key="level" :value="level + 1">
层级 {{ level + 1 }} ({{ getLevelComponentCount(level) }} 个组件)
</option>
</select>
</div>
@ -59,7 +61,8 @@
</button>
<button class="params-action-btn danger"
id="execute-deletion-btn"
@click="$emit('execute-deletion', getExecutionParams())">
@click="$emit('execute-deletion', getExecutionParams())"
:disabled="loading || selectedLevel === null">
<i class="fas fa-trash"></i>
执行删除
</button>
@ -70,6 +73,7 @@
<script setup>
import { ref, computed, onMounted } from 'vue'
import { creoApi } from '@/services/creoApi'
// Props - 使
defineProps({
@ -84,23 +88,45 @@ defineEmits(['close', 'execute-deletion'])
//
const selectedLevel = ref(null)
const hierarchyStatistics = ref({})
const totalLevels = ref(0)
const loading = ref(false)
// -
const availableLevels = computed(() => {
return [0, 1, 2, 3, 4]
if (!hierarchyStatistics.value || Object.keys(hierarchyStatistics.value).length === 0) {
return []
}
// statistics
return Object.keys(hierarchyStatistics.value)
.map(level => parseInt(level))
.sort((a, b) => a - b)
})
// -
const maxLevel = computed(() => {
return 4
return totalLevels.value > 0 ? totalLevels.value - 1 : 0
})
// - 1
const displayLevel = computed({
get: () => selectedLevel.value !== null ? selectedLevel.value + 1 : null,
set: (value) => selectedLevel.value = value !== null ? value - 1 : null
})
// -
const rangeDisplayText = computed(() => {
if (selectedLevel.value === null) return '请选择层级'
return `层级 ${selectedLevel.value} 及以下`
return `层级 ${selectedLevel.value + 1} 及以下`
})
//
const getLevelComponentCount = (level) => {
if (!hierarchyStatistics.value || !hierarchyStatistics.value[level]) {
return 0
}
return hierarchyStatistics.value[level]
}
//
const getExecutionParams = () => {
@ -124,9 +150,21 @@ const initializeDefaultLevel = () => {
}
}
//
const fetchHierarchyStatistics = async () => {
loading.value = true
const result = await creoApi.getHierarchyStatistics()
if (result.success && result.data && result.data.data) {
hierarchyStatistics.value = result.data.data.statistics
totalLevels.value = result.data.data.total_levels
initializeDefaultLevel()
}
loading.value = false
}
//
onMounted(() => {
initializeDefaultLevel()
fetchHierarchyStatistics()
})
</script>

View File

@ -83,6 +83,7 @@ const CAD_SOFTWARE_DEFINITIONS = {
status: '/api/status/model',
open: '/api/model/open',
hierarchy: '/api/creo/analysis/hierarchy',
hierarchyStatistics: '/api/analysis/hierarchy-statistics',
geometryComplexity: '/api/analysis/geometry-complexity',
shellAnalysis: '/api/analysis/shell-analysis',
optimization: '/api/creo/shrinkwrap/shell',

View File

@ -150,6 +150,21 @@ class CreoApiService {
}
})
}
/**
* 获取层级统计信息
* @returns {Promise<{success: boolean, data?: any, error?: string}>}
*/
async getHierarchyStatistics() {
const url = buildApiUrl(this.softwareName, 'hierarchyStatistics')
return await apiClient.post(url, {}, {
operationContext: {
software: 'Creo',
operation: '获取层级统计'
}
})
}
}
// 导出单例实例