li.shaoyi пре 2 година
родитељ
комит
254bb0e63d
96 измењених фајлова са 1083 додато и 1318 уклоњено
  1. 157 1
      package-lock.json
  2. 2 1
      package.json
  3. 3 4
      src/business/account/index.ts
  4. 4 8
      src/business/auth/index.ts
  5. 11 15
      src/business/bank/index.ts
  6. 10 13
      src/business/bargain/index.ts
  7. 16 19
      src/business/common/index.ts
  8. 6 7
      src/business/customs/bonded.ts
  9. 9 11
      src/business/customs/exit.ts
  10. 3 3
      src/business/favorite/index.ts
  11. 13 17
      src/business/goods/index.ts
  12. 7 7
      src/business/home/index.ts
  13. 5 4
      src/business/notice/index.ts
  14. 8 10
      src/business/order/index.ts
  15. 6 7
      src/business/report/index.ts
  16. 2 2
      src/business/table/index.ts
  17. 12 13
      src/business/trade/desting.ts
  18. 6 7
      src/business/trade/list.ts
  19. 13 15
      src/business/trade/listing.ts
  20. 8 10
      src/business/user/index.ts
  21. 6 8
      src/business/warehouse/index.ts
  22. 2 2
      src/constants/bank.ts
  23. 2 2
      src/constants/certificate.ts
  24. 2 2
      src/constants/client.ts
  25. 2 2
      src/constants/customs.ts
  26. 2 2
      src/constants/diamond.ts
  27. 2 2
      src/constants/menu.ts
  28. 4 5
      src/constants/order.ts
  29. 2 2
      src/constants/receipt.ts
  30. 2 3
      src/hooks/echarts/candlestick/index.ts
  31. 2 2
      src/hooks/echarts/candlestick/options.ts
  32. 2 3
      src/hooks/echarts/timeline/index.ts
  33. 2 2
      src/hooks/echarts/timeline/options.ts
  34. 11 11
      src/hooks/menu/index.ts
  35. 3 3
      src/packages/mobile/router/index.ts
  36. 3 3
      src/packages/mobile/views/home/components/market/index.vue
  37. 3 4
      src/packages/pc/App.vue
  38. 4 4
      src/packages/pc/components/layouts/header/index.vue
  39. 2 2
      src/packages/pc/components/layouts/page/index.vue
  40. 1 1
      src/packages/pc/components/layouts/sidemenu/submenu.vue
  41. 1 1
      src/packages/pc/components/modules/action-menu/index.vue
  42. 2 3
      src/packages/pc/components/modules/address/index.vue
  43. 1 1
      src/packages/pc/components/modules/auth-component/index.vue
  44. 1 1
      src/packages/pc/components/modules/auth-operation/index.vue
  45. 2 3
      src/packages/pc/components/modules/invoice/index.vue
  46. 2 2
      src/packages/pc/components/modules/performance/index.vue
  47. 1 3
      src/packages/pc/main.ts
  48. 3 4
      src/packages/pc/router/dynamicRouter.ts
  49. 4 4
      src/packages/pc/router/index.ts
  50. 3 5
      src/packages/pc/views/boot/index.vue
  51. 2 2
      src/packages/pc/views/customs/bonded/components/advance-payment/index.vue
  52. 2 2
      src/packages/pc/views/customs/bonded/components/payment/index.vue
  53. 2 2
      src/packages/pc/views/customs/exit/components/advance-payment/index.vue
  54. 1 2
      src/packages/pc/views/customs/exit/components/edit/detail-edit/index.vue
  55. 6 0
      src/packages/pc/views/customs/exit/components/edit/index.less
  56. 20 6
      src/packages/pc/views/customs/exit/components/edit/index.vue
  57. 2 2
      src/packages/pc/views/customs/exit/components/payment/index.vue
  58. 2 3
      src/packages/pc/views/favorite/main/components/cancel/index.vue
  59. 2 2
      src/packages/pc/views/mine/profile/index.vue
  60. 2 4
      src/packages/pc/views/search/diamond/index.vue
  61. 2 4
      src/packages/pc/views/search/fancy/index.vue
  62. 2 2
      src/packages/pc/views/trade/bargain/components/details/index.vue
  63. 3 3
      src/packages/pc/views/trade/buy/components/delisting/index.vue
  64. 3 4
      src/packages/pc/views/trade/buy/components/details/index.vue
  65. 3 4
      src/packages/pc/views/trade/purchase/components/details/index.vue
  66. 3 4
      src/packages/pc/views/trade/sale/components/details/index.vue
  67. 2 4
      src/packages/pc/views/trade/sell/index.vue
  68. 3 3
      src/packages/pc/views/warehousing/goods/components/bargain/index.vue
  69. 11 10
      src/packages/pc/views/warehousing/goods/components/details/index.vue
  70. 2 3
      src/packages/pc/views/warehousing/goods/components/favorite/index.vue
  71. 1 1
      src/services/api/account/index.ts
  72. 2 3
      src/services/http/index.ts
  73. 2 3
      src/services/socket/index.ts
  74. 3 3
      src/services/socket/quote/index.ts
  75. 5 7
      src/services/socket/trade/index.ts
  76. 3 3
      src/services/subscribe/index.ts
  77. 0 157
      src/stores/@next.ts
  78. 78 37
      src/stores/base.ts
  79. 13 49
      src/stores/index.ts
  80. 34 60
      src/stores/modules/account.ts
  81. 58 71
      src/stores/modules/enum.ts
  82. 14 31
      src/stores/modules/errorInfo.ts
  83. 15 31
      src/stores/modules/exrate.ts
  84. 15 32
      src/stores/modules/favorite.ts
  85. 190 208
      src/stores/modules/futures.ts
  86. 16 33
      src/stores/modules/language.ts
  87. 39 66
      src/stores/modules/login.ts
  88. 15 32
      src/stores/modules/menu.ts
  89. 16 35
      src/stores/modules/performance.ts
  90. 11 28
      src/stores/modules/tableColumn.ts
  91. 33 53
      src/stores/modules/theme.ts
  92. 22 37
      src/stores/modules/user.ts
  93. 35 0
      src/stores/storage.ts
  94. 2 2
      src/types/ermcp/account.d.ts
  95. 1 1
      src/types/ermcp/quote.d.ts
  96. 5 3
      src/utils/storage/index.ts

+ 157 - 1
package-lock.json

@@ -25,7 +25,8 @@
         "vue-class-component": "^8.0.0-0",
         "vue-i18n": "^9.2.2",
         "vue-router": "^4.0.3",
-        "vuedraggable": "^4.1.0"
+        "vuedraggable": "^4.1.0",
+        "xlsx": "^0.18.5"
       },
       "devDependencies": {
         "@types/crypto-js": "^4.1.1",
@@ -3707,6 +3708,14 @@
         "node": ">= 0.12.0"
       }
     },
+    "node_modules/adler-32": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmmirror.com/adler-32/-/adler-32-1.3.1.tgz",
+      "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/ajv": {
       "version": "6.12.6",
       "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@@ -4340,6 +4349,18 @@
         "node": ">=4"
       }
     },
+    "node_modules/cfb": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmmirror.com/cfb/-/cfb-1.2.2.tgz",
+      "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
+      "dependencies": {
+        "adler-32": "~1.3.0",
+        "crc-32": "~1.2.0"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/chalk": {
       "version": "2.4.2",
       "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@@ -4601,6 +4622,14 @@
         "node": ">=6"
       }
     },
+    "node_modules/codepage": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz",
+      "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/color-convert": {
       "version": "1.9.3",
       "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@@ -4901,6 +4930,17 @@
         "node": ">=8"
       }
     },
+    "node_modules/crc-32": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmmirror.com/crc-32/-/crc-32-1.2.2.tgz",
+      "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
+      "bin": {
+        "crc32": "bin/crc32.njs"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/cross-spawn": {
       "version": "6.0.5",
       "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
@@ -6837,6 +6877,14 @@
         "node": ">= 0.6"
       }
     },
+    "node_modules/frac": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/frac/-/frac-1.1.2.tgz",
+      "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/fraction.js": {
       "version": "4.2.0",
       "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz",
@@ -10822,6 +10870,17 @@
       "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
       "dev": true
     },
+    "node_modules/ssf": {
+      "version": "0.11.2",
+      "resolved": "https://registry.npmmirror.com/ssf/-/ssf-0.11.2.tgz",
+      "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
+      "dependencies": {
+        "frac": "~1.1.2"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/ssri": {
       "version": "8.0.1",
       "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz",
@@ -12430,6 +12489,22 @@
       "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==",
       "dev": true
     },
+    "node_modules/wmf": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmmirror.com/wmf/-/wmf-1.0.2.tgz",
+      "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
+    "node_modules/word": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmmirror.com/word/-/word-0.3.0.tgz",
+      "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/word-wrap": {
       "version": "1.2.3",
       "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
@@ -12568,6 +12643,26 @@
         }
       }
     },
+    "node_modules/xlsx": {
+      "version": "0.18.5",
+      "resolved": "https://registry.npmmirror.com/xlsx/-/xlsx-0.18.5.tgz",
+      "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
+      "dependencies": {
+        "adler-32": "~1.3.0",
+        "cfb": "~1.2.1",
+        "codepage": "~1.15.0",
+        "crc-32": "~1.2.1",
+        "ssf": "~0.11.2",
+        "wmf": "~1.0.1",
+        "word": "~0.3.0"
+      },
+      "bin": {
+        "xlsx": "bin/xlsx.njs"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
     "node_modules/y18n": {
       "version": "5.0.8",
       "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
@@ -15444,6 +15539,11 @@
       "integrity": "sha512-aT6camzM4xEA54YVJYSqxz1kv4IHnQZRtThJJHhUMRExaU5spC7jX5ugSwTaTgJliIgs4VhZOk7htClvQ/LmRA==",
       "dev": true
     },
+    "adler-32": {
+      "version": "1.3.1",
+      "resolved": "https://registry.npmmirror.com/adler-32/-/adler-32-1.3.1.tgz",
+      "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A=="
+    },
     "ajv": {
       "version": "6.12.6",
       "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
@@ -15896,6 +15996,15 @@
       "integrity": "sha512-roIFONhcxog0JSSWbvVAh3OocukmSgpqOH6YpMkCvav/ySIV3JKg4Dc8vYtQjYi/UxpNE36r/9v+VqTQqgkYmw==",
       "dev": true
     },
+    "cfb": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmmirror.com/cfb/-/cfb-1.2.2.tgz",
+      "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==",
+      "requires": {
+        "adler-32": "~1.3.0",
+        "crc-32": "~1.2.0"
+      }
+    },
     "chalk": {
       "version": "2.4.2",
       "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@@ -16088,6 +16197,11 @@
         "shallow-clone": "^3.0.0"
       }
     },
+    "codepage": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmmirror.com/codepage/-/codepage-1.15.0.tgz",
+      "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA=="
+    },
     "color-convert": {
       "version": "1.9.3",
       "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@@ -16317,6 +16431,11 @@
         "yaml": "^1.7.2"
       }
     },
+    "crc-32": {
+      "version": "1.2.2",
+      "resolved": "https://registry.npmmirror.com/crc-32/-/crc-32-1.2.2.tgz",
+      "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ=="
+    },
     "cross-spawn": {
       "version": "6.0.5",
       "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
@@ -17741,6 +17860,11 @@
       "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
       "dev": true
     },
+    "frac": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/frac/-/frac-1.1.2.tgz",
+      "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA=="
+    },
     "fraction.js": {
       "version": "4.2.0",
       "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz",
@@ -20714,6 +20838,14 @@
       "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
       "dev": true
     },
+    "ssf": {
+      "version": "0.11.2",
+      "resolved": "https://registry.npmmirror.com/ssf/-/ssf-0.11.2.tgz",
+      "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==",
+      "requires": {
+        "frac": "~1.1.2"
+      }
+    },
     "ssri": {
       "version": "8.0.1",
       "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz",
@@ -21901,6 +22033,16 @@
       "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==",
       "dev": true
     },
+    "wmf": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmmirror.com/wmf/-/wmf-1.0.2.tgz",
+      "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw=="
+    },
+    "word": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmmirror.com/word/-/word-0.3.0.tgz",
+      "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA=="
+    },
     "word-wrap": {
       "version": "1.2.3",
       "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
@@ -21991,6 +22133,20 @@
       "dev": true,
       "requires": {}
     },
+    "xlsx": {
+      "version": "0.18.5",
+      "resolved": "https://registry.npmmirror.com/xlsx/-/xlsx-0.18.5.tgz",
+      "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==",
+      "requires": {
+        "adler-32": "~1.3.0",
+        "cfb": "~1.2.1",
+        "codepage": "~1.15.0",
+        "crc-32": "~1.2.1",
+        "ssf": "~0.11.2",
+        "wmf": "~1.0.1",
+        "word": "~0.3.0"
+      }
+    },
     "y18n": {
       "version": "5.0.8",
       "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",

+ 2 - 1
package.json

@@ -27,7 +27,8 @@
     "vue-class-component": "^8.0.0-0",
     "vue-i18n": "^9.2.2",
     "vue-router": "^4.0.3",
-    "vuedraggable": "^4.1.0"
+    "vuedraggable": "^4.1.0",
+    "xlsx": "^0.18.5"
   },
   "devDependencies": {
     "@types/crypto-js": "^4.1.1",

+ 3 - 4
src/business/account/index.ts

@@ -1,11 +1,11 @@
 import { shallowRef, reactive } from 'vue'
-import { useUserStore, useLoginStore } from '@/stores'
+import { userStore, loginStore } from '@/stores'
 import { modifyPassword } from '@/services/api/account'
 import { queryBankAccountSign } from '@/services/api/bank'
 import cryptojs from 'crypto-js'
 
 export function useAccount() {
-    const { getUserDataInfo } = useUserStore()
+    const { getUserDataInfo } = userStore.actions
     const loginInfo = getUserDataInfo('loginAccount')
     const userInfo = getUserDataInfo('userInfo')
     const bankInfo = shallowRef<Ermcp.BankAccountSignRsp>()
@@ -40,8 +40,7 @@ export function useAccount() {
 
 // 修改密码
 export function usePassword(ModifyPwdType: 0 | 1 | 2) {
-    const { loginInfo } = useLoginStore()
-    const { LoginCode, LoginID, AccountIDs } = loginInfo.value
+    const { LoginCode, LoginID, AccountIDs } = loginStore.state.loginInfo
     const loading = shallowRef(false)
     const checkPassword = shallowRef('')
 

+ 4 - 8
src/business/auth/index.ts

@@ -1,15 +1,11 @@
 import { ref, reactive } from 'vue'
 import { v4 } from 'uuid'
 import { ClientType } from '@/constants/client'
-import { useLoginStore, useEnumStore, useErrorInfoStore } from '@/stores'
+import { loginStore, enumStore, errorInfoStore } from '@/stores'
 import { initBaseData, checkTokenLoop } from '@/business/common'
 import eventBus from '@/services/bus'
 
 export function useAuth() {
-    const { getAllEnumList } = useEnumStore()
-    const { getErrorInfoList } = useErrorInfoStore()
-    const { userLogin } = useLoginStore()
-
     const loading = ref(false);
     const user = reactive<Proto.LoginReq>({
         LoginID: '110000000001',
@@ -26,11 +22,11 @@ export function useAuth() {
         try {
             loading.value = true
             // 等待请求枚举
-            await getAllEnumList()
+            await enumStore.actions.getAllEnumList()
             // 等待请求系统错误信息
-            await getErrorInfoList()
+            await errorInfoStore.actions.getErrorInfoList()
             // 等待登录
-            await userLogin(user)
+            await loginStore.actions.userLogin(user)
             // 等待业务数据初始化
             await initBaseData(() => checkTokenLoop())
         } catch (err) {

+ 11 - 15
src/business/bank/index.ts

@@ -1,15 +1,15 @@
 import { shallowRef, reactive } from 'vue'
 import { decryptAES } from '@/utils/websocket/crypto'
 import { useDataTable } from '@/hooks/datatable'
-import { useUserStore, useAccountStore, useLoginStore } from '@/stores'
+import { userStore, accountStore, loginStore } from '@/stores'
 import { queryCusBankSignBank, queryAccountInOutApply, t2bBankSign, t2bBankCancelSign, queryBankAccountSign, t2bBankDeposit, t2bBankWithdraw } from '@/services/api/bank'
 import { SignStatus } from '@/constants/bank'
 
+const { userId, firstAccountId } = loginStore.$mapGetters()
+
 // 银行签约相关
 export function useBankSign() {
-    const { getUserDataInfo } = useUserStore()
-    const { accountId } = useAccountStore()
-    const userInfo = getUserDataInfo('userInfo')
+    const userInfo = userStore.actions.getUserDataInfo('userInfo')
     const loading = shallowRef(false)
     const custodianBanks = shallowRef<Ermcp.CusBankSignBankRsp[]>([]) // 托管银行列表
     const selectedCustodianBank = shallowRef<Ermcp.CusBankSignBankRsp>() // 已选中的托管银行
@@ -27,7 +27,7 @@ export function useBankSign() {
         BankAccountType: 1, // 银行账户类型
         AccountType: 1, // // 账户类型[1-对私; 2-对公]
         extend_info: JSON.stringify(extendInfo), //  扩展信息(JSON串,参考配置要求进行填充)
-        AccountCode: accountId.value.toString(), // 账户
+        AccountCode: accountStore.state.accountId.toString(), // 账户
         AccountName: userInfo.customername, // 客户名称
         BankAccountName: userInfo.customername,
         ExtOperatorID: 0, // 外部操作流水号
@@ -82,7 +82,6 @@ export function useBankSign() {
 
 // 银行解约相关
 export function useBankCancelSign(bankInfo: Ermcp.BankAccountSignRsp) {
-    const { getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
 
     const formSubmit = () => {
@@ -90,7 +89,7 @@ export function useBankCancelSign(bankInfo: Ermcp.BankAccountSignRsp) {
         return t2bBankCancelSign({
             data: {
                 ExtOperatorID: new Date().getTime(), // 外部操作流水号
-                AccountCode: getFirstAccountId().toString(), // 账户
+                AccountCode: firstAccountId.value.toString(), // 账户
                 CusBankID: bankInfo.cusbankid, // 托管银行编号
                 IsForce: 0, // 是否强制
                 Currency: bankInfo.currency, // 币种
@@ -112,7 +111,6 @@ export function useBankCancelSign(bankInfo: Ermcp.BankAccountSignRsp) {
  * @returns 
  */
 export function useAccountInOut() {
-    const { getUserId } = useLoginStore()
     const { dataList } = useDataTable<Ermcp.AccountOutInApplyRsp>()
     const loading = shallowRef(false)
 
@@ -120,7 +118,7 @@ export function useAccountInOut() {
         loading.value = true
         return queryAccountInOutApply({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
                 applystatus: params.applystatus,
                 querytype: params.querytype,
             },
@@ -142,9 +140,8 @@ export function useAccountInOut() {
 
 // 入金
 export function useDeposit() {
-    const { getUserDataInfo } = useUserStore()
-    const { accountInfo } = useAccountStore()
-    const userInfo = getUserDataInfo('userInfo')
+    const { accountInfo } = accountStore.$mapGetters()
+    const userInfo = userStore.actions.getUserDataInfo('userInfo')
     const loading = shallowRef(false)
 
     const formData = reactive<Partial<Proto.t2bBankDepositReq>>({
@@ -212,9 +209,8 @@ export function useDeposit() {
 
 // 出金
 export function useWithdraw() {
-    const { getUserDataInfo } = useUserStore()
-    const { accountInfo } = useAccountStore()
-    const userInfo = getUserDataInfo('userInfo')
+    const { accountInfo } = accountStore.$mapGetters()
+    const userInfo = userStore.actions.getUserDataInfo('userInfo')
     const loading = shallowRef(false)
 
     const formData = reactive<Partial<Proto.t2bBankDepositReq>>({

+ 10 - 13
src/business/bargain/index.ts

@@ -4,15 +4,16 @@ import { ClientType } from '@/constants/client'
 import { Market } from '@/constants/market'
 import { useDataTable } from '@/hooks/datatable'
 import { queryMyBargainApply, queryMyDelistingApply, zsBuyOrderDestingNegPriceOperate, zsSellOrderDestingApplyOperate } from '@/services/api/trade'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import { BuyOrSell } from '@/constants/order'
 import Long from 'long'
 
+const { userId, firstAccountId } = loginStore.$mapGetters()
+
 /**
  * 我的询价
  */
 export function useBargain() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MyBargainApplyRsp | Ermcp.MyDelistingApplyRsp>()
     const loading = shallowRef(false)
 
@@ -25,7 +26,7 @@ export function useBargain() {
             type: 0,
             page: pageIndex.value,
             pagesize: pageSize.value,
-            userid: getUserId(),
+            userid: userId.value,
             applystatus: params.applystatus,
         }
 
@@ -74,7 +75,6 @@ export function useBargain() {
  * 询价消息-买方询价
  */
 export function useBuyBargain() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MyBargainApplyRsp>()
     const loading = shallowRef(false)
 
@@ -86,7 +86,7 @@ export function useBuyBargain() {
                 type: 1,
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
                 applystatus: params.applystatus,
             },
             success: (res) => {
@@ -113,7 +113,6 @@ export function useBuyBargain() {
  * 询价消息-卖方询价
  */
 export function useSellBargain() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MyDelistingApplyRsp>()
     const loading = shallowRef(false)
 
@@ -125,7 +124,7 @@ export function useSellBargain() {
                 type: 1,
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
                 applystatus: params.applystatus,
             },
             success: (res) => {
@@ -153,9 +152,7 @@ export function useSellBargain() {
  * @returns 
  */
 export function useBargainOperate(selectedRow: Ermcp.MyBargainApplyRsp | Ermcp.MyDelistingApplyRsp) {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
-
     const formData = reactive<{ AuditRemark: string }>({
         AuditRemark: ''
     })
@@ -167,8 +164,8 @@ export function useBargainOperate(selectedRow: Ermcp.MyBargainApplyRsp | Ermcp.M
         if ('wrbargainid' in selectedRow) {
             return zsBuyOrderDestingNegPriceOperate({
                 data: {
-                    UserID: getUserId(), // 用户ID,必填
-                    AccountID: getFirstAccountId(), // 资金账号,必填
+                    UserID: userId.value, // 用户ID,必填
+                    AccountID: firstAccountId.value, // 资金账号,必填
                     WRBargainID: Long.fromString(selectedRow.wrbargainid), // 议价申请单ID,必填
                     OperateType, // 操作类型,1:撤销2:拒绝3:同意
                     AuditRemark: formData.AuditRemark,
@@ -187,8 +184,8 @@ export function useBargainOperate(selectedRow: Ermcp.MyBargainApplyRsp | Ermcp.M
         if ('selldelistingapplyid' in selectedRow) {
             return zsSellOrderDestingApplyOperate({
                 data: {
-                    UserID: getUserId(), // 用户ID,必填
-                    AccountID: getFirstAccountId(), // 资金账号,必填
+                    UserID: userId.value, // 用户ID,必填
+                    AccountID: firstAccountId.value, // 资金账号,必填
                     SellDelistingApplyID: Long.fromString(selectedRow.selldelistingapplyid), // 卖摘牌申请ID,必填
                     OperateType, // 操作类型,1:撤销2:拒绝3:同意
                     AuditRemark: formData.AuditRemark,

+ 16 - 19
src/business/common/index.ts

@@ -1,5 +1,5 @@
 import { timerTask } from '@/utils/timer'
-import { useStore } from '@/stores'
+import { loginStore, accountStore, userStore, futuresStore, menuStore, performanceStore, favoriteStore, exrateStore } from '@/stores'
 import { tokenCheck } from '@/services/api/account'
 import eventBus from '@/services/bus'
 import socket from '@/services/socket'
@@ -8,11 +8,10 @@ import socket from '@/services/socket'
  * 退出登录
  */
 export function logout(callback?: () => void) {
-    const { loginStore, accountStore } = useStore()
     socket.closeAll()
     timerTask.clearAll()
-    loginStore.reset()
-    accountStore.reset()
+    loginStore.actions.reset()
+    accountStore.actions.reset()
     callback && callback()
 }
 
@@ -21,20 +20,19 @@ export function logout(callback?: () => void) {
  * @param callback 
  */
 export async function initBaseData(callback?: () => void) {
-    const { userStore, futuresStore, menuStore, performanceStore, accountStore, favoriteStore, exrateStore } = useStore()
     const asyncTask = [
-        userStore.getUserData(),
-        menuStore.getUserMenuList(),
-        futuresStore.getGoodsList(),
-        performanceStore.getPerformanceTemplateList(),
-        performanceStore.getPerformanceStepTypeList(),
-        exrateStore.getExrateList(),
-        //tableColumnStore.getTableColumnList(),
+        userStore.actions.getUserData(),
+        menuStore.actions.getUserMenuList(),
+        futuresStore.actions.getGoodsList(),
+        performanceStore.actions.getPerformanceTemplateList(),
+        performanceStore.actions.getPerformanceStepTypeList(),
+        exrateStore.actions.getExrateList(),
+        //tableColumnStore.actions.getTableColumnList(),
     ]
 
     await Promise.all(asyncTask).then(() => {
-        accountStore.getAccountList()
-        favoriteStore.getFavoriteList()
+        accountStore.actions.getAccountList()
+        favoriteStore.actions.getFavoriteList()
         callback && callback()
     }).catch(() => {
         return Promise.reject('初始化失败')
@@ -45,15 +43,14 @@ export async function initBaseData(callback?: () => void) {
  * 令牌效验
  */
 export function checkToken() {
-    const { loginStore } = useStore()
-    const { LoginID, Token } = loginStore.loginInfo.value
+    const { loginId, token } = loginStore.$mapGetters()
     return tokenCheck({
         data: {
-            LoginID,
-            Token,
+            LoginID: loginId.value,
+            Token: token.value,
         },
         fail: () => {
-            loginStore.reset()
+            loginStore.actions.reset()
         }
     })
 }

+ 6 - 7
src/business/customs/bonded.ts

@@ -4,12 +4,13 @@ import { ClientType } from '@/constants/client'
 import { useDataTable } from '@/hooks/datatable'
 import { getTableColumns } from '@/business/table'
 import { queryGZBSFWOrder, queryGZCJBSOrderFile, queryGZBSFWOrderDetail, queryFworderoperate, bsfwMemberOperate } from '@/services/api/customs'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import Long from 'long'
 
+const { userId } = loginStore.$mapGetters()
+
 // 保税服务
 export function useBSFWOrderList() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.GZBSFWOrderRsp>()
     const loading = shallowRef(false)
 
@@ -19,7 +20,7 @@ export function useBSFWOrderList() {
             data: {
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
                 executestatus: params.executestatus,
             },
             success: (res) => {
@@ -44,7 +45,6 @@ export function useBSFWOrderList() {
 
 // 保税服务单据明细
 export function useBSFWOrderDetail(selectedRow: Ermcp.GZBSFWOrderRsp) {
-    const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
     const detailList = shallowRef<Ermcp.GZBSFWOrderDetailRsp[]>([])
 
@@ -63,7 +63,7 @@ export function useBSFWOrderDetail(selectedRow: Ermcp.GZBSFWOrderRsp) {
         loading.value = true
         return queryGZBSFWOrderDetail({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
                 orderid: selectedRow.orderid,
             },
             success: (res) => {
@@ -144,8 +144,7 @@ export function useBSFWOrderOperate({ orderid, gzbsstatus }: Ermcp.GZBSFWOrderRs
 
 // 保税服务操作
 export function useBSFWMemberOperate(orderId: string) {
-    const { loginInfo } = useLoginStore()
-    const { UserID, LoginID, LoginCode } = loginInfo.value
+    const { UserID, LoginID, LoginCode } = loginStore.state.loginInfo
     const loading = shallowRef(false)
 
     const formData = reactive<Proto.BSFWMemberOperateReq>({

+ 9 - 11
src/business/customs/exit.ts

@@ -3,12 +3,13 @@ import { v4 } from 'uuid'
 import { useDataTable } from '@/hooks/datatable'
 import { cjjcApply, queryGZCJJCOrder, cjjcMemberOperate, queryGZCJJCOrderDetail, queryGzcjjcorderoperate } from '@/services/api/customs'
 import { ClientType } from '@/constants/client'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import Long from 'long'
 
+const { userId } = loginStore.$mapGetters()
+
 // 出境检测列表
 export function useCJJCOrderList() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.GZCJJCOrderRsp>()
     const loading = shallowRef(false)
 
@@ -18,7 +19,7 @@ export function useCJJCOrderList() {
             data: {
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
                 executestatus: params.executestatus,
             },
             success: (res) => {
@@ -43,7 +44,6 @@ export function useCJJCOrderList() {
 
 // 出境检测单据明细
 export function useGZCJJCOrderDetail(selectedRow: Ermcp.GZCJJCOrderRsp) {
-    const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
     const detailList = shallowRef<Ermcp.GZCJJCOrderDetailRsp[]>([])
 
@@ -81,7 +81,7 @@ export function useGZCJJCOrderDetail(selectedRow: Ermcp.GZCJJCOrderRsp) {
         loading.value = true
         return queryGZCJJCOrderDetail({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
                 orderid: selectedRow.orderidstr,
             },
             success: (res) => {
@@ -103,13 +103,12 @@ export function useGZCJJCOrderDetail(selectedRow: Ermcp.GZCJJCOrderRsp) {
 
 // 出境检测申请
 export function useCJJCOrderApply(selectedRow?: Ermcp.GZCJJCOrderRsp) {
-    const { loginInfo, getFirstAccountId, getUserId } = useLoginStore()
-    const { UserID, LoginID, LoginCode } = loginInfo.value
+    const { UserID, LoginID, LoginCode, AccountIDs } = loginStore.state.loginInfo
     const loading = shallowRef(false)
 
     const formData = reactive<Partial<Proto.CJJCApplyReq>>({
         UserID,
-        AccountID: getFirstAccountId(),
+        AccountID: AccountIDs[0],
         OperateID: LoginID, // 操作人ID,LoginAccount的LoginID,必填
         OperateAccount: LoginCode || LoginID.toString(), // 操作人账户,LoginAccount的LoginCode,LoginCode为空则填LoginID,必填
         GZCJCategoryDetails: [],
@@ -167,7 +166,7 @@ export function useCJJCOrderApply(selectedRow?: Ermcp.GZCJJCOrderRsp) {
             data: {
                 page: 1,
                 pagesize: 1,
-                userid: getUserId(),
+                userid: UserID,
             },
             success: (res) => {
                 if (res.data.length) {
@@ -235,8 +234,7 @@ export function useCJJCOrderOperate({ orderidstr, gzcjstatus }: Ermcp.GZCJJCOrde
 
 // 出境检测操作
 export function useCJJCMemberOperate(orderId: string) {
-    const { loginInfo } = useLoginStore()
-    const { UserID, LoginID, LoginCode } = loginInfo.value
+    const { UserID, LoginID, LoginCode } = loginStore.state.loginInfo
     const loading = shallowRef(false)
 
     const formData = reactive<Proto.CJJCMemberOperateReq>({

+ 3 - 3
src/business/favorite/index.ts

@@ -1,9 +1,9 @@
 import { watch } from 'vue'
 import { useDataTable } from '@/hooks/datatable'
-import { useFavoriteStore } from '@/stores'
+import { favoriteStore } from '@/stores'
 
 export function useFavorite() {
-    const { loading, favoriteList, getFavoriteList } = useFavoriteStore()
+    const { loading, favoriteList } = favoriteStore.$mapState()
     const { dataList, total, pageIndex, pageSize, filters } = useDataTable<Ermcp.MyFavoriteRsp>({ pagination: true })
 
     watch(favoriteList, (data) => {
@@ -20,6 +20,6 @@ export function useFavorite() {
         total,
         pageIndex,
         pageSize,
-        getFavoriteList,
+        getFavoriteList: favoriteStore.actions.getFavoriteList,
     }
 }

+ 13 - 17
src/business/goods/index.ts

@@ -7,7 +7,7 @@ import { Market } from '@/constants/market'
 import { queryWarehouseInfo } from '@/services/api/warehouse'
 import { addDiamond, queryDiamondList, queryDiamondDetails, receiptZSOutApply } from '@/services/api/goods'
 import { goodsFavoriteOperate } from '@/services/api/favorite'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import {
     Category,
     getCurrencyTypeList,
@@ -28,9 +28,10 @@ import {
 } from '@/constants/diamond'
 import Long from 'long'
 
+const { userId, firstAccountId } = loginStore.$mapGetters()
+
 // 钻石列表相关
 export function useDiamond() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MyWRPositionRsp>()
     const loading = shallowRef(false)
 
@@ -46,7 +47,7 @@ export function useDiamond() {
             data: {
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                wruserid: getUserId(),
+                wruserid: userId.value,
                 zscategorys: params.zscategorys ?? categoryList.map((e) => e.value).join(','),
                 zsallproperties: params.zsallproperties,
                 warehouseid: params.warehouseid,
@@ -66,7 +67,7 @@ export function useDiamond() {
     // 获取仓库列表
     queryWarehouseInfo({
         data: {
-            userid: getUserId(),
+            userid: userId.value,
             status: 1,
             isincludeexchange: true,
         },
@@ -121,8 +122,6 @@ export function useDiamondDetails(goodsno: string) {
 
 // 钻石上架相关
 export function useDiamondForm(category: Category) {
-    const { loginInfo } = useLoginStore()
-    const { UserID, AccountIDs } = loginInfo.value
     const loading = shallowRef(false)
     const warehouseList = shallowRef<Ermcp.WarehouseInfoRsp[]>([]) // 仓库列表
     const performanceId = shallowRef<number>() // 选中的履约模板ID
@@ -215,8 +214,8 @@ export function useDiamondForm(category: Category) {
         loading.value = true
         return addDiamond({
             data: {
-                UserID,
-                AccountID: AccountIDs[0],
+                UserID: userId.value,
+                AccountID: firstAccountId.value,
                 AddType: performanceId.value ? 2 : 1,
                 MarketID: Market.GZ,
                 OrderSrc: 1,
@@ -234,7 +233,7 @@ export function useDiamondForm(category: Category) {
     // 获取仓库列表
     queryWarehouseInfo({
         data: {
-            userid: UserID,
+            userid: userId.value,
             status: 1,
             isincludeexchange: true,
         },
@@ -259,7 +258,6 @@ export function useDiamondForm(category: Category) {
 
 // 钻石收藏相关
 export function useDiamondFavorite(selectedRow: Ermcp.MyWRPositionRsp | Ermcp.SellOrderRsp) {
-    const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
 
     // 钻石收藏操作
@@ -267,7 +265,7 @@ export function useDiamondFavorite(selectedRow: Ermcp.MyWRPositionRsp | Ermcp.Se
         loading.value = true
         return goodsFavoriteOperate({
             data: {
-                UserID: getUserId(), // 用户ID,必填
+                UserID: userId.value, // 用户ID,必填
                 WRTradeOrderID: Long.fromString(selectedRow.wrtradeorderid), // 委托单ID,必填
                 OperateType: operateType, // 操作类型,1:添加2:删除,必填
                 ClientType: ClientType.Web, // 终端类型
@@ -288,8 +286,6 @@ export function useDiamondFavorite(selectedRow: Ermcp.MyWRPositionRsp | Ermcp.Se
 
 // 钻石删除相关
 export function useDiamondDelete(selectedRow: Ermcp.MyWRPositionRsp) {
-    const { loginInfo } = useLoginStore()
-    const { UserID, AccountIDs } = loginInfo.value
     const loading = shallowRef(false)
 
     const formSubmit = () => {
@@ -297,13 +293,13 @@ export function useDiamondDelete(selectedRow: Ermcp.MyWRPositionRsp) {
         return receiptZSOutApply({
             data: {
                 Common: {
-                    UserID,
-                    AccountID: AccountIDs[0],
+                    UserID: userId.value,
+                    AccountID: firstAccountId.value,
                     RelatedOrderID: new Date().getTime(),
                     TradeID: new Date().getTime(),
                 },
-                UserID,
-                AccountID: AccountIDs[0],
+                UserID: userId.value,
+                AccountID: firstAccountId.value,
                 LadingBillID: Long.fromString(selectedRow.ladingbillid),
                 SubNum: selectedRow.subnum,
                 Qty: selectedRow.weight,

+ 7 - 7
src/business/home/index.ts

@@ -2,16 +2,16 @@ import { shallowRef, computed } from 'vue'
 import { homeData, queryNotice } from '@/services/api/common'
 import { queryMyDeListing } from '@/services/api/trade'
 import { BuyOrSell } from '@/constants/order'
-import { useLoginStore, useFavoriteStore } from '@/stores'
+import { loginStore, favoriteStore } from '@/stores'
+
+const { userId, loginId } = loginStore.$mapGetters()
 
 export function useHomeData() {
-    const { getUserId, getLoginId } = useLoginStore()
-    const favoriteStore = useFavoriteStore()
     const deListingList = shallowRef<Ermcp.MyDeListingRsp[]>([])
     const noticeList = shallowRef<Ermcp.NoticeRsp[]>([])
 
     const favoriteList = computed(() => {
-        return favoriteStore.favoriteList.value.slice(0, 5)
+        return favoriteStore.state.favoriteList.slice(0, 5)
     })
 
     const countData = shallowRef<Ermcp.HomeDataRsp>({
@@ -25,7 +25,7 @@ export function useHomeData() {
     const getCountData = () => {
         return homeData({
             data: {
-                userid: getUserId()
+                userid: userId.value
             },
             success: (res) => {
                 countData.value = res.data
@@ -40,7 +40,7 @@ export function useHomeData() {
                 page: 1,
                 pagesize: 5,
                 buyorsell,
-                userid: getUserId(),
+                userid: userId.value,
             },
             success: (res) => {
                 deListingList.value = res.data
@@ -51,7 +51,7 @@ export function useHomeData() {
     const getNoticeList = () => {
         return queryNotice({
             data: {
-                loginID: getLoginId()
+                loginID: loginId.value
             },
             success: (res) => {
                 noticeList.value = res.data.splice(0, 5)

+ 5 - 4
src/business/notice/index.ts

@@ -1,10 +1,11 @@
 import { shallowRef, computed } from 'vue'
 import { timerTask } from '@/utils/timer'
 import { queryNotice, postNoticeReaded } from '@/services/api/common'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
+
+const { loginId } = loginStore.$mapGetters()
 
 export function useNotice() {
-    const { getLoginId } = useLoginStore()
     const dataList = shallowRef<Ermcp.NoticeRsp[]>([])
     const loading = shallowRef(false)
 
@@ -19,7 +20,7 @@ export function useNotice() {
         loading.value = true
         return queryNotice({
             data: {
-                loginID: getLoginId()
+                loginID: loginId.value
             },
             success: (res) => {
                 dataList.value = res.data
@@ -38,7 +39,7 @@ export function useNotice() {
     const updateNoticeReaded = (id: number) => {
         return postNoticeReaded({
             data: {
-                loginID: Number(getLoginId()),
+                loginID: Number(loginId.value),
                 noticeID: id,
             },
         })

+ 8 - 10
src/business/order/index.ts

@@ -3,13 +3,14 @@ import { useDataTable } from '@/hooks/datatable'
 import { getTableColumns } from '@/business/table'
 import { getReceiptTypeName } from '@/constants/receipt'
 import { queryMyPerformance, performanceManualConfirm, performanceDelayApply, performanceContractedApply, performanceModifyContact, queryWrPerformancePlanStep } from '@/services/api/performance'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import { BuyOrSell } from '@/constants/order'
 import Long from 'long'
 
+const { userId, firstAccountId } = loginStore.$mapGetters()
+
 // 我的履约
 export function usePerformance(buyorsell?: BuyOrSell) {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MyPerformancRsp>()
     const loading = shallowRef(false)
 
@@ -25,7 +26,7 @@ export function usePerformance(buyorsell?: BuyOrSell) {
 
         return queryMyPerformance({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
                 page: pageIndex.value,
                 pagesize: pageSize.value,
                 buyorsell,
@@ -84,12 +85,11 @@ export function usePerformanceManual(selectedRow: Ermcp.MyPerformancRsp) {
 
 // 履约延期申请
 export function usePerformanceDelay(selectedRow: Ermcp.MyPerformancRsp) {
-    const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
 
     const formData = reactive<Proto.PerformanceDelayApplyReq>({
         PerformancePlanStepID: Long.fromString(selectedRow.curstepid), // uint64 履约计划步骤ID
-        applicant: getUserId(), // uint64 申请人
+        applicant: userId.value, // uint64 申请人
     })
 
     const formSubmit = () => {
@@ -111,13 +111,12 @@ export function usePerformanceDelay(selectedRow: Ermcp.MyPerformancRsp) {
 
 // 履约违约申请
 export function usePerformanceContracted(selectedRow: Ermcp.MyPerformancRsp) {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
 
     const formData = reactive<Proto.PerformanceContractedApplyReq>({
         PerformancePlanID: Long.fromString(selectedRow.performanceplanid), // uint64 履约计划ID
-        BreachType: selectedRow.buyaccountid === getFirstAccountId() ? 2 : 1, // uint32 违约方类型
-        Applicant: getUserId(), // uint64 违约申请人
+        BreachType: selectedRow.buyaccountid === firstAccountId.value ? 2 : 1, // uint32 违约方类型
+        Applicant: userId.value, // uint64 违约申请人
     })
 
     const formSubmit = () => {
@@ -139,7 +138,6 @@ export function usePerformanceContracted(selectedRow: Ermcp.MyPerformancRsp) {
 
 // 履约修改联络信息
 export function usePerformanceModify(selectedRow: Ermcp.MyPerformancRsp) {
-    const { getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
     const formData = reactive<{ address?: Ermcp.UserReceiveInfoRsp, invoice?: Ermcp.WrUserReceiptInfoRsp, contactInfo?: string }>({})
 
@@ -201,7 +199,7 @@ export function usePerformanceModify(selectedRow: Ermcp.MyPerformancRsp) {
         return performanceModifyContact({
             data: {
                 PerformancePlanID: Long.fromString(selectedRow.performanceplanid), // uint64 履约计划ID
-                AccountID: getFirstAccountId(), // uint64 账号
+                AccountID: firstAccountId.value, // uint64 账号
                 ContactInfo: JSON.stringify(jsonParam), // string 联络信息
             },
             complete: () => {

+ 6 - 7
src/business/report/index.ts

@@ -3,12 +3,13 @@ import { useDataTable } from '@/hooks/datatable'
 import { getTableColumns } from '@/business/table'
 import { queryMarketRun } from '@/services/api/common'
 import { queryMemberReport, queryWRPositionReport, queryTradeReport } from '@/services/api/report'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import { Market } from '@/constants/market'
 
+const { userId } = loginStore.$mapGetters()
+
 // 会员报表列表
 export function useMemberReportList() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MemberReportRsp>()
     const loading = shallowRef(false)
     const columns = shallowRef(getTableColumns('report_member'))
@@ -45,7 +46,7 @@ export function useMemberReportList() {
         const [begindate, enddate] = dateValue.value
         return queryMemberReport({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
                 page: pageIndex.value,
                 pagesize: pageSize.value,
                 cycletype: cycleType.value === 5 ? undefined : cycleType.value.toString(),
@@ -77,7 +78,6 @@ export function useMemberReportList() {
 
 // 仓储报表列表
 export function useWarehousingReportList() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.WRPositionReportRsp>()
     const loading = shallowRef(false)
     const columns = shallowRef(getTableColumns('report_warehousing'))
@@ -114,7 +114,7 @@ export function useWarehousingReportList() {
 
         return queryWRPositionReport({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
                 page: pageIndex.value,
                 pagesize: pageSize.value,
                 cycletype: cycleType.value === 5 ? undefined : cycleType.value.toString(),
@@ -148,7 +148,6 @@ export function useWarehousingReportList() {
 
 // 交易报表列表
 export function useTradeReportList() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.TradeReportRsp>()
     const loading = shallowRef(false)
     const columns = shallowRef(getTableColumns('report_trade'))
@@ -185,7 +184,7 @@ export function useTradeReportList() {
 
         return queryTradeReport({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
                 page: pageIndex.value,
                 pagesize: pageSize.value,
                 cycletype: cycleType.value === 5 ? undefined : cycleType.value.toString(),

+ 2 - 2
src/business/table/index.ts

@@ -1,9 +1,9 @@
 import { shallowRef } from 'vue'
-import { useTableColumnStore } from '@/stores'
+import { tableColumnStore } from '@/stores'
 import { TableColumnKey, pcTableColumnMap } from './columns'
 
 export function useTableColumns(tableKey: string, operateColumn = true) {
-    const { tableColumns } = useTableColumnStore()
+    const { tableColumns } = tableColumnStore.$mapState()
 
     const columns = shallowRef(tableColumns.value.reduce((res, cur) => {
         if (cur.tablekey === tableKey) {

+ 12 - 13
src/business/trade/desting.ts

@@ -5,31 +5,32 @@ import { Market } from '@/constants/market'
 import { useDataTable } from '@/hooks/datatable'
 import { queryDiamondList } from '@/services/api/goods'
 import { zsBuyOrderDesting, zsBuyOrderDestingNegPrice, zsSellOrderDestingApply } from '@/services/api/trade'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import moment from 'moment'
 import Long from 'long'
 
+const { userId, firstAccountId } = loginStore.$mapGetters()
+
 /**
  * 钻石买摘牌(立即购买)
  * @returns 
  */
 export function useBuyOrderDesting(selectedRow: Ermcp.DiamondDetailsRsp) {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
 
     const formSubmit = () => {
         loading.value = true
         return zsBuyOrderDesting({
             data: {
-                UserID: getUserId(),
-                AccountID: getFirstAccountId(),
+                UserID: userId.value,
+                AccountID: firstAccountId.value,
                 RelatedWRTradeOrderID: Long.fromString(selectedRow.wrtradeorderid),
                 OrderQty: selectedRow.remainqty,
                 OrderSrc: 1,
                 ClientSerialNo: v4(),
                 ClientOrderTime: moment().format('YYYY-MM-DD HH:mm:ss'),
                 ClientType: ClientType.Web,
-                OperatorID: getUserId(),
+                OperatorID: userId.value,
                 MarketID: Market.GZ
             },
             complete: () => {
@@ -49,17 +50,16 @@ export function useBuyOrderDesting(selectedRow: Ermcp.DiamondDetailsRsp) {
  * @returns 
  */
 export function useBuyOrderBargain(selectedRow: Ermcp.DiamondDetailsRsp) {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
 
     const formData = reactive<Proto.ZSBuyOrderDestingNegPriceReq>({
-        UserID: getUserId(), // 用户ID,必填
-        AccountID: getFirstAccountId(), // 资金账号,必填
+        UserID: userId.value, // 用户ID,必填
+        AccountID: firstAccountId.value, // 资金账号,必填
         RelatedOrderID: Long.fromString(selectedRow.wrtradeorderid), // 卖委托单号,必填
         OrderQty: selectedRow.remainqty, // 议价数量,2位小数,必填
         OrderSrc: 1, // 委托来源
         ClientType: ClientType.Web, // 终端类型
-        OperatorID: getUserId(), // 操作员账号ID
+        OperatorID: userId.value, // 操作员账号ID
         MarketID: Market.GZ, // 市场ID,必填
         ApplyRemark: '' // 申请备注
     })
@@ -90,13 +90,12 @@ export function useBuyOrderBargain(selectedRow: Ermcp.DiamondDetailsRsp) {
  * @returns 
  */
 export function useSellOrderBargain(selectedRow: Ermcp.BuyOrderRsp) {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const { dataList } = useDataTable<Ermcp.MyWRPositionRsp>()
     const loading = shallowRef(false)
 
     const formData = reactive<Proto.ZSSellOrderDestingApplyReq>({
-        UserID: getUserId(), // 用户ID,必填
-        AccountID: getFirstAccountId(), // 资金账户ID,必填
+        UserID: userId.value, // 用户ID,必填
+        AccountID: firstAccountId.value, // 资金账户ID,必填
         BuyWRTradeOrderID: Long.fromString(selectedRow.wrtradeorderid), // 买挂牌委托单ID,必填
         WRStandardID: 0, // 现货商品ID,必填
         ApplyQty: 0, // 申请数量,必填,2位小数
@@ -140,7 +139,7 @@ export function useSellOrderBargain(selectedRow: Ermcp.BuyOrderRsp) {
     const getDiamondList = () => {
         return queryDiamondList({
             data: {
-                wruserid: getUserId(),
+                wruserid: userId.value,
                 zscategorys: selectedRow.zscategory.toString(),
             },
             success: (res) => {

+ 6 - 7
src/business/trade/list.ts

@@ -1,7 +1,7 @@
 import { shallowRef, ref } from 'vue'
 import { useDataTable } from '@/hooks/datatable'
 import { queryBuyOrder, querySellOrder, queryMyBuyOrder, queryMySellOrder, queryMyDeListing } from '@/services/api/trade'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import { getBuyOrSellList, BuyOrSell } from '@/constants/order'
 import { Category } from '@/constants/diamond'
 
@@ -10,6 +10,8 @@ const categoryList = [
     { label: '单颗彩钻', value: Category.Fancy }
 ]
 
+const { userId } = loginStore.$mapGetters()
+
 /**
  * 求购大厅
  * @returns 
@@ -96,7 +98,6 @@ export function useSellOrder() {
  * 我的出售
  */
 export function useSaleOrder() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MySellOrderRsp>()
     const loading = shallowRef(false)
 
@@ -115,7 +116,7 @@ export function useSaleOrder() {
             data: {
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
                 zscategorys: params.zscategorys ?? categoryList.map((e) => e.value).join(','),
                 wrtradeorderid: params.wrtradeorderid,
                 zsallproperties: params.zsallproperties,
@@ -149,7 +150,6 @@ export function useSaleOrder() {
  * 我的求购
  */
 export function usePurchaseOrder() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MyBuyOrderRsp>()
     const loading = shallowRef(false)
 
@@ -168,7 +168,7 @@ export function usePurchaseOrder() {
             data: {
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
                 zscategorys: params.zscategorys ?? categoryList.map((e) => e.value).join(','),
                 wrtradeorderid: params.wrtradeorderid,
                 zsallproperties: params.zsallproperties,
@@ -202,7 +202,6 @@ export function usePurchaseOrder() {
  * 我的摘牌
  */
 export function useDelistingOrder(buyorsell = BuyOrSell.Buy) {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.MyDeListingRsp>()
     const loading = shallowRef(false)
     const filterDate = shallowRef<string[]>([])
@@ -217,7 +216,7 @@ export function useDelistingOrder(buyorsell = BuyOrSell.Buy) {
             data: {
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
                 buyorsell: params.buyorsell,
                 matchusername: params.matchusername,
                 zscategorys: params.zscategorys ?? categoryList.map((e) => e.value).join(','),

+ 13 - 15
src/business/trade/listing.ts

@@ -5,7 +5,7 @@ import { useDataTable } from '@/hooks/datatable'
 import { Market } from '@/constants/market'
 import { queryDiamondList } from '@/services/api/goods'
 import { zsBuyOrderListing, zsSellOrderListing, wrListingCancelOrder } from '@/services/api/trade'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import {
     Category,
     getCurrencyTypeList,
@@ -23,18 +23,19 @@ import {
 import moment from 'moment'
 import Long from 'long'
 
+const { userId, firstAccountId } = loginStore.$mapGetters()
+
 /**
  * 钻石求购挂牌
  * @returns 
  */
 export function useBuyOrderListing() {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
     const performanceId = shallowRef<number>() // 选中的履约模板ID
     const currencyId = shallowRef<number>() // 选中的货币类型ID
     const formData = reactive<Proto.GZBuyOrderDetailExInfo>({
-        UserID: getUserId(),
-        AccountID: getFirstAccountId(),
+        UserID: userId.value,
+        AccountID: firstAccountId.value,
         ZSCategory: Category.Diamond,
         ZSCurrencyType: [],
         ZSShapeType: [],
@@ -76,8 +77,8 @@ export function useBuyOrderListing() {
         }
         return zsBuyOrderListing({
             data: {
-                UserID: getUserId(),
-                AccountID: getFirstAccountId(),
+                UserID: userId.value,
+                AccountID: firstAccountId.value,
                 MarketID: Market.GZ,
                 OrderSrc: 1,
                 ClientType: ClientType.Web,
@@ -106,7 +107,6 @@ export function useBuyOrderListing() {
  * @returns 
  */
 export function useSellOrderListing(selectedRow?: Ermcp.MyWRPositionRsp) {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const { dataList } = useDataTable<Ermcp.MyWRPositionRsp>()
     const { zscategory, wrstandardid = 0, ladingbillid = '0', subnum = 0, ftotalqty = 0, ffreezeqty = 0 } = selectedRow ?? {}
     const submitLoading = shallowRef(false)
@@ -133,8 +133,8 @@ export function useSellOrderListing(selectedRow?: Ermcp.MyWRPositionRsp) {
     ])
 
     const formData = reactive<Proto.ZSSellOrderListingReq>({
-        UserID: getUserId(),
-        AccountID: getFirstAccountId(),
+        UserID: userId.value,
+        AccountID: firstAccountId.value,
         WRStandardID: wrstandardid,
         OrderQty: ftotalqty - ffreezeqty,
         LadingBillID: Long.fromString(ladingbillid),
@@ -154,7 +154,7 @@ export function useSellOrderListing(selectedRow?: Ermcp.MyWRPositionRsp) {
         tableLoading.value = true
         queryDiamondList({
             data: {
-                wruserid: getUserId(),
+                wruserid: userId.value,
                 zscategorys: selectedCategoryId.value.toString(),
             },
             success: (res) => {
@@ -197,20 +197,18 @@ export function useSellOrderListing(selectedRow?: Ermcp.MyWRPositionRsp) {
  * 钻石挂牌撤单
  */
 export function useListingCancel(wrtradeorderid: string, buyorsell: number) {
-    const { getUserId, getFirstAccountId } = useLoginStore()
     const loading = shallowRef(false)
-    const userId = getUserId()
 
     const formSubmit = () => {
         loading.value = true
         return wrListingCancelOrder({
             data: {
-                UserID: userId, // 用户ID
-                AccountID: getFirstAccountId(), // 资金账号
+                UserID: userId.value, // 用户ID
+                AccountID: firstAccountId.value, // 资金账号
                 OldWRTradeOrderID: Long.fromString(wrtradeorderid || '0'), // 目标仓单贸易委托单ID
                 OrderSrc: 1, // 委托来源
                 ClientType: ClientType.Web, // 终端类型
-                OperatorID: userId, // 操作员账号ID
+                OperatorID: userId.value, // 操作员账号ID
                 BuyOrSell: buyorsell, // 买卖方向
                 ClientSerialNo: v4(),
                 ClientOrderTime: moment().format('YYYY-MM-DD HH:mm:ss')

+ 8 - 10
src/business/user/index.ts

@@ -1,11 +1,12 @@
 import { shallowRef, reactive } from 'vue'
 import { useDataTable } from '@/hooks/datatable'
 import { queryUserReceiveInfo, queryWrUserReceiptInfo, userReceiveInfo, delUserReceiveInfo, userReceiveIsDefault, userReceiptInfo, delUserReceiptInfo } from '@/services/api/user'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import { getCertificateTypeList } from '@/constants/certificate'
 
+const { userId } = loginStore.$mapGetters()
+
 export function useAddress() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.UserReceiveInfoRsp>()
     const loading = shallowRef(false)
 
@@ -13,7 +14,7 @@ export function useAddress() {
         loading.value = true
         return queryUserReceiveInfo({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
             },
             success: (res) => {
                 total.value = res.total
@@ -36,13 +37,12 @@ export function useAddress() {
 }
 
 export function useAddressForm(selectedRow?: Ermcp.UserReceiveInfoRsp) {
-    const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
     const certificateTypeList = getCertificateTypeList()
 
     const formData = reactive<Proto.UserReceiveInfoReq>({
         ReceiveInfoId: 0,
-        UserID: getUserId(),
+        UserID: userId.value,
         CardTypeID: 0,
         ReceiverName: '',
         CardNum: '',
@@ -94,7 +94,7 @@ export function useAddressForm(selectedRow?: Ermcp.UserReceiveInfoRsp) {
         loading.value = true
         return userReceiveIsDefault({
             data: {
-                UserId: getUserId(),
+                UserId: userId.value,
                 AutoId: formData.ReceiveInfoId
             },
             complete: () => {
@@ -114,7 +114,6 @@ export function useAddressForm(selectedRow?: Ermcp.UserReceiveInfoRsp) {
 }
 
 export function useInvoice() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.WrUserReceiptInfoRsp>()
     const loading = shallowRef(false)
 
@@ -122,7 +121,7 @@ export function useInvoice() {
         loading.value = true
         return queryWrUserReceiptInfo({
             data: {
-                userid: getUserId(),
+                userid: userId.value,
             },
             success: (res) => {
                 total.value = res.total
@@ -145,12 +144,11 @@ export function useInvoice() {
 }
 
 export function useInvoiceForm(selectedRow?: Ermcp.WrUserReceiptInfoRsp) {
-    const { getUserId } = useLoginStore()
     const loading = shallowRef(false)
     const certificateTypeList = getCertificateTypeList()
 
     const formData = reactive<Proto.UserReceiptInfoReq>({
-        UserID: getUserId(), // 用户ID
+        UserID: userId.value, // 用户ID
         UserName: '', // 发票抬头姓名
         ReceiptType: 1, // 发票类型
         TaxpayerID: '', // 纳税人识别号

+ 6 - 8
src/business/warehouse/index.ts

@@ -1,10 +1,11 @@
 import { shallowRef, reactive } from 'vue'
 import { useDataTable } from '@/hooks/datatable'
 import { queryWarehouseInfo, warehouseApply } from '@/services/api/warehouse'
-import { useUserStore, useLoginStore } from '@/stores'
+import { userStore, loginStore } from '@/stores'
+
+const { userId } = loginStore.$mapGetters()
 
 export function useWarehouse() {
-    const { getUserId } = useLoginStore()
     const { dataList, total, pageIndex, pageSize } = useDataTable<Ermcp.WarehouseInfoRsp>()
     const loading = shallowRef(false)
 
@@ -14,7 +15,7 @@ export function useWarehouse() {
             data: {
                 page: pageIndex.value,
                 pagesize: pageSize.value,
-                userid: getUserId(),
+                userid: userId.value,
             },
             success: (res) => {
                 total.value = res.total
@@ -37,13 +38,10 @@ export function useWarehouse() {
 }
 
 export function useWarehouseForm(selectedRow?: Ermcp.WarehouseInfoRsp) {
-    const { getUserId } = useLoginStore()
-    const { getAccountName } = useUserStore()
-
     const loading = shallowRef(false)
     const formData = reactive<Proto.WarehouseApplyReq>({
         type: selectedRow?.warehousecode ? 2 : 1,
-        userid: getUserId(),
+        userid: userId.value,
         warehousetype: 2,
         warehousecode: '',
         warehousename: '',
@@ -77,7 +75,7 @@ export function useWarehouseForm(selectedRow?: Ermcp.WarehouseInfoRsp) {
 
     return {
         loading,
-        accountName: getAccountName(),
+        accountName: userStore.getters.accountName,
         formData,
         addOrUpdate,
     }

+ 2 - 2
src/constants/bank.ts

@@ -1,6 +1,6 @@
-import { useEnumStore } from '@/stores'
+import { enumStore } from '@/stores'
 
-const { getEnumTypeList, getEnumTypeName } = useEnumStore()
+const { getEnumTypeList, getEnumTypeName } = enumStore.actions
 
 /**
  * 签约状态

+ 2 - 2
src/constants/certificate.ts

@@ -1,6 +1,6 @@
-import { useEnumStore } from '@/stores'
+import { enumStore } from '@/stores'
 
-const { getEnumTypeList, getEnumTypeName } = useEnumStore()
+const { getEnumTypeList, getEnumTypeName } = enumStore.actions
 
 /**
  * 获取证件类型列表

+ 2 - 2
src/constants/client.ts

@@ -1,6 +1,6 @@
-import { useEnumStore } from '@/stores'
+import { enumStore } from '@/stores'
 
-const { getEnumTypeList } = useEnumStore()
+const { getEnumTypeList } = enumStore.actions
 
 /**
  * 客户端类型

+ 2 - 2
src/constants/customs.ts

@@ -1,6 +1,6 @@
-import { useEnumStore } from '@/stores'
+import { enumStore } from '@/stores'
 
-const { getEnumTypeList, getEnumTypeName } = useEnumStore()
+const { getEnumTypeList, getEnumTypeName } = enumStore.actions
 
 /**
  * 获取检测账户类型列表

+ 2 - 2
src/constants/diamond.ts

@@ -1,6 +1,6 @@
-import { useEnumStore } from '@/stores'
+import { enumStore } from '@/stores'
 
-const { getEnumTypeList, getEnumTypeInfo } = useEnumStore()
+const { getEnumTypeList, getEnumTypeInfo } = enumStore.actions
 
 /**
  * 钻石类型

+ 2 - 2
src/constants/menu.ts

@@ -1,6 +1,6 @@
-import { useEnumStore } from '@/stores'
+import { enumStore } from '@/stores'
 
-const { getEnumTypeName } = useEnumStore()
+const { getEnumTypeName } = enumStore.actions
 
 /**
  * 权限类型

+ 4 - 5
src/constants/order.ts

@@ -1,7 +1,7 @@
-import { useEnumStore } from '@/stores'
-import { usePerformanceStore } from '@/stores'
+import { enumStore } from '@/stores'
+import { performanceStore } from '@/stores'
 
-const { getEnumTypeList, getEnumTypeName } = useEnumStore()
+const { getEnumTypeList, getEnumTypeName } = enumStore.actions
 
 /**
  * 买卖方向
@@ -90,8 +90,7 @@ export enum StepType {
  * @returns 
  */
 export function getStepTypeList() {
-    const { performanceStepTypes } = usePerformanceStore()
-    return performanceStepTypes.value.map((e) => ({
+    return performanceStore.state.performanceStepTypes.map((e) => ({
         label: e.steptypename,
         value: e.steptypeid,
     }))

+ 2 - 2
src/constants/receipt.ts

@@ -1,6 +1,6 @@
-import { useEnumStore } from '@/stores'
+import { enumStore } from '@/stores'
 
-const { getEnumTypeName } = useEnumStore()
+const { getEnumTypeName } = enumStore.actions
 
 /**
  * 发票类型

+ 2 - 3
src/hooks/echarts/candlestick/index.ts

@@ -2,13 +2,12 @@ import { ref, computed, watch } from 'vue'
 //import { timerInterceptor } from '@/utils/timer'
 import { ChartCycleType } from '@/constants/chart'
 import { queryHistoryDatas } from '@/services/api/quote'
-import { useFuturesStore } from '@/stores'
+import { futuresStore } from '@/stores'
 import { useDataset } from './dataset'
 import { useOptions } from './options'
 import moment from 'moment';
 
 export function useCandlestickChart(goodscode: string) {
-    const { getQuoteDayInfoByCode } = useFuturesStore()
     const { dataset, handleData, clearData, calcIndicator } = useDataset();
     const { options, initOptions, updateOptions } = useOptions(dataset);
 
@@ -16,7 +15,7 @@ export function useCandlestickChart(goodscode: string) {
     const isEmpty = ref(true);
     const dataIndex = ref(-1); // 当前数据索引值
     const cycleType = ref(ChartCycleType.Minutes);
-    const quote = getQuoteDayInfoByCode(goodscode); // 实时行情
+    const quote = futuresStore.actions.getQuoteDayInfoByCode(goodscode); // 实时行情
 
     // 当前选中的数据项
     const selectedItem = computed(() => {

+ 2 - 2
src/hooks/echarts/candlestick/options.ts

@@ -1,11 +1,11 @@
 import { reactive, watch } from 'vue'
 import { ECOption } from '@/components/base/echarts/core'
 import { timerInterceptor } from '@/utils/timer'
-import { useThemeStore } from '@/stores'
+import { themeStore } from '@/stores'
 import { EchartsDataset, EchartsOptions, Colors } from './interface'
 import moment from 'moment'
 
-const { appTheme } = useThemeStore();
+const { appTheme } = themeStore.$mapState();
 
 function getColors() {
     // 默认主题色配置

+ 2 - 3
src/hooks/echarts/timeline/index.ts

@@ -1,20 +1,19 @@
 import { ref, computed, watch } from 'vue'
 //import { timerInterceptor } from '@/utils/timer'
 import { queryTSData } from '@/services/api/quote'
-import { useFuturesStore } from '@/stores'
+import { futuresStore } from '@/stores'
 import { useDataset } from './dataset'
 import { useOptions } from './options'
 import moment from 'moment';
 
 export function useTimelineChart(goodscode: string) {
-    const { getQuoteDayInfoByCode } = useFuturesStore()
     const { dataset, handleData, clearData, calcIndicator } = useDataset();
     const { options, initOptions, updateOptions } = useOptions(dataset);
 
     const loading = ref(false);
     const isEmpty = ref(false);
     const dataIndex = ref(-1); // 当前数据索引值
-    const quote = getQuoteDayInfoByCode(goodscode); // 实时行情
+    const quote = futuresStore.actions.getQuoteDayInfoByCode(goodscode); // 实时行情
 
     // 当前选中的数据项
     const selectedItem = computed(() => {

+ 2 - 2
src/hooks/echarts/timeline/options.ts

@@ -1,10 +1,10 @@
 import { reactive, watch } from 'vue'
 import { timerInterceptor } from '@/utils/timer'
-import { useThemeStore } from '@/stores'
+import { themeStore } from '@/stores'
 import { echarts } from '@/components/base/echarts/core'
 import { EchartsDataset, EchartsOptions, Colors } from './interface'
 
-const { appTheme } = useThemeStore();
+const { appTheme } = themeStore.$mapState();
 
 function getColors() {
     // 默认主题色配置

+ 11 - 11
src/hooks/menu/index.ts

@@ -1,17 +1,17 @@
 import { defineAsyncComponent, Component } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
-import { useMenuStore } from '@/stores'
+import { menuStore } from '@/stores'
 import { AuthType } from '@/constants/menu'
 
 export function useMenu(authCode?: string) {
-    const { userMenus } = useMenuStore()
+    const { userRoutes } = menuStore.$mapState()
     const route = useRoute()
     const router = useRouter()
     const componentMap = new Map<string, Component>()
 
     // 过滤菜单
-    const filterMenu = (data: Ermcp.UserMenu[], parentPath = '') => {
-        const result: Ermcp.UserMenu[] = []
+    const filterMenu = (data: Ermcp.UserRoutes[], parentPath = '') => {
+        const result: Ermcp.UserRoutes[] = []
         data.forEach((e) => {
             if (!e.hidden && e.authType === AuthType.Menu) {
                 const routePath = (parentPath ? parentPath + '/' : '') + e.url
@@ -29,7 +29,7 @@ export function useMenu(authCode?: string) {
      * 根据 code 查找对应的子菜单
      * @returns 
      */
-    const findChildren = (data: Ermcp.UserMenu[], code?: string): Ermcp.UserMenu[] => {
+    const findChildren = (data: Ermcp.UserRoutes[], code?: string): Ermcp.UserRoutes[] => {
         const routeName = code ?? route.name?.toString()
         for (const item of data) {
             const { code, children } = item
@@ -49,13 +49,13 @@ export function useMenu(authCode?: string) {
      */
     const getMenus = (level = 0) => {
         // 过滤层级
-        const filterLevel = (data: Ermcp.UserMenu[], n: number): Ermcp.UserMenu[] => {
+        const filterLevel = (data: Ermcp.UserRoutes[], n: number): Ermcp.UserRoutes[] => {
             if (level) {
                 return data.map((e) => ({ ...e, children: n <= 1 ? [] : filterLevel(e.children ?? [], n - 1) }))
             }
             return data
         }
-        return filterMenu(filterLevel(userMenus.value, level))
+        return filterMenu(filterLevel(userRoutes.value, level))
     }
 
     /**
@@ -64,7 +64,7 @@ export function useMenu(authCode?: string) {
     * @returns 
     */
     const getChildrenMenus = (code?: string) => {
-        const children = findChildren(userMenus.value, code)
+        const children = findChildren(userRoutes.value, code)
         return filterMenu(children)
     }
 
@@ -73,7 +73,7 @@ export function useMenu(authCode?: string) {
      * @returns 
      */
     const getAuth = (authType: AuthType) => {
-        const children = findChildren(userMenus.value, authCode)
+        const children = findChildren(userRoutes.value, authCode)
         return children.reduce((res, cur) => {
             if (!cur.hidden && cur.authType === authType) {
                 if (!componentMap.get(cur.code) && cur.component) {
@@ -87,7 +87,7 @@ export function useMenu(authCode?: string) {
                 res.push(JSON.parse(JSON.stringify(cur)))
             }
             return res
-        }, [] as Ermcp.UserMenu[])
+        }, [] as Ermcp.UserRoutes[])
     }
 
     /**
@@ -129,7 +129,7 @@ export function useMenu(authCode?: string) {
     return {
         route,
         router,
-        userMenus,
+        userRoutes,
         componentMap,
         getMenus,
         getChildrenMenus,

+ 3 - 3
src/packages/mobile/router/index.ts

@@ -1,10 +1,10 @@
 import { createWebHashHistory, RouteRecordRaw } from 'vue-router'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import service from '@/services'
 import Page from '@mobile/components/layouts/page/index.vue'
 import animateRouter from './animateRouter'
 
-const { getToken } = useLoginStore()
+const { token } = loginStore.$mapGetters()
 
 const routes: Array<RouteRecordRaw> = [
   {
@@ -69,7 +69,7 @@ const router = animateRouter.create({
 router.beforeEach((to, from, next) => {
   // 判断服务是否加载完成
   if (service.isReady) {
-    if (to.meta.requireAuth && !getToken()) {
+    if (to.meta.requireAuth && !token.value) {
       next({
         name: 'login',
         query: { redirect: to.fullPath },

+ 3 - 3
src/packages/mobile/views/home/components/market/index.vue

@@ -36,14 +36,14 @@
 <script lang="ts" setup>
 import { ref, reactive, onActivated, onDeactivated } from 'vue'
 import { Grid, GridItem, Button, ActionSheet, ActionSheetAction } from 'vant'
-import { useFuturesStore, useThemeStore } from '@/stores'
+import { futuresStore, themeStore } from '@/stores'
 import { handlePriceColor, handleNoneValue } from '@/filters'
 import AppTable from '@mobile/components/base/table/index.vue'
 import { TableColumn } from '@mobile/components/base/table/interface'
 import subscribe from '@/services/subscribe'
 
-const { setTheme } = useThemeStore();
-const { quoteDayList } = useFuturesStore();
+const { setTheme } = themeStore.actions;
+const { quoteDayList } = futuresStore.$mapState();
 const quoteSubscribe = subscribe.addQuoteSubscribe(['cu2206', 'cu2207', 'cu2208', 'cu2209', 'cu2301', 'cu2303', 'cu2304']);
 const showAction = ref(false);
 

+ 3 - 4
src/packages/pc/App.vue

@@ -16,11 +16,11 @@ import { ref, watch } from 'vue'
 import { useRouter, useRoute } from 'vue-router'
 import { ElMessageBox } from 'element-plus'
 import { logout } from '@/business/common'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import zhCn from 'element-plus/lib/locale/lang/zh-cn'
 import eventBus from '@/services/bus'
 
-const { getToken } = useLoginStore()
+const { token } = loginStore.$mapGetters()
 const route = useRoute()
 const router = useRouter()
 const hasLogin = ref(false)
@@ -36,8 +36,7 @@ eventBus.$on('LogoutNotify', (msg) => {
 })
 
 watch(() => route.name, (routeName) => {
-  const token = getToken()
-  if (routeName === 'boot' || routeName === 'login' || !token) {
+  if (routeName === 'boot' || routeName === 'login' || !token.value) {
     hasLogin.value = false
   } else {
     hasLogin.value = true

+ 4 - 4
src/packages/pc/components/layouts/header/index.vue

@@ -26,8 +26,8 @@
             </div>
             <el-dropdown class="user-dropdown" trigger="click">
                 <span class="user-dropdown__link">
-                    <img class="g-image--avatar" :title="getAccountName()" />
-                    <span v-if="!state.isMobile">{{ getAccountName() }}</span>
+                    <img class="g-image--avatar" :title="accountName" />
+                    <span v-if="!state.isMobile">{{ accountName }}</span>
                     <app-icon class="el-icon--right" icon="ArrowDown" />
                 </span>
                 <template #dropdown>
@@ -47,7 +47,7 @@
 import { ref, onMounted, defineAsyncComponent } from 'vue'
 import { useRouter } from 'vue-router'
 import client from '@/utils/client'
-import { useUserStore } from '@/stores'
+import { userStore } from '@/stores'
 import { useAuth } from '@/business/auth'
 import { useComponent } from '@/hooks/component'
 import { useNotice } from '@/business/notice'
@@ -63,7 +63,7 @@ const { componentId, openComponent, closeComponent } = useComponent()
 const { dataList, unreadList, getNoticeList } = useNotice()
 const { state } = client
 const { logout } = useAuth()
-const { getAccountName } = useUserStore()
+const { accountName } = userStore.$mapGetters()
 const router = useRouter()
 const fullScreen = ref(false)
 

+ 2 - 2
src/packages/pc/components/layouts/page/index.vue

@@ -38,11 +38,11 @@ import AppSidebar from '../sidebar/index.vue'
 
 const { route, router, getChildrenMenus } = useMenu()
 const isCollapse = shallowRef(client.state.isMobile)
-const secondMenus = shallowRef<Ermcp.UserMenu[]>([]) // 二级菜单
+const secondMenus = shallowRef<Ermcp.UserRoutes[]>([]) // 二级菜单
 const dataIndex = shallowRef(-1) // 选中的标签
 
 // 切换标签
-const onTabChange = (index: number, { code }: Ermcp.UserMenu) => {
+const onTabChange = (index: number, { code }: Ermcp.UserRoutes) => {
   router.push({ name: code })
 }
 

+ 1 - 1
src/packages/pc/components/layouts/sidemenu/submenu.vue

@@ -35,7 +35,7 @@ export default defineComponent({
     emits: ['click'],
     props: {
         dataList: {
-            type: Array as PropType<Ermcp.UserMenu[]>,
+            type: Array as PropType<Ermcp.UserRoutes[]>,
             required: true,
         },
     },

+ 1 - 1
src/packages/pc/components/modules/action-menu/index.vue

@@ -58,7 +58,7 @@ import { ActionMenu } from './interface'
 const props = defineProps({
     // 操作菜单
     menus: {
-        type: Array as PropType<Ermcp.UserMenu[]>,
+        type: Array as PropType<Ermcp.UserRoutes[]>,
         required: true,
     },
     // 操作类型

+ 2 - 3
src/packages/pc/components/modules/address/index.vue

@@ -9,7 +9,7 @@
 <script lang="ts" setup>
 import { shallowRef } from 'vue'
 import { queryUserReceiveInfo } from '@/services/api/user'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 
 const props = defineProps({
     modelValue: Number,
@@ -19,7 +19,6 @@ const props = defineProps({
     }
 })
 
-const { getUserId } = useLoginStore()
 const emit = defineEmits(['update:modelValue', 'change'])
 const dataList = shallowRef<Ermcp.UserReceiveInfoRsp[]>([])
 const selectedItem = shallowRef<Ermcp.UserReceiveInfoRsp>()
@@ -31,7 +30,7 @@ const onChange = (item?: Ermcp.UserReceiveInfoRsp) => {
 
 queryUserReceiveInfo({
     data: {
-        userid: getUserId()
+        userid: loginStore.getters.userId
     },
     success: (res) => {
         dataList.value = res.data

+ 1 - 1
src/packages/pc/components/modules/auth-component/index.vue

@@ -43,7 +43,7 @@ const props = defineProps({
 const { componentMap, getAuthComponents } = useMenu(props.code)
 const { onChange } = useAttrs()
 const componentId = shallowRef<string>()
-const dataList = shallowRef<Ermcp.UserMenu[]>([]) // 数据列表
+const dataList = shallowRef<Ermcp.UserRoutes[]>([]) // 数据列表
 
 const onTabChange = (code: string) => {
     if (componentId.value !== code) {

+ 1 - 1
src/packages/pc/components/modules/auth-operation/index.vue

@@ -80,7 +80,7 @@ const props = defineProps({
 const { componentMap, getAuthButtons } = useMenu(props.code);
 const componentId = shallowRef<string>();
 const contextmenuOption = shallowRef(props.contextmenu);
-const auth = shallowRef<Ermcp.UserMenu[]>([]);
+const auth = shallowRef<Ermcp.UserRoutes[]>([]);
 
 // 数据列表
 const dataList = computed(() => {

+ 2 - 3
src/packages/pc/components/modules/invoice/index.vue

@@ -10,7 +10,7 @@
 import { shallowRef } from 'vue'
 import { getReceiptTypeName } from '@/constants/receipt'
 import { queryWrUserReceiptInfo } from '@/services/api/user'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 
 const props = defineProps({
     modelValue: Number,
@@ -20,7 +20,6 @@ const props = defineProps({
     }
 })
 
-const { getUserId } = useLoginStore()
 const emit = defineEmits(['update:modelValue', 'change'])
 const dataList = shallowRef<Ermcp.WrUserReceiptInfoRsp[]>([])
 const selectedItem = shallowRef<Ermcp.WrUserReceiptInfoRsp>()
@@ -32,7 +31,7 @@ const onChange = (item?: Ermcp.WrUserReceiptInfoRsp) => {
 
 queryWrUserReceiptInfo({
     data: {
-        userid: getUserId()
+        userid: loginStore.getters.userId
     },
     success: (res) => {
         dataList.value = res.data

+ 2 - 2
src/packages/pc/components/modules/performance/index.vue

@@ -11,7 +11,7 @@
 
 <script lang="ts" setup>
 import { shallowRef } from 'vue'
-import { usePerformanceStore } from '@/stores'
+import { performanceStore } from '@/stores'
 import AppPerformanceRule from '../performance-rule/index.vue'
 
 const props = defineProps({
@@ -23,7 +23,7 @@ const props = defineProps({
 })
 
 const emit = defineEmits(['update:modelValue'])
-const { performanceTemplates } = usePerformanceStore()
+const { performanceTemplates } = performanceStore.$mapState()
 const selectedItem = shallowRef<Ermcp.PermancePlanTmpRsp>()
 
 const onChange = (item: Ermcp.PermancePlanTmpRsp) => {

+ 1 - 3
src/packages/pc/main.ts

@@ -5,7 +5,7 @@ import directives from '@/directives' // 自定义指令集
 import '@/services/subscribe' // 全局订阅通知
 import '@/mock' // 模拟数据
 import client from '@/utils/client' // 适配客户端
-import { useLanguageStore } from '@/stores' // 国际化语言
+import { i18n } from '@/stores' // 国际化语言
 import layouts from "./components/layouts" // 布局组件
 import ElementPlus from 'element-plus'
 import * as ElementIcons from '@element-plus/icons-vue'
@@ -13,8 +13,6 @@ import 'element-plus/dist/index.css'
 import './assets/themes/style.less' // 主题样式
 import { timerInterceptor } from '@/utils/timer'
 
-const { i18n } = useLanguageStore()
-
 const app = createApp(App)
 app.use(router)
 app.use(directives)

+ 3 - 4
src/packages/pc/router/dynamicRouter.ts

@@ -1,6 +1,6 @@
 import { RouteRecordRaw } from 'vue-router'
 import { AuthType } from '@/constants/menu'
-import { useMenuStore } from '@/stores'
+import { menuStore } from '@/stores'
 import router from '../router'
 
 export default new (class {
@@ -23,7 +23,7 @@ export default new (class {
      * @param routes 
      * @param parentName 
      */
-    private addRoutes(routes: Ermcp.UserMenu[], parentName = '') {
+    private addRoutes(routes: Ermcp.UserRoutes[], parentName = '') {
         routes.forEach((item) => {
             if (item.authType === AuthType.Menu && item.component) {
                 let component;
@@ -68,9 +68,8 @@ export default new (class {
      * @returns 
      */
     registerRoutes() {
-        const { userMenus } = useMenuStore();
         this.addNotFound();
-        this.addRoutes(userMenus.value);
+        this.addRoutes(menuStore.state.userRoutes);
         this.isReady = true;
     }
 })

+ 4 - 4
src/packages/pc/router/index.ts

@@ -1,14 +1,14 @@
 import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import dynamicRouter from './dynamicRouter'
 import service from '@/services'
 
-const { getToken } = useLoginStore()
+const { token } = loginStore.$mapGetters()
 
 const routes: Array<RouteRecordRaw> = [
     {
         path: '/',
-        redirect: () => getToken() ? '/home' : '/login', // 重定向到默认页面
+        redirect: () => token.value ? '/home' : '/login', // 重定向到默认页面
     },
     {
         path: '/login',
@@ -59,7 +59,7 @@ router.beforeEach((to, from, next) => {
 
     // 判断服务是否加载完成
     if (service.isReady) {
-        if (getToken()) {
+        if (token.value) {
             if (dynamicRouter.isReady) {
                 if (isLoginOrRegister) {
                     next('/');

+ 3 - 5
src/packages/pc/views/boot/index.vue

@@ -6,14 +6,12 @@
 import { ref } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { initBaseData, checkToken, checkTokenLoop } from '@/business/common'
-import { useEnumStore, useErrorInfoStore } from '@/stores'
+import { enumStore, errorInfoStore } from '@/stores'
 import service from '@/services'
 import socket from '@/services/socket'
 
 const route = useRoute()
 const router = useRouter()
-const { getAllEnumList } = useEnumStore()
-const { getErrorInfoList } = useErrorInfoStore()
 const loading = ref(true)
 
 // 初始化数据
@@ -21,9 +19,9 @@ const onLoad = (async () => {
   // 等待服务初始化
   await service.onReady()
   // 等待请求枚举
-  await getAllEnumList()
+  await enumStore.actions.getAllEnumList()
   // 等待请求系统错误信息
-  await getErrorInfoList()
+  await errorInfoStore.actions.getErrorInfoList()
   // 等待连接交易服务
   await socket.connectTrade()
   // 等待令牌效验

+ 2 - 2
src/packages/pc/views/customs/bonded/components/advance-payment/index.vue

@@ -22,7 +22,7 @@
 <script lang="ts" setup>
 import { shallowRef, PropType, computed } from 'vue'
 import { ElMessage } from 'element-plus'
-import { useAccountStore } from '@/stores'
+import { accountStore } from '@/stores'
 import { useBSFWOrderOperate, useBSFWMemberOperate } from '@/business/customs/bonded'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
@@ -35,7 +35,7 @@ const props = defineProps({
 
 const { details, getFworderoperate } = useBSFWOrderOperate(props.selectedRow)
 const { loading, formData, formSubmit } = useBSFWMemberOperate(props.selectedRow.orderid)
-const { avaiableMoney } = useAccountStore()
+const { avaiableMoney } = accountStore.$mapGetters()
 const show = shallowRef(true)
 const refresh = shallowRef(false)
 

+ 2 - 2
src/packages/pc/views/customs/bonded/components/payment/index.vue

@@ -26,7 +26,7 @@
 <script lang="ts" setup>
 import { shallowRef, PropType, computed } from 'vue'
 import { ElMessage } from 'element-plus'
-import { useAccountStore } from '@/stores'
+import { accountStore } from '@/stores'
 import { useBSFWOrderOperate, useBSFWMemberOperate } from '@/business/customs/bonded'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
@@ -39,7 +39,7 @@ const props = defineProps({
 
 const { details, getFworderoperate } = useBSFWOrderOperate(props.selectedRow)
 const { loading, formData, formSubmit } = useBSFWMemberOperate(props.selectedRow.orderid)
-const { avaiableMoney } = useAccountStore()
+const { avaiableMoney } = accountStore.$mapGetters()
 const show = shallowRef(true)
 const refresh = shallowRef(false)
 

+ 2 - 2
src/packages/pc/views/customs/exit/components/advance-payment/index.vue

@@ -23,7 +23,7 @@
 <script lang="ts" setup>
 import { shallowRef, PropType, computed } from 'vue'
 import { ElMessage } from 'element-plus'
-import { useAccountStore } from '@/stores'
+import { accountStore } from '@/stores'
 import { useCJJCOrderOperate, useCJJCMemberOperate } from '@/business/customs/exit'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
@@ -36,7 +36,7 @@ const props = defineProps({
 
 const { details, getGzcjjcorderoperate } = useCJJCOrderOperate(props.selectedRow)
 const { loading, formData, formSubmit } = useCJJCMemberOperate(props.selectedRow.orderidstr)
-const { avaiableMoney } = useAccountStore()
+const { avaiableMoney } = accountStore.$mapGetters()
 const show = shallowRef(true)
 const refresh = shallowRef(false)
 

+ 1 - 2
src/packages/pc/views/customs/exit/components/edit/detail-edit/index.vue

@@ -56,7 +56,7 @@
 <script lang="ts" setup>
 import { ref, PropType, computed } from 'vue'
 import type { FormInstance, FormRules } from 'element-plus'
-import { useEnumStore } from '@/stores'
+import { enumMap } from '@/stores'
 import { getGZCJShapeTypeList, getGZCJMarkTypeList, getGZCJPublishTypeList } from '@/constants/customs'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
@@ -71,7 +71,6 @@ const props = defineProps({
 })
 
 const emit = defineEmits(['update'])
-const { enumMap } = useEnumStore()
 const show = ref(true)
 const formRef = ref<FormInstance>()
 const formItem = ref<Partial<Proto.GZCJCategoryDetail>>({ ...props.detail })

+ 6 - 0
src/packages/pc/views/customs/exit/components/edit/index.less

@@ -7,4 +7,10 @@
         padding: 15px;
         margin-bottom: 20px;
     }
+
+    &__table {
+        .el-button {
+            margin-left: 0;
+        }
+    }
 }

+ 20 - 6
src/packages/pc/views/customs/exit/components/edit/index.vue

@@ -65,11 +65,11 @@
             v-if="formData.GZCJAccountType === 2 ? !!formData.GZCJCategoryType : !!formData.GZCJAccountType">
             <app-table :data="formData.GZCJCategoryDetails" :columns="columns" :max-height="400" border>
                 <template #toolbar>
-                    <el-button-group>
-                        <!-- <el-button size="small">导入</el-button> -->
-                        <el-button size="small" @click="openEdit()">新增</el-button>
-                        <el-button size="small" @click="clearList()">清空</el-button>
-                    </el-button-group>
+                    <el-upload accept=".xlsx,.xls" :show-file-list="false" :auto-upload="false" @change="handleExcel">
+                        <el-button size="small">导入</el-button>
+                    </el-upload>
+                    <el-button size="small" @click="openEdit()">新增</el-button>
+                    <el-button size="small" @click="clearList()">清空</el-button>
                 </template>
                 <!-- 形状 -->
                 <template #GZCJShapeType="{ value }">
@@ -107,7 +107,8 @@
 <script lang="ts" setup>
 import { ref, computed, onMounted, defineAsyncComponent, PropType } from 'vue'
 import { ElMessage } from 'element-plus'
-import type { FormInstance, FormRules, } from 'element-plus'
+import type { FormInstance, FormRules, UploadFile } from 'element-plus'
+import { read, utils } from 'xlsx'
 import { useComponent } from '@/hooks/component'
 import { validateRules } from '@/constants/regex'
 import { getGZCJAccountTypeList, getGZCJCategoryTypeList, getGZCJDeliveryTypeList, getGZCJShapeTypeName, getGZCJPublishTypeName, getGZCJMarkTypeName, getGZCJServiceTypeName } from '@/constants/customs'
@@ -263,6 +264,19 @@ const deleteDetail = (index: number) => {
     formData.GZCJCategoryDetails?.forEach((e, i) => e.OrderIndex = i + 1) // 重置序列
 }
 
+// 处理导入的excel表格
+const handleExcel = (uploadFile: UploadFile) => {
+    const fileReader = new FileReader()
+    fileReader.readAsBinaryString(uploadFile.raw as Blob)
+    fileReader.onload = (ev) => {
+        const data = ev.target?.result
+        if (data) {
+            const workbook = read(data, { type: 'binary' })
+            console.log(workbook)
+        }
+    }
+}
+
 // 更新列表数据
 const onUpdate = (item: Proto.GZCJCategoryDetail) => {
     const { GZCJCategoryDetails = [] } = formData

+ 2 - 2
src/packages/pc/views/customs/exit/components/payment/index.vue

@@ -27,7 +27,7 @@
 <script lang="ts" setup>
 import { shallowRef, PropType, computed } from 'vue'
 import { ElMessage } from 'element-plus'
-import { useAccountStore } from '@/stores'
+import { accountStore } from '@/stores'
 import { useCJJCOrderOperate, useCJJCMemberOperate } from '@/business/customs/exit'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
@@ -40,7 +40,7 @@ const props = defineProps({
 
 const { details, getGzcjjcorderoperate } = useCJJCOrderOperate(props.selectedRow)
 const { loading, formData, formSubmit } = useCJJCMemberOperate(props.selectedRow.orderidstr)
-const { avaiableMoney } = useAccountStore()
+const { avaiableMoney } = accountStore.$mapGetters()
 const show = shallowRef(true)
 const refresh = shallowRef(false)
 

+ 2 - 3
src/packages/pc/views/favorite/main/components/cancel/index.vue

@@ -13,7 +13,7 @@
 import { shallowRef, PropType } from 'vue'
 import { ElMessage } from 'element-plus'
 import { useDiamondFavorite } from '@/business/goods'
-import { useFavoriteStore } from '@/stores'
+import { favoriteStore } from '@/stores'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
 const props = defineProps({
@@ -24,7 +24,6 @@ const props = defineProps({
 })
 
 const { loading, formSubmit } = useDiamondFavorite(props.selectedRow)
-const { getFavoriteList } = useFavoriteStore()
 const show = shallowRef(true)
 const refresh = shallowRef(false)
 
@@ -36,7 +35,7 @@ const onCancel = (isRefresh = false) => {
 const onSubmit = () => {
     formSubmit(2).then(() => {
         ElMessage.success('提交成功')
-        getFavoriteList()
+        favoriteStore.actions.getFavoriteList()
         onCancel(true)
     }).catch((err) => {
         ElMessage.error('提交失败:' + err)

+ 2 - 2
src/packages/pc/views/mine/profile/index.vue

@@ -49,10 +49,10 @@ import { decryptAES } from '@/utils/websocket/crypto'
 import { handleNoneValue } from '@/filters'
 import { getCertificateTypeName } from '@/constants/certificate'
 import { SignStatus, getSignStatusName } from '@/constants/bank'
-import { useAccountStore } from '@/stores'
+import { accountStore } from '@/stores'
 import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
 
-const { accountInfo, avaiableMoney, freezeMargin } = useAccountStore()
+const { accountInfo, avaiableMoney, freezeMargin } = accountStore.$mapGetters()
 const { loading, loginInfo, userInfo, bankInfo, getBankAccountSign } = useAccount()
 
 const handleTableButtons = computed(() => {

+ 2 - 4
src/packages/pc/views/search/diamond/index.vue

@@ -77,7 +77,7 @@ import { ref } from 'vue'
 import { ElMessage } from 'element-plus'
 import type { FormInstance, FormRules } from 'element-plus'
 import { formatDecimal } from '@/filters'
-import { useLoginStore, useFavoriteStore } from '@/stores'
+import { loginStore, favoriteStore } from '@/stores'
 import { useSearch } from '@/business/search'
 import { Category } from '@/constants/diamond'
 import { useComposeTable } from '@pc/components/base/table'
@@ -86,8 +86,6 @@ import AppTable from '@pc/components/base/table/index.vue'
 import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
 import AppPagination from '@pc/components/base/pagination/index.vue'
 
-const { getUserId } = useLoginStore()
-const { hasFavorite } = useFavoriteStore()
 const { loading, dataList, total, pageIndex, pageSize, formData, enums, getSellOrderList, onSearch, onReset } = useSearch(Category.Diamond)
 const { tableColumns } = useComposeTable<Ermcp.SellOrderSearchRsp>({ rowKey: 'wrtradeorderid', columnKey: 'listing_sellorder' })
 const formRef = ref<FormInstance>()
@@ -115,7 +113,7 @@ const formRules: FormRules = {
 
 // 未收藏的卖委托有收藏按钮
 const handleOperateButtons = (row: Ermcp.SellOrderSearchRsp) => {
-    if (hasFavorite(row.goodsno) || row.userid === getUserId()) {
+    if (favoriteStore.actions.hasFavorite(row.goodsno) || row.userid === loginStore.getters.userId) {
         return ['search_diamond_details']
     }
     return ['search_diamond_details', 'search_diamond_favorite']

+ 2 - 4
src/packages/pc/views/search/fancy/index.vue

@@ -73,7 +73,7 @@
 import { ref } from 'vue'
 import type { FormInstance, FormRules } from 'element-plus'
 import { formatDecimal } from '@/filters'
-import { useLoginStore, useFavoriteStore } from '@/stores'
+import { loginStore, favoriteStore } from '@/stores'
 import { useSearch } from '@/business/search'
 import { Category } from '@/constants/diamond'
 import { useComposeTable } from '@pc/components/base/table'
@@ -82,8 +82,6 @@ import AppTable from '@pc/components/base/table/index.vue'
 import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
 import AppPagination from '@pc/components/base/pagination/index.vue'
 
-const { getUserId } = useLoginStore()
-const { hasFavorite } = useFavoriteStore()
 const { loading, dataList, total, pageIndex, pageSize, formData, enums, getSellOrderList, onSearch, onReset } = useSearch(Category.Fancy)
 const { tableColumns } = useComposeTable<Ermcp.SellOrderSearchRsp>({ rowKey: 'wrtradeorderid', columnKey: 'listing_sellorder' })
 const formRef = ref<FormInstance>()
@@ -111,7 +109,7 @@ const formRules: FormRules = {
 
 // 未收藏的卖委托有收藏按钮
 const handleOperateButtons = (row: Ermcp.SellOrderSearchRsp) => {
-    if (hasFavorite(row.goodsno) || row.userid === getUserId()) {
+    if (favoriteStore.actions.hasFavorite(row.goodsno) || row.userid === loginStore.getters.userId) {
         return ['search_fancy_details']
     }
     return ['search_fancy_details', 'search_fancy_favorite']

+ 2 - 2
src/packages/pc/views/trade/bargain/components/details/index.vue

@@ -84,7 +84,7 @@ export default defineComponent({
 <script lang="ts" setup>
 import { PropType, computed } from 'vue'
 import { handleNoneValue } from '@/filters'
-import { usePerformanceStore } from '@/stores'
+import { performanceStore } from '@/stores'
 import AppGoods from '@pc/views/warehousing/goods/components/details/index.vue'
 import AppPerformanceRule from '@pc/components/modules/performance-rule/index.vue'
 import AppIcon from '@pc/components/base/icon/index.vue'
@@ -96,7 +96,7 @@ const props = defineProps({
     },
 })
 
-const { getPerformanceTemplateById } = usePerformanceStore()
+const { getPerformanceTemplateById } = performanceStore.actions
 
 const details = computed(() => {
     if ('buywrtradeorderid' in props.selectedRow) {

+ 3 - 3
src/packages/pc/views/trade/buy/components/delisting/index.vue

@@ -23,7 +23,7 @@
                     <el-input type="number" placeholder="请输入" v-model="formData.ApplyPrice" />
                     <span style="white-space:nowrap;"
                         v-if="selectedGoods && selectedGoods.zscurrencytype !== CurrencyType.CNY">汇率:{{
-                                getExrate(selectedGoods.zscurrencytype)
+                            getExrate(selectedGoods.zscurrencytype)
                         }}</span>
                 </div>
             </el-form-item>
@@ -45,7 +45,7 @@ import type { FormInstance, FormRules } from 'element-plus'
 import { formatDecimal } from '@/filters'
 import { CurrencyType } from '@/constants/diamond'
 import { useSellOrderBargain } from '@/business/trade/desting'
-import { useExrateStore } from '@/stores'
+import { exrateStore } from '@/stores'
 import AppTable from '@pc/components/base/table/index.vue'
 
 const props = defineProps({
@@ -55,7 +55,7 @@ const props = defineProps({
     }
 })
 
-const { getExrate } = useExrateStore()
+const { getExrate } = exrateStore.actions
 const { loading, dataList, columns, formData, formSubmit, getDiamondList } = useSellOrderBargain(props.selectedRow)
 const selectedGoods = ref<Ermcp.MyWRPositionRsp>() // 当前选中的商品
 const formRef = ref<FormInstance>()

+ 3 - 4
src/packages/pc/views/trade/buy/components/details/index.vue

@@ -87,7 +87,7 @@ export default defineComponent({
 import { computed, PropType } from 'vue'
 import { handleNoneValue } from '@/filters'
 import { useMenu } from '@/hooks/menu'
-import { useLoginStore, usePerformanceStore } from '@/stores'
+import { loginStore, performanceStore } from '@/stores'
 import AppPerformanceRule from '@pc/components/modules/performance-rule/index.vue'
 import AppIcon from '@pc/components/base/icon/index.vue'
 
@@ -103,14 +103,13 @@ const props = defineProps({
     }
 })
 
-const { getUserId } = useLoginStore()
 const { componentMap, getAuthComponents } = useMenu(props.code)
-const { getPerformanceTemplateById } = usePerformanceStore()
+const { getPerformanceTemplateById } = performanceStore.actions
 const components = getAuthComponents()
 
 // 不能购买自己发布的求购
 const showComponent = computed(() => {
-    return props.selectedRow.userid !== getUserId()
+    return props.selectedRow.userid !== loginStore.getters.userId
 })
 </script>
 

+ 3 - 4
src/packages/pc/views/trade/purchase/components/details/index.vue

@@ -101,7 +101,7 @@ export default defineComponent({
 import { PropType, shallowRef } from 'vue'
 import { formatDecimal, handleNoneValue } from '@/filters'
 import { getApplyStatusName } from '@/constants/order'
-import { useLoginStore, usePerformanceStore } from '@/stores'
+import { loginStore, performanceStore } from '@/stores'
 import { queryMyDelistingApply } from '@/services/api/trade'
 import AppTable from '@pc/components/base/table/index.vue'
 import AppPerformanceRule from '@pc/components/modules/performance-rule/index.vue'
@@ -118,8 +118,7 @@ const props = defineProps({
     },
 })
 
-const { getUserId } = useLoginStore()
-const { getPerformanceTemplateById } = usePerformanceStore()
+const { getPerformanceTemplateById } = performanceStore.actions
 
 const dataList = shallowRef<Ermcp.MyDelistingApplyRsp[]>([])
 const columns = shallowRef<Ermcp.TableColumn[]>([
@@ -135,7 +134,7 @@ const columns = shallowRef<Ermcp.TableColumn[]>([
 queryMyDelistingApply({
     data: {
         type: 1,
-        userid: getUserId(),
+        userid: loginStore.getters.userId,
         buywrtradeorderid: props.selectedRow.wrtradeorderid
     },
     success: (res) => {

+ 3 - 4
src/packages/pc/views/trade/sale/components/details/index.vue

@@ -93,7 +93,7 @@ export default defineComponent({
 import { PropType, shallowRef } from 'vue'
 import { formatDecimal } from '@/filters'
 import { getApplyStatusName } from '@/constants/order'
-import { useLoginStore, usePerformanceStore } from '@/stores'
+import { loginStore, performanceStore } from '@/stores'
 import { queryMyBargainApply } from '@/services/api/trade'
 import AppTable from '@pc/components/base/table/index.vue'
 import AppPerformanceRule from '@pc/components/modules/performance-rule/index.vue'
@@ -110,8 +110,7 @@ const props = defineProps({
     },
 })
 
-const { getUserId } = useLoginStore()
-const { getPerformanceTemplateById } = usePerformanceStore()
+const { getPerformanceTemplateById } = performanceStore.actions
 
 const dataList = shallowRef<Ermcp.MyBargainApplyRsp[]>([])
 const columns = shallowRef<Ermcp.TableColumn[]>([
@@ -125,7 +124,7 @@ const columns = shallowRef<Ermcp.TableColumn[]>([
 queryMyBargainApply({
     data: {
         type: 1,
-        userid: getUserId(),
+        userid: loginStore.getters.userId,
         wrtradeorderid: props.selectedRow.wrtradeorderid
     },
     success: (res) => {

+ 2 - 4
src/packages/pc/views/trade/sell/index.vue

@@ -31,7 +31,7 @@
 import { ElMessage } from 'element-plus'
 import { formatDecimal } from '@/filters'
 import { useDataFilter } from '@/hooks/datatable'
-import { useLoginStore, useFavoriteStore } from '@/stores'
+import { loginStore, favoriteStore } from '@/stores'
 import { useSellOrder } from '@/business/trade/list'
 import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
 import { useComposeTable } from '@pc/components/base/table'
@@ -39,15 +39,13 @@ import AppTable from '@pc/components/base/table/index.vue'
 import AppPagination from '@pc/components/base/pagination/index.vue'
 import AppFilter from '@pc/components/base/table-filter/index.vue'
 
-const { getUserId } = useLoginStore()
-const { hasFavorite } = useFavoriteStore()
 const { loading, dataList, total, pageIndex, pageSize, categoryList, getSellOrderList } = useSellOrder()
 const { tableColumns } = useComposeTable<Ermcp.SellOrderRsp>({ rowKey: 'wrtradeorderid', columnKey: 'listing_sellorder' })
 const { filterOptons, getQueryParams } = useDataFilter<Ermcp.SellOrderReq>()
 
 // 未收藏的卖委托有收藏按钮
 const handleOperateButtons = (row: Ermcp.SellOrderRsp) => {
-    if (hasFavorite(row.goodsno) || row.userid === getUserId()) {
+    if (favoriteStore.actions.hasFavorite(row.goodsno) || row.userid === loginStore.getters.userId) {
         return ['trade_sell_details']
     }
     return ['trade_sell_details', 'trade_sell_favorite']

+ 3 - 3
src/packages/pc/views/warehousing/goods/components/bargain/index.vue

@@ -6,7 +6,7 @@
                 <div class="el-form-item--col">
                     <el-input type="number" placeholder="请输入" v-model="formData.ApplyPrice" />
                     <span style="white-space:nowrap;"
-                        v-if="selectedRow.zscurrencytype !== CurrencyType.CNY">汇率:{{getExrate(selectedRow.zscurrencytype)}}</span>
+                        v-if="selectedRow.zscurrencytype !== CurrencyType.CNY">汇率:{{ getExrate(selectedRow.zscurrencytype) }}</span>
                 </div>
             </el-form-item>
             <el-form-item label="备注" prop="ApplyRemark">
@@ -25,7 +25,7 @@ import { ref, PropType } from 'vue'
 import { ElMessage } from 'element-plus'
 import type { FormInstance, FormRules } from 'element-plus'
 import { CurrencyType } from '@/constants/diamond'
-import { useExrateStore } from '@/stores'
+import { exrateStore } from '@/stores'
 import { useBuyOrderBargain } from '@/business/trade/desting'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
@@ -36,7 +36,7 @@ const props = defineProps({
     }
 })
 
-const { getExrate } = useExrateStore()
+const { getExrate } = exrateStore.actions
 const { loading, formData, formSubmit } = useBuyOrderBargain(props.selectedRow)
 const formRef = ref<FormInstance>()
 const show = ref(true)

+ 11 - 10
src/packages/pc/views/warehousing/goods/components/details/index.vue

@@ -19,8 +19,9 @@
                             </li>
                             <li>
                                 <span>仓库地址</span>
-                                <span>{{ [details.provincename, details.cityname, details.districtname,
-                                    details.address].join(' ')
+                                <span>{{
+                                    [details.provincename, details.cityname, details.districtname,
+                                        details.address].join(' ')
                                 }}</span>
                             </li>
                         </ul>
@@ -50,7 +51,8 @@
                             </li>
                             <li>
                                 <span>市场价:</span>
-                                <span>{{ details.zscurrencytypedisplayunit + formatDecimal(details.marketprice)
+                                <span>{{
+                                    details.zscurrencytypedisplayunit + formatDecimal(details.marketprice)
                                 }}</span>
                             </li>
                         </ul>
@@ -58,7 +60,7 @@
                     <div class="sku-price">
                         <span>{{ exchangeRate(details.zscurrencytype, details.price) }}</span>
                         <span v-if="details.zscurrencytype !== CurrencyType.CNY">汇率: {{
-                                getExrate(details.zscurrencytype)
+                            getExrate(details.zscurrencytype)
                         }}</span>
                     </div>
                     <div class="sku-button" v-if="showButton && details.wrtradeorderid">
@@ -135,7 +137,7 @@ export default defineComponent({
 import { computed, PropType, defineAsyncComponent } from 'vue'
 import { getImageUrl, formatDecimal, handleNoneValue } from '@/filters'
 import { CurrencyType } from '@/constants/diamond'
-import { useLoginStore, useFavoriteStore, useExrateStore, usePerformanceStore } from '@/stores'
+import { loginStore, favoriteStore, exrateStore, performanceStore } from '@/stores'
 import { useComponent } from '@/hooks/component'
 import { useDiamondDetails } from '@/business/goods'
 import AppPerformanceRule from '@pc/components/modules/performance-rule/index.vue'
@@ -159,10 +161,9 @@ const props = defineProps({
 })
 
 const emit = defineEmits(['closed'])
-const { getUserId } = useLoginStore()
-const { getExrate, exchangeRate } = useExrateStore()
-const { hasFavorite } = useFavoriteStore()
-const { getPerformanceTemplateById } = usePerformanceStore()
+const { getExrate, exchangeRate } = exrateStore.actions
+const { hasFavorite } = favoriteStore.actions
+const { getPerformanceTemplateById } = performanceStore.actions
 const { details, getDiamondDetails } = useDiamondDetails(props.selectedRow.goodsno)
 
 const { componentId, openComponent, closeComponent } = useComponent((componentName) => {
@@ -177,7 +178,7 @@ const { componentId, openComponent, closeComponent } = useComponent((componentNa
 // 不能购买自己上架的商品
 const showButton = computed(() => {
     if (details.value) {
-        return details.value.userid !== getUserId()
+        return details.value.userid !== loginStore.getters.userId
     }
     return false
 })

+ 2 - 3
src/packages/pc/views/warehousing/goods/components/favorite/index.vue

@@ -12,7 +12,7 @@
 import { shallowRef, PropType } from 'vue'
 import { ElMessage } from 'element-plus'
 import { useDiamondFavorite } from '@/business/goods'
-import { useFavoriteStore } from '@/stores'
+import { favoriteStore } from '@/stores'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
 const props = defineProps({
@@ -23,7 +23,6 @@ const props = defineProps({
 })
 
 const { loading, formSubmit } = useDiamondFavorite(props.selectedRow)
-const { getFavoriteList } = useFavoriteStore()
 const show = shallowRef(true)
 
 const onCancel = () => {
@@ -33,7 +32,7 @@ const onCancel = () => {
 const onSubmit = () => {
     formSubmit(1).then(() => {
         ElMessage.success('提交成功')
-        getFavoriteList()
+        favoriteStore.actions.getFavoriteList()
         onCancel()
     }).catch((err) => {
         ElMessage.error('提交失败:' + err)

+ 1 - 1
src/services/api/account/index.ts

@@ -27,7 +27,7 @@ export function modifyPassword(params: TradeParams<Proto.ModifyPwdReq, Proto.Mod
 /**
  * 查询用户菜单
  */
-export function queryAccountMenu(params: HttpParams<{ rsp: Ermcp.UserMenu[] }>) {
+export function queryAccountMenu(params: HttpParams<{ rsp: Ermcp.UserRoutes[] }>) {
     return httpRequest('/account/menu', 'get', params);
 }
 

+ 2 - 3
src/services/http/index.ts

@@ -2,7 +2,7 @@ import axios, { AxiosRequestConfig, Method, AxiosInstance } from 'axios'
 //import qs from 'qs'
 //import cryptojs from 'crypto-js'
 //import { addPending, removePending } from './pending'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import { HttpParams, CommonParams, HttpResponse, Payload, ResultCode } from './interface'
 import service from '@/services'
 
@@ -23,13 +23,12 @@ const httpService = new (class {
             // 请求拦截器
             this.axiosInstance.interceptors.request.use(
                 (config) => {
-                    const { getToken } = useLoginStore()
                     //removePending(config) //在请求开始前,对之前的请求做检查取消操作
                     //addPending(config) //将当前请求添加到列表中
 
                     //请求头签名
                     const sign = {
-                        token: getToken(),
+                        token: loginStore.getters.token,
                         signsecret: 'qz7qWOMXKTMT5JlDs5w4NTPwWeR3xhF1v6wqbZ9cExmP6cc3spvNAp1wJJ1SqRI5',
                         timestamp: new Date().getTime(),
                     }

+ 2 - 3
src/services/socket/index.ts

@@ -6,7 +6,7 @@ import { FunCode } from '@/constants/funcode'
 import { parseReceivePush } from './quote/build/decode'
 import protobuf from './trade/protobuf'
 import { checkToken, stopCheckToken, checkTokenLoop } from '@/business/common'
-import { useErrorInfoStore } from '@/stores/modules/errorInfo'
+import { errorInfoStore } from '@/stores'
 import service from '@/services'
 import eventBus from '@/services/bus'
 
@@ -35,7 +35,6 @@ export default new (class {
         }
 
         this.tradeServer.onPush = (p) => {
-            const { getErrorInfoByCode } = useErrorInfoStore();
             const { funCode, content } = p;
             const delay = 1000; // 延迟推送消息,防止短时间内重复请求
 
@@ -50,7 +49,7 @@ export default new (class {
                 case FunCode.LogoutRsp: {
                     // 通知上层 用户登出
                     protobuf.responseDecode<Proto.LogoutRsp>(FunCode[funCode], content).then(({ RetCode, RetDesc }) => {
-                        const msg = getErrorInfoByCode(RetCode)
+                        const msg = errorInfoStore.actions.getErrorInfoByCode(RetCode)
                         const error = (RetDesc || RetCode).toString();
                         eventBus.$emit('LogoutNotify', msg ?? error);
                     })

+ 3 - 3
src/services/socket/quote/index.ts

@@ -4,7 +4,7 @@ import { FunCode } from '@/constants/funcode'
 import { QuoteRequest } from './interface'
 import { subscribeListToByteArrary } from './build/encode'
 import { parseSubscribeRsp } from './build/decode'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import socket from '../index'
 
 /**
@@ -12,8 +12,8 @@ import socket from '../index'
  * @param params 
  */
 function quoteServerMiddleware(params: QuoteRequest): Promise<Proto.QuoteRsp[]> {
-    const { getLoginId, getToken } = useLoginStore();
-    const content = subscribeListToByteArrary(params.data, getToken(), Long.fromNumber(getLoginId()));
+    const { loginId, token } = loginStore.$mapGetters();
+    const content = subscribeListToByteArrary(params.data, token.value, Long.fromNumber(loginId.value));
 
     return new Promise((resolve, reject) => {
         socket.sendQuoteServer({

+ 5 - 7
src/services/socket/trade/index.ts

@@ -1,8 +1,7 @@
 import { v4 } from 'uuid'
 import { Package50 } from '@/utils/websocket/package'
 import { FunCode } from '@/constants/funcode'
-import { useLoginStore } from '@/stores/modules/login'
-import { useErrorInfoStore } from '@/stores/modules/errorInfo'
+import { loginStore, errorInfoStore } from '@/stores'
 import { IMessageHead } from './protobuf/proto'
 import { TradeParams, TradeResponse } from './interface'
 import Protobuf from './protobuf'
@@ -12,13 +11,13 @@ import socket from '../index'
  * 构建消息头部
  */
 function getProtoHeader(funCode: keyof typeof FunCode, header?: IMessageHead, marketId?: number) {
-    const { getUserId, getFirstAccountId } = useLoginStore();
+    const { userId, firstAccountId } = loginStore.$mapGetters();
     // 组合请求头
     const protoHeader: IMessageHead = {
         FunCode: FunCode[funCode],
         UUID: v4(),
-        UserID: getUserId(),
-        AccountID: getFirstAccountId(),
+        UserID: userId.value,
+        AccountID: firstAccountId.value,
         ...(header ?? {})
     }
     if (marketId) {
@@ -75,7 +74,6 @@ function tradeServerMiddleware<Req, Rsp>(reqKey: keyof typeof FunCode, rspKey: k
  * @param marketId 
  */
 export async function tradeServerRequest<Req, Rsp>(reqKey: keyof typeof FunCode, rspKey: keyof typeof FunCode, params: TradeParams<Req, Rsp & TradeResponse>, marketId?: number) {
-    const { getErrorInfoByCode } = useErrorInfoStore();
     const { success, fail, complete } = params;
 
     await tradeServerMiddleware(reqKey, rspKey, params, marketId).then((res) => {
@@ -102,7 +100,7 @@ export async function tradeServerRequest<Req, Rsp>(reqKey: keyof typeof FunCode,
                     success && success(res);
                     return Promise.resolve();
                 }
-                const msg = getErrorInfoByCode(RetCode || Status);
+                const msg = errorInfoStore.actions.getErrorInfoByCode(RetCode || Status);
                 const error = String(RetDesc || RetCode);
                 return Promise.reject(msg ?? error);
             }

+ 3 - 3
src/services/subscribe/index.ts

@@ -1,6 +1,6 @@
 import { v4 } from 'uuid'
 import { quoteServerRequest } from '@/services/socket/quote'
-import { useLoginStore } from '@/stores'
+import { loginStore } from '@/stores'
 import eventBus from '@/services/bus'
 import socket from '@/services/socket'
 
@@ -61,7 +61,7 @@ export default new (class {
      * @returns 
      */
     addQuoteSubscribe = (goodsCodes: string[], key?: string) => {
-        const { getToken } = useLoginStore()
+        const { token } = loginStore.$mapGetters()
         const uuid = key ?? v4()
         const value = this.quoteSubscribeMap.get(uuid) ?? []
 
@@ -79,7 +79,7 @@ export default new (class {
                 if (flag) {
                     console.log('删除订阅', uuid)
                 }
-                if (getToken()) {
+                if (token.value) {
                     this.quoteSubscribe()
                 }
                 return flag

+ 0 - 157
src/stores/@next.ts

@@ -1,157 +0,0 @@
-import { reactive, toRefs, ToRefs, UnwrapNestedRefs } from 'vue'
-
-type Getters<T> = {
-    [key in keyof T]: () => void
-}
-
-interface Store<S extends object, G extends Getters<G>, A extends object> {
-    state: UnwrapNestedRefs<S>;
-    getters: { readonly [key in keyof G]: ReturnType<G[key]> };
-    actions: A;
-    methods: {
-        $setData: (callback: (state: UnwrapNestedRefs<S>) => void) => void;
-        $storeToRefs: () => ToRefs<UnwrapNestedRefs<S>>;
-    };
-}
-
-/**
- * 存储配置项
- */
-interface StoreOptions<S extends object, G extends Getters<G>, A extends object> {
-    state: () => S;
-    created?: (context: Store<S, G, A>) => void;
-    getters?: G & ThisType<Store<S, G, A>>;
-    actions?: A & ThisType<Store<S, G, A>>;
-}
-
-/**
- * 实例化存储对象
- * @param options 
- * @returns 
- */
-export function createStore<S extends object, G extends Getters<G>, A extends object>(options: StoreOptions<S, G, A>) {
-    const state = reactive(options.state())
-    const getters = {} as { readonly [key in keyof G]: ReturnType<G[key]> }
-    const actions = {} as { [key in keyof A]: A[key] }
-
-    const store: Store<S, G, A> = {
-        state,
-        getters,
-        actions,
-        methods: {
-            $setData: (callback) => {
-                callback(state)
-            },
-            $storeToRefs: () => {
-                return toRefs(state)
-            },
-        },
-    }
-
-    if (options.getters) {
-        for (const key in options.getters) {
-            const fn = options.getters[key]
-            const prop = {
-                get() {
-                    return fn.call(store)
-                }
-            }
-            Object.defineProperty(getters, key, prop)
-        }
-    }
-
-    if (options.actions) {
-        for (const key in options.actions) {
-            const fn = options.actions[key]
-            if (fn instanceof Function) {
-                actions[key] = fn.bind(store)
-            }
-        }
-    }
-
-    if (options.created) {
-        options.created(store)
-    }
-
-    return store
-}
-
-const store = createStore({
-    state() {
-        return {
-            id: 0,
-            userName: '李兔饼'
-        }
-    },
-    getters: {
-        getUserid() {
-            return this.state.id
-        },
-    },
-    actions: {
-        getAllEnumList(userid: number) {
-            this.state.id = userid
-        },
-        hello() {
-            console.log(this.getters.getUserid)
-        }
-    },
-})
-
-store.actions.getAllEnumList(10086)
-
-setTimeout(() => {
-    console.log(store.state)
-    store.actions.hello()
-}, 2000);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-interface DefineStoreOptions<S extends object, A extends object> {
-    state: S;
-    actions: {
-        [key in keyof A]: (context: S, ...args: never) => unknown
-    }
-}
-
-function defineStore<S extends object, A extends object>(options: DefineStoreOptions<S, A>) {
-    const actions = {} as { [key in keyof A]: <T extends unknown[]>(...args: T) => unknown }
-
-    for (const p in options.actions) {
-        const fn = options.actions[p]
-
-        actions[p] = (...args) => {
-            return fn(options.state, args as never)
-        }
-    }
-
-    return {
-        actions
-    }
-}
-
-const dStore = defineStore({
-    state: {
-        id: 0,
-        userName: '李兔饼'
-    },
-    actions: {
-        getAllEnumList(context, userid: number) {
-            context.id = userid
-            return context
-        },
-    }
-})
-
-dStore.actions.getAllEnumList(10086)

+ 78 - 37
src/stores/base.ts

@@ -1,49 +1,90 @@
-import { reactive, toRefs, ComputedRef, UnwrapNestedRefs, ToRefs } from 'vue'
+import { reactive, shallowReactive, toRefs, ToRefs, UnwrapNestedRefs, ShallowReactive } from 'vue'
 
 /**
- * 状态存储
+ * getters 属性
  */
-export interface Store<T> {
-    state: UnwrapNestedRefs<T>;
-    getters?: { [propName: string]: ComputedRef };
-    actions?: { [propName: string]: (...args: never[]) => unknown };
-    methods?: {
-        $setData: (callback: (state: UnwrapNestedRefs<T>) => void) => void;
-        $storeToRefs: () => ToRefs<UnwrapNestedRefs<T>>;
-    }
+type Getters<T> = {
+    [key in keyof T]: () => void;
 }
 
 /**
- * 状态存储控制类
+ * getters 计算属性
  */
-export abstract class VueStore<T extends object> implements Store<T>{
-    constructor(state: T) {
-        this.state = reactive<T>(state)
-    }
+type ComputedGetters<T extends Getters<T>> = { readonly [key in keyof T]: ReturnType<T[key]> };
 
-    state
-    getters = {}
-    actions = {}
-    methods = {
-        $setData: (callback: (state: UnwrapNestedRefs<T>) => void) => {
-            callback(this.state)
-        },
-        $storeToRefs: () => {
-            return toRefs(this.state)
-        },
-    }
+/**
+ * store 对象
+ */
+interface Store<S extends object, G extends Getters<G>, A extends object> {
+    state: UnwrapNestedRefs<S>;
+    getters: ComputedGetters<G>;
+    actions: A;
+    $setState: (callback: (state: UnwrapNestedRefs<S>) => void) => void;
+    $mapState: () => ToRefs<UnwrapNestedRefs<S>>;
+    $mapGetters: () => ToRefs<ShallowReactive<ComputedGetters<G>>>;
+}
+
+/**
+ * store 配置项
+ */
+interface StoreOptions<S extends object, G extends Getters<G>, A extends object> {
+    state: () => S;
+    //created?: (this: Store<S, G, A>) => void;
+    getters?: G & ThisType<Store<S, G, A>>;
+    actions?: A & ThisType<Store<S, G, A>>;
 }
 
 /**
- * 创建状态管理
- * @param store
- * @returns
+ * 创建 store 对象
+ * @param options 
+ * @returns 
  */
-// export function createStore<T extends object>(store: VueStore<T>) {
-//     return shallowReadonly({
-//         ...toRefs(store.state),
-//         ...store.getters,
-//         ...store.actions,
-//         ...store.methods,
-//     })
-// }
+export function createStore<S extends object, G extends Getters<G>, A extends object>(options: StoreOptions<S, G, A>) {
+    const state = reactive(options.state())
+    const getters: ComputedGetters<G> = Object.create(null)
+    const actions: A = Object.create(null)
+
+    const store: Store<S, G, A> = {
+        state,
+        getters,
+        actions,
+        $setState: (callback) => {
+            callback(state)
+        },
+        $mapState: () => {
+            return toRefs(state)
+        },
+        $mapGetters: () => {
+            const data = shallowReactive(store.getters)
+            return toRefs(data)
+        }
+    }
+
+    if (options.getters) {
+        for (const key in options.getters) {
+            const fn = options.getters[key]
+            // https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
+            Object.defineProperty(getters, key, {
+                get: () => fn.call(store),
+                enumerable: true
+            })
+        }
+    }
+
+    if (options.actions) {
+        for (const key in options.actions) {
+            const fn = options.actions[key]
+            if (fn instanceof Function) {
+                actions[key] = fn.bind(store)
+            } else {
+                actions[key] = fn
+            }
+        }
+    }
+
+    // if (options.created) {
+    //     options.created.call(store)
+    // }
+
+    return store
+}

+ 13 - 49
src/stores/index.ts

@@ -1,49 +1,13 @@
-import { useLoginStore } from './modules/login'
-import { useUserStore } from './modules/user'
-import { useThemeStore } from './modules/theme'
-import { useMenuStore } from './modules/menu'
-import { useAccountStore } from './modules/account'
-import { useFuturesStore } from './modules/futures'
-import { useLanguageStore } from './modules/language'
-import { useEnumStore } from './modules/enum'
-import { useErrorInfoStore } from './modules/errorInfo'
-import { useFavoriteStore } from './modules/favorite'
-import { useTableColumnStore } from './modules/tableColumn'
-import { usePerformanceStore } from './modules/performance'
-import { useExrateStore } from './modules/exrate'
-
-export {
-    useLoginStore,
-    useUserStore,
-    useThemeStore,
-    useMenuStore,
-    useAccountStore,
-    useFuturesStore,
-    useLanguageStore,
-    useEnumStore,
-    useErrorInfoStore,
-    useFavoriteStore,
-    useTableColumnStore,
-    usePerformanceStore,
-    useExrateStore,
-}
-
-export function useStore() {
-    return {
-        loginStore: useLoginStore(),
-        userStore: useUserStore(),
-        themeStore: useThemeStore(),
-        menuStore: useMenuStore(),
-        accountStore: useAccountStore(),
-        futuresStore: useFuturesStore(),
-        languageStore: useLanguageStore(),
-        enumStore: useEnumStore(),
-        errorInfoStore: useErrorInfoStore(),
-        favoriteStore: useFavoriteStore(),
-        tableColumnStore: useTableColumnStore(),
-        performanceStore: usePerformanceStore(),
-        exrateStore: useExrateStore(),
-    }
-}
-
-import './@next.ts'
+export { loginStore } from './modules/login'
+export { userStore } from './modules/user'
+export { themeStore } from './modules/theme'
+export { menuStore } from './modules/menu'
+export { accountStore } from './modules/account'
+export { futuresStore } from './modules/futures'
+export { languageStore, i18n } from './modules/language'
+export { enumStore, enumMap } from './modules/enum'
+export { errorInfoStore } from './modules/errorInfo'
+export { favoriteStore } from './modules/favorite'
+export { tableColumnStore } from './modules/tableColumn'
+export { performanceStore } from './modules/performance'
+export { exrateStore } from './modules/exrate'

+ 34 - 60
src/stores/modules/account.ts

@@ -1,64 +1,42 @@
-import { computed, toRefs, shallowReadonly } from 'vue'
 import { queryTaAccounts } from '@/services/api/account'
-import { useLoginStore } from './login'
-import { VueStore } from '../base'
+import { loginStore } from './login'
+import { createStore } from '../base'
 import eventBus from '@/services/bus'
 
-interface StoreState {
-    loading: boolean;
-    accountList: Ermcp.TaAccountsRsp[]; // 资金账户列表
-    accountId: number; // 当前资金账户ID
-}
-
 /**
- * 账号存储
+ * 账号存储对象
  */
-const store = new (class extends VueStore<StoreState> {
-    constructor() {
-        const state: StoreState = {
+export const accountStore = createStore({
+    state() {
+        return {
             loading: false,
-            accountList: [],
+            accountList: <Ermcp.TaAccountsRsp[]>[],
             accountId: 0,
         }
-        super(state)
-
-        // 接收资金变动通知
-        eventBus.$on('MoneyChangedNotify', () => {
-            this.actions.getAccountList()
-        })
-    }
-
-    /** 当前资金账户信息 */
-    private accountInfo = computed(() => {
-        return this.state.accountList.find((e) => e.accountid === this.state.accountId)
-    })
-
-    /** 冻结资金 */
-    private freezeMargin = computed(() => {
-        const { freezecharge = 0, freezemargin = 0, otherfreezemargin = 0, outamountfreeze = 0 } = this.accountInfo.value ?? {}
-        return freezecharge + freezemargin + otherfreezemargin + outamountfreeze
-    })
-
-    /** 可用资金 */
-    private avaiableMoney = computed(() => {
-        const { currentbalance = 0 } = this.accountInfo.value ?? {}
-        return currentbalance - this.freezeMargin.value
-    })
-
-    getters = {
-        accountInfo: this.accountInfo,
-        freezeMargin: this.freezeMargin,
-        avaiableMoney: this.avaiableMoney,
-    }
-
-    actions = {
-        /** 获取资金账户列表 */
-        getAccountList: () => {
-            const { getLoginId } = useLoginStore()
+    },
+    getters: {
+        // 当前资金账户信息
+        accountInfo() {
+            return this.state.accountList.find((e) => e.accountid === this.state.accountId)
+        },
+        // 冻结资金
+        freezeMargin() {
+            const { freezecharge = 0, freezemargin = 0, otherfreezemargin = 0, outamountfreeze = 0 } = this.getters.accountInfo ?? {}
+            return freezecharge + freezemargin + otherfreezemargin + outamountfreeze
+        },
+        // 可用资金
+        avaiableMoney() {
+            const { currentbalance = 0 } = this.getters.accountInfo ?? {}
+            return currentbalance - this.getters.freezeMargin
+        }
+    },
+    actions: {
+        // 获取资金账户列表
+        getAccountList() {
             this.state.loading = true
             return queryTaAccounts({
                 data: {
-                    loginID: getLoginId()
+                    loginID: loginStore.getters.loginId
                 },
                 success: (res) => {
                     const dataList = res.data
@@ -82,19 +60,15 @@ const store = new (class extends VueStore<StoreState> {
                 }
             })
         },
-        /** 重置数据 */
-        reset: () => {
+        // 重置数据
+        reset() {
             this.state.accountList = []
             this.state.accountId = 0
         }
     }
 })
 
-export function useAccountStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.getters,
-        ...store.actions,
-        ...store.methods,
-    })
-}
+// 接收资金变动通知
+export const moneyChangedNotify = eventBus.$on('MoneyChangedNotify', () => {
+    accountStore.actions.getAccountList()
+})

+ 58 - 71
src/stores/modules/enum.ts

@@ -1,7 +1,7 @@
-import { toRefs, shallowRef, shallowReadonly, ShallowRef } from 'vue'
+import { shallowRef, ShallowRef } from 'vue'
 import { queryAllEnums } from '@/services/api/common'
-import { VueStore } from '../base'
-import WebStorage from '@/utils/storage/base'
+import { createStore } from '../base'
+import { sessionData } from '../storage'
 
 /**
  * 枚举类型
@@ -12,73 +12,64 @@ export interface EnumType {
     disabled?: boolean;
 }
 
-interface StoreState {
-    loading: boolean;
-    allEnums: ShallowRef<Ermcp.EnumRsp[]>;
-}
-
 const enumKeys = ['ZSCategory', 'ZSCurrencyType', 'ZSCurrencyType', 'ZSColorType', 'ZSClarityType', 'ZSCutType', 'ZSShapeType', 'ZSSymmetryType', 'ZSPolishType', 'ZSFluorescenceType', 'ZSCertType', 'ZSCrystalType', 'ZSCZColor1Type', 'ZSCZColor2Type', 'ZSCZColor3Type', 'ZSStyleType', 'signstatus', 'applystatus', 'executetype', 'certificatetype', 'clientType', 'wrApplyStatus', 'performanceStatus', 'stepStatus', 'GZCJAccountType', 'GZCJCategoryType', 'GZCJDeliveryType', 'GZCJShapeType', 'GZCJMarkType', 'GZCJPublishType', 'GZCJServiceType', 'GZCJStatus', 'GZBSStatus', 'GZBSDeliveryType'] as const
 
+export const enumMap = new Map<typeof enumKeys[number], ShallowRef<Ermcp.EnumRsp[]>>()
+
+// 初始化枚举列表
+for (const key of enumKeys) {
+    enumMap.set(key, shallowRef<Ermcp.EnumRsp[]>([]))
+}
+
 /**
- * 枚举存储类
+ * 枚举存储对象
  */
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const storage = new WebStorage<Ermcp.EnumRsp[]>(sessionStorage, 'allEnums', [])
-        const state: StoreState = {
+export const enumStore = createStore({
+    state() {
+        return {
             loading: false,
-            allEnums: storage.getRef(),
-        }
-        super(state)
-
-        // 初始化枚举列表
-        for (const key of enumKeys) {
-            this.enumMap.set(key, shallowRef<Ermcp.EnumRsp[]>([]))
-        }
-    }
-
-    enumMap = new Map<typeof enumKeys[number], ShallowRef<Ermcp.EnumRsp[]>>()
-
-    private setEnumMap = () => {
-        // 清空列表数据
-        for (const item of this.enumMap.values()) {
-            item.value = []
+            allEnums: sessionData.getRef('allEnums'),
         }
-        this.state.allEnums.forEach((e) => {
-            const mapKey = enumKeys.find((key) => key === e.enumdiccode)
-            if (mapKey && e.enumitemstatus === 1) {
-                const enumRef = this.enumMap.get(mapKey)
-                enumRef?.value.push(e)
-            }
-        })
-    }
-
-    actions = {
-        /** 获取所有枚举列表 */
-        getAllEnumList: () => {
-            if (this.state.allEnums.length) {
-                this.setEnumMap()
-                return Promise.resolve()
+    },
+    actions: {
+        // 获取所有枚举列表
+        async getAllEnumList() {
+            await new Promise<void>((resolve) => {
+                if (this.state.allEnums.length) {
+                    resolve()
+                } else {
+                    this.state.loading = true
+                    queryAllEnums({
+                        success: (res) => {
+                            this.state.allEnums = res.data
+                            resolve()
+                        },
+                        complete: () => {
+                            this.state.loading = false
+                        }
+                    })
+                }
+            })
+            // 清空列表数据
+            for (const item of enumMap.values()) {
+                item.value = []
             }
-            this.state.loading = true
-            return queryAllEnums({
-                success: (res) => {
-                    this.state.allEnums = res.data
-                    this.setEnumMap()
-                },
-                complete: () => {
-                    this.state.loading = false
+            this.state.allEnums.forEach((e) => {
+                const mapKey = enumKeys.find((key) => key === e.enumdiccode)
+                if (mapKey && e.enumitemstatus === 1) {
+                    const enumRef = enumMap.get(mapKey)
+                    enumRef?.value.push(e)
                 }
             })
         },
-        /** 获取枚举信息 */
-        getEnumTypeInfo: (enumKey: typeof enumKeys[number], value: number) => {
-            const enums = this.enumMap.get(enumKey)
+        // 获取枚举信息
+        getEnumTypeInfo(enumKey: typeof enumKeys[number], value: number) {
+            const enums = enumMap.get(enumKey)
             return enums?.value.find((e) => e.enumitemname === value)
         },
-        /** 获取枚举列表 */
+        // 获取枚举列表
         getEnumTypeList: (enumKey: typeof enumKeys[number], propertys?: (keyof Ermcp.EnumRsp)[]) => {
-            const enums = this.enumMap.get(enumKey)
+            const enums = enumMap.get(enumKey)
             if (enums) {
                 return enums.value.map((e) => {
                     const props = propertys?.reduce((res, prop) => {
@@ -94,19 +85,15 @@ const store = new (class extends VueStore<StoreState>{
             }
             return []
         },
-        /** 根据枚举值获取枚举名称 */
-        getEnumTypeName: (enums: EnumType[], value?: number) => {
+        // 根据枚举值获取枚举名称
+        getEnumTypeName(enums: EnumType[], value?: number) {
             const item = enums.find((e) => e.value === value)
-            return item?.label ?? value
+            return item?.label ?? value?.toString() ?? '无效枚举'
+        },
+        // 根据枚举名称获取对应的值
+        getEnumTypeValue(enums: EnumType[], label?: string) {
+            const item = enums.find((e) => e.label === label)
+            return item?.value ?? label
         }
-    }
-})
-
-export function useEnumStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-        enumMap: store.enumMap,
-    })
-}
+    },
+})

+ 14 - 31
src/stores/modules/errorInfo.ts

@@ -1,29 +1,20 @@
-import { toRefs, shallowReadonly, ShallowRef } from 'vue'
 import { queryErrorInfos } from '@/services/api/common'
-import { VueStore } from '../base'
-import WebStorage from '@/utils/storage/base'
-
-interface StoreState {
-    loading: boolean;
-    errorInfos: ShallowRef<Ermcp.ErrorInfosRsp[]>;
-}
+import { createStore } from '../base'
+import { sessionData } from '../storage'
 
 /**
- * 错误信息存储
+ * 错误信息存储对象
  */
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const storage = new WebStorage<Ermcp.ErrorInfosRsp[]>(sessionStorage, 'errorInfos', [])
-        const state: StoreState = {
+export const errorInfoStore = createStore({
+    state() {
+        return {
             loading: false,
-            errorInfos: storage.getRef(),
+            errorInfos: sessionData.getRef('errorInfos'),
         }
-        super(state)
-    }
-
-    actions = {
-        /** 获取系统错误信息 */
-        getErrorInfoList: () => {
+    },
+    actions: {
+        // 获取系统错误信息
+        getErrorInfoList() {
             if (this.state.errorInfos.length) {
                 return Promise.resolve()
             }
@@ -37,19 +28,11 @@ const store = new (class extends VueStore<StoreState>{
                 }
             })
         },
-        /** 根据 code 获取错误信息 */
-        getErrorInfoByCode: (code: number) => {
+        // 根据 code 获取错误信息
+        getErrorInfoByCode(code: number) {
             const errorInfos = this.state.errorInfos
             const error = errorInfos.find((e) => e.errorid === code)
             return error?.description
         }
     }
-})
-
-export function useErrorInfoStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 15 - 31
src/stores/modules/exrate.ts

@@ -1,28 +1,20 @@
-import { toRefs, shallowReadonly } from 'vue'
 import { getCurrencyTypeInfo, CurrencyType } from '@/constants/diamond'
 import { queryRates } from '@/services/api/common'
-import { VueStore } from '../base'
-
-interface StoreState {
-    loading: boolean;
-    exrateList: Ermcp.RatesRsp[]; // 汇率列表
-}
+import { createStore } from '../base'
 
 /**
- * 汇率存储
+ * 汇率存储对象
  */
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const state: StoreState = {
+export const exrateStore = createStore({
+    state() {
+        return {
             loading: false,
-            exrateList: [],
+            exrateList: <Ermcp.RatesRsp[]>[], // 汇率列表
         }
-        super(state)
-    }
-
-    actions = {
-        /** 获取汇率列表 */
-        getExrateList: () => {
+    },
+    actions: {
+        // 获取汇率列表
+        getExrateList() {
             this.state.loading = true
             return queryRates({
                 success: (res) => {
@@ -33,13 +25,13 @@ const store = new (class extends VueStore<StoreState>{
                 }
             })
         },
-        /** 获取币种汇率 */
-        getExrate: (currencyId: number) => {
+        // 获取币种汇率
+        getExrate(currencyId: number) {
             const exrate = this.state.exrateList.find((e) => e.oricurrencyid === currencyId)
             return exrate?.exchangerate ?? 0
         },
-        /** 汇率转换 */
-        exchangeRate: (currencyId: number, currencyValue: number, prefix = true) => {
+        // 汇率转换
+        exchangeRate(currencyId: number, currencyValue: number, prefix = true) {
             const exrate = this.actions.getExrate(currencyId)
             const currency = getCurrencyTypeInfo(currencyId)
             const cny = getCurrencyTypeInfo(CurrencyType.CNY) // 人民币
@@ -48,12 +40,4 @@ const store = new (class extends VueStore<StoreState>{
             return unit + (exrate ? currencyValue * exrate : currencyValue).toFixed(2)
         }
     }
-})
-
-export function useExrateStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 15 - 32
src/stores/modules/favorite.ts

@@ -1,33 +1,24 @@
-import { toRefs, shallowReadonly } from 'vue'
 import { queryMyFavorite } from '@/services/api/favorite'
-import { useLoginStore } from './login'
-import { VueStore } from '../base'
-
-interface StoreState {
-    loading: boolean;
-    favoriteList: Ermcp.MyFavoriteRsp[]; // 收藏列表
-}
+import { loginStore } from './login'
+import { createStore } from '../base'
 
 /**
- * 商品收藏存储
+ * 商品收藏存储对象
  */
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const state: StoreState = {
+export const favoriteStore = createStore({
+    state() {
+        return {
             loading: false,
-            favoriteList: [],
+            favoriteList: <Ermcp.MyFavoriteRsp[]>[], // 收藏列表
         }
-        super(state)
-    }
-
-    actions = {
-        /** 获取收藏列表 */
-        getFavoriteList: () => {
-            const { getUserId } = useLoginStore()
+    },
+    actions: {
+        // 获取收藏列表
+        getFavoriteList() {
             this.state.loading = true
             return queryMyFavorite({
                 data: {
-                    userid: getUserId(),
+                    userid: loginStore.getters.userId,
                 },
                 success: (res) => {
                     this.state.favoriteList = res.data
@@ -37,17 +28,9 @@ const store = new (class extends VueStore<StoreState>{
                 }
             })
         },
-        /** 是否已收藏 */
-        hasFavorite: (goodsno: string) => {
+        // 是否已收藏
+        hasFavorite(goodsno: string) {
             return this.state.favoriteList.some((e) => e.goodsno === goodsno)
         }
     }
-})
-
-export function useFavoriteStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 190 - 208
src/stores/modules/futures.ts

@@ -1,214 +1,30 @@
-import { computed, toRefs, shallowReadonly } from 'vue'
+import { computed } from 'vue'
 import { timerInterceptor } from '@/utils/timer'
 import { queryGoodsList } from '@/services/api/goods'
-import { useLoginStore } from './login'
-import { VueStore } from '../base'
+import { loginStore } from './login'
+import { createStore } from '../base'
 import eventBus from '@/services/bus'
 import moment from 'moment'
 
-interface StoreState {
-    loading: boolean;
-    goodsList: Ermcp.GoodsRsp[]; // 商品列表
-    quoteDayList: Ermcp.QuoteDay[]; // 盘面列表
-}
-
 /**
- * 期货存储
+ * 期货存储对象
  */
-const store = new (class extends VueStore<StoreState> {
-    constructor() {
-        const state: StoreState = {
+export const futuresStore = createStore({
+    state() {
+        return {
             loading: false,
-            goodsList: [],
-            quoteDayList: [],
+            quotes: <Proto.Quote[]>[], // 行情数据
+            goodsList: <Ermcp.GoodsRsp[]>[], // 商品列表
+            quoteDayList: <Ermcp.QuoteDayRsp[]>[], // 盘面列表
         }
-        super(state)
-
-        // 接收行情推送通知
-        eventBus.$on('QuotePushNotify', (res) => {
-            const data = res as Proto.Quote[]
-            data.forEach((item) => {
-                const index = this.quotes.findIndex((e) => e.goodscode === item.goodscode)
-                if (index > -1) {
-                    this.quotes[index] = item
-                } else {
-                    this.quotes.push(item)
-                }
-            })
-            this.handleQuote()
-        })
-    }
-
-    private quotes: Proto.Quote[] = [] // 行情数据
-
-    /** 处理行情数据 */
-    private handleQuote = timerInterceptor.setThrottle(() => {
-        const quoteList = this.state.quoteDayList
-        this.quotes.forEach((item) => {
-            const quote = quoteList.find((e) => e.goodscode.toUpperCase() === item.goodscode?.toUpperCase())
-            const last = item.last ?? 0
-            const lasttime = (item.date && item.time) ? moment(item.date + item.time, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm:ss') : ''
-
-            if (quote) {
-                Object.entries(item).forEach(([key, value]) => {
-                    // 只更新存在的属性
-                    if (Reflect.has(quote, key)) {
-                        const prop = key as keyof Ermcp.QuoteDay;
-                        (<K extends typeof prop>(key: K) => quote[key] = value)(prop);
-                    }
-                })
-                // 处理最高最低价
-                if (last) {
-                    if (last > quote.highest) {
-                        quote.highest = last;
-                    }
-                    if (last < quote.lowest) {
-                        quote.lowest = last;
-                    }
-                }
-                // 处理最新时间
-                if (lasttime) {
-                    quote.lasttime = lasttime;
-                }
-            } else {
-                console.warn('行情推送的商品 ' + item.goodscode + ' 缺少盘面信息')
-                quoteList.push({
-                    Lastturnover: 0,
-                    ask: item.ask ?? 0,
-                    ask2: item.ask2 ?? 0,
-                    ask3: item.ask3 ?? 0,
-                    ask4: item.ask4 ?? 0,
-                    ask5: item.ask5 ?? 0,
-                    ask6: 0,
-                    ask7: 0,
-                    ask8: 0,
-                    ask9: 0,
-                    ask10: 0,
-                    askorderid: 0,
-                    askorderid2: 0,
-                    askorderid3: 0,
-                    askorderid4: 0,
-                    askorderid5: 0,
-                    askordervolume: 0,
-                    askordervolume2: 0,
-                    askordervolume3: 0,
-                    askordervolume4: 0,
-                    askordervolume5: 0,
-                    askordervolume6: 0,
-                    askordervolume7: 0,
-                    askordervolume8: 0,
-                    askordervolume9: 0,
-                    askordervolume10: 0,
-                    askqueueinfo: "",
-                    askvolume: item.askvolume ?? 0,
-                    askvolume2: item.askvolume2 ?? 0,
-                    askvolume3: item.askvolume3 ?? 0,
-                    askvolume4: item.askvolume4 ?? 0,
-                    askvolume5: item.askvolume5 ?? 0,
-                    askvolume6: 0,
-                    askvolume7: 0,
-                    askvolume8: 0,
-                    askvolume9: 0,
-                    askvolume10: 0,
-                    averageprice: 0,
-                    bid: item.bid ?? 0,
-                    bid2: item.bid2 ?? 0,
-                    bid3: item.bid3 ?? 0,
-                    bid4: item.bid4 ?? 0,
-                    bid5: item.bid5 ?? 0,
-                    bid6: 0,
-                    bid7: 0,
-                    bid8: 0,
-                    bid9: 0,
-                    bid10: 0,
-                    bidorderid: 0,
-                    bidorderid2: 0,
-                    bidorderid3: 0,
-                    bidorderid4: 0,
-                    bidorderid5: 0,
-                    bidordervolume: 0,
-                    bidordervolume2: 0,
-                    bidordervolume3: 0,
-                    bidordervolume4: 0,
-                    bidordervolume5: 0,
-                    bidordervolume6: 0,
-                    bidordervolume7: 0,
-                    bidordervolume8: 0,
-                    bidordervolume9: 0,
-                    bidordervolume10: 0,
-                    bidqueueinfo: "",
-                    bidvolume: item.bidvolume ?? 0,
-                    bidvolume2: item.bidvolume2 ?? 0,
-                    bidvolume3: item.bidvolume3 ?? 0,
-                    bidvolume4: item.bidvolume4 ?? 0,
-                    bidvolume5: item.bidvolume5 ?? 0,
-                    bidvolume6: 0,
-                    bidvolume7: 0,
-                    bidvolume8: 0,
-                    bidvolume9: 0,
-                    bidvolume10: 0,
-                    calloptionpremiums: item.calloptionpremiums ?? 0,
-                    calloptionpremiums2: item.calloptionpremiums2 ?? 0,
-                    calloptionpremiums3: item.calloptionpremiums3 ?? 0,
-                    calloptionpremiums4: item.calloptionpremiums4 ?? 0,
-                    calloptionpremiums5: item.calloptionpremiums5 ?? 0,
-                    cleartime: 0,
-                    exchangecode: item.exchangecode ?? 0,
-                    exchangedate: item.exchangedate ?? 0,
-                    goodscode: item.goodscode ?? '',
-                    grepmarketprice: 0,
-                    highest: item.highest ?? 0,
-                    holdincrement: 0,
-                    holdvolume: item.holdvolume ?? 0,
-                    iep: 0,
-                    iev: 0,
-                    inventory: item.inventory ?? 0,
-                    iscleared: 0,
-                    issettled: 0,
-                    last,
-                    lastlot: 0,
-                    lasttime,
-                    lastvolume: item.lastvolume ?? 0,
-                    limitdown: item.limitlow ?? 0,
-                    limitup: item.limithigh ?? 0,
-                    lowest: item.lowest ?? 0,
-                    nontotalholdervolume: 0,
-                    nontotallot: 0,
-                    nontotalturnover: 0,
-                    nontotalvolume: 0,
-                    opened: item.opened ?? 0,
-                    opentime: '',
-                    orderid: 0,
-                    preclose: item.preclose ?? 0,
-                    preholdvolume: item.preholdvolume ?? 0,
-                    presettle: item.presettle ?? 0,
-                    publictradetype: '',
-                    putoptionpremiums: item.putoptionpremiums ?? 0,
-                    putoptionpremiums2: item.putoptionpremiums2 ?? 0,
-                    putoptionpremiums3: item.putoptionpremiums3 ?? 0,
-                    putoptionpremiums4: item.putoptionpremiums4 ?? 0,
-                    putoptionpremiums5: item.putoptionpremiums5 ?? 0,
-                    settle: item.settle ?? 0,
-                    strikeprice: 0,
-                    totalaskvolume: 0,
-                    totalbidvolume: 0,
-                    totallot: 0,
-                    totalturnover: item.totalturnover ?? 0,
-                    totalvolume: item.totalvolume ?? 0,
-                    utclasttime: ''
-                })
-            }
-        })
-    }, 200)
-
-    actions = {
+    },
+    actions: {
         // 获取商品列表
-        getGoodsList: () => {
-            const { getUserId } = useLoginStore()
+        getGoodsList() {
             this.state.loading = true
             return queryGoodsList({
                 data: {
-                    userid: getUserId()
+                    userid: loginStore.getters.userId
                 },
                 success: (res) => {
                     this.state.goodsList = res.data
@@ -218,12 +34,12 @@ const store = new (class extends VueStore<StoreState> {
                 }
             })
         },
-        /** 通过 goodscode 获取盘面实时行情 */
-        getQuoteDayInfoByCode: (goodscode: string) => {
+        // 通过 goodscode 获取盘面实时行情
+        getQuoteDayInfoByCode(goodscode: string) {
             return computed(() => this.state.quoteDayList.find((e) => e.goodscode.toUpperCase() === goodscode.toUpperCase()))
         },
-        /** 通过 goodscode 获取商品实时报价 */
-        getGoodsPriceByCode: (goodscode: string) => {
+        // 通过 goodscode 获取商品实时报价
+        getGoodsPriceByCode(goodscode: string) {
             return computed(() => {
                 const quote = this.actions.getQuoteDayInfoByCode(goodscode)
                 return quote.value?.last ?? 0
@@ -232,10 +48,176 @@ const store = new (class extends VueStore<StoreState> {
     }
 })
 
-export function useFuturesStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
+// 接收行情推送通知
+export const quotePushNotify = eventBus.$on('QuotePushNotify', (res) => {
+    const { quotes } = futuresStore.$mapState()
+    const data = res as Proto.Quote[]
+    data.forEach((item) => {
+        const index = quotes.value.findIndex((e) => e.goodscode === item.goodscode)
+        if (index > -1) {
+            quotes.value[index] = item
+        } else {
+            quotes.value.push(item)
+        }
+    })
+    handleQuote()
+})
+
+// 处理行情数据
+const handleQuote = timerInterceptor.setThrottle(() => {
+    const { quotes, quoteDayList } = futuresStore.$mapState()
+    quotes.value.forEach((item) => {
+        const quote = quoteDayList.value.find((e) => e.goodscode.toUpperCase() === item.goodscode?.toUpperCase())
+        const last = item.last ?? 0
+        const lasttime = (item.date && item.time) ? moment(item.date + item.time, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm:ss') : ''
+
+        if (quote) {
+            Object.entries(item).forEach(([key, value]) => {
+                // 只更新存在的属性
+                if (Reflect.has(quote, key)) {
+                    Object.defineProperty(quote, key, value)
+                }
+            })
+            // 处理最高最低价
+            if (last) {
+                if (last > quote.highest) {
+                    quote.highest = last
+                }
+                if (last < quote.lowest) {
+                    quote.lowest = last
+                }
+            }
+            // 处理最新时间
+            if (lasttime) {
+                quote.lasttime = lasttime
+            }
+        } else {
+            console.warn('行情推送的商品 ' + item.goodscode + ' 缺少盘面信息')
+            quoteDayList.value.push({
+                Lastturnover: 0,
+                ask: item.ask ?? 0,
+                ask2: item.ask2 ?? 0,
+                ask3: item.ask3 ?? 0,
+                ask4: item.ask4 ?? 0,
+                ask5: item.ask5 ?? 0,
+                ask6: 0,
+                ask7: 0,
+                ask8: 0,
+                ask9: 0,
+                ask10: 0,
+                askorderid: 0,
+                askorderid2: 0,
+                askorderid3: 0,
+                askorderid4: 0,
+                askorderid5: 0,
+                askordervolume: 0,
+                askordervolume2: 0,
+                askordervolume3: 0,
+                askordervolume4: 0,
+                askordervolume5: 0,
+                askordervolume6: 0,
+                askordervolume7: 0,
+                askordervolume8: 0,
+                askordervolume9: 0,
+                askordervolume10: 0,
+                askqueueinfo: "",
+                askvolume: item.askvolume ?? 0,
+                askvolume2: item.askvolume2 ?? 0,
+                askvolume3: item.askvolume3 ?? 0,
+                askvolume4: item.askvolume4 ?? 0,
+                askvolume5: item.askvolume5 ?? 0,
+                askvolume6: 0,
+                askvolume7: 0,
+                askvolume8: 0,
+                askvolume9: 0,
+                askvolume10: 0,
+                averageprice: 0,
+                bid: item.bid ?? 0,
+                bid2: item.bid2 ?? 0,
+                bid3: item.bid3 ?? 0,
+                bid4: item.bid4 ?? 0,
+                bid5: item.bid5 ?? 0,
+                bid6: 0,
+                bid7: 0,
+                bid8: 0,
+                bid9: 0,
+                bid10: 0,
+                bidorderid: 0,
+                bidorderid2: 0,
+                bidorderid3: 0,
+                bidorderid4: 0,
+                bidorderid5: 0,
+                bidordervolume: 0,
+                bidordervolume2: 0,
+                bidordervolume3: 0,
+                bidordervolume4: 0,
+                bidordervolume5: 0,
+                bidordervolume6: 0,
+                bidordervolume7: 0,
+                bidordervolume8: 0,
+                bidordervolume9: 0,
+                bidordervolume10: 0,
+                bidqueueinfo: "",
+                bidvolume: item.bidvolume ?? 0,
+                bidvolume2: item.bidvolume2 ?? 0,
+                bidvolume3: item.bidvolume3 ?? 0,
+                bidvolume4: item.bidvolume4 ?? 0,
+                bidvolume5: item.bidvolume5 ?? 0,
+                bidvolume6: 0,
+                bidvolume7: 0,
+                bidvolume8: 0,
+                bidvolume9: 0,
+                bidvolume10: 0,
+                calloptionpremiums: item.calloptionpremiums ?? 0,
+                calloptionpremiums2: item.calloptionpremiums2 ?? 0,
+                calloptionpremiums3: item.calloptionpremiums3 ?? 0,
+                calloptionpremiums4: item.calloptionpremiums4 ?? 0,
+                calloptionpremiums5: item.calloptionpremiums5 ?? 0,
+                cleartime: 0,
+                exchangecode: item.exchangecode ?? 0,
+                exchangedate: item.exchangedate ?? 0,
+                goodscode: item.goodscode ?? '',
+                grepmarketprice: 0,
+                highest: item.highest ?? 0,
+                holdincrement: 0,
+                holdvolume: item.holdvolume ?? 0,
+                iep: 0,
+                iev: 0,
+                inventory: item.inventory ?? 0,
+                iscleared: 0,
+                issettled: 0,
+                last,
+                lastlot: 0,
+                lasttime,
+                lastvolume: item.lastvolume ?? 0,
+                limitdown: item.limitlow ?? 0,
+                limitup: item.limithigh ?? 0,
+                lowest: item.lowest ?? 0,
+                nontotalholdervolume: 0,
+                nontotallot: 0,
+                nontotalturnover: 0,
+                nontotalvolume: 0,
+                opened: item.opened ?? 0,
+                opentime: '',
+                orderid: 0,
+                preclose: item.preclose ?? 0,
+                preholdvolume: item.preholdvolume ?? 0,
+                presettle: item.presettle ?? 0,
+                publictradetype: '',
+                putoptionpremiums: item.putoptionpremiums ?? 0,
+                putoptionpremiums2: item.putoptionpremiums2 ?? 0,
+                putoptionpremiums3: item.putoptionpremiums3 ?? 0,
+                putoptionpremiums4: item.putoptionpremiums4 ?? 0,
+                putoptionpremiums5: item.putoptionpremiums5 ?? 0,
+                settle: item.settle ?? 0,
+                strikeprice: 0,
+                totalaskvolume: 0,
+                totalbidvolume: 0,
+                totallot: 0,
+                totalturnover: item.totalturnover ?? 0,
+                totalvolume: item.totalvolume ?? 0,
+                utclasttime: ''
+            })
+        }
     })
-}
+}, 200)

+ 16 - 33
src/stores/modules/language.ts

@@ -1,52 +1,35 @@
-import { toRefs, shallowReadonly, ShallowRef } from 'vue'
 import axios from 'axios'
 import { createI18n } from 'vue-i18n'
 import { Language } from '@/constants/language'
-import { VueStore } from '../base'
-import WebStorage from '@/utils/storage/base'
+import { createStore } from '../base'
+import { localData } from '../storage'
 
-interface StoreState {
-    lang: ShallowRef<Language>;
-}
+export const i18n = createI18n({})
 
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const storage = new WebStorage<Language>(localStorage, 'language', Language.ZhCN)
-        const state: StoreState = {
-            lang: storage.getRef()
+export const languageStore = createStore({
+    state() {
+        return {
+            lang: localData.getRef('appLanguage'),
         }
-
-        super(state)
-        const lang = this.state.lang
-        this.actions.setLanguage(lang)
-    }
-
-    i18n = createI18n({})
-
-    actions = {
-        /** 设置语言 */
-        setLanguage: async (lang: Language) => {
-            const locale = this.i18n.global.getLocaleMessage(lang)
+    },
+    actions: {
+        // 设置语言
+        async setLanguage(lang: Language) {
+            const locale = i18n.global.getLocaleMessage(lang)
 
             if (!Object.keys(locale).length) {
                 await axios(`./language/${lang}.json`).then((res) => {
-                    this.i18n.global.setLocaleMessage(lang, res.data)
+                    i18n.global.setLocaleMessage(lang, res.data)
                 }).catch(() => {
                     // 默认语言
                 })
             }
 
-            this.i18n.global.locale = lang
+            i18n.global.locale = lang
             this.state.lang = lang
         }
     }
 })
 
-export function useLanguageStore() {
-    return shallowReadonly({
-        i18n: store.i18n,
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+const { actions, state } = languageStore
+actions.setLanguage(state.lang)

+ 39 - 66
src/stores/modules/login.ts

@@ -1,44 +1,41 @@
-import { toRefs, shallowReadonly, ShallowRef } from 'vue'
-import { login, queryLoginId } from '@/services/api/account'
-import { VueStore } from '../base'
+import { v4 } from 'uuid'
+import { login, queryLoginId } from '@/services/api/account' // 引入可能会引起 Cannot access 'loginStore' before initialization
+import { createStore } from '../base'
+import { sessionData } from '../storage'
 import cryptojs from 'crypto-js'
-import WebStorage from '@/utils/storage/base'
-
-interface StoreState {
-    loading: boolean;
-    loginInfo: ShallowRef<Proto.LoginRsp>;
-}
-
-function getInitData(): Proto.LoginRsp {
-    return {
-        AccountIDs: [],
-        LoginCode: '',
-        LoginID: 0,
-        LoginUserType: 0,
-        AccountStatus: 0,
-        UserID: 0,
-        ClientID: 0,
-        MemberUserID: 0,
-        Token: '',
-    }
-}
 
 /**
- * 登录存储
+ * 登录存储对象
  */
-const store = new (class extends VueStore<StoreState> {
-    constructor() {
-        const storage = new WebStorage(sessionStorage, 'loginInfo', getInitData())
-        const state: StoreState = {
+export const loginStore = createStore({
+    state() {
+        return {
             loading: false,
-            loginInfo: storage.getRef(),
+            loginInfo: sessionData.getRef('loginInfo'),
         }
-        super(state)
-    }
-
-    actions = {
-        /** 用户登录 */
-        userLogin: (param: Proto.LoginReq) => {
+    },
+    getters: {
+        // 登录令牌
+        token() {
+            return this.state.loginInfo.Token
+        },
+        // 用户ID
+        userId() {
+            return this.state.loginInfo.UserID
+        },
+        // 登录ID
+        loginId() {
+            return this.state.loginInfo.LoginID
+        },
+        // 首个资金账户ID
+        firstAccountId() {
+            const accounts = this.state.loginInfo.AccountIDs
+            return accounts[0] ?? 0
+        },
+    },
+    actions: {
+        // 用户登录
+        userLogin(param: Proto.LoginReq) {
             this.state.loading = true
             return new Promise<Proto.LoginRsp>((resolve, reject) => {
                 queryLoginId({
@@ -49,6 +46,7 @@ const store = new (class extends VueStore<StoreState> {
                         login({
                             data: {
                                 ...param,
+                                GUID: v4(),
                                 LoginID: res.data,
                                 LoginPWD: cryptojs.SHA256(res.data + param.LoginPWD).toString(),
                             },
@@ -71,38 +69,13 @@ const store = new (class extends VueStore<StoreState> {
                 })
             })
         },
-        /** 获取用户登录信息 */
-        getLoginInfo: <K extends keyof Proto.LoginRsp>(key: K) => {
+        // 获取用户登录信息
+        getLoginInfo<K extends keyof Proto.LoginRsp>(key: K) {
             return this.state.loginInfo[key]
         },
-        /** 获取登录令牌 */
-        getToken: () => {
-            return this.state.loginInfo.Token
-        },
-        /** 获取用户ID */
-        getUserId: () => {
-            return this.state.loginInfo.UserID
-        },
-        /** 获取登录ID */
-        getLoginId: () => {
-            return Number(this.state.loginInfo.LoginID)
-        },
-        /** 获取首个账户ID */
-        getFirstAccountId: () => {
-            const accounts = this.state.loginInfo.AccountIDs
-            return accounts[0] ?? 0
-        },
-        /** 重置数据 */
-        reset: () => {
-            this.state.loginInfo = getInitData()
+        // 重置数据
+        reset() {
+            sessionData.reset('loginInfo')
         }
     }
-})
-
-export function useLoginStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 15 - 32
src/stores/modules/menu.ts

@@ -1,31 +1,22 @@
-import { toRefs, shallowReadonly, ShallowRef } from 'vue'
 import { queryNewFuncmenu } from '@/services/api/common'
 import { queryAccountMenu } from '@/services/api/account'
-import { VueStore } from '../base'
-import WebStorage from '@/utils/storage/base'
+import { createStore } from '../base'
+import { sessionData } from '../storage'
 
-interface StoreState {
-    loading: boolean;
-    userMenus: ShallowRef<Ermcp.UserMenu[]>;
-}
-
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const storage = new WebStorage<Ermcp.UserMenu[]>(sessionStorage, 'userMenus', [])
-        const state: StoreState = {
+export const menuStore = createStore({
+    state() {
+        return {
             loading: false,
-            userMenus: storage.getRef()
+            userRoutes: sessionData.getRef('userRoutes'),
         }
-        super(state)
-    }
-
-    actions = {
+    },
+    actions: {
         /** 获取用户菜单列表 */
-        getUserMenuList: () => {
+        getUserMenuList() {
             this.state.loading = true
             return queryAccountMenu({
                 success: (res) => {
-                    this.state.userMenus = res.data
+                    this.state.userRoutes = res.data
                 },
                 complete: () => {
                     this.state.loading = false
@@ -39,7 +30,7 @@ const store = new (class extends VueStore<StoreState>{
                     // 扁平列表树形化
                     const arrayToTree = (list: Ermcp.NewFuncmenuRsp[], code: null | string = null) => {
                         const getChildren = (parent: null | string) => {
-                            const result: Ermcp.UserMenu[] = []
+                            const result: Ermcp.UserRoutes[] = []
                             list.forEach((e) => {
                                 if (e.parentcode === parent) {
                                     const item = {
@@ -66,7 +57,7 @@ const store = new (class extends VueStore<StoreState>{
                         }
                         return getChildren(code)
                     }
-                    this.state.userMenus = arrayToTree(res.data)
+                    this.state.userRoutes = arrayToTree(res.data)
                 },
                 complete: () => {
                     this.state.loading = false
@@ -74,16 +65,8 @@ const store = new (class extends VueStore<StoreState>{
             })
         },
         /** 重置数据 */
-        reset: () => {
-            this.state.userMenus = []
+        reset() {
+            this.state.userRoutes = []
         }
     }
-})
-
-export function useMenuStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 16 - 35
src/stores/modules/performance.ts

@@ -1,28 +1,18 @@
-import { toRefs, shallowReadonly, ShallowRef } from 'vue'
 import { queryWrPerformanceStepType, queryPermancePlanTmp } from '@/services/api/performance'
-import { VueStore } from '../base'
-import WebStorage from '@/utils/storage'
+import { createStore } from '../base'
+import { sessionData } from '../storage'
 
-interface StoreState {
-    loading: boolean;
-    performanceStepTypes: ShallowRef<Ermcp.WrPerformanceStepTypeRsp[]>; // 履约步骤枚举
-    performanceTemplates: ShallowRef<Ermcp.PermancePlanTmpRsp[]>; // 履约模板
-}
-
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const storage = new WebStorage(sessionStorage, { performanceStepTypes: [], performanceTemplates: [] })
-        const state: StoreState = {
+export const performanceStore = createStore({
+    state() {
+        return {
             loading: false,
-            performanceStepTypes: storage.getRef('performanceStepTypes'),
-            performanceTemplates: storage.getRef('performanceTemplates'),
+            performanceStepTypes: sessionData.getRef('performanceStepTypes'), // 履约步骤枚举
+            performanceTemplates: sessionData.getRef('performanceTemplates'), // 履约模板
         }
-        super(state)
-    }
-
-    actions = {
-        /** 获取履约模板列表 */
-        getPerformanceTemplateList: () => {
+    },
+    actions: {
+        // 获取履约模板列表
+        getPerformanceTemplateList() {
             if (this.state.performanceTemplates.length) {
                 return Promise.resolve()
             }
@@ -36,12 +26,12 @@ const store = new (class extends VueStore<StoreState>{
                 }
             })
         },
-        /** 根据 id 查找对应的履约模板 */
-        getPerformanceTemplateById: (id: number) => {
+        // 根据 id 查找对应的履约模板
+        getPerformanceTemplateById(id: number) {
             return this.state.performanceTemplates.find((e) => e.autoid === id)
         },
-        /** 获取履约步骤枚举列表 */
-        getPerformanceStepTypeList: () => {
+        // 获取履约步骤枚举列表
+        getPerformanceStepTypeList() {
             if (this.state.performanceStepTypes.length) {
                 return Promise.resolve()
             }
@@ -55,14 +45,5 @@ const store = new (class extends VueStore<StoreState>{
                 }
             })
         },
-
     }
-})
-
-export function usePerformanceStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 11 - 28
src/stores/modules/tableColumn.ts

@@ -1,26 +1,17 @@
-import { toRefs, shallowReadonly, ShallowRef } from 'vue'
 import { queryTableDefine } from '@/services/api/common'
-import { VueStore } from '../base'
-import WebStorage from '@/utils/storage/base'
+import { createStore } from '../base'
+import { sessionData } from '../storage'
 
-interface StoreState {
-    loading: boolean;
-    tableColumns: ShallowRef<Ermcp.TableDefineRsp[]>;
-}
-
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const storage = new WebStorage<Ermcp.TableDefineRsp[]>(sessionStorage, 'tableColumns', [])
-        const state: StoreState = {
+export const tableColumnStore = createStore({
+    state() {
+        return {
             loading: false,
-            tableColumns: storage.getRef()
+            tableColumns: sessionData.getRef('tableColumns'),
         }
-        super(state)
-    }
-
-    actions = {
-        /** 获取表格列列表 */
-        getTableColumnList: () => {
+    },
+    actions: {
+        // 获取表格列列表
+        getTableColumnList() {
             if (this.state.tableColumns.length) {
                 return Promise.resolve()
             }
@@ -38,12 +29,4 @@ const store = new (class extends VueStore<StoreState>{
             })
         }
     }
-})
-
-export function useTableColumnStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 33 - 53
src/stores/modules/theme.ts

@@ -1,65 +1,45 @@
-import { toRefs, shallowReadonly, ShallowRef } from 'vue'
 import { AppTheme } from '@/constants/theme'
-import { VueStore } from '../base'
-import WebStorage from '@/utils/storage/base'
+import { createStore } from '../base'
+import { localData } from '../storage'
 import plus from '@/utils/h5plus'
 
-interface StoreState {
-    appTheme: ShallowRef<AppTheme>;
-}
-
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const storage = new WebStorage<AppTheme>(localStorage, 'appTheme', AppTheme.Default)
-        const state: StoreState = {
-            appTheme: storage.getRef()
+export const themeStore = createStore({
+    state() {
+        return {
+            appTheme: localData.getRef('appTheme'),
         }
-        super(state)
-        document.addEventListener('DOMContentLoaded', this.loadTheme, false)
-    }
-
-    /**
-     * 加载主题
-     */
-    private loadTheme = () => {
-        const theme = this.state.appTheme
-        this.setStatusBarTheme(theme)
-        document.documentElement.setAttribute('theme', theme)
-        document.removeEventListener('DOMContentLoaded', this.loadTheme)
-    }
-
-    /**
-     * 设置状态栏主题色
-     * @param theme 
-     */
-    private setStatusBarTheme = (theme: AppTheme) => {
-        switch (theme) {
-            case AppTheme.Default:
-            case AppTheme.Dark: {
-                plus.setStatusBarStyle('light')
-                break
+    },
+    actions: {
+        // 设置状态栏主题色
+        setStatusBarTheme(theme: AppTheme) {
+            switch (theme) {
+                case AppTheme.Default:
+                case AppTheme.Dark: {
+                    plus.setStatusBarStyle('light')
+                    break
+                }
+                default: {
+                    plus.setStatusBarStyle('dark')
+                }
             }
-            default: {
-                plus.setStatusBarStyle('dark')
-            }
-        }
-    }
-
-    actions = {
-        /** 设置主题 */
-        setTheme: (key: keyof typeof AppTheme) => {
+        },
+        // 设置主题
+        setTheme(key: keyof typeof AppTheme) {
             const theme = AppTheme[key]
-            this.setStatusBarTheme(theme)
+            this.actions.setStatusBarTheme(theme)
             document.documentElement.setAttribute('theme', theme)
             this.state.appTheme = theme
         }
     }
 })
 
-export function useThemeStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+// 加载主题
+const loadTheme = () => {
+    const theme = themeStore.state.appTheme
+    themeStore.actions.setStatusBarTheme(theme)
+    document.documentElement.setAttribute('theme', theme)
+    document.removeEventListener('DOMContentLoaded', loadTheme)
+}
+
+// 等待 dom 加载完毕
+document.addEventListener('DOMContentLoaded', loadTheme, false)

+ 22 - 37
src/stores/modules/user.ts

@@ -1,21 +1,15 @@
-import { toRefs, shallowReadonly } from 'vue'
 import { queryLoginData } from '@/services/api/account'
-import { useLoginStore } from './login'
-import { VueStore } from '../base'
-
-interface StoreState {
-    loading: boolean;
-    userData: Ermcp.LoginQueryRsp;
-}
+import { loginStore } from './login'
+import { createStore } from '../base'
 
 /**
- * 用户存储
+ * 用户存储对象
  */
-const store = new (class extends VueStore<StoreState>{
-    constructor() {
-        const state: StoreState = {
+export const userStore = createStore({
+    state() {
+        return {
             loading: false,
-            userData: {
+            userData: <Ermcp.LoginQueryRsp>{
                 arearole: [],
                 externalExchanges: [],
                 goodsgroups: [],
@@ -23,17 +17,21 @@ const store = new (class extends VueStore<StoreState>{
                 systemParams: []
             },
         }
-        super(state)
-    }
-
-    actions = {
-        /** 获取用户数据 */
-        getUserData: () => {
-            const { getLoginId } = useLoginStore()
+    },
+    getters: {
+        // 登录机构名称
+        accountName() {
+            const { userAccount } = this.state.userData
+            return userAccount?.accountname
+        }
+    },
+    actions: {
+        // 获取用户数据
+        getUserData() {
             this.state.loading = true
             return queryLoginData({
                 data: {
-                    loginID: getLoginId()
+                    loginID: loginStore.getters.loginId
                 },
                 success: (res) => {
                     this.state.userData = res.data
@@ -43,22 +41,9 @@ const store = new (class extends VueStore<StoreState>{
                 }
             })
         },
-        /** 获取用户数据 */
-        getUserDataInfo: <K extends keyof Ermcp.LoginQueryRsp>(key: K) => {
+        // 获取用户数据
+        getUserDataInfo<K extends keyof Ermcp.LoginQueryRsp>(key: K) {
             return this.state.userData[key]!
         },
-        /** 获取登录机构名称 */
-        getAccountName: () => {
-            const { userAccount } = this.state.userData
-            return userAccount?.accountname
-        }
     }
-})
-
-export function useUserStore() {
-    return shallowReadonly({
-        ...toRefs(store.state),
-        ...store.actions,
-        ...store.methods,
-    })
-}
+})

+ 35 - 0
src/stores/storage.ts

@@ -0,0 +1,35 @@
+import { Language } from '@/constants/language'
+import { AppTheme } from '@/constants/theme'
+import WebStorage from '@/utils/storage'
+
+function createLocalData() {
+    return {
+        appLanguage: Language.ZhCN,
+        appTheme: AppTheme.Default,
+    }
+}
+
+function createSessionData() {
+    return {
+        loginInfo: <Proto.LoginRsp>{
+            AccountIDs: [],
+            LoginCode: '',
+            LoginID: 0,
+            LoginUserType: 0,
+            AccountStatus: 0,
+            UserID: 0,
+            ClientID: 0,
+            MemberUserID: 0,
+            Token: '',
+        },
+        userRoutes: <Ermcp.UserRoutes[]>[],
+        allEnums: <Ermcp.EnumRsp[]>[], // 枚举信息
+        errorInfos: <Ermcp.ErrorInfosRsp[]>[], // 错误信息
+        performanceStepTypes: <Ermcp.WrPerformanceStepTypeRsp[]>[], // 履约步骤枚举
+        performanceTemplates: <Ermcp.PermancePlanTmpRsp[]>[], // 履约模板
+        tableColumns: <Ermcp.TableDefineRsp[]>[],
+    }
+}
+
+export const localData = new WebStorage(localStorage, createLocalData(), 'gz@')
+export const sessionData = new WebStorage(sessionStorage, createSessionData(), 'gz@')

+ 2 - 2
src/types/ermcp/account.d.ts

@@ -272,7 +272,7 @@ declare global {
         }
 
         /** 用户菜单 */
-        interface UserMenu {
+        interface UserRoutes {
             id: number; // 自增ID
             authType: AuthType; // 权限类型
             title: string; // 标题
@@ -287,7 +287,7 @@ declare global {
             hidden: boolean; // 是否隐藏
             sort: number; // 排序
             remark: string; // 备注
-            children?: UserMenu[],
+            children?: UserRoutes[],
         }
 
         /** 用户角色 */

+ 1 - 1
src/types/ermcp/quote.d.ts

@@ -1,7 +1,7 @@
 /** 企业风管 */
 declare namespace Ermcp {
     /** 商品盘面 */
-    interface QuoteDay {
+    interface QuoteDayRsp {
         Lastturnover: number;
         ask: number;
         ask2: number;

+ 5 - 3
src/utils/storage/index.ts

@@ -4,7 +4,8 @@ import { shallowRef, ShallowRef, watch } from 'vue'
  * 本地存储类
  */
 export default class <T extends object> {
-    constructor(storage: Storage, source: T) {
+    constructor(storage: Storage, source: T, prefix = '@') {
+        this.prefix = prefix
         this.storage = storage
         this.source = source
 
@@ -18,6 +19,7 @@ export default class <T extends object> {
 
     private readonly storage: Storage
     private readonly source // 初始数据
+    private readonly prefix // 防止命名冲突
     private state = {} as { [K in keyof T]: ShallowRef<T[K]> }
 
     /**
@@ -30,7 +32,7 @@ export default class <T extends object> {
                 this.reset(key)
             } else {
                 const strValue = JSON.stringify(value) // 注意数值长度过长会被自动转换为 String 类型
-                this.storage.setItem(key.toString(), strValue)
+                this.storage.setItem(this.prefix + key.toString(), strValue)
             }
         })
     }
@@ -41,7 +43,7 @@ export default class <T extends object> {
      * @returns 
      */
     getValue<K extends keyof T>(key: K) {
-        const storageValue = this.storage.getItem(key.toString())
+        const storageValue = this.storage.getItem(this.prefix + key.toString())
         if (storageValue !== 'undefined' && storageValue !== null) {
             return JSON.parse(storageValue) as T[K]
         } else {