feat: 设置自动备份时间
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { useRoute } from 'vue-router';
|
||||
import { reactive, ref, onMounted, toRaw } from 'vue';
|
||||
import { PageContainer } from '@ant-design-vue/pro-layout';
|
||||
import { message, Modal } from 'ant-design-vue/lib';
|
||||
import { Form, message, Modal } from 'ant-design-vue/lib';
|
||||
import { SizeType } from 'ant-design-vue/lib/config-provider';
|
||||
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
|
||||
import { ColumnsType } from 'ant-design-vue/lib/table';
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from '@/api/configManage/backupManage';
|
||||
import { saveAs } from 'file-saver';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { getConfigInfo, updateConfig } from '@/api/configManage/config';
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
@@ -213,6 +214,104 @@ function fnGetList() {
|
||||
});
|
||||
}
|
||||
|
||||
/**对话框对象信息状态类型 */
|
||||
type ModalStateType = {
|
||||
/**新增框或修改框是否显示 */
|
||||
visibleByEdit: boolean;
|
||||
/**标题 */
|
||||
title: string;
|
||||
/**表单数据 */
|
||||
from: Record<string, any>;
|
||||
/**确定按钮 loading */
|
||||
confirmLoading: boolean;
|
||||
};
|
||||
|
||||
/**对话框对象信息状态 */
|
||||
let modalState: ModalStateType = reactive({
|
||||
visibleByEdit: false,
|
||||
title: '任务设置',
|
||||
from: {
|
||||
configTag: "",
|
||||
autoBackupTime: "",
|
||||
},
|
||||
confirmLoading: false,
|
||||
});
|
||||
|
||||
/**
|
||||
* 对话框弹出显示为 新增或者修改
|
||||
* @param noticeId 网元id, 不传为新增
|
||||
*/
|
||||
function fnModalVisibleByEdit() {
|
||||
if (modalState.confirmLoading) return;
|
||||
const hide = message.loading('正在打开...', 0);
|
||||
modalState.confirmLoading = true;
|
||||
getConfigInfo('NfConfigSet').then(res => {
|
||||
modalState.confirmLoading = false;
|
||||
hide();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
modalState.from.configTag = res.data.configTag
|
||||
modalState.from.autoBackupTime = res.data.value
|
||||
modalState.title = t('views.configManage.backupManage.SetBackupTask');
|
||||
modalState.visibleByEdit = true;
|
||||
} else {
|
||||
message.error(`获取配置信息失败`, 2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**对话框内表单属性和校验规则 */
|
||||
const modalStateFrom = Form.useForm(
|
||||
modalState.from,
|
||||
reactive({
|
||||
autoBackupTime: [{ required: true, message: '备份时间不能为空' }],
|
||||
})
|
||||
);
|
||||
/**
|
||||
* 对话框弹出确认执行函数
|
||||
* 进行表达规则校验
|
||||
*/
|
||||
function fnModalOk() {
|
||||
modalStateFrom
|
||||
.validate()
|
||||
.then(e => {
|
||||
modalState.confirmLoading = true;
|
||||
const from = toRaw(modalState.from);
|
||||
const hide = message.loading({ content: t('common.loading') });
|
||||
updateConfig(from.configTag, {value: from.autoBackupTime})
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
message.success({
|
||||
content: t('common.msgSuccess', { msg: modalState.title }),
|
||||
duration: 3,
|
||||
});
|
||||
modalState.visibleByEdit = false;
|
||||
modalStateFrom.resetFields();
|
||||
} else {
|
||||
message.error({
|
||||
content: `${res.msg}`,
|
||||
duration: 3,
|
||||
});
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
hide();
|
||||
modalState.confirmLoading = false;
|
||||
});
|
||||
})
|
||||
.catch(e => {
|
||||
message.error(t('common.errorFields', { num: e.errorFields.length }), 3);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 对话框弹出关闭执行函数
|
||||
* 进行表达规则校验
|
||||
*/
|
||||
function fnModalCancel() {
|
||||
modalState.visibleByEdit = false;
|
||||
modalStateFrom.resetFields();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 获取列表数据
|
||||
fnGetList();
|
||||
@@ -261,7 +360,14 @@ onMounted(() => {
|
||||
|
||||
<a-card :bordered="false" :body-style="{ padding: '0px' }">
|
||||
<!-- 插槽-卡片左侧侧 -->
|
||||
<template #title> </template>
|
||||
<template #title>
|
||||
<a-space :size="8" align="center">
|
||||
<a-button type="primary" @click.prevent="fnModalVisibleByEdit()">
|
||||
<template #icon><FieldTimeOutlined /></template>
|
||||
{{ t('views.configManage.backupManage.SetBackupTask') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<!-- 插槽-卡片右侧 -->
|
||||
<template #extra>
|
||||
@@ -339,6 +445,33 @@ onMounted(() => {
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 新增框或修改框 -->
|
||||
<a-modal
|
||||
width="800px"
|
||||
:keyboard="false"
|
||||
:mask-closable="false"
|
||||
:visible="modalState.visibleByEdit"
|
||||
:title="modalState.title"
|
||||
:confirm-loading="modalState.confirmLoading"
|
||||
@ok="fnModalOk"
|
||||
@cancel="fnModalCancel"
|
||||
>
|
||||
<a-form name="modalStateFrom" layout="horizontal">
|
||||
<a-form-item
|
||||
label="自动备份任务备份时间(小时)"
|
||||
name="autoBackupTime"
|
||||
v-bind="modalStateFrom.validateInfos.autoBackupTime"
|
||||
>
|
||||
<a-input
|
||||
v-model:value="modalState.from.autoBackupTime"
|
||||
allow-clear
|
||||
placeholder="备份任务执行单位是小时"
|
||||
>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</PageContainer>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -212,13 +212,13 @@ let modalState: ModalStateType = reactive({
|
||||
const modalStateFrom = Form.useForm(
|
||||
modalState.from,
|
||||
reactive({
|
||||
ne_type: [{ required: true, message: '网元类型不能为空' }],
|
||||
ne_id: [{ required: true, message: '网元内部标识不能为空' }],
|
||||
rm_uid: [{ required: true, message: '资源唯一标识不能为空' }],
|
||||
neType: [{ required: true, message: '网元类型不能为空' }],
|
||||
neId: [{ required: true, message: '网元内部标识不能为空' }],
|
||||
rmUid: [{ required: true, message: '资源唯一标识不能为空' }],
|
||||
ip: [{ required: true, message: 'IP地址不能为空' }],
|
||||
port: [{ required: true, message: '端口不能为空' }],
|
||||
pv_flag: [{ required: true, message: '请选择网元虚拟化标识' }],
|
||||
ne_name: [{ required: true, message: '网元名称不能为空' }],
|
||||
pvFlag: [{ required: true, message: '请选择网元虚拟化标识' }],
|
||||
neName: [{ required: true, message: '网元名称不能为空' }],
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user