fix order items

This commit is contained in:
2026-04-03 10:17:18 +08:00
parent 5189798732
commit 240a714f6e
+6 -5
View File
@@ -1,6 +1,7 @@
import { api } from '@/utils/request'
import type { PaginatedData, OrderItemFilters } from '@/types/api'
import type { OrderItemRecord } from '@/stores/order'
export type { OrderItemRecord }
/** 名称映射用的查找表 */
interface LookupItem {
@@ -31,24 +32,24 @@ export const useOrderItemStore = defineStore('orderItem', () => {
// 名称映射数据
const companies = ref<LookupItem[]>([])
const platforms = ref<{ id: number; developer_id: number }[]>([])
const platforms = ref<{ id: number; name: string; label?: string; developer_id: number }[]>([])
const stores = ref<(LookupItem & { company_id: number; platform_id: number })[]>([])
const companyMap = computed(
() => new Map(companies.value.map((c) => [c.id, c.label || c.name])),
() => new Map(companies.value.map((c) => [c.id, (c.label && c.label !== 'null') ? c.label : c.name])),
)
const platformMap = computed(
() => new Map(platforms.value.map((p) => [p.id, `平台 #${p.id}`])),
() => new Map(platforms.value.map((p) => [p.id, (p.label && p.label !== 'null') ? p.label : (p.name || `平台 #${p.id}`)])),
)
const storeMap = computed(
() => new Map(stores.value.map((s) => [s.id, s.label || s.name])),
() => new Map(stores.value.map((s) => [s.id, (s.label && s.label !== 'null') ? s.label : s.name])),
)
async function loadLookups() {
try {
const [c, p, s] = await Promise.all([
api.get<LookupItem[]>('/api/v1/companies'),
api.get<{ id: number; developer_id: number }[]>('/api/v1/platforms'),
api.get<{ id: number; name: string; label?: string; developer_id: number }[]>('/api/v1/platforms'),
api.get<(LookupItem & { company_id: number; platform_id: number })[]>(
'/api/v1/stores',
),