zs 1 年之前
父節點
當前提交
f8fed43d3c
共有 2 個文件被更改,包括 42 次插入2 次删除
  1. 40 0
      src/store/api/platform/supply.js
  2. 2 2
      src/views/platform/demand/supply/index.vue

+ 40 - 0
src/store/api/platform/supply.js

@@ -0,0 +1,40 @@
+import { defineStore } from 'pinia'
+import { AxiosWrapper } from '@/utils/axios-wrapper'
+import { get } from 'lodash-es'
+const url = '/supply'
+const axios = new AxiosWrapper()
+
+export const SupplyStore = defineStore('supply', () => {
+  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
+  }
+  return {
+    query,
+    fetch,
+    create,
+    update,
+    del
+  }
+})

+ 2 - 2
src/views/platform/demand/supply/index.vue

@@ -58,9 +58,9 @@ import { cloneDeep, get } from 'lodash-es'
 const $checkRes = inject('$checkRes')
 const { t } = useI18n()
 // 接口
-import { DemandStore } from '@/store/api/platform/demand'
+import { SupplyStore } from '@/store/api/platform/supply'
 import { DictDataStore } from '@/store/api/system/dictData'
-const store = DemandStore()
+const store = SupplyStore()
 const dictDataStore = DictDataStore()
 const data = ref([])
 const searchForm = ref({})