From 0832f91e1919734e0710830d0000d24230ceb037 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Fri, 23 Oct 2026 09:37:01 +0800 Subject: [PATCH] 1 --- src/libs/searchHistory.js | 28 +++++++++++++++ .../app/business/logistics/logistics.vue | 34 ++++++++++++++++--- src/views/app/shop/shop.vue | 26 ++++++++++++-- src/views/sys/order-manage/orderManage.vue | 26 +++++++++++--- 4 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 src/libs/searchHistory.js diff --git a/src/libs/searchHistory.js b/src/libs/searchHistory.js new file mode 100644 index 0000000..b8b14fc --- /dev/null +++ b/src/libs/searchHistory.js @@ -0,0 +1,28 @@ +import { getStore, setStore } from "@/libs/storage"; + +const DEFAULT_LIMIT = 5; + +export const SEARCH_HISTORY_KEYS = { + shopName: "search-history:shop-name", + workerName: "search-history:worker-name" +}; + +export const getSearchHistory = (key) => { + try { + const value = getStore(key); + const list = JSON.parse(value); + return Array.isArray(list) ? list.filter((item) => typeof item === "string" && item.trim() !== "") : []; + } catch (e) { + return []; + } +}; + +export const saveSearchHistory = (key, value, limit = DEFAULT_LIMIT) => { + const text = String(value || "").trim(); + if (!text) return getSearchHistory(key); + + const list = getSearchHistory(key).filter((item) => item !== text); + const nextList = [text, ...list].slice(0, limit); + setStore(key, nextList); + return nextList; +}; diff --git a/src/views/app/business/logistics/logistics.vue b/src/views/app/business/logistics/logistics.vue index 23fd5a6..82ef5a6 100644 --- a/src/views/app/business/logistics/logistics.vue +++ b/src/views/app/business/logistics/logistics.vue @@ -154,8 +154,9 @@ - -
+ + - - @@ -181,7 +184,7 @@ :root-id="currentRegionId" @on-change="handlePutAreaChange" @on-clear="handlePutAreaChange('')" /> - + @@ -285,6 +288,7 @@ import addEdit from "./addEdit.vue"; import logisticsAddress from "@/views/app/business/logistics/logisticsAddress"; import shopAreaTreeChoose from "@/views/my-components/hiver/shopArea-tree-choose"; + import { SEARCH_HISTORY_KEYS, getSearchHistory, saveSearchHistory } from "@/libs/searchHistory"; const HALL_TYPE_MAP = { waimai: 1, @@ -314,6 +318,10 @@ Visiable: false, transferList: [], tableSize: "default", + searchHistory: { + shopName: getSearchHistory(SEARCH_HISTORY_KEYS.shopName), + workerName: getSearchHistory(SEARCH_HISTORY_KEYS.workerName) + }, showOrder: false, showType: "0", openSearch: true, @@ -463,6 +471,20 @@ this.getBaseDeliveryFeeSetting(); this.getDeliverySwitch(); }, + loadSearchHistory() { + this.searchHistory.shopName = getSearchHistory(SEARCH_HISTORY_KEYS.shopName); + this.searchHistory.workerName = getSearchHistory(SEARCH_HISTORY_KEYS.workerName); + }, + filterSearchHistory(value, option) { + if (!value) return true; + return String(option || "").toLowerCase().indexOf(String(value).toLowerCase()) > -1; + }, + saveCurrentSearchHistory() { + this.searchHistory.shopName = saveSearchHistory(SEARCH_HISTORY_KEYS.shopName, this.activeSearchForm.shopName); + if (this.tabName === "delivery") { + this.searchHistory.workerName = saveSearchHistory(SEARCH_HISTORY_KEYS.workerName, this.deliverySearchForm.workerName); + } + }, refreshOnMenuClick() { if (this.isOrderTab) { this.getLogisticsInfo(); @@ -731,6 +753,7 @@ this.handleSearch(); }, handleSearch() { + this.saveCurrentSearchHistory(); this.activeSearchForm.pageNum = 1; this.getLogisticsInfo(); this.refreshOrderCounts(); @@ -1601,6 +1624,7 @@ this.init(); }, activated() { + this.loadSearchHistory(); this.startCountRefreshTimer(); if (this.hasActivatedOnce) { this.refreshOnMenuClick(); diff --git a/src/views/app/shop/shop.vue b/src/views/app/shop/shop.vue index 3236d7a..14998db 100644 --- a/src/views/app/shop/shop.vue +++ b/src/views/app/shop/shop.vue @@ -30,9 +30,11 @@ - + @@ -276,6 +278,7 @@ } from "@/api/index"; import addEdit from "./addEdit.vue"; import logisticsAddress from "@/views/sys/order-manage/logisticsAddress"; + import { SEARCH_HISTORY_KEYS, getSearchHistory, saveSearchHistory } from "@/libs/searchHistory"; export default { name: "order-manage", components: { @@ -285,6 +288,9 @@ data() { return { tableSize: "default", + searchHistory: { + shopName: getSearchHistory(SEARCH_HISTORY_KEYS.shopName) + }, Visiable: false, showOrder: false, showType: "0", @@ -946,6 +952,7 @@ this.init(); }, activated() { + this.loadSearchHistory(); if (this.hasActivatedOnce) { this.refreshOnMenuClick(); } @@ -957,6 +964,16 @@ this.getFeedbackTodoCount(); this.getLogisticsInfo() }, + loadSearchHistory() { + this.searchHistory.shopName = getSearchHistory(SEARCH_HISTORY_KEYS.shopName); + }, + filterSearchHistory(value, option) { + if (!value) return true; + return String(option || "").toLowerCase().indexOf(String(value).toLowerCase()) > -1; + }, + saveCurrentSearchHistory() { + this.searchHistory.shopName = saveSearchHistory(SEARCH_HISTORY_KEYS.shopName, this.searchForm.shopName); + }, refreshOnMenuClick() { this.refreshWholePage(); }, @@ -1172,6 +1189,7 @@ }, handleSearch() { + this.saveCurrentSearchHistory(); if (this.isRefundTab) { this.returnForm.pageNum = 1; this.returnForm.pageSize = 10;