common.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { store } from "@/store";
  2. import { defineStore } from "pinia";
  3. export const useCommonStore = defineStore("commonStore", {
  4. state: () => ({
  5. // 弹出公共Table的弹窗
  6. isShowTable: false,
  7. tableType: 1,
  8. tableTitle: "",
  9. loadingMap: new Map<string, boolean>(),
  10. storageInOrderId: -1, // 入库界面的出库使用
  11. orderId: -1, // 出库后在检料位使用,派发后重置。
  12. }),
  13. actions: {
  14. // 获取当前时间格式的函数
  15. currentTimeFormat() {
  16. const now = new Date();
  17. const options = {
  18. year: "numeric",
  19. month: "short",
  20. day: "numeric",
  21. hour: "2-digit",
  22. minute: "2-digit",
  23. second: "2-digit",
  24. };
  25. return now.toLocaleDateString(undefined, options);
  26. },
  27. },
  28. // persist: { 有map类型的时候不能使用持久化, 因为storage只支持存储字符串键值对,会转为object
  29. // paths: ["orderId", "storageInOrderId"],
  30. // },
  31. });
  32. export function useCommonStoreHook() {
  33. return useCommonStore(store);
  34. }