admin_new/src/modules/sys/FileListView.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

152 lines
5.2 KiB
Vue

<script setup lang="ts">
/**
* F006 文件管理 - W4.16
*
* 后端: GET /sys/file/page
* 字段: id/url/creator/createDate
*/
import { onMounted, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { httpGet, httpDelete } from '@/utils/request'
import DataTable from '@/components/DataTable/DataTable.vue'
interface FileItem {
id: string
url: string
creator: string | null
createDate: string | number
raw: any
}
const list = ref<FileItem[]>([])
const total = ref(0)
const loading = ref(false)
const error = ref<string | null>(null)
const page = ref(1)
const limit = ref(20)
function fmtDate(ts?: string | number | null) {
if (!ts) return '--'
const n = typeof ts === 'string' ? Date.parse(ts) : 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<{ total: number | string; list: any[] }>('/sys/file/page', {
page: page.value,
limit: limit.value
})
list.value = (data.list || []).map((it: any) => ({
id: String(it.id),
url: it.url || '--',
creator: it.creator,
createDate: it.createDate,
raw: it
}))
total.value = Number(data.total) || 0
} catch (e: any) {
error.value = e?.msg || e?.message || '后端接口异常'
list.value = []
total.value = 0
} finally {
loading.value = false
}
}
function onPageChange(p: number) { page.value = p; load() }
function onLimitChange(l: number) { limit.value = l; page.value = 1; load() }
async function copyText(text: string) {
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text)
ElMessage.success('链接已复制')
} else {
ElMessage.warning('请手动复制')
}
} catch { ElMessage.warning('复制失败') }
}
async function deleteHandle(row: FileItem) {
try { await ElMessageBox.confirm('确认删除该文件吗?', '删除确认', { type: 'warning' }) } catch { return }
try { await httpDelete(`/sys/file/${row.id}`); ElMessage.success('删除成功'); load() }
catch (e: any) { ElMessage.error(e?.msg || e?.message || '删除失败') }
}
onMounted(load)
</script>
<template>
<div class="rr-sys-file">
<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="load" class="rr-btn-secondary">刷新</el-button>
</div>
</div>
<div class="rr-list-card">
<DataTable
:columns="[
{ prop: 'id', label: 'ID', width: 180, slot: 'id' },
{ prop: 'url', label: '文件链接', minWidth: 480, slot: 'url' },
{ prop: 'creator', label: '创建者', width: 140 },
{ prop: 'createDate', label: '创建时间', width: 170, slot: 'createDate' },
{ label: '操作', width: 180, slot: 'action' }
]"
: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"
>
<template #id="{ row }"><code class="rr-mono-sm">{{ row.id }}</code></template>
<template #url="{ row }">
<a :href="row.url" target="_blank" class="rr-link">{{ row.url }}</a>
</template>
<template #createDate="{ row }"><span class="rr-time">{{ fmtDate(row.createDate) }}</span></template>
<template #action="{ row }">
<el-button text type="primary" size="small" @click="copyText(row.url)">复制链接</el-button>
<el-button text type="primary" size="small" @click="deleteHandle(row)">删除</el-button>
</template>
</DataTable>
</div>
</div>
</template>
<style scoped>
.rr-sys-file { 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-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); }
.rr-mono-sm { font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace; font-size: 11px; padding: 2px 6px; background: var(--el-fill-color-light); border-radius: 4px; color: var(--el-color-primary); }
.rr-link {
font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
font-size: 11px;
color: var(--el-color-primary);
text-decoration: none;
word-break: break-all;
}
.rr-link:hover { text-decoration: underline; }
</style>