|
@@ -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
|
|
|
}
|