import { store } from "@/store"; import { defineStore } from "pinia"; export const useCommonStore = defineStore("commonStore", { state: () => ({ // 弹出公共Table的弹窗 isShowTable: false, tableType: 1, tableTitle: "", loadingMap: new Map(), storageInOrderId: -1, // 入库界面的出库使用 orderId: -1, // 出库后在检料位使用,派发后重置。 }), actions: { // 获取当前时间格式的函数 currentTimeFormat() { const now = new Date(); const options = { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", second: "2-digit", }; return now.toLocaleDateString(undefined, options); }, }, // persist: { 有map类型的时候不能使用持久化, 因为storage只支持存储字符串键值对,会转为object // paths: ["orderId", "storageInOrderId"], // }, }); export function useCommonStoreHook() { return useCommonStore(store); }