diff --git a/.workbuddy/expert-history.json b/.workbuddy/expert-history.json index 96d9057..c1e38f3 100644 --- a/.workbuddy/expert-history.json +++ b/.workbuddy/expert-history.json @@ -13,5 +13,5 @@ } ] }, - "lastUpdated": 1776157357538 + "lastUpdated": 1776158712744 } \ No newline at end of file diff --git a/backend/my_work/routers/apiPurchase.go b/backend/my_work/routers/apiPurchase.go index 82bebc1..b7ba704 100644 --- a/backend/my_work/routers/apiPurchase.go +++ b/backend/my_work/routers/apiPurchase.go @@ -709,4 +709,42 @@ func ApiPurchase(r *gin.RouterGroup) { ReturnJson(ctx, "apiOK", nil) }) + // 获取订单数量统计 + r.POST("/getordercount", func(ctx *gin.Context) { + isAuth, _, _ := AuthenticationAuthority(ctx) + if !isAuth { + ReturnJson(ctx, "userCookieError", nil) + return + } + + type OrderCount struct { + Pending int64 `json:"pending"` // 待处理 + Ordered int64 `json:"ordered"` // 已下单 + Arrived int64 `json:"arrived"` // 已到达 + Received int64 `json:"received"` // 已收件 + Lost int64 `json:"lost"` // 丢件 + Returned int64 `json:"returned"` // 退件 + Total int64 `json:"total"` // 总数 + } + + var count OrderCount + models.DB.Model(&TabPurchaseOrder{}).Count(&count.Total) + models.DB.Model(&TabPurchaseOrder{}).Where("order_status = ?", "pending").Count(&count.Pending) + models.DB.Model(&TabPurchaseOrder{}).Where("order_status = ?", "ordered").Count(&count.Ordered) + models.DB.Model(&TabPurchaseOrder{}).Where("order_status = ?", "arrived").Count(&count.Arrived) + models.DB.Model(&TabPurchaseOrder{}).Where("order_status = ?", "received").Count(&count.Received) + models.DB.Model(&TabPurchaseOrder{}).Where("order_status = ?", "lost").Count(&count.Lost) + models.DB.Model(&TabPurchaseOrder{}).Where("order_status = ?", "returned").Count(&count.Returned) + + ReturnJson(ctx, "apiOK", map[string]interface{}{ + "pending": count.Pending, + "ordered": count.Ordered, + "arrived": count.Arrived, + "received": count.Received, + "lost": count.Lost, + "returned": count.Returned, + "total": count.Total, + }) + }) + } diff --git a/frontend/ops_vue_js/src/api/purchase.js b/frontend/ops_vue_js/src/api/purchase.js index 6c22164..3602d69 100644 --- a/frontend/ops_vue_js/src/api/purchase.js +++ b/frontend/ops_vue_js/src/api/purchase.js @@ -6,6 +6,11 @@ export const purchaseApi = { return api.post('/purchase/getorders', params) }, + /** 获取订单数量统计 */ + getOrderCount() { + return api.post('/purchase/getordercount', {}) + }, + /** 新增采购订单 */ addOrder(data) { return api.post('/purchase/addorder', data) diff --git a/frontend/ops_vue_js/src/i18n/en.json b/frontend/ops_vue_js/src/i18n/en.json index a451719..b27fe02 100644 --- a/frontend/ops_vue_js/src/i18n/en.json +++ b/frontend/ops_vue_js/src/i18n/en.json @@ -94,6 +94,7 @@ "link": "Link", "no_photos": "No photos", "open_link": "Open Link", + "copy_link": "Copy Link", "no_costs": "No cost records", "cost_total": "Total", "change_status": "Change Status", @@ -191,7 +192,8 @@ "today_schedule_count": "Today: {count} schedule(s)", "today_no_schedule": "No schedules today", "loading": "Loading...", - "today": "Today: {date}" + "today": "Today: {date}", + "pending_orders": "Pending orders" }, "message": { "functionality_not_yet_developed": "Functionality not yet developed", diff --git a/frontend/ops_vue_js/src/i18n/zh-CN.json b/frontend/ops_vue_js/src/i18n/zh-CN.json index d9eb120..7702ac9 100644 --- a/frontend/ops_vue_js/src/i18n/zh-CN.json +++ b/frontend/ops_vue_js/src/i18n/zh-CN.json @@ -94,6 +94,7 @@ "link": "链接", "no_photos": "暂无图片", "open_link": "打开链接", + "copy_link": "复制链接", "no_costs": "暂无费用记录", "cost_total": "合计", "change_status": "变更状态", @@ -191,7 +192,8 @@ "today_schedule_count": "今日共 {count} 个日程", "today_no_schedule": "今日暂无日程", "loading": "加载中...", - "today": "今日:{date}" + "today": "今日:{date}", + "pending_orders": "待处理订单" }, "message": { "functionality_not_yet_developed": "功能未开发", diff --git a/frontend/ops_vue_js/src/views/HomeView.vue b/frontend/ops_vue_js/src/views/HomeView.vue index 977b076..e9a13c4 100644 --- a/frontend/ops_vue_js/src/views/HomeView.vue +++ b/frontend/ops_vue_js/src/views/HomeView.vue @@ -4,6 +4,7 @@ import { useUserStore } from '@/stores/user' import { useUsersStore } from '@/stores/users' import { usePageTitle } from '@/composables/usePageTitle' import { scheduleApi } from '@/api/schedule' +import { purchaseApi } from '@/api/purchase' import { ref, computed, onMounted } from 'vue' usePageTitle('appname.home') @@ -15,6 +16,10 @@ const usersStore = useUsersStore() const todaySchedules = ref([]) const loadingSchedules = ref(false) +// 采购订单数据 +const pendingOrderCount = ref(0) +const loadingOrders = ref(false) + // 获取今日日期字符串 const todayStr = computed(() => { const today = new Date() @@ -57,6 +62,21 @@ async function fetchTodaySchedules() { } } +// 获取待处理订单数量 +async function fetchPendingOrders() { + loadingOrders.value = true + try { + const { errCode, data } = await purchaseApi.getOrderCount() + if (errCode === 0 && data) { + pendingOrderCount.value = data.pending || 0 + } + } catch (e) { + console.error('获取订单数量失败', e) + } finally { + loadingOrders.value = false + } +} + // 获取用户名 function getUsername(userId) { if (!userId) return '' @@ -100,6 +120,9 @@ function getWeekday(dateStr) { onMounted(() => { fetchTodaySchedules() + if (userStore.isLoggedIn) { + fetchPendingOrders() + } }) @@ -161,12 +184,19 @@ onMounted(() => {
{{ t('appname.purchase') }}
-—
-+ ... + + {{ pendingOrderCount || '—' }} + +
+{{ t('home.pending_orders') }}
++