feat(config): 增强配置历史管理并统一数据库时间
- 新增 dao.Now() 函数获取数据库毫秒精度时间,避免多实例时钟偏差 - 增量同步查询增加上界(updated_at <= upperBound)防止竞态条件 - 配置创建、更新、删除、回滚统一使用数据库时间替代 time.Now() - 配置历史新增 operate 字段记录操作类型(update/delete/rollback) - 删除配置和回滚操作前增加历史快照记录 - 新增 DeleteHistory 接口支持手动删除单条历史记录 - 移除 GetHistory 的 Limit(5) 限制,返回完整历史列表 - 删除应用时同步更新关联配置的 updated_at 以便增量同步识别 - version 字段改为必填,前后端同步增加校验规则 - 前端历史列表增加操作类型列、删除按钮及表格最大高度限制 - 数据库表结构 datetime 升级为 datetime(3) 支持毫秒精度
This commit is contained in:
@@ -57,9 +57,17 @@
|
||||
></el-pagination>
|
||||
|
||||
<el-dialog title="变更历史" :visible.sync="historyVisible" width="900px">
|
||||
<el-table :data="historyList" border stripe>
|
||||
<el-table :data="historyList" border stripe max-height="500">
|
||||
<el-table-column prop="id" label="ID" width="60"></el-table-column>
|
||||
<el-table-column prop="createdBy" label="操作人" width="100"></el-table-column>
|
||||
<el-table-column label="操作类型" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.operate === 'delete'" style="color: #F56C6C">删除</span>
|
||||
<span v-else-if="scope.row.operate === 'rollback'">回滚</span>
|
||||
<span v-else-if="scope.row.operate === 'update'">更新</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作时间" width="180">
|
||||
<template slot-scope="scope">
|
||||
{{ formatTime(scope.row.createdAt) }}
|
||||
@@ -68,7 +76,8 @@
|
||||
<el-table-column label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="viewHistoryContent(scope.row)">查看内容</el-button>
|
||||
<el-button type="text" @click="handleRollback(scope.row)">回滚到此版本</el-button>
|
||||
<el-button v-if="scope.row.operate !== 'delete'" type="text" @click="handleRollback(scope.row)">回滚到此版本</el-button>
|
||||
<el-button type="text" style="color: #F56C6C" @click="handleDeleteHistory(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -128,7 +137,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getConfigList, deleteConfig, getConfigHistory, rollbackConfig, getConfig } from '../../api/config'
|
||||
import { getConfigList, deleteConfig, getConfigHistory, rollbackConfig, getConfig, deleteConfigHistory } from '../../api/config'
|
||||
import { getClientListByConfig } from '../../api/client'
|
||||
import request from '../../api/request'
|
||||
|
||||
@@ -299,6 +308,15 @@ export default {
|
||||
this.historyVisible = true
|
||||
} catch (e) {}
|
||||
},
|
||||
async handleDeleteHistory(row) {
|
||||
try {
|
||||
await this.$confirm('确定删除这条历史记录?删除后不可恢复。')
|
||||
await deleteConfigHistory(row.id)
|
||||
this.$message.success('删除成功')
|
||||
const res = await getConfigHistory(row.originId)
|
||||
this.historyList = res.data || []
|
||||
} catch (e) {}
|
||||
},
|
||||
async viewHistoryContent(row) {
|
||||
this.currentHistory = row
|
||||
const historyContent = row.contents || ''
|
||||
|
||||
Reference in New Issue
Block a user