zs 11 месяцев назад
Родитель
Сommit
0257ff6f11
2 измененных файлов с 71 добавлено и 1 удалено
  1. 54 0
      src/store/api/platform/supply.js
  2. 17 1
      src/views/demand/index.vue

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

@@ -0,0 +1,54 @@
+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 list = 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}/list`, cond)
+    return res
+  }
+  const fetch = async (payload) => {
+    const res = await axios.$get(`${url}/${payload}`)
+    return res
+  }
+  const detail = async (payload) => {
+    const res = await axios.$get(`${url}/detail/${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,
+    list,
+    fetch,
+    create,
+    detail,
+    update,
+    del
+  }
+})

+ 17 - 1
src/views/demand/index.vue

@@ -163,6 +163,10 @@
             </el-row>
           </el-col>
           <el-col :span="24" class="two">
+            <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
+              <el-tab-pane label="需求" name="0"></el-tab-pane>
+              <el-tab-pane label="供给" name="1"></el-tab-pane>
+            </el-tabs>
             <el-col
               :span="24"
               class="list"
@@ -220,8 +224,10 @@ const $checkRes = inject('$checkRes')
 import { get } from 'lodash-es'
 // 接口
 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 supplyStore = SupplyStore()
 const dictDataStore = DictDataStore()
 // 图片引入
 import demand from '@/assets/innovation.png'
@@ -229,6 +235,7 @@ import demand from '@/assets/innovation.png'
 const router = useRouter()
 // 加载中
 const loading = ref(false)
+const type = ref('0')
 // 列表
 const list = ref([])
 let skip = 0
@@ -300,7 +307,10 @@ const search = async (query = { skip: 0, limit }) => {
       return i.value
     })
   }
-  const res = await store.list(info)
+
+  let res
+  if (type.value == '0') res = await store.list(info)
+  else if (type.value == '1') res = await supplyStore.list(info)
   if (res.errcode == '0') {
     list.value = res.data
     total.value = res.total
@@ -317,6 +327,12 @@ const getArea = (data) => {
   if (data) return data.join(',')
   else return '暂无地区'
 }
+const handleClick = async (tab) => {
+  type.value = tab.props.name
+  loading.value = true
+  await search({ skip, limit })
+  loading.value = false
+}
 // 选择查询
 const toSelect = async (item, num) => {
   if (item.is_active) return