incubator.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { defineStore } from 'pinia'
  2. import { AxiosWrapper } from '@/utils/axios-wrapper'
  3. import { get } from 'lodash-es'
  4. const url = '/incubator'
  5. const axios = new AxiosWrapper()
  6. export const IncubatorStore = defineStore('incubator', () => {
  7. const query = async ({ skip = 0, limit = undefined, ...info } = {}) => {
  8. let cond = {}
  9. if (skip) cond.skip = skip
  10. if (limit) cond.limit = limit
  11. cond = { ...cond, ...info }
  12. const res = await axios.$get(`${url}`, cond)
  13. return res
  14. }
  15. const list = async ({ skip = 0, limit = undefined, ...info } = {}) => {
  16. let cond = {}
  17. if (skip) cond.skip = skip
  18. if (limit) cond.limit = limit
  19. cond = { ...cond, ...info }
  20. const res = await axios.$get(`${url}/list`, cond)
  21. return res
  22. }
  23. const all = async ({ skip = 0, limit = undefined, ...info } = {}) => {
  24. let cond = {}
  25. if (skip) cond.skip = skip
  26. if (limit) cond.limit = limit
  27. cond = { ...cond, ...info }
  28. const res = await axios.$get(`${url}/allList`, cond)
  29. return res
  30. }
  31. const statistics = async (payload) => {
  32. const res = await axios.$get(`${url}/statistics`, payload)
  33. return res
  34. }
  35. const fetch = async (payload) => {
  36. const res = await axios.$get(`${url}/${payload}`)
  37. return res
  38. }
  39. const detail = async (payload) => {
  40. const res = await axios.$get(`${url}/detail/${payload}`)
  41. return res
  42. }
  43. const create = async (payload) => {
  44. const res = await axios.$post(`${url}`, payload)
  45. return res
  46. }
  47. const update = async (payload) => {
  48. const id = get(payload, 'id', get(payload, '_id'))
  49. const res = await axios.$post(`${url}/${id}`, payload)
  50. return res
  51. }
  52. const del = async (payload) => {
  53. const res = await axios.$delete(`${url}/${payload}`)
  54. return res
  55. }
  56. return {
  57. query,
  58. list,
  59. all,
  60. statistics,
  61. detail,
  62. fetch,
  63. create,
  64. update,
  65. del
  66. }
  67. })