集成旋转底座、机械臂示教与坐标系,完善扫描参数、电量和框架点复用。增加组合执行、步骤进度与日志,优化首屏和流程画布性能,修复表头主题适配,并保留验证脚本和回归测试。
57 lines
4.9 KiB
HTML
57 lines
4.9 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN"><meta charset="UTF-8"><title>E2E 本地框架文件导入</title>
|
|
<style>body{margin:24px;font:14px Arial;background:#f5f7fa;color:#303133}main{max-width:800px;margin:16px auto;padding:24px;background:#fff}.buttons{display:flex;gap:12px}#result{white-space:pre-wrap}h1{font-size:20px}</style>
|
|
<main><h1>本地框架文件导入检查</h1><p>使用真实界面,接口在内存中模拟,不操作扫描仪、不保存业务数据。</p><div id="app"></div><pre id="result" role="status"></pre></main>
|
|
<script type="module">
|
|
import {createApp,h,ref,nextTick} from 'vue'
|
|
import ElementPlus from 'element-plus'
|
|
import 'element-plus/dist/index.css'
|
|
import {setupStore} from '/src/store/index.ts'
|
|
import {setupI18n} from '/src/plugins/vueI18n/index.ts'
|
|
import {setupGlobCom} from '/src/components/index.ts'
|
|
import {service} from '/src/config/axios/service.ts'
|
|
import request from '/src/cmvr/request.ts'
|
|
import Panel from '/src/cmvr/common/views/flow/components/params/ScannerFrameworkImportParams.vue'
|
|
import Fixture from '/src/views/lab/md/fixture/FixtureFramework.vue'
|
|
import {createWorkcellNodeGroups} from '/src/cmvr/common/utils/scanMotorNodes.mjs'
|
|
let fileSeq=0,versionSeq=0,current={},history=[]
|
|
const calls=[]
|
|
const result=()=>document.querySelector('#result').textContent=JSON.stringify({calls,saved:importer.properties,startInputs:graph.nodes[0].properties.inputParams,current,history},null,2)
|
|
const respond=(config,data,code=200)=>({data:{code,data},status:200,statusText:'OK',headers:{},config,request:{responseType:config.responseType}})
|
|
request.defaults.adapter=async config=>{
|
|
const method=(config.method||'get').toLowerCase(),path=config.url
|
|
if(method==='get'&&path==='/scanner/configuration')return respond(config,{configured:false})
|
|
if(method==='get'&&path==='/resource/robots')return {...respond(config,null),data:{code:200,rows:[],total:0}}
|
|
if(method==='post'&&path==='/scanner/validate')return respond(config,true)
|
|
if(method==='post'&&path==='/scanner/framework/local-files'){
|
|
const file=config.data.get('file');calls.push({upload:file.name,bytes:file.size})
|
|
if(file.name.startsWith('fail'))throw Error('模拟上传失败')
|
|
await new Promise(resolve=>setTimeout(resolve,500))
|
|
return respond(config,{fileId:(++fileSeq).toString(16).padStart(32,'0'),name:file.name,bytes:file.size,sha256:'a'.repeat(64),downloadUrl:'/admin-api/cmvr/scanner/files/'+fileSeq.toString(16).padStart(32,'0')})
|
|
}
|
|
throw Error('Unexpected device operation blocked: '+method+' '+path)
|
|
}
|
|
service.defaults.adapter=async config=>{
|
|
const method=(config.method||'get').toLowerCase(),path=config.url,body=typeof config.data==='string'?JSON.parse(config.data):config.data
|
|
if(['get','post'].includes(method)&&['/lab/master/fixture/framework/get','/lab/master/fixture/framework/sync'].includes(path))return respond(config,{current,history},0)
|
|
if(method==='get'&&path==='/lab/master/fixture/framework/definition')return respond(config,{caseName:'框架点录入流程',flowData:JSON.stringify({nodes:[],edges:[]})},0)
|
|
if(method==='post'&&path==='/lab/master/fixture/framework/import'){
|
|
if(body.expectedVersion!==(current.id||null))throw Error('version changed')
|
|
current={id:(++versionSeq).toString().padStart(32,'0'),updatedAt:Date.now(),urlsJson:JSON.stringify(body.frameworkUrls)}
|
|
history=[{...current,status:'READY',createdAt:Date.now(),message:'本地导入:'+body.frameworkUrls.length+'个文件'},...history]
|
|
calls.push({fixtureImport:body});result();return respond(config,current.id,0)
|
|
}
|
|
throw Error('Unexpected host operation blocked: '+method+' '+path)
|
|
}
|
|
const templates=createWorkcellNodeGroups()[0].nodeList
|
|
const importer={id:'E2E-local-import',type:'serviceNode',properties:{...templates.find(n=>n.action==='SCANNER_FRAMEWORK_IMPORT'),executionTarget:{roleKey:'scanner',deviceSlotKey:'scanner'}}}
|
|
const graph={nodes:[{id:'E2E-start',type:'start',properties:{name:'开始',inputParams:[{name:'fixtureFrameworkUrls',type:'string',required:true}],resourceRoles:[{roleKey:'scanner',displayName:'现场扫描工位',deviceSlots:[{slotKey:'scanner',deviceKind:14,displayName:'FreeScan扫描仪'}]}]}},importer],edges:[{sourceNodeId:'E2E-start',targetNodeId:importer.id}]}
|
|
window.lf={getGraphData:()=>graph,setProperties:(id,value)=>{const n=graph.nodes.find(n=>n.id===id);n.properties=value;result()}}
|
|
const app=createApp({setup(){const mode=ref(''),fixture=ref();return()=>h('div',[
|
|
h('div',{class:'buttons'},[h('button',{onClick:()=>{mode.value='workflow'}},'工作流导入组件'),h('button',{onClick:async()=>{mode.value='fixture';await nextTick();fixture.value.open({id:1,fixtureName:'E2E检查夹具'})}},'夹具框架点'),h('button',{onClick:()=>{mode.value='';result()}},'关闭检查面板')]),
|
|
mode.value==='workflow'?h(Panel,{data:importer,onSaveSuccess:result}):null,
|
|
mode.value==='fixture'?h(Fixture,{ref:fixture,onUpdated:result}):null
|
|
])}})
|
|
setupStore(app);await setupI18n(app);setupGlobCom(app);app.use(ElementPlus);app.mount('#app')
|
|
</script></html>
|