feat: 新增PDMS模型导出工具页面及相关配置与API服务。
This commit is contained in:
parent
3315486514
commit
0073eb3a6f
@ -47,42 +47,34 @@
|
||||
<div class="export-options">
|
||||
<div class="option-group">
|
||||
<label for="export-format">导出格式</label>
|
||||
<select id="export-format" v-model="exportForm.format">
|
||||
<option value="STP">STP (STEP 中性格式)</option>
|
||||
<option value="IGES">IGES (中性格式)</option>
|
||||
<option value="RVM">RVM</option>
|
||||
<select id="export-format" v-model="exportForm.format" disabled>
|
||||
<option value="IFC">IFC 模型格式</option>
|
||||
</select>
|
||||
<small class="form-hint">选择目标导出格式</small>
|
||||
<small class="form-hint">系统当前支持直接导出标准 IFC 模型</small>
|
||||
</div>
|
||||
|
||||
<div class="option-group">
|
||||
<label for="output-path">输出路径</label>
|
||||
<label for="export-dir">输出目录 (选填)</label>
|
||||
<input
|
||||
type="text"
|
||||
id="output-path"
|
||||
v-model="exportForm.outputPath"
|
||||
:placeholder="`D:\\export.${exportForm.format.toLowerCase()}`"
|
||||
id="export-dir"
|
||||
v-model="exportForm.exportPath"
|
||||
placeholder="例如: C:\temp"
|
||||
class="form-input"
|
||||
>
|
||||
<small class="form-hint">请输入完整的文件路径,包含文件名和后缀名</small>
|
||||
<small class="form-hint">指定服务端导出的文件夹路径。留空则使用默认路径</small>
|
||||
</div>
|
||||
|
||||
<div class="option-group">
|
||||
<label for="export-range">导出范围</label>
|
||||
<select id="export-range" v-model="exportForm.range">
|
||||
<option value="ZONE">当前选中的Zone/Site</option>
|
||||
<option value="EQUI">当前选中的设备(Equipment)</option>
|
||||
<option value="ALL">整个项目</option>
|
||||
</select>
|
||||
<small class="form-hint">选择要导出的模型层级范围</small>
|
||||
</div>
|
||||
|
||||
<div class="option-group" v-if="exportForm.format !== 'RVM'">
|
||||
<label>
|
||||
<input type="checkbox" v-model="exportForm.includeAttributes">
|
||||
包含属性数据
|
||||
</label>
|
||||
<small class="form-hint">导出时一并带上UDAs (User Defined Attributes)</small>
|
||||
<label for="file-name">文件名称 (选填)</label>
|
||||
<input
|
||||
type="text"
|
||||
id="file-name"
|
||||
v-model="exportForm.fileName"
|
||||
placeholder="例如: test_export.ifc"
|
||||
class="form-input"
|
||||
>
|
||||
<small class="form-hint">指定导出的文件名称(需带.ifc后缀)。留空则自动生成时间戳命名文件</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -104,36 +96,45 @@ import { ElMessage } from 'element-plus'
|
||||
|
||||
// 导出表单数据
|
||||
const exportForm = reactive({
|
||||
format: 'STP',
|
||||
outputPath: 'D:\\export.stp',
|
||||
range: 'ZONE',
|
||||
includeAttributes: true
|
||||
format: 'IFC',
|
||||
exportPath: '',
|
||||
fileName: ''
|
||||
})
|
||||
|
||||
// 计算属性:是否可以开始导出
|
||||
const canExport = computed(() => {
|
||||
return exportForm.outputPath && exportForm.outputPath.trim()
|
||||
return true // 所有参数可选填,后端有默认值
|
||||
})
|
||||
|
||||
// 开始导出
|
||||
const startExport = async () => {
|
||||
if (!canExport.value) return
|
||||
|
||||
try {
|
||||
// 假设 api 服务中有对应的统一导出接口
|
||||
if (pdmsApi.exportNeutralFormat) {
|
||||
await pdmsApi.exportNeutralFormat({
|
||||
format: exportForm.format,
|
||||
outputPath: exportForm.outputPath,
|
||||
range: exportForm.range,
|
||||
includeAttributes: exportForm.includeAttributes
|
||||
})
|
||||
ElMessage.success(`正在触发 ${exportForm.format} 导出流程...`)
|
||||
if (pdmsApi.exportIfc) {
|
||||
const params = {}
|
||||
if (exportForm.exportPath && exportForm.exportPath.trim()) {
|
||||
params.ExportPath = exportForm.exportPath.trim()
|
||||
}
|
||||
if (exportForm.fileName && exportForm.fileName.trim()) {
|
||||
params.FileName = exportForm.fileName.trim()
|
||||
}
|
||||
|
||||
ElMessage.info(`正在请求 IFC 模型导出,请稍候...`)
|
||||
const response = await pdmsApi.exportIfc(params)
|
||||
|
||||
if (response && response.data && response.data.Success) {
|
||||
ElMessage.success(`导出成功!文件耗时 ${response.data.DurationSeconds}s,保存至: ${response.data.FullPath}`)
|
||||
} else {
|
||||
ElMessage.success(`已触发导出流程`)
|
||||
}
|
||||
} else {
|
||||
ElMessage.success(`前端导出配置已收集,等待后端接口联调: ${exportForm.format}`)
|
||||
ElMessage.warning(`尚未找到相关导出接口`)
|
||||
}
|
||||
} catch(e) {
|
||||
ElMessage.error(`导出请求失败: ${e.message}`)
|
||||
if (e.response && e.response.data && e.response.data.message) {
|
||||
ElMessage.error(`导出失败: ${e.response.data.message}`)
|
||||
} else {
|
||||
ElMessage.error(`导出请求失败: ${e.message || '未知错误'}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -129,14 +129,15 @@ const CAD_SOFTWARE_DEFINITIONS = {
|
||||
apiVersion: 'v1',
|
||||
priority: 3,
|
||||
description: '工厂设计管理',
|
||||
features: ['status', 'piping', 'shrinkwrap', 'openProject', 'openMdb'],
|
||||
features: ['status', 'piping', 'shrinkwrap', 'openProject', 'openMdb', 'exportIfc'],
|
||||
endpoints: {
|
||||
connect: '/test',
|
||||
status: '/api/status/model',
|
||||
piping: '/api/v1/piping',
|
||||
shrinkwrap: '/api/model/shrinkwrap',
|
||||
openProject: '/api/project/open',
|
||||
openMdb: '/api/mdb/open'
|
||||
openMdb: '/api/mdb/open',
|
||||
exportIfc: '/api/export/ifc'
|
||||
}
|
||||
},
|
||||
AUTOCAD: {
|
||||
|
||||
@ -114,6 +114,23 @@ class PdmsApiService {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出为IFC格式
|
||||
* @param {Object} params - 导出参数 { ExportPath, FileName }
|
||||
* @returns {Promise<{success: boolean, data?: any, error?: string}>}
|
||||
*/
|
||||
async exportIfc(params) {
|
||||
const url = buildApiUrl(this.softwareName, 'exportIfc')
|
||||
|
||||
return await apiClient.post(url, params || {}, {
|
||||
timeout: 600000, // 导出可能需要较长时间
|
||||
operationContext: {
|
||||
software: 'PDMS',
|
||||
operation: '导出IFC格式'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const pdmsApi = new PdmsApiService()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user