am-freescan/scripts/prepare_result_files_ui.py
lixiaolong ba0f749d40 feat: 完善检测任务、夹具轨迹与设备工作流
完善扫描成果与比对资料管理,精简业务菜单和任务工作台,更新批量导入模板。

适配机械臂新协议、坐标系管理及目标位姿组件,增加扫描参数字典和角色自动分配。

修复试运行终止状态与过期扫描任务资源释放,补充回归测试、迁移脚本及接口文档。
2026-11-06 10:50:49 +08:00

29 lines
2.6 KiB
Python

"""Generate an offline UI fixture. All reads and downloads stay in memory; no device/API calls."""
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
PAGE = r'''<!doctype html><html lang="zh-CN"><meta charset="utf-8"><title>成果下载离线验证</title><body><div id="app"></div>
<script type="module">
import {createApp,h,ref} from 'vue';
import {createRouter,createWebHistory} from 'vue-router';
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import 'element-plus/dist/index.css';
import Panel from '/src/views/lab/dimension/ResultFilesDialog.vue';
import {Dialog} from '/src/components/Dialog/index.ts';
const panel=ref(),calls=ref([]),failed=ref(false);
const units=[{id:'9007199254740993',unit_no:'样件01'},{id:'9007199254740994',unit_no:'样件02'}];
const files=[{id:'stl-01',file_name:'样件01-比对.stl'},{id:'pdf-01',file_name:'样件01-报告.pdf'},{id:'stl-old',file_name:'样件01-历史.stl'},{id:'pdf-old',file_name:'样件01-历史.pdf'}];
const deliveries=[{id:'delivery-current',external_no:'比对版本02',status:'DELIVERED',current:true,stl_id:'stl-01',pdf_id:'pdf-01'},{id:'delivery-old',external_no:'比对版本01',status:'DELIVERED',current:false,stl_id:'stl-old',pdf_id:'pdf-old'}];
const app=createApp({setup(){return()=>h('main',{style:'max-width:1000px;margin:32px auto;font:14px sans-serif'},[h('h2','成果查询与下载离线验证'),h('p','数据仅在内存中;下载按钮只记录参数,不连接实际接口。'),h('button',{onClick:()=>panel.value.open({id:'offline-task',task_no:'OFFLINE-01',task_name:'离线成果验证任务'})},'打开成果'),h('button',{onClick:()=>failed.value=!failed.value},failed.value?'恢复读取':'模拟读取失败'),h('pre',{'data-testid':'calls'},calls.value.join('\n')),h(Panel,{ref:panel})])}});
app.provide('dimensionResultReader',async(taskId,unitId)=>{calls.value.push('读取 '+taskId+' / '+unitId);if(failed.value)throw Error('离线模拟:成果读取失败');return {units,files,deliveries:String(unitId)===units[0].id?deliveries:[]}});
app.provide('dimensionResultDownloader',async(id,name,pack)=>{calls.value.push(JSON.stringify({id,name,pack}));});
app.directive('hasPermi',()=>{});
app.component('Dialog',Dialog);
app.use(createRouter({history:createWebHistory(),routes:[{path:'/:pathMatch(.*)*',component:{render:()=>null}}]}));
app.use(ElementPlus,{locale:zhCn});app.mount('#app');
</script></body></html>'''
if __name__ == '__main__':
target = ROOT/'am-web/result-files-verification.html'
target.write_text(PAGE, encoding='utf-8')
print(target)