Browse Source

fix: 修复采购清单中购买状态无法切换的BUG

YuJing 1 month ago
parent
commit
e2100ea4d8

+ 1 - 1
features/feature/src/main/ets/model/Index.ets

@@ -35,7 +35,7 @@ export class PurchaseList {
   foodWeeklyPlanId?: number;
   id?: number;
   ingredientName?: string;
-  purchased?: boolean;
+  purchased?: string;
   unit?: string;
 }
 

+ 1 - 1
features/feature/src/main/ets/view/MainView.ets

@@ -181,7 +181,7 @@ export struct MainView {
                     .fontColor('#4F4F4F')
 
                     // 是否购买按钮
-                    Image(this.vm.purchaseList?.[index].purchased ?
+                    Image(this.vm.purchaseList?.[index].purchased == '1' ?
                     $r('app.media.icon_select') : $r('app.media.icon_unSelect'))
                       .width(20)
                       .aspectRatio(1)

+ 1 - 2
features/feature/src/main/ets/viewModel/MainViewModel.ets

@@ -127,8 +127,7 @@ export class MainViewModel{
     try {
       let ans = await BabyFoodApi.updatePurchaseStatus(Id)
       let l = this.purchaseList![index]
-      if(ans == '0') l.purchased = true
-      else l.purchased = false
+      l.purchased = l.purchased == '1' ? '0' : '1'
       this.purchaseList?.splice(index, 1, l)
     } catch (e) {
       console.log(`e = ${JSON.stringify(e)}`)