fix: 用户商品模块
Build and Deploy Vue3 / build (push) Successful in 1m34s
Build and Deploy Vue3 / deploy (push) Successful in 1m10s

This commit is contained in:
2026-04-16 15:43:08 +08:00
parent 985412c3bc
commit c7245cec67
3 changed files with 196 additions and 61 deletions
+42 -17
View File
@@ -101,15 +101,20 @@
</span>
</template>
</el-table-column>
<el-table-column label="操作" width="280" fixed="right">
<el-table-column label="操作" width="180" fixed="right">
<template #default="{ row }">
<div class="action-buttons">
<el-button link type="primary" size="small" @click="handleDetail(row)">详情</el-button>
<el-button link type="primary" size="small" @click="handleEdit(row)">编辑</el-button>
<el-button link type="warning" size="small" @click="openRemindList(row)">提醒记录</el-button>
<el-button link type="success" size="small" @click="handleSendRemind(row)">发送提醒</el-button>
<el-button link type="danger" size="small" @click="handleDelete(row)">删除</el-button>
</div>
<el-button link type="primary" size="small" @click="handleDetail(row)">详情</el-button>
<el-button link type="primary" size="small" @click="handleEdit(row)">编辑</el-button>
<el-dropdown trigger="click" @command="cmd => handleMoreCmd(cmd, row)" style="margin-left:8px">
<el-button link type="primary" size="small" style="transform: translateY(4px);">更多<el-icon style="margin-left:2px"><ArrowDown /></el-icon></el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="remind">提醒记录</el-dropdown-item>
<el-dropdown-item command="send">发送提醒</el-dropdown-item>
<el-dropdown-item command="delete" divided style="color:#F56C6C">删除商品</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
</el-table-column>
@@ -410,23 +415,31 @@
<el-button type="primary" size="small" :icon="Refresh" @click="loadRemindList">刷新</el-button>
</div>
<el-table :data="remindList" v-loading="remindLoading" stripe size="small" :max-height="400">
<el-table-column prop="id" label="ID" width="70" />
<el-table-column prop="user_goods_id" label="用户商品ID" width="110" />
<el-table-column prop="user_id" label="用户ID" width="80" />
<el-table-column label="提醒类型" width="100">
<el-table-column prop="id" label="ID" width="60" />
<el-table-column label="用户" width="100">
<template #default="{ row }">{{ row.user?.UserName || row.user?.user_name || `#${row.userId ?? row.user_id ?? '-'}` }}</template>
</el-table-column>
<el-table-column label="提醒类型" width="80">
<template #default="{ row }">
<el-tag size="small" :type="row.type === 'manual' ? 'warning' : 'info'">{{ row.type === 'manual' ? '手动' : '自动' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="发送状态" width="90">
<el-table-column label="发送方式" width="80">
<template #default="{ row }">
<el-tag size="small" :type="row.status === 'success' ? 'success' : row.status === 'failed' ? 'danger' : 'info'">{{ row.status || '-' }}</el-tag>
<el-tag size="small" :type="row.method === 'sms' ? 'success' : row.method === 'email' ? 'primary' : 'info'">{{ row.method === 'sms' ? '短信' : row.method === 'email' ? '邮件' : (row.method || '-') }}</el-tag>
</template>
</el-table-column>
<el-table-column label="发送状态" width="80">
<template #default="{ row }">
<el-tag size="small" :type="row.success ? 'success' : 'danger'">{{ row.success ? '成功' : '失败' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="发送时间" min-width="160">
<template #default="{ row }">{{ row.created_at ? dayjs(row.created_at).format('YYYY-MM-DD HH:mm:ss') : (row.send_time || '-') }}</template>
<template #default="{ row }">{{ formatRemindTime(row) }}</template>
</el-table-column>
<el-table-column label="备注" min-width="120" show-overflow-tooltip>
<template #default="{ row }">{{ row.note || '-' }}</template>
</el-table-column>
<el-table-column prop="message" label="内容" min-width="180" show-overflow-tooltip />
</el-table>
<div style="display:flex;justify-content:flex-end;margin-top:12px" v-if="remindTotal > remindQuery.count">
<el-pagination v-model:current-page="remindQuery.page" :page-size="remindQuery.count" :total="remindTotal" layout="total, prev, pager, next" small background @current-change="loadRemindList" />
@@ -443,7 +456,7 @@
import { ref, reactive, computed, onMounted, watch } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Plus, Refresh, Search } from '@element-plus/icons-vue'
import { Plus, Refresh, Search, ArrowDown } from '@element-plus/icons-vue'
import { getUserGoodsList, createUserGoods, updateUserGoods, deleteUserGoods, getUserVmList, getExpireRemindList, sendExpireRemind } from '@/api/admin/userVm'
import { extractApiError } from '@/utils/kvmErrorUtil'
import { formatToApiTime } from '@/utils/tool'
@@ -828,6 +841,12 @@ const handleDetail = (row) => {
}
}
const handleMoreCmd = (cmd, row) => {
if (cmd === 'remind') openRemindList(row)
else if (cmd === 'send') handleSendRemind(row)
else if (cmd === 'delete') handleDelete(row)
}
const handleDelete = (row) => {
ElMessageBox.confirm(`确定删除该用户商品吗?`, '删除确认', { type: 'warning' })
.then(async () => {
@@ -854,6 +873,12 @@ const openRemindList = (row) => {
loadRemindList()
}
const formatRemindTime = (row) => {
const t = row.CreatedAt || row.created_at || row.send_time
if (!t || t.startsWith('0001')) return '-'
try { return dayjs(t).format('YYYY-MM-DD HH:mm:ss') } catch { return t }
}
const loadRemindList = async () => {
remindLoading.value = true
try {