From e4e304318532574e418bc01b5a45b8836dac3e1a Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期四, 11 十二月 2025 23:26:20 +0800
Subject: [PATCH] 提交

---
 项目代码/WIDESEA_WMSClient/src/uitils/stationManager.js |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/uitils/stationManager.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/uitils/stationManager.js"
new file mode 100644
index 0000000..2899b76
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/uitils/stationManager.js"
@@ -0,0 +1,100 @@
+// 鏈湴瀛樺偍閿悕
+export const STATION_STORAGE_KEY = "wms_selected_station";
+
+/**
+ * 绔欏彴绠$悊鍣� - 鎻愪緵绔欏彴淇℃伅鐨勬寔涔呭寲瀛樺偍鍜岃幏鍙�
+ */
+export const stationManager = {
+  /**
+   * 淇濆瓨绔欏彴淇℃伅鍒版湰鍦板瓨鍌�
+   * @param {string} station - 绔欏彴鍊�
+   */
+  saveStation(station) {
+    try {
+      // 浣跨敤localStorage杩涜鎸佷箙鍖栧瓨鍌�
+      localStorage.setItem(STATION_STORAGE_KEY, station);
+      
+      // 鍚屾椂淇濆瓨鍒皊essionStorage锛屼綔涓哄鐢�
+      sessionStorage.setItem(STATION_STORAGE_KEY, station);
+      
+      // 瑙﹀彂鑷畾涔変簨浠讹紝閫氱煡鍏朵粬缁勪欢绔欏彴宸叉洿鏂�
+      window.dispatchEvent(new CustomEvent('station-changed', { 
+        detail: { station } 
+      }));
+      
+      console.log(`绔欏彴宸蹭繚瀛�: ${station}`);
+    } catch (error) {
+      console.error("淇濆瓨绔欏彴淇℃伅澶辫触:", error);
+    }
+  },
+
+  /**
+   * 鑾峰彇淇濆瓨鐨勭珯鍙颁俊鎭�
+   * @returns {string|null} 绔欏彴鍊兼垨null
+   */
+  getStation() {
+    try {
+      // 浼樺厛浠巐ocalStorage鑾峰彇
+      let station = localStorage.getItem(STATION_STORAGE_KEY);
+      
+      // 濡傛灉localStorage娌℃湁锛屽皾璇曚粠sessionStorage鑾峰彇
+      if (!station) {
+        station = sessionStorage.getItem(STATION_STORAGE_KEY);
+      }
+      
+      return station;
+    } catch (error) {
+      console.error("鑾峰彇绔欏彴淇℃伅澶辫触:", error);
+      return null;
+    }
+  },
+
+  /**
+   * 娓呴櫎绔欏彴淇℃伅
+   */
+  clearStation() {
+    try {
+      localStorage.removeItem(STATION_STORAGE_KEY);
+      sessionStorage.removeItem(STATION_STORAGE_KEY);
+      console.log("绔欏彴淇℃伅宸叉竻闄�");
+    } catch (error) {
+      console.error("娓呴櫎绔欏彴淇℃伅澶辫触:", error);
+    }
+  },
+
+  /**
+   * 鐩戝惉绔欏彴鍙樺寲
+   * @param {Function} callback - 鍙樺寲鍥炶皟鍑芥暟
+   * @returns {Function} 鍙栨秷鐩戝惉鐨勫嚱鏁�
+   */
+  onStationChange(callback) {
+    const handler = (event) => {
+      if (callback && typeof callback === 'function') {
+        callback(event.detail.station);
+      }
+    };
+    
+    window.addEventListener('station-changed', handler);
+    
+    // 杩斿洖鍙栨秷鐩戝惉鐨勫嚱鏁�
+    return () => {
+      window.removeEventListener('station-changed', handler);
+    };
+  },
+
+  /**
+   * 鑾峰彇绔欏彴鏄剧ず鏍囩
+   * @param {string} value - 绔欏彴鍊�
+   * @param {Array} options - 绔欏彴閫夐」鏁扮粍
+   * @returns {string} 绔欏彴鏍囩
+   */
+  getStationLabel(value, options) {
+    if (!value || !options) return value || '';
+    
+    const option = options.find(opt => opt.value === value);
+    return option ? option.label : value;
+  }
+};
+
+// 榛樿瀵煎嚭
+export default stationManager;
\ No newline at end of file

--
Gitblit v1.9.3