<template>
	<div class="common-page qyzz page-t1">
		<el-row>
			<el-button type="primary" @click="bakDatabase">备份数据库</el-button>
		</el-row>
	</div>
</template>

<script>
import { reqApi, Config } from '@/assets/js/httpApi.js';
import { Tools } from '@/assets/js/common.js';

export default {
	name: 'Dashboard',
	components: {
	},
	data() {
		return {
			Dict:{selectList:[]},
			table:{
				page: 1,
				size: 10,
				total: 0,
				loading: false,
				dataList:[],
			},
			rules: {},
			form: {
				title:'', visible:false, reqType:'add', historyDialog:false,
				status:{cu:0},
				query:{},
				search:{},
				item:{},
				file:0,
			},
		}
	},
	mounted() {
		var that = this;
		// 获取基本信息
		this.pageApi = Config.getModuleInfo(this);
	},
	methods: {
		bakDatabase() {
			this.$confirm('数据库备份时间较长，您确定要继续吗？', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then((e) => {
				var loadingText = '数据备份中，请等待';
				var loading = this.$loading({
					lock: true,
					text: loadingText,
					spinner: 'el-icon-loading',
					background: 'rgba(0, 0, 0, 0.7)'
				});
				var i = 0;
				var timerA = new qf.Async.intervalLoop(1500, function(){
					i %= 6;
					var spots = new Array(i+2).join('.');
					loading.text = loadingText + spots;
					i++
				});
				this.pageApi.backupDatabase({}).then((res)=>{
					timerA.clear();
					loading.close();
					if(res.code === 200){
						this.$notify({
							title: '备份成功！',
							type: 'success',
							duration: 2500
						});
					};
				});
			})
		},
	}
}
</script>
<style rel="stylesheet/scss" lang="scss" scope>
</style>
