瀏覽代碼

feat: 添加删除全部搜索记录功能

YuJing 1 月之前
父節點
當前提交
7aac796928

+ 1 - 0
features/feature/src/main/ets/components/ytBuildComp.ets

@@ -28,6 +28,7 @@ export struct ytBuildComp {
     emitter.on(EmitterKeyCollection.LOGOUT, () => {
       this.LoginStatusChange()
     })
+    // 防止横幅闪烁
     setTimeout(() => {
       this.LoginStatusChange()
     }, 300)

+ 6 - 1
features/feature/src/main/ets/pages/RecipeSearchPage.ets

@@ -151,8 +151,13 @@ struct RecipeSearchPage{
         .fontSize(16)
         .fontColor(Color.Black)
 
-      Row(){
+      Row({space: 5}){
         if(this.vm.delModel) {
+          Text('全部删除')
+            .fontSize(14)
+            .fontColor('#ff625a5a')
+            .onClick(() => { this.vm.clearSearchRecord() })
+
           Text("取消")
             .fontSize(14)
             .fontColor('#ff625a5a')

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

@@ -1,7 +1,7 @@
 import { DateFormat, IBestToast, userInfo, UserInfo, YTAvoid, YTDateUtil, yTRouter } from "basic"
 import { BabyFoodApi } from "../Apis/BabyFoodApi"
 import { routerUtils } from "../utils/RouterUtils"
-import { AppStorageV2 } from "@kit.ArkUI"
+import { AppStorageV2, UIUtils } from "@kit.ArkUI"
 import {
   AddRecipeEventData,
   BabyInfo, Cuisine, DayPlan, PurchaseList, WeeklyPlan, WeeklyPlanPurchaseList } from "../model/Index"
@@ -181,7 +181,8 @@ export class MainViewModel{
     try {
       IBestToast.showLoading({message: "修改中"})
 
-      await BabyFoodApi.updateWeeklyPlan(WeeklyPlanPurchaseList.clone(this.planList!))
+      let requestData = WeeklyPlanPurchaseList.clone(this.planList!)
+      await BabyFoodApi.updateWeeklyPlan(requestData)
       // 修改食谱清单后需刷新采购清单
       this.getWeeklyPurchaseList()
       // 刷新数据源

+ 5 - 0
features/feature/src/main/ets/viewModel/RecipeSearchViewModel.ets

@@ -47,6 +47,11 @@ export class RecipeSearchViewModel{
     this.historicalSearchRecords.searchList.splice(index, 1)
   }
 
+  // 清空搜索记录
+  clearSearchRecord(){
+    this.historicalSearchRecords.searchList = []
+  }
+
   // 清空搜索框
   clearKeyWord(){
     this.keyWord = ''