feat: 设置自动备份时间
This commit is contained in:
56
src/api/configManage/config.ts
Normal file
56
src/api/configManage/config.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import {
|
||||||
|
RESULT_CODE_ERROR,
|
||||||
|
RESULT_CODE_SUCCESS,
|
||||||
|
RESULT_MSG_ERROR,
|
||||||
|
} from '@/constants/result-constants';
|
||||||
|
import { request } from '@/plugins/http-fetch';
|
||||||
|
import { parseObjLineToHump } from '@/utils/parse-utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询配置详细
|
||||||
|
* @param tag 配置ID
|
||||||
|
* @returns object
|
||||||
|
*/
|
||||||
|
export async function getConfigInfo(tag: string) {
|
||||||
|
// 发起请求
|
||||||
|
const result = await request({
|
||||||
|
url: `/databaseManagement/v1/omc_db/config`,
|
||||||
|
method: 'get',
|
||||||
|
params: {
|
||||||
|
SQL: `SELECT * FROM config WHERE config_tag = '${tag}'`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// 解析数据
|
||||||
|
if (result.code === RESULT_CODE_SUCCESS && Array.isArray(result.data.data)) {
|
||||||
|
let data = result.data.data[0];
|
||||||
|
return Object.assign(result, {
|
||||||
|
data: parseObjLineToHump(data['config'][0]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改配置
|
||||||
|
* @param data 配置对象
|
||||||
|
* @returns object
|
||||||
|
*/
|
||||||
|
export async function updateConfig(tag: string, data: Record<string, any>) {
|
||||||
|
const result = await request({
|
||||||
|
url: `/databaseManagement/v1/omc_db/config?WHERE=config_tag='${tag}'`,
|
||||||
|
method: 'put',
|
||||||
|
data: { data },
|
||||||
|
});
|
||||||
|
// 解析数据
|
||||||
|
if (result.code === RESULT_CODE_SUCCESS && result.data.data) {
|
||||||
|
let rows = result.data.data.affectedRows;
|
||||||
|
if (rows) {
|
||||||
|
delete result.data;
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
delete result.data;
|
||||||
|
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -100,6 +100,7 @@ export default {
|
|||||||
},
|
},
|
||||||
configManage: {
|
configManage: {
|
||||||
backupManage: {
|
backupManage: {
|
||||||
|
SetBackupTask: 'Set automatic backup time',
|
||||||
neTypePlease: 'Query network element type',
|
neTypePlease: 'Query network element type',
|
||||||
neType: 'Type',
|
neType: 'Type',
|
||||||
neID: 'Identifying',
|
neID: 'Identifying',
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export default {
|
|||||||
},
|
},
|
||||||
configManage: {
|
configManage: {
|
||||||
backupManage: {
|
backupManage: {
|
||||||
|
SetBackupTask: '设置自动备份时间',
|
||||||
neTypePlease: '查询网元类型',
|
neTypePlease: '查询网元类型',
|
||||||
neType: '网元类型',
|
neType: '网元类型',
|
||||||
neID: '网元内部标识',
|
neID: '网元内部标识',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { reactive, ref, onMounted, toRaw } from 'vue';
|
import { reactive, ref, onMounted, toRaw } from 'vue';
|
||||||
import { PageContainer } from '@ant-design-vue/pro-layout';
|
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 { SizeType } from 'ant-design-vue/lib/config-provider';
|
||||||
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
|
import { MenuInfo } from 'ant-design-vue/lib/menu/src/interface';
|
||||||
import { ColumnsType } from 'ant-design-vue/lib/table';
|
import { ColumnsType } from 'ant-design-vue/lib/table';
|
||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
} from '@/api/configManage/backupManage';
|
} from '@/api/configManage/backupManage';
|
||||||
import { saveAs } from 'file-saver';
|
import { saveAs } from 'file-saver';
|
||||||
import useI18n from '@/hooks/useI18n';
|
import useI18n from '@/hooks/useI18n';
|
||||||
|
import { getConfigInfo, updateConfig } from '@/api/configManage/config';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
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(() => {
|
onMounted(() => {
|
||||||
// 获取列表数据
|
// 获取列表数据
|
||||||
fnGetList();
|
fnGetList();
|
||||||
@@ -261,7 +360,14 @@ onMounted(() => {
|
|||||||
|
|
||||||
<a-card :bordered="false" :body-style="{ padding: '0px' }">
|
<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>
|
<template #extra>
|
||||||
@@ -339,6 +445,33 @@ onMounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
</a-card>
|
</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>
|
</PageContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -212,13 +212,13 @@ let modalState: ModalStateType = reactive({
|
|||||||
const modalStateFrom = Form.useForm(
|
const modalStateFrom = Form.useForm(
|
||||||
modalState.from,
|
modalState.from,
|
||||||
reactive({
|
reactive({
|
||||||
ne_type: [{ required: true, message: '网元类型不能为空' }],
|
neType: [{ required: true, message: '网元类型不能为空' }],
|
||||||
ne_id: [{ required: true, message: '网元内部标识不能为空' }],
|
neId: [{ required: true, message: '网元内部标识不能为空' }],
|
||||||
rm_uid: [{ required: true, message: '资源唯一标识不能为空' }],
|
rmUid: [{ required: true, message: '资源唯一标识不能为空' }],
|
||||||
ip: [{ required: true, message: 'IP地址不能为空' }],
|
ip: [{ required: true, message: 'IP地址不能为空' }],
|
||||||
port: [{ required: true, message: '端口不能为空' }],
|
port: [{ required: true, message: '端口不能为空' }],
|
||||||
pv_flag: [{ required: true, message: '请选择网元虚拟化标识' }],
|
pvFlag: [{ required: true, message: '请选择网元虚拟化标识' }],
|
||||||
ne_name: [{ required: true, message: '网元名称不能为空' }],
|
neName: [{ required: true, message: '网元名称不能为空' }],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user