|
@@ -10,18 +10,27 @@
|
|
|
>
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
<template #tableHeader>
|
|
|
- <el-button type="primary" v-auth="['manage:backupRestore:sync']" @click="backup()"> 备份文件 </el-button>
|
|
|
- <el-button type="primary" v-auth="['manage:faultCase:sync']" icon="Refresh" @click="syncFileData()"> 同步文件至服务器 </el-button>
|
|
|
+ <el-button type="primary" v-auth="['manage:backupRestore:sync']" @click="backupAll()"> 全量备份 </el-button>
|
|
|
+ <el-button type="primary" v-auth="['manage:faultCase:sync']" @click="backup()"> 增量备份 </el-button>
|
|
|
</template>
|
|
|
<!-- 表格操作 -->
|
|
|
<template #operation="scope">
|
|
|
<el-button type="primary" link icon="View" v-auth="['manage:backupRestore:query']" @click="openDialog(3, '备份恢复日志查看', scope.row)">
|
|
|
查看
|
|
|
</el-button>
|
|
|
- <el-button type="primary" v-if="scope.row.operateType === '备份'" link icon="View" @click="restore()"> 恢复 </el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ v-if="scope.row.operateType === '备份' && scope.row.restoreStatus !== '成功'"
|
|
|
+ link
|
|
|
+ icon="View"
|
|
|
+ @click="restore(scope.row)"
|
|
|
+ >
|
|
|
+ 恢复
|
|
|
+ </el-button>
|
|
|
</template>
|
|
|
</ProTable>
|
|
|
<FormDialog ref="formDialogRef" />
|
|
|
+ <TableDialog ref="tableDialogRef" @submit-form="submitForm" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -30,8 +39,10 @@ import { ref, reactive } from 'vue'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import ProTable from '@/components/ProTable/index.vue'
|
|
|
import FormDialog from '@/components/FormDialog/index.vue'
|
|
|
+import TableDialog from '@/components/TableDialog/index.vue'
|
|
|
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
|
|
-import { listBackupRestoreLogApi, dbBackupAllApi, dbRestoreApi, syncFileDataApi } from '@/api/modules/manage/backupRestore'
|
|
|
+import { listBackupRestoreLogApi, dbBackupAllApi, dbRestoreApi, dbBackupApi } from '@/api/modules/manage/backupRestore'
|
|
|
+import { listDbTableApi } from '@/api/modules/tool/gen'
|
|
|
|
|
|
// ProTable 实例
|
|
|
const proTable = ref<ProTableInstance>()
|
|
@@ -49,7 +60,7 @@ const dataType = [
|
|
|
{ label: '数据库', value: 2 }
|
|
|
]
|
|
|
const initParam = reactive({ type: 2 })
|
|
|
-const backup = () => {
|
|
|
+const backupAll = () => {
|
|
|
dbBackupAllApi({}).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
proTable.value?.getTableList()
|
|
@@ -59,8 +70,8 @@ const backup = () => {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-const restore = () => {
|
|
|
- dbRestoreApi().then(res => {
|
|
|
+const restore = (val: any) => {
|
|
|
+ dbRestoreApi(val.id).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
proTable.value?.getTableList()
|
|
|
ElMessage.success('恢复成功')
|
|
@@ -69,15 +80,33 @@ const restore = () => {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-const syncFileData = () => {
|
|
|
- syncFileDataApi({}).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- ElMessage.success('同步成功')
|
|
|
- proTable.value?.getTableList()
|
|
|
- } else {
|
|
|
- ElMessage.error(res.msg)
|
|
|
- }
|
|
|
- })
|
|
|
+// const syncFileData = () => {
|
|
|
+// syncFileDataApi({}).then(res => {
|
|
|
+// if (res.code === 200) {
|
|
|
+// ElMessage.success('同步成功')
|
|
|
+// proTable.value?.getTableList()
|
|
|
+// } else {
|
|
|
+// ElMessage.error(res.msg)
|
|
|
+// }
|
|
|
+// })
|
|
|
+// }
|
|
|
+// 表格弹框提交
|
|
|
+const submitForm = () => {
|
|
|
+ proTable.value?.getTableList()
|
|
|
+}
|
|
|
+// 批量添加表信息
|
|
|
+const tableDialogRef = ref<InstanceType<typeof TableDialog> | null>(null)
|
|
|
+const backup = () => {
|
|
|
+ const params = {
|
|
|
+ title: '备份表',
|
|
|
+ width: 880,
|
|
|
+ toolButton: false,
|
|
|
+ rowKey: 'tableName',
|
|
|
+ columns: subColumns,
|
|
|
+ api: dbBackupApi,
|
|
|
+ getTableList: listDbTableApi
|
|
|
+ }
|
|
|
+ tableDialogRef.value?.openDialog(params)
|
|
|
}
|
|
|
|
|
|
const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
|
|
@@ -114,6 +143,10 @@ const columns = reactive<ColumnProps<any>[]>([
|
|
|
el: 'input'
|
|
|
}
|
|
|
},
|
|
|
+ {
|
|
|
+ prop: 'target',
|
|
|
+ label: '目标'
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'status',
|
|
|
label: '备份状态'
|
|
@@ -137,6 +170,13 @@ const setItemsOptions = () => {
|
|
|
placeholder: '请输入数据类型'
|
|
|
}
|
|
|
},
|
|
|
+ {
|
|
|
+ label: '目标',
|
|
|
+ prop: 'target',
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入操作方式'
|
|
|
+ }
|
|
|
+ },
|
|
|
{
|
|
|
label: '操作方式',
|
|
|
prop: 'operateType',
|
|
@@ -153,4 +193,26 @@ const setItemsOptions = () => {
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
+// 表格配置项
|
|
|
+const subColumns: ColumnProps[] = [
|
|
|
+ { type: 'selection', fixed: 'left', width: 60 },
|
|
|
+ {
|
|
|
+ prop: 'tableName',
|
|
|
+ label: '表名称',
|
|
|
+ search: {
|
|
|
+ el: 'input'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'tableComment',
|
|
|
+ label: '表描述',
|
|
|
+ search: {
|
|
|
+ el: 'input'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'createTime',
|
|
|
+ label: '创建时间'
|
|
|
+ }
|
|
|
+]
|
|
|
</script>
|