IDCDatasync-vue/src/views/securityAndBackup/backup.vue
2025-04-21 18:30:53 +08:00

236 lines
7.1 KiB
Vue

<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<!-- <div class="table-page-search-wrapper">-->
<!-- <a-form layout="inline" @keyup.enter.native="searchQuery">-->
<!-- <a-row :gutter="24">-->
<!-- -->
<!-- <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">-->
<!-- <a-col :md="4" :sm="4">-->
<!-- <a-button type="primary" style="left: 10px" @click="backup" icon="plus">一键备份</a-button>-->
<!-- <a-button type="primary" @click="handleAdd" icon="plus"-->
<!-- style="margin-left: 8px;left: 10px">添加</a-button>-->
<!-- </a-col>-->
<!-- </span>-->
<!-- </a-row>-->
<!-- </a-form>-->
<!-- </div>-->
<div class="linese"></div>
<!-- table区域-begin -->
<div style="height:calc(100vh - 316px);background: #e6e9f1;overflow:hidden;padding: 15px;">
<a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
:pagination="ipagination" :loading="loading"
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" @change="handleTableChange">
<!-- :locale="myLocale"-->
<!-- 字符串超长截取省略号显示-->
<template slot="sourceType" slot-scope="text">
<span style="color:black;" v-if="text === 1">原始库</span>
<span style="color:darkorange;" v-if="text === 2">标准库</span>
<span style="color:#87d068;" v-if="text === 3">专题库</span>
</template>
<template slot="backupStatus" slot-scope="text">
<span style="color:black;" v-if="text === 0">未启用</span>
<span style="color:#87d068;" v-if="text === 1">启用</span>
</template>
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" />
<a v-if="record.backupStatus === 0" @click="handleStartStop(record.id,1)">启动</a>
<a v-if="record.backupStatus === 1" @click="handleStartStop(record.id,0)">暂停</a>
<a-divider type="vertical" />
<a @click="handleRun(record.sourceType)">一键备份</a>
<a-divider type="vertical" />
<a @click="handleRun(record.sourceType)">同步日志</a>
</span>
</a-table>
</div>
<div class="linese"></div>
<!-- table区域-end -->
<!-- 表单区域 -->
<backupModal ref="modalForm" @ok="modalFormOk"></backupModal>
</a-card>
</template>
<script>
import { getAction, deleteAction, putAction, postAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from "@/components/jeecg/JEllipsis";
import backupModal from './modules/backupModal'
export default {
name: "backup",
mixins: [JeecgListMixin],
components: {
JEllipsis,
backupModal,
VNodes: {
functional: true,
render: (h, ctx) => ctx.props.vnodes,
},
},
data() {
return {
description: '数据库备份',
dataSource: [
],
schemaName: "",
allSchemaName: [],
queryParam: {
pageNum: 1,
pageSize: 10
},
columns: [
{
title: '序号',
dataIndex: '',
key: 'id',
width: 60,
align: "id",
customRender: function (t, r, index) {
return parseInt(index) + 1;
}
},
{
title: '任务名称',
align: "center",
dataIndex: 'taskName',
},
{
title: '数据库',
align: "center",
dataIndex: 'sourceType',
scopedSlots: { customRender: 'sourceType' }
},
{
title: '是否启用',
align: "center",
dataIndex: 'backupStatus',
scopedSlots: { customRender: 'backupStatus' }
},
{
title: '备注',
align: "center",
dataIndex: 'remark'
},
{
title: '操作',
dataIndex: 'action',
align: "center",
width: 260,
scopedSlots: { customRender: 'action' },
}
]
}
},
computed: {
},
created() {
this.getAllSchemaName();
this.loadData();
},
methods: {
//筛选需要重写handleTableChange
handleTableChange(pagination, filters, sorter) {
//分页、排序、筛选变化时触发
//TODO 筛选
if (Object.keys(sorter).length > 0) {
this.isorter.column = sorter.field;
this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
}
this.ipagination = pagination;
this.loadData();
},
getAllSchemaName() {
getAction("/fileDataLink/getAllSchemaName").then((res) => {
if (res.success) {
console.log(res)
this.allSchemaName = res.result;
} else {
this.$message.warning(res.message);
}
});
},
loadData() {
getAction("/idcDataBackup/list?pageNo=1&pageSize=10").then((res) => {
if (res.success) {
console.log(res)
this.dataSource = res.result.records;
} else {
this.$message.warning(res.message);
}
});
},
handleRun(sourceType) {
postAction("/idcDataBackup/dmExportByUserName",{sourceType:sourceType}).then((res) => {
if (res.success) {
this.$message.success(res.result);
} else {
this.$message.warning(res.message);
}
});
},
handleStartStop(id,backupStatus) {
postAction("/idcDataBackup/edit",{id:id,backupStatus:backupStatus}).then((res) => {
if (res.success) {
this.loadData()
} else {
this.$message.warning(res.message);
}
});
},
handleDelete: function (id) {
var that = this;
taskDeleteById({ id: id }).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.loadData();
} else {
that.$message.warning(res.message);
}
});
},
handleEdit: function (record) {
this.$refs.modalForm.edit(record);
this.$refs.modalForm.title = "编辑";
},
handleAdd() {
this.$refs.modalForm.add();
this.$refs.modalForm.title = "新增";
},
handleDistribute: function (id) {
var that = this;
taskDistributeTask({ id: id }).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.loadData();
} else {
that.$message.warning(res.message);
}
});
},
backup() {
postAction("/idcDataBackup/dmExportByUserName?userName=data_conn_original",{}).then(res => {
if (res.success) {
that.$message.success(res.message);
} else {
that.$message.warning(res.message);
}
})
},
onChangeStartTime(date, dateString) {
console.log(date, dateString);
},
onChangeEndTime(date, dateString) {
console.log(date, dateString);
},
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>