- 33 个 ListView.vue 加 :borderless=true + :page-sizes=[10,20,50,100]
覆盖: order/inquiry/finance/operateguide/sys/Dept|Menu|File|Notice|
Params|User|Role|Post|DictType|DictData|Product|Schedule|RoleGroup
user/Enterprise|enterpriselevel|enterprisescore|enterpriserating
supplier/promoter|couponscope|historylog|logistics|ordercomment|Activity
other/goodunit|label|textconfig
api/feedback|help|lunbo
openapi/AuditLog|CompanyAccount
- OrderListView: columns 抽到 script setup (computed) + :borderless +
:page-sizes + sub 动态显示选中数
- router/index.ts: /product/shop → redirect /supplier/good
(删 src/modules/product/shop/ShopListView.vue 旧占位, 后端 404 无意义)
- 沿用 W17 设计规范 v2 (PageHeader+SearchBar+DataTable+ListTabs)
208 lines
6.6 KiB
Vue
208 lines
6.6 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* F006 询价管理列表 - W4.9 套 v1.6 设计规范
|
|
*
|
|
* 后端: GET /sys/openapi/inquiry/list?page=&limit=&status=
|
|
* 状态: pending(0) 待报价 / quoting(1) 报价中 / done(2) 已成交 / cancelled(3) 已取消
|
|
*
|
|
* 设计规范:§16 列表页完整模板 + §17.7 紧凑弹窗 + §17.8 主题色弹窗 + §17.9 列优化
|
|
*/
|
|
import { onMounted, computed, reactive, ref } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import { ElMessage } 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 { useInquiryStore, STATUS_OPTIONS } from '@/stores/inquiry'
|
|
import { httpGet } from '@/utils/request'
|
|
|
|
interface InquiryRow {
|
|
id: string
|
|
customer: string
|
|
product: string
|
|
qty: string
|
|
status: 'pending' | 'quoting' | 'done' | 'cancelled' | string
|
|
time: string | number
|
|
raw: any
|
|
}
|
|
|
|
const router = useRouter()
|
|
const store = useInquiryStore()
|
|
|
|
const STATUS_TABS = STATUS_OPTIONS.map(o => ({ value: o.value, label: o.label, key: o.value, count: 0 }))
|
|
|
|
// 各 status 计数 (在当前结果中累加)
|
|
const stats = reactive<Record<string, number>>({ pending: 0, quoting: 0, done: 0, cancelled: 0, all: 0 })
|
|
|
|
const STATUS_LABEL: Record<string, string> = {
|
|
pending: '待报价',
|
|
quoting: '报价中',
|
|
done: '已成交',
|
|
cancelled: '已取消'
|
|
}
|
|
|
|
const list = ref<InquiryRow[]>([])
|
|
const total = ref(0)
|
|
const loading = ref(false)
|
|
const error = ref<string | null>(null)
|
|
const page = ref(1)
|
|
const limit = ref(10)
|
|
|
|
const filters = ref({
|
|
status: '',
|
|
customer: '',
|
|
searchKey: ''
|
|
})
|
|
|
|
function fmtDate(ts?: string | number | null) {
|
|
if (!ts) return '--'
|
|
let n: number
|
|
if (typeof ts === 'string') {
|
|
n = /^\d+$/.test(ts) ? Number(ts) : Date.parse(ts)
|
|
} else {
|
|
n = ts
|
|
}
|
|
if (!n || isNaN(n)) return String(ts)
|
|
const d = new Date(n)
|
|
if (isNaN(d.getTime())) return String(ts)
|
|
const pad = (x: number) => String(x).padStart(2, '0')
|
|
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
|
|
}
|
|
|
|
async function load() {
|
|
loading.value = true
|
|
error.value = null
|
|
try {
|
|
const data = await httpGet<any>('/sys/openapi/inquiry/list', {
|
|
page: page.value,
|
|
limit: limit.value,
|
|
...(filters.value.status ? { status: filters.value.status } : {})
|
|
})
|
|
const arr = Array.isArray(data) ? data : []
|
|
list.value = arr.map((it: any) => ({
|
|
id: String(it.id ?? ''),
|
|
customer: it.inquiryEnterpriseName || it.customer || it.customerName || '--',
|
|
product: it.title || it.product || it.productName || '--',
|
|
qty: it.purchaseQuantity || it.qty || '--',
|
|
status: it.status || (it.apprStatus != null ? (['pending','quoting','done','cancelled'][it.apprStatus] || 'pending') : 'pending'),
|
|
time: it.publishDate || it.createDate || it.time,
|
|
raw: it
|
|
}))
|
|
total.value = arr.length + (page.value - 1) * limit.value
|
|
// 各状态计数 (基于当前页结果)
|
|
stats.all = list.value.length
|
|
list.value.forEach(r => { stats[r.status] = (stats[r.status] || 0) + 1 })
|
|
} catch (e: any) {
|
|
error.value = e?.msg || e?.message || '后端接口异常(详见 console)'
|
|
list.value = []
|
|
total.value = 0
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
function onSearch() { page.value = 1; load() }
|
|
|
|
const tabItems = computed(() => STATUS_TABS.map(t => ({
|
|
key: t.value,
|
|
label: t.label,
|
|
count: t.value === '' ? stats.all : (stats[t.value] || 0)
|
|
})))
|
|
function onReset() { filters.value.status = ''; filters.value.customer = ''; filters.value.searchKey = ''; page.value = 1; load() }
|
|
function onPageChange(p: number) { page.value = p; load() }
|
|
function onLimitChange(l: number) { limit.value = l; page.value = 1; load() }
|
|
function onStatusTab(v: string) {
|
|
filters.value.status = v
|
|
page.value = 1
|
|
load()
|
|
}
|
|
function onRowClick(row: InquiryRow) { router.push(`/inquiry/${row.id}`) }
|
|
function onView(row: InquiryRow) { router.push(`/inquiry/${row.id}`) }
|
|
|
|
const columns = computed(() => [
|
|
{ prop: 'id', label: '单号', width: 180 },
|
|
{ prop: 'customer', label: '客户', minWidth: 180 },
|
|
{ prop: 'product', label: '商品', minWidth: 180 },
|
|
{ prop: 'qty', label: '数量', width: 120 },
|
|
{ prop: 'status', label: '状态', width: 100, slot: 'status' },
|
|
{ prop: 'time', label: '时间', width: 170, slot: 'time' },
|
|
{ label: '操作', width: 100, slot: 'action' }
|
|
])
|
|
|
|
onMounted(() => { load() })
|
|
</script>
|
|
|
|
<template>
|
|
<div class="rr-inquiry-list">
|
|
<PageHeader title="询价管理" :sub="`共 ${total} 条询价`">
|
|
<el-button @click="onReset">重置</el-button>
|
|
</PageHeader>
|
|
|
|
<ListTabs v-model="filters.status" :items="tabItems" @change="onStatusTab" />
|
|
|
|
<SearchBar
|
|
v-model:filters="filters"
|
|
:fields='[{ key: "searchKey", label: "", type: "text", placeholder: "搜索单号/客户/商品", clearable: true }]'
|
|
:show-reset="false"
|
|
@search="onSearch"
|
|
/>
|
|
|
|
<div class="rr-list-card">
|
|
<DataTable
|
|
:columns="columns"
|
|
:data="list"
|
|
:loading="loading"
|
|
:total="total"
|
|
:page="page"
|
|
:limit="limit"
|
|
:show-pagination="true" :page-sizes="[10, 20, 50, 100]"
|
|
:error="error"
|
|
empty-text="暂无询价"
|
|
borderless
|
|
row-key="id"
|
|
@page-change="onPageChange"
|
|
@limit-change="onLimitChange"
|
|
@row-click="onRowClick"
|
|
>
|
|
<template #status="{ row }">
|
|
<span :class="['rr-badge', `rr-badge-${row.status}`]">{{ STATUS_LABEL[row.status] || row.status }}</span>
|
|
</template>
|
|
<template #time="{ row }">
|
|
<span class="rr-time">{{ fmtDate(row.time) }}</span>
|
|
</template>
|
|
<template #action="{ row }">
|
|
<el-button text type="primary" size="small" @click.stop="onView(row)">查看</el-button>
|
|
</template>
|
|
</DataTable>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.rr-inquiry-list {
|
|
padding: 16px;
|
|
}
|
|
|
|
.rr-time {
|
|
font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
|
|
font-size: 12px;
|
|
color: var(--el-text-color-regular);
|
|
}
|
|
|
|
/* 状态徽章(4 种) - 浅底色块(套设计规范 §5.4) */
|
|
.rr-badge {
|
|
display: inline-block;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
font-size: 11.5px;
|
|
font-weight: 500;
|
|
line-height: 17.25px;
|
|
height: 21.25px;
|
|
box-sizing: border-box;
|
|
}
|
|
.rr-badge-pending { background: #FEF3C7; color: #D97706; }
|
|
.rr-badge-quoting { background: #DBEAFE; color: #2563EB; }
|
|
.rr-badge-done { background: #D1FAE5; color: #059669; }
|
|
.rr-badge-cancelled { background: #FEE2E2; color: #DC2626; }
|
|
</style> |