useSetWareHouseStore.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import {
  2. defineStore
  3. } from 'pinia';
  4. export const useSetWareHouseStore = defineStore('warehouse', {
  5. state: () => ({
  6. warehouseList: [],
  7. regionList: [],
  8. locationList: []
  9. }),
  10. getters: {
  11. getData: (state) => {
  12. state.warehouseList, state.regionList, state.locationList
  13. },
  14. },
  15. actions: {
  16. // 仓库列表数据
  17. getList(state) {
  18. return new Promise((resolve, reject) => {
  19. uni.$reqGet('warehouseDropDownList')
  20. .then(({
  21. code,
  22. data,
  23. msg
  24. }) => {
  25. if (code === 0) {
  26. this.warehouseList = []
  27. data?.forEach(item => {
  28. this.warehouseList.push({
  29. id: item.id,
  30. text: item.name,
  31. value: item.id
  32. })
  33. })
  34. resolve(this.warehouseList)
  35. } else {
  36. reject(msg)
  37. }
  38. })
  39. })
  40. },
  41. // 根据ID查询区域列表数据
  42. handleGetRegionList(wmsStockId) {
  43. return new Promise((resolve, reject) => {
  44. uni.$reqGet('regionDropDownList', {
  45. wmsStockId
  46. })
  47. .then(({
  48. code,
  49. data,
  50. msg
  51. }) => {
  52. if (code === 0) {
  53. this.regionList = []
  54. data?.forEach(item => {
  55. this.regionList.push({
  56. id: item.id,
  57. text: item.name,
  58. value: item.id
  59. })
  60. })
  61. resolve(this.regionList)
  62. } else {
  63. reject(msg)
  64. }
  65. })
  66. })
  67. },
  68. // 根据ID查询货位列表数据
  69. handleGetLocationList(stockArea) {
  70. return new Promise((resolve, reject) => {
  71. uni.$reqGet('locationDropDownList', {
  72. stockArea
  73. })
  74. .then(({
  75. code,
  76. data,
  77. msg
  78. }) => {
  79. if (code === 0) {
  80. this.locationList = []
  81. data?.forEach(item => {
  82. this.locationList.push({
  83. id: item.id,
  84. text: item.name,
  85. value: item.id
  86. })
  87. })
  88. resolve(this.locationList)
  89. } else {
  90. reject(msg)
  91. }
  92. })
  93. })
  94. }
  95. },
  96. persist: true, // 设置持久化
  97. // 单独设置存储位置
  98. // persist: {
  99. // storage: window.localStorage,
  100. // },
  101. })