修复CAM和CAE模块切换错误

This commit is contained in:
JackLee 2026-03-12 19:42:16 +08:00
parent ecae5dca40
commit fc26212ddd
5 changed files with 88 additions and 36 deletions

View File

@ -50,7 +50,16 @@ export struct SwitchModelBtn {
build() {
Column({ space: 2 }) {
if (this.eventBtn != undefined) {
EventBtn({eventBtn:this.eventBtn}).onClick(() => {
Button()
.width('35vp')
.height('35vp')
.backgroundImage($r('app.media.' + this.eventBtn.eIcon))
.backgroundImagePosition({ x: '10%', y: '10%' })
.backgroundColor(Color.Transparent)
.backgroundImageSize({
width: '80%', // 图片宽度占满按钮
height: '80%' // 图片高度占满按钮
}).onClick(() => {
if (this.eventBtn?.eEvent == 'Switch_Model_CAD') {
this.curtModel = TitleData.mModels.get(1)
} else if (this.eventBtn?.eEvent == 'Switch_Model_CAM') {
@ -59,6 +68,11 @@ export struct SwitchModelBtn {
this.curtModel = TitleData.mModels.get(3)
}
})
Text(this.eventBtn.eName)
.fontSize('10fp')
.width('45vp')
.height('10vp')
.textAlign(TextAlign.Center)
}
}
.height('50vp')

View File

@ -8,22 +8,43 @@ import { TitleButton } from "../Interface/ButtonInterface";
export let TitleCAE:Array<TitleModel>=[
TitleMainPage[0],
{cmName:'加工',cmPage:'',cmTips:'',cmEvents: [
{cmName:'仿真',cmPage:'',cmTips:'',cmEvents: [
//数组表示非单个BtnEvent
[
//数组成员区别是GroupEvent还是BtnEvent
[{grpName:'加工环境',grpBtn:[
{eModel:[ModelType.BASE],eName:"重置环境",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"工艺",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
[{grpName:'初始化仿真',grpBtn:[
{eModel:[ModelType.BASE],eName:"导入模型",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"导出模型",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"设定仿真环境",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
[
{eModel:[ModelType.BASE],eName:"切削参数",eNamed:"",eIcon:"base_save_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"切削速度",eNamed:"",eIcon:"base_saveas_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"主轴参数",eNamed:"",eIcon:"base_saveall_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"环境参数",eNamed:"",eIcon:"base_save_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"力学参数",eNamed:"",eIcon:"base_saveas_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"化学参数",eNamed:"",eIcon:"base_saveall_file",eTips:"",eEvent:""},
] as Array<TitleButton>,
{eModel:[ModelType.BASE],eName:"显示刀路",eNamed:"",eIcon:"base_close_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"新建工序",eNamed:"",eIcon:"base_import_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"新建刀具",eNamed:"",eIcon:"base_export_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"选项",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"帮助",eNamed:"",eIcon:"base_help_file",eTips:"",eEvent:""},
],grpMenu:GroupOption}] as Array<TitleGroup>
]
]},
MatrixModel,
DevModel
]
export let TitleCAM:Array<TitleModel>=[TitleMainPage[0],
{cmName:'仿真',cmPage:'',cmTips:'',cmEvents: [
//数组表示非单个BtnEvent
[
//数组成员区别是GroupEvent还是BtnEvent
[{grpName:'初始化仿真',grpBtn:[
{eModel:[ModelType.BASE],eName:"导入模型",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"导出模型",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"设定仿真环境",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
[
{eModel:[ModelType.BASE],eName:"环境参数",eNamed:"",eIcon:"base_save_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"力学参数",eNamed:"",eIcon:"base_saveas_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"化学参数",eNamed:"",eIcon:"base_saveall_file",eTips:"",eEvent:""},
] as Array<TitleButton>,
{eModel:[ModelType.BASE],eName:"选项",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"帮助",eNamed:"",eIcon:"base_help_file",eTips:"",eEvent:""},
],grpMenu:GroupOption}] as Array<TitleGroup>
]
]},

View File

@ -6,22 +6,24 @@ import { TitleGroup } from "../Interface/GroupInterface";
import { MatrixModel,DevModel } from "./MatrixModel";
import { TitleButton } from "../Interface/ButtonInterface";
export let TitleCAM:Array<TitleModel>=[TitleMainPage[0],
{cmName:'仿真',cmPage:'',cmTips:'',cmEvents: [
export let TitleCAM:Array<TitleModel>=[
TitleMainPage[0],
{cmName:'加工',cmPage:'',cmTips:'',cmEvents: [
//数组表示非单个BtnEvent
[
//数组成员区别是GroupEvent还是BtnEvent
[{grpName:'初始化仿真',grpBtn:[
{eModel:[ModelType.BASE],eName:"导入模型",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"导出模型",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"设定仿真环境",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
[{grpName:'加工环境',grpBtn:[
{eModel:[ModelType.BASE],eName:"重置环境",eNamed:"",eIcon:"base_new_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"工艺",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
[
{eModel:[ModelType.BASE],eName:"环境参数",eNamed:"",eIcon:"base_save_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"力学参数",eNamed:"",eIcon:"base_saveas_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"化学参数",eNamed:"",eIcon:"base_saveall_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"切削参数",eNamed:"",eIcon:"base_save_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"切削速度",eNamed:"",eIcon:"base_saveas_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"主轴参数",eNamed:"",eIcon:"base_saveall_file",eTips:"",eEvent:""},
] as Array<TitleButton>,
{eModel:[ModelType.BASE],eName:"显示刀路",eNamed:"",eIcon:"base_close_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"新建工序",eNamed:"",eIcon:"base_import_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"新建刀具",eNamed:"",eIcon:"base_export_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"选项",eNamed:"",eIcon:"base_open_file",eTips:"",eEvent:""},
{eModel:[ModelType.BASE],eName:"帮助",eNamed:"",eIcon:"base_help_file",eTips:"",eEvent:""},
],grpMenu:GroupOption}] as Array<TitleGroup>
]
]},

View File

@ -18,7 +18,7 @@ export struct TitleTab {
//TabBar默认焦点
@Local titleBarDefaultFocusIndex: number = 0;
//模块Bar栏
@Provider('curtModel') curtModel:Array<TitleModel>|undefined= TitleData.mModels.get(0)
@Provider('curtModel') curtModel:Array<TitleModel>|undefined= TitleData.mModels.get(this.titleBarFocusIndex)
@Builder
FileMenu(menus: Array<TitleButton>) {
Menu() {
@ -69,7 +69,7 @@ export struct TitleTab {
Tabs({barPosition: BarPosition.Start, index: this.titleBarDefaultFocusIndex,controller: this.titleBarTabs}){
ForEach(this.curtModel,(item:TitleModel, index: number)=>{
TabContent() {
TitleTabContent({tabLayout:item.cmEvents as Array<Array<TitleButton|Array<TitleGroup>|Array<TitleButton>>>})
TitleTabContent({curtLayout:item})
}.align(Alignment.Start)
.padding(1)
.margin({ top: 0,left:0,bottom:2,right:0})

View File

@ -3,37 +3,52 @@ import { TitleButton} from '../LayoutInterface/Interface/ButtonInterface';
import { TitleGroup} from '../LayoutInterface/Interface/GroupInterface';
import {GroupTextEventMenu,MenuBtn} from '../CustomStyle/Menu'
import {EventBtn,SwitchModelBtn} from '../CustomStyle/Button'
import { TitleModel } from '../LayoutInterface/Layout/TabContent';
@ComponentV2
export struct TitleTabContent {
@Param tabLayout:Array<Array<TitleButton|Array<TitleGroup>|Array<TitleButton>>>=[];
@Param curtLayout:TitleModel|undefined=undefined;
@Builder
BtnMenu(item:Array<TitleButton>){
MenuBtn({menuBtn:item})
}
@Builder
BtnEvent(item: TitleButton){
EventBtn({eventBtn:item})
}
@Builder
BtnSwitchMode(item: TitleButton){
SwitchModelBtn({eventBtn:item})
}
build() {
//垂直布局展示多行
Column({ space: 0 }) {
//迭代生成行容器
ForEach(this.tabLayout, (row_items: Array<TitleButton|Array<TitleGroup>|Array<TitleButton>>, mIndex: number) => {
ForEach(this.curtLayout?.cmEvents, (row_items: Array<TitleButton|Array<TitleGroup>|Array<TitleButton>>, mIndex: number) => {
//行的按钮组容器
Row(){
ForEach(row_items, (row_item: TitleButton|Array<TitleGroup>|Array<TitleButton>, index: number) => {
//首先判断是否为数组.如果不为数组者为BtnEvent
if(!Array.isArray(row_item)){
if(!Array.isArray(row_item)){//TitleButton
//单按钮
EventBtn({eventBtn:row_item})
}else if(row_item instanceof Array<TitleGroup>){
}else if(row_item instanceof Array<TitleGroup>){ //Array<TitleGroup>
//功能组,迭代多个功能组
ForEach(row_item, (group_item: TitleGroup, index: number) =>{
Column({ space: 5 }){
Row({ space: 1 }){
ForEach(group_item.grpBtn, (btn_item: TitleButton|Array<TitleButton>, index: number) =>{
//如果是数组则为菜单按钮否则为单功能按钮
if(this.curtLayout?.cmName=='应用模块'){
if(Array.isArray(btn_item)){
MenuBtn({menuBtn:btn_item})
this.BtnMenu(btn_item)
}else{
//针对最后一个Bar特化处理.如果为最后一个Bar则在子组件Image真假onClick事件
if(mIndex==this.tabLayout.length-2){
SwitchModelBtn({eventBtn:btn_item})
this.BtnSwitchMode(btn_item)
}
}else{
EventBtn({eventBtn:btn_item})
if(Array.isArray(btn_item)){
this.BtnMenu(btn_item)
}else{
this.BtnEvent(btn_item)
}
}
})