用户原话: 不是让你沿用老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)
180 lines
5.8 KiB
Vue
180 lines
5.8 KiB
Vue
<script setup lang="ts">
|
|
/**
|
|
* F006 登录日志 - W4.14
|
|
*
|
|
* 后端: GET /sys/log/login/page
|
|
* 字段: id/operation/status/userAgent/ip/creatorName/createDate
|
|
*
|
|
* 设计规范:v1.6
|
|
*/
|
|
import { onMounted, ref } from 'vue'
|
|
import { httpGet } from '@/utils/request'
|
|
import DataTable from '@/components/DataTable/DataTable.vue'
|
|
|
|
interface LogEntry {
|
|
id: string
|
|
operation: number | null
|
|
status: number | null
|
|
userAgent: string | null
|
|
ip: string | null
|
|
creatorName: string | null
|
|
createDate: string
|
|
raw: any
|
|
}
|
|
|
|
const OPERATION_LABEL: Record<number, string> = {
|
|
0: '登录成功',
|
|
1: '登录失败',
|
|
2: '退出登录'
|
|
}
|
|
|
|
const STATUS_LABEL: Record<number, { label: string; type: string }> = {
|
|
0: { label: '正常', type: 'success' },
|
|
1: { label: '失败', type: 'danger' }
|
|
}
|
|
|
|
const list = ref<LogEntry[]>([])
|
|
const total = ref(0)
|
|
const loading = ref(false)
|
|
const error = ref<string | null>(null)
|
|
const page = ref(1)
|
|
const limit = ref(20)
|
|
|
|
const filters = ref({ creatorName: '', ip: '' })
|
|
|
|
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/log/login/page', {
|
|
page: page.value,
|
|
limit: limit.value,
|
|
...(filters.value.creatorName ? { creatorName: filters.value.creatorName } : {}),
|
|
...(filters.value.ip ? { ip: filters.value.ip } : {})
|
|
})
|
|
list.value = (data.list || []).map((it: any) => ({
|
|
id: String(it.id),
|
|
operation: it.operation,
|
|
status: it.status,
|
|
userAgent: it.userAgent,
|
|
ip: it.ip,
|
|
creatorName: it.creatorName,
|
|
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 onSearch() { page.value = 1; load() }
|
|
function onReset() { filters.value.creatorName = ''; filters.value.ip = ''; page.value = 1; load() }
|
|
function onPageChange(p: number) { page.value = p; load() }
|
|
function onLimitChange(l: number) { limit.value = l; page.value = 1; load() }
|
|
|
|
onMounted(load)
|
|
</script>
|
|
|
|
<template>
|
|
<div class="rr-sys-log-login">
|
|
<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-filters-row">
|
|
<el-input
|
|
v-model="filters.creatorName"
|
|
placeholder="用户名搜索"
|
|
clearable
|
|
class="rr-name-input"
|
|
size="small"
|
|
@keyup.enter="onSearch"
|
|
/>
|
|
<el-input
|
|
v-model="filters.ip"
|
|
placeholder="IP 搜索"
|
|
clearable
|
|
class="rr-ip-input"
|
|
size="small"
|
|
@keyup.enter="onSearch"
|
|
/>
|
|
<el-button class="rr-btn-secondary" size="small" @click="onSearch">查询</el-button>
|
|
</div>
|
|
|
|
<div class="rr-list-card">
|
|
<DataTable
|
|
:columns="[
|
|
{ prop: 'creatorName', label: '用户', width: 140 },
|
|
{ prop: 'operation', label: '操作', width: 100, slot: 'operation' },
|
|
{ prop: 'status', label: '状态', width: 80, slot: 'status' },
|
|
{ prop: 'ip', label: 'IP', width: 140 },
|
|
{ prop: 'userAgent', label: 'User Agent', minWidth: 280 },
|
|
{ prop: 'createDate', label: '时间', width: 170, slot: 'createDate' }
|
|
]"
|
|
: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 #operation="{ row }">
|
|
<span>{{ OPERATION_LABEL[row.operation ?? -1] || '--' }}</span>
|
|
</template>
|
|
<template #status="{ row }">
|
|
<el-tag
|
|
v-if="row.status != null && STATUS_LABEL[row.status]"
|
|
:type="STATUS_LABEL[row.status].type as any"
|
|
size="small"
|
|
effect="light"
|
|
>{{ STATUS_LABEL[row.status].label }}</el-tag>
|
|
<span v-else>--</span>
|
|
</template>
|
|
<template #createDate="{ row }">
|
|
<span class="rr-time">{{ fmtDate(row.createDate) }}</span>
|
|
</template>
|
|
</DataTable>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.rr-sys-log-login { 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-filters-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 12px 16px; background: var(--el-fill-color-light); border-radius: 8px; }
|
|
.rr-name-input { width: 200px; }
|
|
.rr-ip-input { width: 200px; }
|
|
.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); }
|
|
</style> |