1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { defineStore } from 'pinia'
- import { AxiosWrapper } from '@/utils/axios-wrapper'
- import { get } from 'lodash-es'
- const url = '/unit'
- const axios = new AxiosWrapper()
- export const UnitStore = defineStore('unit', () => {
- const query = async ({ skip = 0, limit = undefined, ...info } = {}) => {
- let cond = {}
- if (skip) cond.skip = skip
- if (limit) cond.limit = limit
- cond = { ...cond, ...info }
- const res = await axios.$get(`${url}`, cond)
- return res
- }
- const fetch = async (payload) => {
- const res = await axios.$get(`${url}/${payload}`)
- return res
- }
- const create = async (payload) => {
- const res = await axios.$post(`${url}`, payload)
- return res
- }
- const update = async (payload) => {
- const id = get(payload, 'id', get(payload, 'id'))
- const res = await axios.$post(`${url}/${id}`, payload)
- return res
- }
- const del = async (payload) => {
- const res = await axios.$delete(`${url}/${payload}`)
- return res
- }
- const examine = async (payload) => {
- const id = get(payload, 'id')
- const status = get(payload, 'status')
- const res = await axios.$post(`${url}/examine`, { id, status })
- return res
- }
- return {
- query,
- fetch,
- create,
- update,
- del,
- examine
- }
- })
|