Browse Source

feat: 新增添加座位表页面。

YuJing 1 tháng trước cách đây
mục cha
commit
d111e828d2

+ 57 - 0
features/feature/src/main/ets/pages/SeatingPlanPage.ets

@@ -0,0 +1,57 @@
+import { SeatingPlanPageViewModel } from '../viewModel/SeatingPlanPageViewModel';
+import { window } from '@kit.ArkUI';
+
+@ComponentV2
+struct SeatingPlanPage {
+  @Local vm: SeatingPlanPageViewModel = new SeatingPlanPageViewModel(this.getUIContext());
+
+  aboutToAppear() {
+    window.getLastWindow(this.getUIContext().getHostContext())
+      .then(res => {
+        res.setPreferredOrientation(window.Orientation.LANDSCAPE)
+      })
+  }
+
+  aboutToDisappear(): void {
+    this.vm._onBackPressed()
+  }
+
+  build() {
+    NavDestination() {
+      Column() {
+        Column(){
+          List({space: 4}){
+            ForEach(this.vm.dataSource, (item: number, index) => {
+              ListItem(){
+                Text('四个字的人')
+                  .width('100%')
+                  .fontSize(14)
+                  .borderRadius(15)
+                  .border({width: 1, color: item == 1 ? '#7186F9' : '#FB9BC1'})
+                  .padding({top: 7, bottom: 7})
+              }
+            })
+          }
+          .width('100%')
+          .height('100%')
+          .scrollBar(BarState.Off)
+        }
+        .width(95)
+        .height('100%')
+        .padding({top: 6, bottom: 6, left: 8, right: 8})
+      }
+      .width('100%')
+      .height('100%')
+      .justifyContent(FlexAlign.Center)
+      .alignItems(HorizontalAlign.Start)
+    }
+    .hideTitleBar(true)
+    .onBackPressed(() => { return this.vm._onBackPressed() })
+    .padding({ left: this.vm.safeTop })
+  }
+}
+
+@Builder
+function SeatingPlanPageBuilder() {
+  SeatingPlanPage()
+}

+ 5 - 0
features/feature/src/main/ets/utils/RouterUtils.ets

@@ -20,6 +20,11 @@ class RouterUtils{
     return yTRouter.getParamByName('IncreaseStudentPage').pop() as IncreaseStudentPageModel
   }
 
+  router2SeatingPlanPage(param: ESObject, back: Callback<PopInfo>){
+    yTRouter.pushPathByName('SeatingPlanPage', param, back)
+  }
+
+
   // DiaLog
   // 添加座位表弹窗
   router2AddSeatTableDialog(param: BasicType<AddSeatTablePageModel>, back: Callback<PopInfo>){

+ 33 - 0
features/feature/src/main/ets/viewModel/SeatingPlanPageViewModel.ets

@@ -0,0 +1,33 @@
+import { YTAvoid, yTRouter } from "basic"
+import { window } from "@kit.ArkUI"
+
+@ObservedV2
+export class SeatingPlanPageViewModel{
+  @Trace safeTop: number = 0
+  // 学生列表
+  @Trace dataSource: number[] = [0, 1, 1, 0, 0, 1, 0, 1, 0, 0]
+  // 座位表
+  @Trace seatingPlan: string[][] = []
+
+  conText: UIContext
+
+  constructor(conText: UIContext) {
+    this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
+    this.conText = conText
+  }
+
+  
+
+  /**
+   * 重写的返回逻辑
+   * @returns
+   */
+  _onBackPressed(){
+    window.getLastWindow(this.conText.getHostContext())
+      .then(res => {
+        res.setPreferredOrientation(window.Orientation.UNSPECIFIED)
+        yTRouter.pop('')
+      })
+    return true;
+  }
+}

+ 6 - 2
features/feature/src/main/ets/viewModel/SecondViewModel.ets

@@ -12,7 +12,11 @@ export class SecondViewModel{
   }
 
   // 添加座位表
-  _onAddSeatTable() {}
+  _onAddSeatTable() {
+    iRouter.router2SeatingPlanPage({}, () => {
+
+    })
+  }
 
   // 删除
   _onDeleteSeatTable() {
@@ -26,7 +30,7 @@ export class SecondViewModel{
     })
   }
 
-  // 编辑
+  // 编辑 座位表信息
   _onEditSeatTable() {
     iRouter.router2AddSeatTableDialog({
       color: '#5668FC',

+ 4 - 0
features/feature/src/main/resources/base/profile/router_map.json

@@ -20,6 +20,10 @@
       "name": "IncreaseStudentPage",
       "pageSourceFile": "src/main/ets/pages/IncreaseStudentPage.ets",
       "buildFunction": "IncreaseStudentPageBuilder"
+    }, {
+      "name": "SeatingPlanPage",
+      "pageSourceFile": "src/main/ets/pages/SeatingPlanPage.ets",
+      "buildFunction": "SeatingPlanPageBuilder"
     }
   ]
 }