zs преди 2 години
родител
ревизия
eb88d60288
променени са 2 файла, в които са добавени 59 реда и са изтрити 1 реда
  1. 53 0
      src/stores/allAdmin/dockChat.ts
  2. 6 1
      src/stores/allAdmin/dockUser.ts

+ 53 - 0
src/stores/allAdmin/dockChat.ts

@@ -0,0 +1,53 @@
+import { ref, computed } from 'vue'
+import { defineStore } from 'pinia'
+import { AxiosWrapper } from '@/util/axios-wrapper'
+import _ from 'lodash'
+
+import type { IQueryType, IQueryResult, IQueryParams } from '@/util/types.util'
+const axios = new AxiosWrapper()
+const api = {
+  url: `/zkzx/v2/api/dockChat`
+}
+export const DockChatStore = defineStore('dockChat', () => {
+  const count = ref(0)
+  const doubleCount = computed(() => count.value * 2)
+  function increment() {
+    count.value++
+  }
+  const query = async ({ skip = 0, limit = undefined, ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    let cond: IQueryType = {}
+    if (skip) cond.skip = skip
+    if (limit) cond.limit = limit
+    cond = { ...cond, ...info }
+    const res = await axios.$get(`${api.url}`, cond)
+    return res
+  }
+  const fetch = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/${payload}`)
+    return res
+  }
+  const create = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$post(`${api.url}`, payload)
+    return res
+  }
+  const update = async (payload: any): Promise<IQueryResult> => {
+    const id = _.get(payload, 'id', _.get(payload, '_id'))
+    const res = await axios.$post(`${api.url}/${id}`, payload)
+    return res
+  }
+  const del = async (payload: any): Promise<IQueryResult> => {
+    const res = await axios.$delete(`${api.url}/${payload}`)
+    return res
+  }
+
+  return {
+    count,
+    doubleCount,
+    increment,
+    query,
+    fetch,
+    create,
+    update,
+    del
+  }
+})

+ 6 - 1
src/stores/allAdmin/dockUser.ts

@@ -39,6 +39,10 @@ export const DockUserStore = defineStore('dockUser', () => {
     const res = await axios.$delete(`${api.url}/${payload}`)
     return res
   }
+  const dockQuery = async ({ ...info }: IQueryParams = {}): Promise<IQueryResult> => {
+    const res = await axios.$get(`${api.url}/getProductListByDockId`, info)
+    return res
+  }
 
   return {
     count,
@@ -48,6 +52,7 @@ export const DockUserStore = defineStore('dockUser', () => {
     fetch,
     create,
     update,
-    del
+    del,
+    dockQuery
   }
 })