feat 供应商添加拉取库存

This commit is contained in:
timerzz 2024-11-21 14:35:50 +08:00
parent 1f836ffbed
commit 225446f201
6 changed files with 67 additions and 22 deletions

View File

@ -42,6 +42,14 @@ export const FetchProviderArticles = (providerId)=>{
return provider.post(`/${providerId}/pull`) return provider.post(`/${providerId}/pull`)
} }
export const FetchProviderArticle = (providerArticle)=>{ export const FetchProviderArticlePrice = (providerArticle)=>{
return provider.post(`/${providerArticle.providerId}/fetch/${providerArticle.id}`) return provider.post(`/${providerArticle.providerId}/price/fetch/${providerArticle.id}`)
}
export const FetchProviderArticleAts = (providerArticle)=>{
return provider.post(`/${providerArticle.providerId}/ats/fetch/${providerArticle.skuID}`)
}
export const FetchProviderArticleDetail = (pid)=>{
return provider.post(`/${providerArticle.providerId}/detail/fetch/${pid}`)
} }

View File

@ -8,7 +8,9 @@
</div> </div>
</template> </template>
<template #header> <template #header>
<span class="text-lg">{{header}}</span> <div>
<span class="text-lg">{{header}}</span>
</div>
</template> </template>
<div class="flex flex-col space-y-8"> <div class="flex flex-col space-y-8">
<div class="flex space-x-4 "> <div class="flex space-x-4 ">
@ -22,17 +24,25 @@
</div> </div>
<div class="flex space-x-4 items-center"> <div class="flex space-x-4 items-center">
<div class="w-full">当前售价$ {{provider.cost.originalPrice || '-'}}</div> <div class="w-full">当前售价$ {{provider.cost.originalPrice || '-'}}</div>
<a-popover v-if="provider.cost.calMark" trigger="hover">
<template #content> <div v-if="provider.cost.calMark" class="w-full flex items-center space-x-4">
<a-popover trigger="hover">
<template #content>
<span class="whitespace-pre"> <span class="whitespace-pre">
{{provider.cost.calMark}} {{provider.cost.calMark}}
</span> </span>
</template> </template>
<div class="w-full">当前到手价 {{provider.cost.finalPrice || '-'}}</div> <div>当前到手价 {{provider.cost.finalPrice || '-'}}</div>
</a-popover> </a-popover>
<div class="w-full" v-else>当前到手价 {{provider.cost.finalPrice || '-'}}</div> <a-button type="primary" @click="fetchArticle(provider)" :loading="fetchLoading">拉取价格</a-button>
<div class="w-full"> </div>
<a-button type="primary" @click="fetchArticle(provider)" :loading="fetchLoading">立即拉取</a-button> <div class="w-full flex items-center space-x-4" v-else>
<div>当前到手价 {{provider.cost.finalPrice || '-'}}</div>
<a-button type="primary" @click="fetchArticle(provider)" :loading="fetchLoading">拉取价格</a-button>
</div>
<div class="w-full flex items-center space-x-4">
<div>库存{{provider.ast }}</div>
<a-button type="primary" @click="fetchArticleAts(provider)" :loading="fetchLoading">拉取库存</a-button>
</div> </div>
</div> </div>
<v-chart class="h-400px w-full" :option="options" /> <v-chart class="h-400px w-full" :option="options" />
@ -112,7 +122,7 @@ import { use } from 'echarts/core'
import { LineChart } from 'echarts/charts' import { LineChart } from 'echarts/charts'
import { GridComponent, TitleComponent, TooltipComponent, LegendComponent } from 'echarts/components' import { GridComponent, TitleComponent, TooltipComponent, LegendComponent } from 'echarts/components'
import { CanvasRenderer } from 'echarts/renderers' import { CanvasRenderer } from 'echarts/renderers'
import {FetchProviderArticle} from "@/api/provider.js"; import {FetchProviderArticleAts, FetchProviderArticlePrice} from "@/api/provider.js";
use([GridComponent, LineChart, CanvasRenderer, TitleComponent , TooltipComponent, LegendComponent ]) use([GridComponent, LineChart, CanvasRenderer, TitleComponent , TooltipComponent, LegendComponent ])
@ -156,7 +166,7 @@ const fetchLoading = ref(false)
// //
const fetchArticle = (pArticle) => { const fetchArticle = (pArticle) => {
fetchLoading.value = true fetchLoading.value = true
FetchProviderArticle(pArticle).then(res=>{ FetchProviderArticlePrice(pArticle).then(res=>{
if(res.code !== 200){ if(res.code !== 200){
message.error(`拉取失败:${res.msg}`) message.error(`拉取失败:${res.msg}`)
}else { }else {
@ -167,8 +177,28 @@ const fetchArticle = (pArticle) => {
console.log(err) console.log(err)
}).finally(()=>{ }).finally(()=>{
fetchLoading.value = false fetchLoading.value = false
emits('fetched')
}) })
} }
const fetchArticleAts = (pArticle) => {
fetchLoading.value = true
FetchProviderArticleAts(pArticle).then(res=>{
if(res.code !== 200){
message.error(`拉取失败:${res.msg}`)
}else {
message.success('拉取成功')
}
}).catch(err => {
message.error('拉取失败')
console.log(err)
}).finally(()=>{
fetchLoading.value = false
emits('fetched')
})
}
const emits = defineEmits(['fetched'])
</script> </script>

View File

@ -9,3 +9,7 @@ html,body,#app {
width: 0; width: 0;
background: transparent; background: transparent;
} }
.ant-collapse-header{
align-items: center !important;
}

View File

@ -1,6 +1,6 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import './css/base.css'
import App from './App.vue' import App from './App.vue'
import './css/base.css'
import 'virtual:uno.css' import 'virtual:uno.css'
import router from "@/routers/index.js"; import router from "@/routers/index.js";

View File

@ -51,7 +51,10 @@
</seller-article-panel> </seller-article-panel>
<provider-article-panel v-else-if="activeTabKey === 'providers'" v-for="item in data.providers || []" :key="`${item.providerId}`" <provider-article-panel v-else-if="activeTabKey === 'providers'" v-for="item in data.providers || []" :key="`${item.providerId}`"
:provider="item" :provider-dict="dict.providers" :open="openTabKey.indexOf(item.providerId) > -1"> :provider="item" :provider-dict="dict.providers"
:open="openTabKey.indexOf(item.providerId) > -1"
@fetched="load"
>
</provider-article-panel> </provider-article-panel>
</a-collapse> </a-collapse>

View File

@ -35,36 +35,36 @@ export default defineConfig({
ws: true, ws: true,
}, },
'/api/v2/sellers': { '/api/v2/sellers': {
target: 'http://localhost:8081/', // target: 'http://localhost:8081/',
// target: 'http://192.168.31.55:2280/', target: 'https://ht.timerzz.com:20443/',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
ws: true, ws: true,
}, },
'/api/v2/seller': { '/api/v2/seller': {
target: 'http://localhost:8083/', // target: 'http://localhost:8083/',
// target: 'http://192.168.31.55:2280/', target: 'https://ht.timerzz.com:20443/',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
ws: true, ws: true,
}, },
'/api/v2/providers': { '/api/v2/providers': {
target: 'http://localhost:8080/', target: 'http://localhost:8080/',
// target: 'http://192.168.31.55:2280/', // target: 'https://ht.timerzz.com:20443/',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
ws: true, ws: true,
}, },
'/api/v2/provider': { '/api/v2/provider': {
target: 'http://172.21.195.130:8082/', target: 'http://172.21.195.130:8082/',
// target: 'http://192.168.31.55:2280/', // target: 'https://ht.timerzz.com:20443/',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
ws: true, ws: true,
}, },
'/api/v2/articles': { '/api/v2/articles': {
// target: 'https://ht.timerzz.com:20443/',
target: 'http://localhost:8085/', target: 'http://localhost:8085/',
// target: 'http://192.168.31.55:2280/',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
ws: true, ws: true,