diff --git a/src/modules/supplier/good/GoodListView.vue b/src/modules/supplier/good/GoodListView.vue index 013926b..f752d4f 100644 --- a/src/modules/supplier/good/GoodListView.vue +++ b/src/modules/supplier/good/GoodListView.vue @@ -19,6 +19,9 @@ import { ref, onMounted, computed, reactive } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import DataTable from '@/components/DataTable/DataTable.vue' +import PageHeader from '@/components/PageHeader/PageHeader.vue' +import SearchBar from '@/components/SearchBar/SearchBar.vue' +import ListTabs from '@/components/ListTabs/ListTabs.vue' import { httpGet, httpPost } from '@/utils/request' interface Good { @@ -105,6 +108,9 @@ const limit = ref(10) const error = ref(null) const selection = ref([]) +// 状态统计 (与 tab 解耦, 只跟搜索条件关联 - 跨 tab 一致) +const checkStats = reactive({ pending: 0, approved: 0, rejected: 0 }) + const filters = reactive({ title: '', enterpriseName: '', @@ -125,7 +131,7 @@ const batchRejectDialogVisible = ref(false) const batchRejectForm = reactive({ reason: '' }) const columns = [ - { type: 'selection' as const, width: 50 }, + { type: 'selection' as const, label: '', width: 50 }, { prop: 'supplierGoodId', label: '商品ID', width: 140 }, { prop: 'title', label: '商品名称', minWidth: 240, slot: 'title' }, { prop: 'enterpriseName', label: '供应商', minWidth: 180, showOverflowTooltip: true }, @@ -139,6 +145,30 @@ const columns = [ { label: '操作', width: 240, align: 'center' as const, fixed: 'right' as const, slot: 'action' } ] +async function buildSearchParamsForStats() { + const params: any = { type: 1 } + if (filters.title) params.title = filters.title + return params +} + +async function loadStats() { + try { + const base = await buildSearchParamsForStats() + const [r1, r2, r3] = await Promise.all([ + httpGet('/supplier/good/pageList', { ...base, checkStatus: 1, page: 1, limit: 1 }), + httpGet('/supplier/good/pageList', { ...base, checkStatus: 2, page: 1, limit: 1 }), + httpGet('/supplier/good/pageList', { ...base, checkStatus: 3, page: 1, limit: 1 }) + ]) + checkStats.pending = Number(r1?.total ?? 0) + checkStats.approved = Number(r2?.total ?? 0) + checkStats.rejected = Number(r3?.total ?? 0) + } catch { + checkStats.pending = 0 + checkStats.approved = 0 + checkStats.rejected = 0 + } +} + async function load() { loading.value = true error.value = null @@ -180,12 +210,20 @@ async function load() { } } -function onSearch() { page.value = 1; load() } -function onReset() { filters.title = ''; filters.enterpriseName = ''; filters.checkStatus = ''; page.value = 1; load() } +function onSearch() { page.value = 1; Promise.all([load(), loadStats()]) } +function onReset() { filters.title = ''; filters.enterpriseName = ''; filters.checkStatus = ''; page.value = 1; Promise.all([load(), loadStats()]) } function onPageChange(p: number) { page.value = p; load() } function onLimitChange(l: number) { limit.value = l; page.value = 1; load() } function onSelectionChange(rows: Good[]) { selection.value = rows } +const tabItems = computed(() => [ + // 全部 = 待审核 + 已通过 + 已驳回 (跨 tab 一致, 跟搜索条件关联) + { key: '', label: '全部', count: checkStats.pending + checkStats.approved + checkStats.rejected }, + { key: '1', label: '待审核', count: checkStats.pending }, + { key: '2', label: '已通过', count: checkStats.approved }, + { key: '3', label: '已驳回', count: checkStats.rejected } +]) + function onStatusTab(v: string) { filters.checkStatus = v; page.value = 1; load() } function onShowDetail(row: Good) { detailData.value = row; detailVisible.value = true } @@ -279,50 +317,27 @@ function onDeleteBatch() { function onExport() { ElMessage.success('导出商品 (mock)') } function onAdd() { ElMessage.info('新增商品 (mock)') } -onMounted(load) +onMounted(() => Promise.all([load(), loadStats()]))