admin_new/src/modules/inquiry/InquiryListView.vue
Sisyphus 59a235d56c feat(F006-W5xx5): 关键 view 完整化 (沿用老 vue 字段/操作/弹窗) + W3.x C 补 commit
用户原话: 不是让你沿用老vue页面内容了吗, 只是更换成新版本的UI
用户原话: 要能够交付使用, 像原有的vue平台一样使用

整改 (5 个 view 从严重简化变完整版):
- OrderListView 240 行: 订单号/合同号/供应商/状态/时间范围 完整搜索, 8 种状态 tab,
  操作 (详情/付款/发货/收货/退款/取消/打印), 批量导出, type 自适应 good/service/group
- OrderDetailView 582 行: 完整 4-tab (订单信息/商品明细/物流/付款发票),
  状态卡 + 操作按钮 (按状态动态显示), 9 种订单状态, 推广信息, 多状态按需渲染
- GoodListView 507 行: 12 列表格 (封面/商品/供应商/3 级分类/品牌/单位/铺货/审核/状态),
  4 种状态 tab, 5 种操作 (详情/审核/上下架/改分类/删除), 5 种批量操作,
  详情弹窗含 SKU 列表 (编码/原价/现价/秒杀价/拼团价/库存)
- ServiceGoodListView 302 行: 同上针对服务商品
- InquiryDetailView 229 行: 询价基本信息 (产品/品牌/规格/数量/收货地址/交货日期/价格有效),
  附件下载, 报价列表 (供应商/状态/金额/次数/来源/查看报价)

字段 100% 沿用老 vue (supplierGoodId/contractCode/groupNumber/acceptNum 等),
新增 mock 数据 (3-8 条覆盖各种业务场景), 弹窗/操作/批量/导出 全部走通 (mock 实现)
+ W3.x C P0-P2 累计 30+ 个 view 文件补 commit (inquiry/openapi/order/sys 等 11+ 模块)

router 调整: 9 个 order 路由统一到 OrderListView (type 自动推断)
+ /supplier/servicegood 路由独立 (避免被 tree-shake)
2026-07-05 12:12:41 +08:00

299 lines
7.8 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, ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import DataTable from '@/components/DataTable/DataTable.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 }))
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
} 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() }
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">
<div class="rr-page-header">
<div class="rr-page-titles">
<h2 class="rr-page-title">询价管理</h2>
<p class="rr-page-sub">共 {{ total }} 条询价</p>
</div>
<div class="rr-page-actions">
<el-button @click="onReset" class="rr-btn-secondary">重置</el-button>
</div>
</div>
<div class="rr-tabs-row">
<div class="rr-tabs">
<div
v-for="t in STATUS_TABS"
:key="t.value"
class="rr-tab"
:class="{ active: filters.status === t.value }"
@click="onStatusTab(t.value)"
>{{ t.label }}</div>
</div>
<div class="rr-filters">
<el-input
v-model="filters.searchKey"
placeholder="搜索单号/客户/商品"
clearable
class="rr-search-input"
size="small"
:prefix-icon="'Search'"
@keyup.enter="onSearch"
/>
<el-button class="rr-btn-secondary" size="small" @click="onSearch">查询</el-button>
</div>
</div>
<div class="rr-list-card">
<DataTable
:columns="columns"
:data="list"
:loading="loading"
:total="total"
:page="page"
:limit="limit"
:show-pagination="true"
: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-page-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
}
.rr-page-titles {
display: flex;
flex-direction: column;
gap: 2px;
}
.rr-page-title {
margin: 0;
font-size: 18px;
font-weight: 600;
color: var(--el-text-color-primary);
}
.rr-page-sub {
margin: 0;
font-size: 12px;
color: var(--el-text-color-secondary);
}
.rr-page-actions {
display: flex;
gap: 8px;
}
.rr-tabs-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
gap: 16px;
}
.rr-tabs {
display: flex;
gap: 24px;
flex: 1;
}
.rr-tab {
position: relative;
padding: 6px 0;
font-size: 13px;
font-weight: 500;
color: var(--el-text-color-secondary);
cursor: pointer;
user-select: none;
transition: color 0.15s ease;
}
.rr-tab:hover { color: var(--el-text-color-primary); }
.rr-tab.active {
color: var(--el-color-primary);
font-weight: 600;
}
.rr-tab.active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 2px;
background: var(--el-color-primary);
border-radius: 1px;
}
.rr-filters {
display: flex;
gap: 8px;
flex-shrink: 0;
}
.rr-search-input { width: 240px; }
.rr-list-card {
background: var(--el-bg-color);
border-radius: 12px;
padding: 4px;
}
.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>