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,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>