shizhongqi 10 месяцев назад
Родитель
Сommit
3ce32717c5

+ 57 - 4
ghsApp/src/admin/home/member.vue

@@ -120,7 +120,12 @@ export default {
           name: "最近未下单",
           value: 0
         },
-      ]
+      ],
+      // 搜索相关
+      seekVal: "",
+      searchText: "",
+      lastSearchText: "",
+      searchTimer: null
     };
   },
 	computed: {
@@ -155,6 +160,20 @@ export default {
 	onShow(){
 		uni.removeStorageSync('newClient')
 	},
+  onUnload() {
+    // 清理搜索定时器
+    if (this.searchTimer) {
+      clearTimeout(this.searchTimer);
+      this.searchTimer = null;
+    }
+  },
+  onHide() {
+    // 清理搜索定时器
+    if (this.searchTimer) {
+      clearTimeout(this.searchTimer);
+      this.searchTimer = null;
+    }
+  },
   methods: {
     init(){
 
@@ -173,9 +192,43 @@ export default {
       });
     },
     searchFn(e) {
-      this.resetList();
-      this.seekVal = e;
-      this.getCustomList();
+      // 统一更新当前输入值
+      this.searchText = e;
+
+      // 清除之前的定时器
+      if (this.searchTimer) {
+        clearTimeout(this.searchTimer);
+        this.searchTimer = null;
+      }
+
+      // 1. 首次点击搜索框:searchText 为空,lastSearchText 也为空 → 跳过搜索
+      if (this.$util.isEmpty(this.searchText) && this.$util.isEmpty(this.lastSearchText)) {
+        return;
+      }
+
+      // 2. 用户输入后清空:searchText 为空,但 lastSearchText 有值 → 恢复默认列表
+      if (this.$util.isEmpty(this.searchText) && !this.$util.isEmpty(this.lastSearchText)) {
+        this.lastSearchText = "";
+        this.seekVal = "";
+        this.resetList();
+        this.getCustomList();
+        return;
+      }
+
+      // 3. 重复相同搜索:searchText 与 lastSearchText 相同 → 跳过搜索
+      if (this.searchText === this.lastSearchText) {
+        return;
+      }
+
+      // 4. 正常输入搜索:searchText 有值且与 lastSearchText 不同 → 执行搜索(1秒后触发)
+      if (!this.$util.isEmpty(this.searchText)) {
+        this.searchTimer = setTimeout(() => {
+          this.lastSearchText = this.searchText;
+          this.seekVal = this.lastSearchText;
+          this.resetList();
+          this.getCustomList();
+        }, 1000);
+      }
     },
     getCustomList() {
       return getList({

+ 20 - 1
ghsApp/src/admin/home/order.vue

@@ -24,7 +24,10 @@
       <view class="select-dn_bx">
         <DateSelect class="bar" top="0" @selectDateFn="selectDateFn" defaultShowName="时间" />
       </view>
-      <view> <AppSearchModule placeholder="这里搜索" @input="searchFn" /> </view>
+      <view class="search-container">
+        <AppSearchModule placeholder="这里搜索" @input="searchFn" />
+        <view v-if="customId != 0" class="search-clear-overlay" @click.stop="clearSearch">清空搜索</view>
+      </view>
       <view>
         <button class="admin-button-com big" style="width: 120upx; margin-left: 16upx" @click="getMore()">更多</button>
       </view>
@@ -497,6 +500,9 @@ page {
     & > view:nth-child(2) {
       flex: 1;
     }
+    .search-container {
+      position: relative;
+    }
   }
   .list-wrap {
     padding-top: 100upx;
@@ -506,6 +512,19 @@ page {
     }
   }
 }
+.search-clear-overlay {
+  position: absolute;
+  top: 50%;
+  right: 20upx;
+  transform: translateY(-50%);
+  z-index: 11;
+  padding: 10upx 20upx;
+  border-radius: 24upx;
+  font-size: 24upx;
+  color: #3385FF;
+  border: 1upx solid #3385FF;
+  background-color: rgba(255, 255, 255, 0.9);
+}
 .upload-confirm-wrap {
   max-height: 600upx;
   overflow-y: auto;

+ 2 - 1
ghsApp/src/components/module/app-search.vue

@@ -10,7 +10,8 @@
 					ref="searchInput"
 					v-model="search"
 					:focus="focus"
-					@input="inputFn" @focus="inputEmptyFn"
+					@input="inputFn"
+					@focus="inputEmptyFn"
 					:style="{ fontSize: fontSize + 'upx' }"
 					:placeholder="placeholder"
 					placeholder-class="placeholder"

+ 12 - 1
hdApp/src/admin/home/member.vue

@@ -119,7 +119,8 @@ export default {
       ],
       customType:0,
       searchStyle:0,
-      searchText:''
+      searchText:'',
+      lastSearchText:'',
     };
   },
   onPullDownRefresh() {
@@ -166,6 +167,16 @@ export default {
       this.getMyCustomList()      
     },
     searchFn() {
+      // 首次点击搜索框:searchText 为空,lastSearchText 也为空 → 跳过搜索
+      if (this.$util.isEmpty(this.searchText) && this.$util.isEmpty(this.lastSearchText)) {
+        return;
+      }
+
+      if (this.searchText === this.lastSearchText) {
+        return;
+      }
+      
+      this.lastSearchText = this.searchText;
       this.resetList();
       this.getMyCustomList()
     },

+ 55 - 4
hdApp/src/admin/home/order.vue

@@ -25,7 +25,8 @@
       </view>
       <button class="admin-button-com middle" @click="changeSearchStyle()">{{searchStyle==0?'客户':'编号'}}</button>
       <view class="search-container">
-        <AppSearchModule placeholder="填写" v-model="searchText" @input="searchFn"/>
+        <AppSearchModule ref="searchRef" placeholder="填写" v-model="searchText" @input="searchFn"/>
+        <view v-if="customId != 0" class="search-clear-overlay" @click.stop="clearFn">清空</view>
       </view>
       <button class="admin-button-com middle blue filter-btn" @click.stop="openFilterPanel">
         筛选
@@ -208,6 +209,8 @@ export default {
       repeat:-1,
       searchStyle:0,//0客户 1编号
       searchText:'',
+      lastSearchText:'',
+      searchKey: 0,
       // 面板相关
       showFilterPanel: false,
       repeatOptions: [
@@ -255,6 +258,11 @@ export default {
       this.getOrderList()
       this.refreshPage = 0
     }
+
+    // 重置搜索
+    if (this.customId !== 0) {
+      this.clearFn()
+    }
   },
   methods: {
     // 面板相关
@@ -301,11 +309,22 @@ export default {
     searchFn(e) {
       let that = this
       if(this.searchStyle == 0){
+        // 首次点击搜索框:searchText 为空,lastSearchText 也为空 → 跳过搜索
+        if (this.$util.isEmpty(this.searchText) && this.$util.isEmpty(this.lastSearchText)) {
+          // console.log('000001')
+          return;
+        } else {
+          // console.log('000002')
+        }
+
         if(that.$util.isEmpty(e)){
           that.showSearch = false
-          that.searchList = []     
+          that.searchList = []
+          // console.log('111 空 111')
         }else{
-          getList({ page:1,name:e,type:0}).then((res) => {
+          // console.log('222222')
+          this.lastSearchText = this.searchText;
+          getList({ page:1, name:e, type:0}).then((res) => {
               if (!that.$util.isEmpty(res.data) && !that.$util.isEmpty(res.data.list)){
                 that.showSearch = true
                 that.searchList = res.data.list
@@ -316,6 +335,19 @@ export default {
           })
         }
       }else{
+        // console.log('333333')
+        // 首次点击搜索框:searchText 为空,lastSearchText 也为空 → 跳过搜索
+        if (this.$util.isEmpty(this.searchText) && this.$util.isEmpty(this.lastSearchText)) {
+          // console.log('33333-空')
+          return;
+        }
+
+        if (this.searchText === this.lastSearchText) {
+          // console.log('33333-111')
+          return;
+        }
+
+        this.lastSearchText = this.searchText;
         this.resetList()
         this.getOrderList()
       }
@@ -381,14 +413,19 @@ export default {
     selectStaffFn(){
       this.$refs.getStaffRef.open('top')
     },
-    cancelFn(){
+    clearFn(){
       this.resetList();
       this.shopAdminId = 0
       this.searchText = ''
+      this.lastSearchText = ''
+      this.showSearch = false
       this.customId = 0
       this.searchTime = ''
       this.startTime = ''
       this.endTime = ''
+      if (this.$refs && this.$refs.searchRef) {
+        this.$refs.searchRef.search = ''
+      }
       this.getOrderList()
     },
     printOrder(item){
@@ -500,6 +537,7 @@ export default {
     .search-container {
       flex: 1;
       min-width: 0;
+        position: relative;
     }
     
     button {
@@ -521,6 +559,19 @@ export default {
       }
     }
   }
+  .search-clear-overlay {
+    position: absolute;
+    top: 50%;
+    right: 20upx;
+    transform: translateY(-50%);
+    z-index: 11;
+    padding: 10upx 20upx;
+    border-radius: 24upx;
+    font-size: 24upx;
+    color: #09C567;
+    border: 1upx solid #09C567;
+    background-color: rgba(255,255,255,0.9);
+  }
   .list-wrap {
     padding-top: 115upx;
     .list {