From 3525d7567ea283ab91037034a2867736caddbc11 Mon Sep 17 00:00:00 2001
From: TsMask <340112800@qq.com>
Date: Mon, 25 Sep 2023 10:39:28 +0800
Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=B8=8A=E4=BC=A0?=
=?UTF-8?q?=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/UploadImport/index.vue | 186 --------------------------
src/components/UploadModal/index.vue | 111 +++++++++++++++
src/views/neUser/auth/index.vue | 106 +++++++++------
src/views/neUser/sub/index.vue | 81 +++++++----
4 files changed, 232 insertions(+), 252 deletions(-)
delete mode 100644 src/components/UploadImport/index.vue
create mode 100644 src/components/UploadModal/index.vue
diff --git a/src/components/UploadImport/index.vue b/src/components/UploadImport/index.vue
deleted file mode 100644
index 6ef13eaa..00000000
--- a/src/components/UploadImport/index.vue
+++ /dev/null
@@ -1,186 +0,0 @@
-
-
-
-
-
-
-
-
-
- 点击选择或将文件拖入边框区域进行上传
-
- 仅允许导入
- {{ props.fileExt.join('、') }}
- 格式文件,上传文件大小
- {{ props.fileSize }}
- MB。
-
-
-
-
-
- 是否更新已经存在的数据
-
-
-
-
- 下载模板
-
-
-
-
-
-
-
-
-
diff --git a/src/components/UploadModal/index.vue b/src/components/UploadModal/index.vue
new file mode 100644
index 00000000..67fb814c
--- /dev/null
+++ b/src/components/UploadModal/index.vue
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+ 点击选择或将文件拖入边框区域进行上传
+
+
+ 允许上传文件大小 {{ props.size }} MB
+
+
+ 允许导入
+ {{ props.ext.join('、') }}
+ 格式文件
+
+
+
+
+
+
+
+
+
diff --git a/src/views/neUser/auth/index.vue b/src/views/neUser/auth/index.vue
index fb23dfb2..aad0a601 100644
--- a/src/views/neUser/auth/index.vue
+++ b/src/views/neUser/auth/index.vue
@@ -6,7 +6,7 @@ import { message, Modal, Form, notification } 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';
-import UploadImport from '@/components/UploadImport/index.vue';
+import UploadModal from '@/components/UploadModal/index.vue';
import {
listAuth,
getAuth,
@@ -22,7 +22,6 @@ import useNeInfoStore from '@/store/modules/neinfo';
import useI18n from '@/hooks/useI18n';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { saveAs } from 'file-saver';
-import { formItemProps } from 'ant-design-vue/lib/form';
const { t } = useI18n();
const route = useRoute();
@@ -186,7 +185,7 @@ let modalState: ModalStateType = reactive({
visibleByBatchDel: false,
title: 'UDM鉴权用户',
from: {
- id:'',
+ id: '',
imsi: '',
amf: '',
ki: '',
@@ -237,18 +236,18 @@ const modalStateBatchFrom = Form.useForm(
})
);
-
/**对话框内批量删除表单属性和校验规则 */
const modalStateBatchDelFrom = Form.useForm(
modalState.BatchDelForm,
reactive({
- num: [{ required: true, message: '放号数不能为空' },
- { min: 1, max: 100, message: '放号数必须小于等于100' }],
+ num: [
+ { required: true, message: '放号数不能为空' },
+ { min: 1, max: 100, message: '放号数必须小于等于100' },
+ ],
imsi: [{ required: true, message: 'IMSI不能为空' }],
})
);
-
/**
* 对话框弹出显示为 新增或者修改
* @param noticeId 网元id, 不传为新增
@@ -347,7 +346,7 @@ function fnBatchModalOk() {
const from = toRaw(modalState.BatchForm);
const neID = queryParams.neId || '-';
// const result = from.id ? updateAuth(from) : addAuth(neID, from);
- from.neID=neID;
+ from.neID = neID;
const result = batchAuth(from);
const hide = message.loading({ content: t('common.loading') });
result
@@ -500,39 +499,54 @@ type ModalUploadImportStateType = {
visible: boolean;
/**标题 */
title: string;
- /**导入模板下载触发 */
- templateDownload: boolean;
+ /**是否上传中 */
+ loading: boolean;
+ /**上传结果信息 */
+ msg: string;
};
/**对话框表格信息导入对象信息状态 */
-let modalUploadImportState: ModalUploadImportStateType = reactive({
+let uploadImportState: ModalUploadImportStateType = reactive({
visible: false,
title: '数据导入',
- templateDownload: false,
+ loading: false,
+ msg: '',
});
-/**
- * 对话框表格信息导入确认执行函数
- * @param isUpload 是否已上传文件
- */
-function fnModalUploadImportClose(isUpload: boolean) {
- if (isUpload) {
- fnGetList();
- }
-}
-
/**对话框表格信息导入弹出窗口 */
-function fnModalImportOpen() {
- modalUploadImportState.visible = true;
+function fnModalUploadImportOpen() {
+ uploadImportState.msg = '';
+ uploadImportState.loading = false;
+ uploadImportState.visible = true;
}
-/**列表导入数据 */
-async function fnModalImportData(data: FormData) {
+/**对话框表格信息导入关闭窗口 */
+function fnModalUploadImportClose() {
+ uploadImportState.visible = false;
+ fnGetList();
+}
+
+/**对话框表格信息导入上传 */
+function fnModalUploadImportUpload(file: File) {
+ let formData = new FormData();
+ formData.append('file', file);
const neID = queryParams.neId;
if (!neID) {
return Promise.reject('未知网元');
}
- return importAuthData(neID, data);
+ const hide = message.loading('正在上传...', 0);
+ uploadImportState.loading = true;
+ importAuthData(neID, formData)
+ .then(res => {
+ uploadImportState.msg = res.msg;
+ })
+ .catch((err: { code: number; msg: string }) => {
+ message.error(`上传失败 ${err.msg}`);
+ })
+ .finally(() => {
+ hide();
+ uploadImportState.loading = false;
+ });
}
onMounted(() => {
@@ -635,7 +649,12 @@ onMounted(() => {
{{ t('views.neUser.auth.batchAddText') }}
-
+
@@ -659,7 +678,7 @@ onMounted(() => {
-
+
{{ t('views.neUser.auth.import') }}
@@ -785,7 +804,8 @@ onMounted(() => {
:label-col="{ span: 7 }"
>
- {{ modalState.from }}
+
+ {{ modalState.from }}
{
>
@@ -985,14 +1005,24 @@ onMounted(() => {
-
+ v-model:visible="uploadImportState.visible"
+ :ext="['.csv', '.txt']"
+ :size="5"
+ >
+
+
+
+
diff --git a/src/views/neUser/sub/index.vue b/src/views/neUser/sub/index.vue
index 60c63f49..888dafdd 100644
--- a/src/views/neUser/sub/index.vue
+++ b/src/views/neUser/sub/index.vue
@@ -6,7 +6,7 @@ import { message, Modal, Form, notification } 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';
-import UploadImport from '@/components/UploadImport/index.vue';
+import UploadModal from '@/components/UploadModal/index.vue';
import {
loadSub,
listSub,
@@ -463,39 +463,54 @@ type ModalUploadImportStateType = {
visible: boolean;
/**标题 */
title: string;
- /**导入模板下载触发 */
- templateDownload: boolean;
+ /**是否上传中 */
+ loading: boolean;
+ /**上传结果信息 */
+ msg: string;
};
/**对话框表格信息导入对象信息状态 */
-let modalUploadImportState: ModalUploadImportStateType = reactive({
+let uploadImportState: ModalUploadImportStateType = reactive({
visible: false,
title: '数据导入',
- templateDownload: false,
+ loading: false,
+ msg: '',
});
-/**
- * 对话框表格信息导入确认执行函数
- * @param isUpload 是否已上传文件
- */
-function fnModalUploadImportClose(isUpload: boolean) {
- if (isUpload) {
- fnGetList();
- }
-}
-
/**对话框表格信息导入弹出窗口 */
-function fnModalImportOpen() {
- modalUploadImportState.visible = true;
+function fnModalUploadImportOpen() {
+ uploadImportState.msg = '';
+ uploadImportState.loading = false;
+ uploadImportState.visible = true;
}
-/**列表导入数据 */
-async function fnModalImportData(data: FormData) {
+/**对话框表格信息导入关闭窗口 */
+function fnModalUploadImportClose() {
+ uploadImportState.visible = false;
+ fnGetList();
+}
+
+/**对话框表格信息导入上传 */
+function fnModalUploadImportUpload(file: File) {
+ let formData = new FormData();
+ formData.append('file', file);
const neID = queryParams.neId;
if (!neID) {
return Promise.reject('未知网元');
}
- return importSubData(neID, data);
+ const hide = message.loading('正在上传...', 0);
+ uploadImportState.loading = true;
+ importSubData(neID, formData)
+ .then(res => {
+ uploadImportState.msg = res.msg;
+ })
+ .catch((err: { code: number; msg: string }) => {
+ message.error(`上传失败 ${err.msg}`);
+ })
+ .finally(() => {
+ hide();
+ uploadImportState.loading = false;
+ });
}
onMounted(() => {
@@ -621,7 +636,7 @@ onMounted(() => {
-
+
@@ -1074,14 +1089,24 @@ onMounted(() => {
-
+ v-model:visible="uploadImportState.visible"
+ :ext="['.csv', '.txt']"
+ :size="5"
+ >
+
+
+
+