This commit is contained in:
2025-09-17 14:40:16 +08:00
parent 46c5682960
commit a3bbc0098a
94 changed files with 3549 additions and 105 deletions

View File

@@ -69,7 +69,7 @@
<view class="tab" :class="{ active: activeTab==='home' }" @click="activeTab='home'">
<text>首页</text>
</view>
<view class="tab" :class="{ active: activeTab==='product' }" @click="activeTab='product'">
<view class="tab" :class="{ active: activeTab==='product' }" @click="goProduct">
<text>货品</text>
</view>
<view class="tab primary" @click="onCreateOrder">
@@ -99,6 +99,7 @@
loadingNotices: false,
noticeError: '',
features: [
{ key: 'product', title: '货品', img: '/static/icons/product.png', emoji: '📦' },
{ key: 'customer', title: '客户', img: '/static/icons/customer.png', emoji: '👥' },
{ key: 'sale', title: '销售', img: '/static/icons/sale.png', emoji: '💰' },
{ key: 'account', title: '账户', img: '/static/icons/account.png', emoji: '💳' },
@@ -118,12 +119,14 @@
methods: {
async fetchMetrics() {
try {
const d = await get('/api/metrics/overview')
const d = await get('/api/dashboard/overview')
const toNum = v => (typeof v === 'number' ? v : Number(v || 0))
this.kpi = {
todaySales: (d && d.todaySales) || '0.00',
monthSales: (d && d.monthSales) || '0.00',
monthProfit: (d && d.monthProfit) || '0.00',
stockCount: (d && d.stockCount) || '0'
...this.kpi,
todaySales: toNum(d && d.todaySalesAmount).toFixed(2),
monthSales: toNum(d && d.monthSalesAmount).toFixed(2),
monthProfit: toNum(d && d.monthGrossProfit).toFixed(2),
stockCount: String((d && d.stockTotalQuantity) != null ? d.stockTotalQuantity : 0)
}
} catch (e) {
// 忽略错误,保留默认值
@@ -145,8 +148,16 @@
}
},
onFeatureTap(item) {
if (item.key === 'product') {
uni.navigateTo({ url: '/pages/product/list' })
return
}
uni.showToast({ title: item.title + '(开发中)', icon: 'none' })
},
goProduct() {
this.activeTab = 'product'
uni.navigateTo({ url: '/pages/product/list' })
},
onCreateOrder() {
uni.navigateTo({ url: '/pages/order/create' })
},