feat: 软件管理

This commit is contained in:
TsMask
2023-10-07 15:35:40 +08:00
parent ee2a5290b1
commit aab98b016f
5 changed files with 416 additions and 149 deletions

View File

@@ -1,4 +1,8 @@
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
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';
@@ -95,6 +99,75 @@ export function uploadNeSoftware(data: FormData) {
});
}
/**
* 下发文件
* @param data 数据对象
* @returns object
*/
export async function sendNeSoftware(data: Record<string, any>) {
const result = await request({
url: `/systemManagement/v1/${data.neType}/software/${data.version}/${data.neId}`,
method: 'post',
});
// 解析数据
if (result.code === RESULT_CODE_SUCCESS && result.data.data) {
let rows = result.data.data.affectedRows;
if (rows) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
}
}
return result;
}
/**
* 激活文件
* @param data 数据对象
* @returns object
*/
export async function runNeSoftware(data: Record<string, any>) {
const result = await request({
url: `/systemManagement/v1/${data.neType}/software/${data.version}/${data.neId}`,
method: 'put',
});
// 解析数据
if (result.code === RESULT_CODE_SUCCESS && result.data.data) {
let rows = result.data.data.affectedRows;
if (rows) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
}
}
return result;
}
/**
* 回退文件
* @param data 数据对象
* @returns object
*/
export async function backNeSoftware(data: Record<string, any>) {
const result = await request({
url: `/systemManagement/v1/${data.neType}/software/${data.version}/${data.neId}`,
method: 'patch',
});
// 解析数据
if (result.code === RESULT_CODE_SUCCESS && result.data.data) {
let rows = result.data.data.affectedRows;
if (rows) {
delete result.data;
return result;
} else {
return { code: RESULT_CODE_ERROR, msg: RESULT_MSG_ERROR };
}
}
return result;
}
/**
* 查询版本列表
* @param query 查询参数
@@ -102,7 +175,7 @@ export function uploadNeSoftware(data: FormData) {
*/
export async function listNeVersion(query: Record<string, any>) {
let totalSQL = 'select count(id) as total from ne_version ';
let rowsSQL = ' select * from ne_version ';
let rowsSQL = 'select * from ne_version ';
// 查询
let querySQL = 'where 1=1';

View File

@@ -22,6 +22,8 @@ export default {
editText: 'Edit',
deleteText: 'Delete',
downloadText: 'Download',
uploadText: 'Upload',
moreText: 'More',
searchBarText: 'Search bar',
reloadText: 'Refresh',
sizeText: 'Density',
@@ -110,16 +112,32 @@ export default {
createAt: 'CreateAt',
},
softwareManage: {
uploadBtn: '上传',
downBtn: '下发',
actBtn: '激活',
historyBtn: '网元版本历史',
neTypePlease: '查询网元类型',
sendBtn: 'Distribute',
runBtn: 'Activation',
backBtn: 'Back',
historyBtn: 'Distribution Record',
neTypePlease: 'Select network element type',
neType: 'Type',
fileName: 'FileName',
version: 'Version',
softwareLoadTime: '软件加载时间',
description: '功能描述',
versionPlease: 'Version number cannot be empty',
updateTime: 'Uploaded',
description: 'Description',
deleteTip: 'Are you sure to delete the data item with record number [{num}]?',
updateComment: 'software documentation',
updateCommentPlease: 'Please enter the software description',
updateFile: 'Software Files',
updateFilePlease: 'Please upload the updated software file',
verifyFile: 'Verify File',
selectFile: 'SELECT FILE',
sendTitle: 'Distribute software version',
sendContent: 'Are you sure to send the data item file with the number [{num}] to the corresponding network element?',
runTitle: 'Activate software version',
runContent: 'Confirm that the software version with the number [{num}] has been issued for activation on the corresponding network element?',
backTitle: 'Fallback software version',
backContent: 'Confirm that the software version with the number [{num}] has been issued for the corresponding network element rollback?',
neId: 'Corresponding network element',
neIdPlease: 'Please select the corresponding network element',
},
},
neUser: {

View File

@@ -22,6 +22,8 @@ export default {
editText: '编辑',
deleteText: '删除',
downloadText: '下载',
uploadText: '上传',
moreText: '更多',
searchBarText: '搜索栏',
reloadText: '刷新',
sizeText: '密度',
@@ -110,16 +112,32 @@ export default {
createAt: '创建时间',
},
softwareManage: {
uploadBtn: '上传',
downBtn: '下发',
actBtn: '激活',
historyBtn: '网元版本历史',
neTypePlease: '查询网元类型',
sendBtn: '下发',
runBtn: '激活',
backBtn: '回退',
historyBtn: '下发记录',
neTypePlease: '选择网元类型',
neType: '网元类型',
fileName: '文件名',
version: '版本',
softwareLoadTime: '软件加载时间',
version: '版本',
versionPlease: '版本号不能为空',
updateTime: '上传时间',
description: '功能描述',
deleteTip: '确认删除记录编号为 【{num}】 的数据项?',
updateComment: '软件说明',
updateCommentPlease: '请输入软件说明',
updateFile: '软件文件',
updateFilePlease: '请上传更新软件文件',
verifyFile: '校验文件',
selectFile: '选择文件',
sendTitle: '下发软件版本',
sendContent: '确认下发编号为【{num}】的数据项文件到对应网元?',
runTitle: '激活软件版本',
runContent: '确认在对应网元激活已下发编号为【{num}】的软件版本?',
backTitle: '回退软件版本',
backContent: '确认在对应网元回退已下发编号为【{num}】的软件版本?',
neId: '对应网元',
neIdPlease: '请选择对应网元',
},
},
neUser: {

View File

@@ -1,11 +1,11 @@
<script setup lang="ts">
import { reactive, toRaw, watch, ref } from 'vue';
import { message } from 'ant-design-vue/lib';
import { SizeType } from 'ant-design-vue/lib/config-provider';
import { ColumnsType } from 'ant-design-vue/lib/table';
import { listNeVersion } from '@/api/configManage/softwareManage';
import { parseDateToStr } from '@/utils/date-utils';
import useDictStore from '@/store/modules/dict';
import useNeInfoStore from '@/store/modules/neinfo';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import useI18n from '@/hooks/useI18n';
const { t } = useI18n();
@@ -159,11 +159,6 @@ let tablePagination = reactive({
},
});
/**表格多选 */
function fnTableSelectedRowKeys(keys: (string | number)[]) {
tableState.selectedRowKeys = keys;
}
/**查询角色未授权用户列表 */
function fnGetList() {
if (tableState.loading) return;
@@ -175,10 +170,6 @@ function fnGetList() {
queryParams.endTime = queryRangePicker.value[1];
listNeVersion(toRaw(queryParams)).then(res => {
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
}
tablePagination.total = res.total;
tableState.data = res.rows;
}
@@ -186,20 +177,8 @@ function fnGetList() {
});
}
/**弹框确认按钮事件 */
function fnModalOk() {
const userIds = tableState.selectedRowKeys;
if (userIds.length <= 0) {
message.error(`请选择要分配的用户`, 2);
return;
}
emit('update:visible', false);
emit('ok', userIds);
}
/**弹框取消按钮事件 */
function fnModalCancel() {
emit('update:visible', false);
emit('cancel');
}
@@ -231,8 +210,8 @@ watch(
:visible="props.visible"
:keyboard="false"
:mask-closable="false"
@ok="fnModalOk"
@cancel="fnModalCancel"
:footer="null"
>
<!-- 表格搜索栏 -->
<a-form
@@ -243,13 +222,16 @@ watch(
>
<a-row :gutter="16">
<a-col :lg="12" :md="12" :xs="24">
<a-form-item label="网元类型" name="neType">
<a-input
<a-form-item
:label="t('views.configManage.softwareManage.neType')"
name="neType"
>
<a-auto-complete
v-model:value="queryParams.neType"
:options="useNeInfoStore().getNeSelectOtions"
allow-clear
:maxlength="30"
placeholder="查询网元类型"
></a-input>
:placeholder="t('views.configManage.softwareManage.neTypePlease')"
/>
</a-form-item>
</a-col>
<a-col :lg="12" :md="12" :xs="24">
@@ -299,19 +281,9 @@ watch(
:loading="tableState.loading"
:data-source="tableState.data"
:size="tableState.size"
:scroll="{ scrollToFirstRowOnChange: true, y: 400, x: true }"
:scroll="{ y: 400, x: true }"
:pagination="tablePagination"
:row-selection="{
type: 'checkbox',
selectedRowKeys: tableState.selectedRowKeys,
onChange: fnTableSelectedRowKeys,
}"
>
<!-- <template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<DictTag :options="dict.sysNormalDisable" :value="record.status" />
</template>
</template> -->
</a-table>
</a-modal>
</template>

View File

@@ -15,6 +15,9 @@ import {
delNeSoftware,
downloadNeSoftware,
uploadNeSoftware,
sendNeSoftware,
runNeSoftware,
backNeSoftware,
} from '@/api/configManage/softwareManage';
import { saveAs } from 'file-saver';
import useI18n from '@/hooks/useI18n';
@@ -95,7 +98,7 @@ let tableColumns: ColumnsType = [
align: 'center',
},
{
title: t('views.configManage.softwareManage.softwareLoadTime'),
title: t('views.configManage.softwareManage.updateTime'),
dataIndex: 'updateTime',
align: 'center',
customRender(opt) {
@@ -148,60 +151,156 @@ function fnTableSize({ key }: MenuInfo) {
tableState.size = key as SizeType;
}
/**信息文件下发 */
function fnSendFile(row: Record<string, any>) {
Modal.confirm({
title: '提示',
content: `确认下发编号为【${row.id}】的数据项文件BBBB?`,
onOk() {
const key = 'downloadNeSoftware';
message.loading({ content: t('common.loading'), key });
downloadNeSoftware(toRaw(row)).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已完成下载`,
key,
duration: 2,
});
saveAs(res.data, `user_${Date.now()}.xlsx`);
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
/**文件对话框对象信息状态类型 */
type FileStateType = {
/**是否下发或激活框 */
visible: boolean;
/**框类型 */
visibleType: string;
/**标题 */
title: string;
/**提示内容 */
content: string;
/**网元参数 */
neOtions: Record<string, any>[];
/**表单数据 */
from: Record<string, any>;
/**确定按钮 loading */
confirmLoading: boolean;
};
/**文件对话框对象信息状态类型 */
let fileModalState: FileStateType = reactive({
visible: false,
visibleType: 'send',
title: '下发激活回退',
content: '',
neOtions: [],
from: {
neId: undefined,
},
confirmLoading: false,
});
/**对话框内表单属性和校验规则 */
const fileModalStateFrom = Form.useForm(
fileModalState.from,
reactive({
neId: [
{
required: true,
message: t('views.configManage.softwareManage.neIdPlease'),
},
],
})
);
/**
* 文件对话框弹出显示为 下发或激活
*/
function fnFileModalVisible(type: string | number, row: Record<string, any>) {
if (type === 'send') {
fileModalState.title = t('views.configManage.softwareManage.sendTitle');
fileModalState.content = t(
'views.configManage.softwareManage.sendContent',
{ num: row.id }
);
}
if (type === 'run') {
fileModalState.title = t('views.configManage.softwareManage.runTitle');
fileModalState.content = t('views.configManage.softwareManage.runContent', {
num: row.id,
});
}
if (type === 'back') {
fileModalState.title = t('views.configManage.softwareManage.backTitle');
fileModalState.content = t(
'views.configManage.softwareManage.backContent',
{ num: row.id }
);
}
if (!fileModalState.content) {
return;
}
fileModalState.from = Object.assign(fileModalState.from, row);
// 过滤网元类型
const neType = row.neType;
let arr: Record<string, any>[] = [];
for (const item of useNeInfoStore().getNeSelectOtions) {
if (item.value === neType && Array.isArray(item.children)) {
arr = item.children.concat();
if (arr.length > 0) {
fileModalState.from.neId = arr[0].neId;
}
break;
}
}
fileModalState.neOtions = arr;
fileModalState.visible = true;
fileModalState.visibleType = type as string;
}
/**信息文件下发 */
function fnRunFile(row: Record<string, any>) {
Modal.confirm({
title: '提示',
content: `确认激活 【${row.id}】 的数据项文件?`,
onOk() {
const key = 'downloadNeSoftware';
message.loading({ content: t('common.loading'), key });
downloadNeSoftware(toRaw(row)).then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `已完成下载`,
key,
duration: 2,
});
saveAs(res.data, `user_${Date.now()}.xlsx`);
} else {
message.error({
content: `${res.msg}`,
key,
duration: 2,
});
}
});
},
});
/**
* 文件对话框弹出确认执行函数
* 进行表达规则校验
*/
function fnFileModalOk() {
fileModalStateFrom
.validate()
.then(e => {
const from = toRaw(fileModalState.from);
const type = fileModalState.visibleType;
let fnType = null;
console.log(type, from);
if (type === 'send') {
fnType = sendNeSoftware(from);
}
if (type === 'run') {
fnType = runNeSoftware(from);
}
if (type === 'back') {
fnType = backNeSoftware(from);
}
if (fnType === null) {
return;
}
// 发送请求
fileModalState.confirmLoading = true;
const hide = message.loading({ content: t('common.loading') });
fnType
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: t('common.msgSuccess', { msg: fileModalState.title }),
duration: 3,
});
fnFileModalCancel();
} else {
message.error({
content: `${fileModalState.title} ${res.msg}`,
duration: 3,
});
}
})
.finally(() => {
hide();
fileModalState.confirmLoading = false;
});
})
.catch(e => {
message.error(t('common.errorFields', { num: e.errorFields.length }), 3);
});
}
/**
* 文件对话框弹出关闭执行函数
* 进行表达规则校验
*/
function fnFileModalCancel() {
fileModalState.visible = false;
fileModalState.visibleType = 'send';
fileModalStateFrom.resetFields();
}
/**信息文件下载 */
@@ -233,20 +332,20 @@ function fnDownloadFile(row: Record<string, any>) {
}
/**
* 备份信息删除
* 信息删除
* @param row 记录编号ID
*/
function fnRecordDelete(row: Record<string, any>) {
Modal.confirm({
title: '提示',
content: `确认删除记录编号为 【${row.id}】 的数据项?`,
title: t('commont.tipTitle'),
content: t('views.configManage.softwareManage.deleteTip', { num: row.id }),
onOk() {
const key = 'delNeSoftware';
message.loading({ content: t('common.loading'), key });
delNeSoftware(toRaw(row)).then(res => {
if (res.code === 200) {
if (res.code === RESULT_CODE_SUCCESS) {
message.success({
content: `删除成功`,
content: t('common.msgSuccess', { msg: row.id }),
key,
duration: 2,
});
@@ -300,7 +399,7 @@ let modalState: ModalStateType = reactive({
visibleByHistory: false,
title: '任务设置',
from: {
neType: '',
neType: undefined,
version: '',
comment: '',
file: undefined,
@@ -316,7 +415,7 @@ let modalState: ModalStateType = reactive({
* @param noticeId 网元id, 不传为新增
*/
function fnModalVisibleByEdit() {
modalState.title = t('views.configManage.softwareManage.uploadBtn');
modalState.title = t('common.uploadText');
modalState.visibleByEdit = true;
}
@@ -324,12 +423,33 @@ function fnModalVisibleByEdit() {
const modalStateFrom = Form.useForm(
modalState.from,
reactive({
neType: [{ required: true, message: '网元类型不能为空' }],
version: [{ required: true, message: '版本号不能为空' }],
comment: [{ required: true, message: '软件说明不能为空' }],
file: [{ required: true, message: '软件文件不能为空' }],
neType: [
{
required: true,
message: t('views.configManage.softwareManage.neTypePlease'),
},
],
version: [
{
required: true,
message: t('views.configManage.softwareManage.versionPlease'),
},
],
comment: [
{
required: true,
message: t('views.configManage.softwareManage.updateCommentPlease'),
},
],
file: [
{
required: true,
message: t('views.configManage.softwareManage.updateFilePlease'),
},
],
})
);
/**
* 对话框弹出确认执行函数
* 进行表达规则校验
@@ -379,6 +499,7 @@ function fnModalOk() {
*/
function fnModalCancel() {
modalState.visibleByEdit = false;
modalState.visibleByHistory = false;
modalStateFrom.resetFields();
}
@@ -514,7 +635,7 @@ onMounted(() => {
<a-space :size="8" align="center">
<a-button type="primary" @click.prevent="fnModalVisibleByEdit()">
<template #icon><UploadOutlined /></template>
{{ t('views.configManage.softwareManage.uploadBtn') }}
{{ t('common.uploadText') }}
</a-button>
<a-button type="dashed" @click.prevent="fnModalVisibleByHistory()">
<template #icon><HistoryOutlined /></template>
@@ -582,22 +703,6 @@ onMounted(() => {
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'id'">
<a-space :size="8" align="center">
<a-tooltip>
<template #title>{{
t('views.configManage.softwareManage.downBtn')
}}</template>
<a-button type="link" @click.prevent="fnSendFile(record)">
<template #icon><SendOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>{{
t('views.configManage.softwareManage.actBtn')
}}</template>
<a-button type="link" @click.prevent="fnRunFile(record)">
<template #icon><ThunderboltOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>{{ t('common.downloadText') }}</template>
<a-button type="link" @click.prevent="fnDownloadFile(record)">
@@ -610,6 +715,35 @@ onMounted(() => {
<template #icon><DeleteOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip>
<template #title>{{ t('common.moreText') }}</template>
<a-dropdown
placement="bottomRight"
:trigger="['hover', 'click']"
>
<a-button type="link">
<template #icon><EllipsisOutlined /> </template>
</a-button>
<template #overlay>
<a-menu
@click="({ key }) => fnFileModalVisible(key, record)"
>
<a-menu-item key="send">
<SendOutlined />
{{ t('views.configManage.softwareManage.sendBtn') }}
</a-menu-item>
<a-menu-item key="run">
<ThunderboltOutlined />
{{ t('views.configManage.softwareManage.runBtn') }}
</a-menu-item>
<a-menu-item key="back">
<UndoOutlined />
{{ t('views.configManage.softwareManage.backBtn') }}
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-tooltip>
</a-space>
</template>
</template>
@@ -633,30 +767,30 @@ onMounted(() => {
:label-col="{ span: 4 }"
>
<a-form-item
label="网元类型"
:label="t('views.configManage.softwareManage.neType')"
name="neType"
v-bind="modalStateFrom.validateInfos.neType"
>
<a-select
v-model:value="modalState.from.neType"
placeholder="网元类型"
:options="useNeInfoStore().getNeSelectOtions"
:placeholder="t('views.configManage.softwareManage.neTypePlease')"
>
</a-select>
</a-form-item>
<a-form-item
label="版本号"
:label="t('views.configManage.softwareManage.version')"
name="version"
v-bind="modalStateFrom.validateInfos.version"
>
<a-input
v-model:value="modalState.from.version"
allow-clear
placeholder="请输入版本号"
:placeholder="t('views.configManage.softwareManage.versionPlease')"
></a-input>
</a-form-item>
<a-form-item
label="软件说明"
:label="t('views.configManage.softwareManage.updateComment')"
name="comment"
v-bind="modalStateFrom.validateInfos.comment"
>
@@ -665,11 +799,13 @@ onMounted(() => {
:auto-size="{ minRows: 4, maxRows: 6 }"
:maxlength="200"
:show-count="true"
placeholder="请输入软件说明"
:placeholder="
t('views.configManage.softwareManage.updateCommentPlease')
"
/>
</a-form-item>
<a-form-item
label="软件文件"
:label="t('views.configManage.softwareManage.updateFile')"
name="file"
v-bind="modalStateFrom.validateInfos.file"
>
@@ -684,11 +820,14 @@ onMounted(() => {
:custom-request="fnUploadFile"
>
<a-button type="default" :loading="modalState.confirmLoading">
选择文件
{{ t('views.configManage.softwareManage.selectFile') }}
</a-button>
</a-upload>
</a-form-item>
<a-form-item label="校验文件" name="cms">
<a-form-item
:label="t('views.configManage.softwareManage.verifyFile')"
name="cms"
>
<a-upload
name="cms"
v-model:file-list="modalState.from.cmsList"
@@ -700,19 +839,51 @@ onMounted(() => {
:custom-request="fnUploadCms"
>
<a-button type="default" :loading="modalState.confirmLoading">
选择文件
{{ t('views.configManage.softwareManage.selectFile') }}
</a-button>
</a-upload>
</a-form-item>
</a-form>
</a-modal>
<!-- 分配用户选择框 -->
<!-- 上传激活历史 -->
<SoftwareHistory
title="查询网元版本信息"
:title="t('views.configManage.softwareManage.historyBtn')"
v-model:visible="modalState.visibleByHistory"
@ok="fnModalOk"
@cancel="fnModalCancel"
/>
<!-- 文件框 下发激活回退 -->
<a-modal
width="600px"
:keyboard="false"
:mask-closable="false"
:visible="fileModalState.visible"
:title="fileModalState.title"
:confirm-loading="fileModalState.confirmLoading"
@ok="fnFileModalOk"
@cancel="fnFileModalCancel"
>
<a-form name="fileModalState" layout="horizontal">
<a-form-item name="content">
<QuestionCircleOutlined class="file-model__icon" />
<span class="file-model__tip">
{{ fileModalState.content }}
</span>
</a-form-item>
<a-form-item
:label="t('views.configManage.softwareManage.neId')"
name="neId"
v-bind="fileModalStateFrom.validateInfos.neId"
>
<a-select
v-model:value="fileModalState.from.neId"
:options="fileModalState.neOtions"
:placeholder="t('views.configManage.softwareManage.neIdPlease')"
/>
</a-form-item>
</a-form>
</a-modal>
</PageContainer>
</template>
@@ -720,4 +891,19 @@ onMounted(() => {
.table :deep(.ant-pagination) {
padding: 0 24px;
}
.file-model {
&__icon {
color: var(--ant-warning-color);
margin-right: 16px;
font-size: 22px;
}
&__tip {
overflow: hidden;
color: #000000d9;
font-weight: 500;
font-size: 16px;
line-height: 1.4;
}
}
</style>