hh 1 rok temu
rodzic
commit
74045efc89

+ 96 - 0
entry/src/main/ets/common/component/AddAndSubtractComp.ets

@@ -0,0 +1,96 @@
+@Component
+export struct AddAndSubtractComp {
+  // 输入值
+  @State inputNum: number = 0
+  // 输入值所在的对象(不存在则不传)
+  obj: any
+  // 输入值上限、下限
+  upperLimit: number
+  lowerLimit: number
+  // 点击加、减事件调用的方法
+  addFunction: Function
+  subFunction: Function
+
+  build() {
+    Row() {
+      Row() {
+        Image(this.lowerLimit && this.inputNum <= this.lowerLimit ? $r('app.media.subtract_disabled') : $r('app.media.subtract'))
+          .width($r('app.float.title_icon_size'))
+          .height($r('app.float.title_icon_size'))
+      }
+      .width('25%')
+      .height('100%')
+      .justifyContent(FlexAlign.Center)
+      .onClick(()=>{
+        if (this.inputNum <= this.lowerLimit) {
+          return
+        }
+        if (this.subFunction) {
+          this.subFunction()
+        } else {
+          this.inputNum --
+        }
+      })
+      Row() {
+        TextInput({text: this.inputNum.toString()})
+          .fontSize($r('app.float.title_font_size'))
+          .fontWeight(FontWeight.Bold)
+          .fontColor($r('app.color.general_font_color'))
+          // .opacity($r('app.float.general_font_opacity'))
+          .height('100%')
+          .width('100%')
+          .type(InputType.Number)
+          .textAlign(TextAlign.Center)
+          .backgroundColor($r('app.color.general_card_background_color'))
+          .onChange((value: string)=>{
+            if (!value || value.length === 0) {
+              this.inputNum = 0
+              return
+            }
+            let num: number = Number.parseInt(value)
+            // 校验数据有效性
+            if (this.lowerLimit && num < this.lowerLimit) {
+              this.inputNum = this.lowerLimit
+              this.obj['standardValue'] = this.inputNum
+              return
+            } else if (this.upperLimit && num > this.upperLimit) {
+              this.inputNum = this.upperLimit
+              this.obj['standardValue'] = this.inputNum
+              return
+            }
+            this.inputNum = num
+            if (this.obj.hasOwnProperty('actualValue')) {
+              this.obj['actualValue'] = num
+            }
+          })
+      }
+      .width('50%')
+      .height('100%')
+      .border({width:{left: 1, right: 1}})
+      .borderColor($r('app.color.general_border_white_color'))
+      Row() {
+        Image(this.upperLimit && this.upperLimit >= this.lowerLimit ? $r('app.media.add_disabled') : $r('app.media.add'))
+          .width($r('app.float.title_icon_size'))
+          .height($r('app.float.title_icon_size'))
+      }
+      .width('25%')
+      .height('100%')
+      .justifyContent(FlexAlign.Center)
+      .onClick(()=>{
+        if (this.inputNum >= this.upperLimit) {
+          return
+        }
+        if (this.subFunction) {
+          this.addFunction()
+        } else {
+          this.inputNum ++
+        }
+      })
+    }
+    .width('100%')
+    .height('100%')
+    .borderWidth(1)
+    .borderColor($r('app.color.general_border_white_color'))
+    .borderRadius($r('app.float.general_border_radius'))
+  }
+}

+ 1 - 1
entry/src/main/ets/entryability/EntryAbility.ets

@@ -50,7 +50,7 @@ export default class EntryAbility extends UIAbility {
       windowClass.setWindowLayoutFullScreen(true)
     })
 
-    windowStage.loadContent('pages/LoginPage', (err, data) => {
+    windowStage.loadContent('pages/Index', (err, data) => {
       if (err.code) {
         hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
         return;

+ 6 - 6
entry/src/main/ets/pages/process/ProcessStepPage.ets

@@ -21,15 +21,15 @@ import { pinyin } from 'pinyin-pro';
 import HashMap from '@ohos.util.HashMap';
 import { ProcessTitleComp } from '../../common/component/ProcessTitleComp';
 
-const params = router.getParams(); // 获取传递过来的参数对象
-const mainMaterial = params['mainMaterial']; // 获取主料号
-const processInfo = params['processInfo']; // 获取当前工序信息
+// const params = router.getParams(); // 获取传递过来的参数对象
+// const mainMaterial = params['mainMaterial']; // 获取主料号
+// const processInfo = params['processInfo']; // 获取当前工序信息
 
 @Entry
 @Component
 struct ProcessStepPage {
-  @State mainMaterial: string = mainMaterial
-  @State process: ProcessData = processInfo
+  @State mainMaterial: string = '23'
+  @State process: ProcessData = {completeNum:'101',operationCode:'32434', operationSort:1, operationName: '物流采集'}
 
   @State product: ProductInfo = CommonConstants.PRODUCT_DATA
   @State productSteps: ProcessStep[] = CommonConstants.PROCESS_STEP_ARRAY
@@ -61,7 +61,7 @@ struct ProcessStepPage {
 
   aboutToAppear() {
     if (this.productSteps && this.productSteps.length > 0) {
-      this.selectStep = 0
+      this.selectStep = 1
     }
     // todo 查询产品数据,查询当前工序的工步
   }

+ 32 - 18
entry/src/main/ets/view/processview/RecordItemView.ets

@@ -1,7 +1,9 @@
+import { AddAndSubtractComp } from '../../common/component/AddAndSubtractComp'
+
 @Component
 export struct RecordItemView {
   @State recordArray: RecordItem[] = [
-    {unit: 'cm', standardValue: 10, upperLimit: 10.3, lowerLimit: 9.8, actualValue: 0},
+    {unit: 'cm', standardValue: 10, upperLimit: 100, lowerLimit: 5, actualValue: 0},
     {unit: 'cm', standardValue: 10, upperLimit: 10.3, lowerLimit: 9.8, actualValue: 0},
     {unit: 'cm', standardValue: 10, upperLimit: 10.3, lowerLimit: 9.8, actualValue: 0},
     {unit: 'cm', standardValue: 10, upperLimit: 10.3, lowerLimit: 9.8, actualValue: 0},
@@ -12,13 +14,12 @@ export struct RecordItemView {
 
   // todo 查询数据
   aboutToAppear() {
-
   }
 
   build() {
     Column() {
       Grid() {
-        ForEach(this.recordArray, (item: RecordItem) => {
+        ForEach(this.recordArray, (item: RecordItem, index: number) => {
           GridItem() {
             Row() {
               Column() {
@@ -61,21 +62,34 @@ export struct RecordItemView {
                   .fontColor($r('app.color.general_font_color'))
                   .opacity($r('app.float.process_step_font_opacity'))
                   .fontWeight(FontWeight.Regular)
-                Counter() {
-                  Text(item.actualValue.toString())
-                    .fontSize($r('app.float.process_card_large_font_size'))
-                    .fontColor($r('app.color.general_font_color'))
-                    .opacity($r('app.float.general_font_opacity'))
-                    .fontWeight(FontWeight.Bold)
+                Row() {
+                  AddAndSubtractComp({
+                    inputNum: item.actualValue,
+                    obj: item,
+                    upperLimit: item.upperLimit,
+                    lowerLimit: item.lowerLimit,
+                    addFunction: ()=>{
+                      item.actualValue++
+                      this.recordArray[index] = {
+                        unit: item.unit,
+                        standardValue: item.standardValue,
+                        upperLimit: item.upperLimit,
+                        lowerLimit: item.lowerLimit,
+                        actualValue: item.actualValue
+                      }
+                    },
+                    subFunction: ()=>{
+                      item.actualValue--
+                      this.recordArray[index] = {
+                        unit: item.unit,
+                        standardValue: item.standardValue,
+                        upperLimit: item.upperLimit,
+                        lowerLimit: item.lowerLimit,
+                        actualValue: item.actualValue
+                      }
+                    }
+                  })
                 }
-                .onInc(() => {
-                  item.actualValue++
-                })
-                .onDec(() => {
-                  if (item.actualValue > 0) {
-                    item.actualValue--
-                  }
-                })
                 .width('95%')
                 .height($r('app.float.record_item_counter_height'))
               }
@@ -107,5 +121,5 @@ class RecordItem {
   standardValue: number
   upperLimit: number
   lowerLimit: number
-  actualValue: number
+  public actualValue: number
 }

+ 4 - 0
entry/src/main/resources/base/element/color.json

@@ -146,6 +146,10 @@
     {
       "name": "login_text_input_font_color",
       "value": "#1A1A1A"
+    },
+    {
+      "name": "general_border_white_color",
+      "value": "#000000"
     }
   ]
 }

Plik diff jest za duży
+ 3 - 0
entry/src/main/resources/base/media/add.svg


Plik diff jest za duży
+ 3 - 0
entry/src/main/resources/base/media/add_disabled.svg


+ 3 - 0
entry/src/main/resources/base/media/subtract.svg

@@ -0,0 +1,3 @@
+<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M30 16.3333C30 17.0697 29.403 17.6667 28.6667 17.6667L4.66667 17.6667C3.93029 17.6667 3.33333 17.0697 3.33333 16.3333C3.33333 15.597 3.93029 15 4.66667 15L28.6667 15C29.403 15 30 15.597 30 16.3333Z" fill="black"/>
+</svg>

+ 3 - 0
entry/src/main/resources/base/media/subtract_disabled.svg

@@ -0,0 +1,3 @@
+<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M30 16.3333C30 17.0697 29.403 17.6667 28.6667 17.6667L4.66667 17.6667C3.93029 17.6667 3.33333 17.0697 3.33333 16.3333C3.33333 15.597 3.93029 15 4.66667 15L28.6667 15C29.403 15 30 15.597 30 16.3333Z" fill="black"/>
+</svg>