feat: 用户商品状态筛选与统计对接
Build and Deploy Vue3 / build (push) Successful in 1m46s
Build and Deploy Vue3 / deploy (push) Successful in 39s

- 新增 getUserGoodsCount 接口对接,列表页/虚拟机列表页增加状态筛选与统计卡片

- 已删除/已到期商品适配及相关页面更新

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shiran
2026-06-24 22:12:50 +08:00
parent a8954bd85d
commit 6f82e5e79d
17 changed files with 1637 additions and 371 deletions
+27 -3
View File
@@ -28,11 +28,19 @@
<el-option label="未绑定" :value="false" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="query.status" style="width:120px" @change="handleSearch">
<el-option label="全部" value="all" />
<el-option label="正常" value="normal" />
<el-option label="已到期" value="expired" />
<el-option label="已删除" value="deleted" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">
<el-icon><Search /></el-icon>查询
</el-button>
<el-button @click="query.user_id = ''; query.good_id = ''; query.key = ''; query.bound = null; filterUserName = ''; filterGoodName = ''; handleSearch()">重置</el-button>
<el-button @click="query.user_id = ''; query.good_id = ''; query.key = ''; query.bound = null; query.status = 'all'; filterUserName = ''; filterGoodName = ''; handleSearch()">重置</el-button>
</el-form-item>
</el-form>
<div class="action-bar">
@@ -73,6 +81,14 @@
</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" width="90">
<template #default="{ row }">
<el-tooltip v-if="isDeleted(row)" :content="`删除于 ${deletedTimeText(row)}`" placement="top">
<el-tag size="small" type="danger">已删除</el-tag>
</el-tooltip>
<el-tag v-else size="small" type="success">正常</el-tag>
</template>
</el-table-column>
<el-table-column label="续费价格" width="100">
<template #default="{ row }">
<span v-if="row.renewPrice">¥{{ (row.renewPrice / 100).toFixed(2) }}</span>
@@ -939,7 +955,7 @@ const router = useRouter()
const loading = ref(false)
const list = ref([])
const total = ref(0)
const query = reactive({ page: 1, count: 10, bound: null, user_id: '', good_id: '', key: '' })
const query = reactive({ page: 1, count: 10, bound: null, user_id: '', good_id: '', key: '', status: 'all' })
const filterUserName = ref('')
const filterGoodName = ref('')
const showFilterUserSelector = ref(false)
@@ -961,6 +977,13 @@ const formatExpireTime = (t) => {
return d.format('YYYY-MM-DD HH:mm')
}
// 判断用户商品是否已删除(后端返回 deleteAt 字段,有值即已删除)
const isDeleted = (row) => !!(row?.deleteAt || row?.DeleteAt || row?.deleted_at)
const deletedTimeText = (row) => {
const t = row?.deleteAt || row?.DeleteAt || row?.deleted_at
return t ? dayjs(t).format('YYYY-MM-DD HH:mm:ss') : '-'
}
const loadGoods = async () => {
// 不再需要加载商品列表,直接加载用户商品
loadList()
@@ -976,6 +999,7 @@ const loadList = async () => {
if (query.user_id) params.user_id = query.user_id
if (query.good_id) params.good_id = query.good_id
if (query.key) params.key = query.key
if (query.status && query.status !== 'all') params.status = query.status
const res = await getUserGoodsList(params)
if (res?.data?.code === 200 && res?.data?.data) {
const d = res.data.data
@@ -1001,7 +1025,7 @@ const handleSearch = () => { query.page = 1; loadList() }
const goDetail = (row) => {
if (!row.id) return
router.push({ path: '/user-goods/vm-detail', query: { id: row.id } })
router.push({ name: 'UserGoodsDetail', params: { id: row.id } })
}
// ---- 新建 ----