Merge branch 'main-v2' into lichang

This commit is contained in:
TsMask
2025-06-16 19:41:00 +08:00
5 changed files with 145 additions and 34 deletions

View File

@@ -16,7 +16,8 @@ import useNeStore from '@/store/modules/ne';
import useI18n from '@/hooks/useI18n';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { saveAs } from 'file-saver';
import { uploadFileToNE } from '@/api/tool/file';
import { uploadFile } from '@/api/tool/file';
import { getNeViewFile } from '@/api/tool/neFile';
import {
addUDMVolteIMS,
batchAddUDMVolteIMS,
@@ -541,15 +542,27 @@ function fnModalUploadImportUpload(file: File) {
}
const hide = message.loading(t('common.loading'), 0);
uploadImportState.loading = true;
uploadFileToNE('UDM', neID, file, 5)
// 上传文件
let formData = new FormData();
formData.append('file', file);
formData.append('subPath', 'import');
uploadFile(formData)
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
return importUDMVolteIMS({
neId: neID,
uploadPath: res.data,
});
return res.data.filePath;
} else {
uploadImportState.msg = res.msg;
uploadImportState.loading = false;
return '';
}
return res;
})
.then((filePath: string) => {
if (!filePath) return;
// 文件导入
return importUDMVolteIMS({
neId: neID,
uploadPath: filePath,
});
})
.then(res => {
if (!res) return;
@@ -569,6 +582,33 @@ function fnModalUploadImportUpload(file: File) {
});
}
/**对话框表格信息导入失败原因 */
function fnModalUploadImportFailReason() {
const neId = queryParams.neId;
if (!neId) return;
const hide = message.loading(t('common.loading'), 0);
getNeViewFile({
neType: 'UDM',
neId: neId,
path: '/tmp',
fileName: 'import_imsuser_err_records.txt',
})
.then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
message.success(t('common.operateOk'), 3);
const blob = new Blob([res.data], {
type: 'text/plain',
});
saveAs(blob, `import_udmvolte_err_records_${Date.now()}.txt`);
} else {
message.error(`${res.msg}`, 3);
}
})
.finally(() => {
hide();
});
}
/**对话框表格信息导入模板 */
function fnModalDownloadImportTemplate() {
const hide = message.loading(t('common.loading'), 0);
@@ -1089,13 +1129,23 @@ onMounted(() => {
</a-button>
</a-col>
</a-row>
<a-textarea
:disabled="true"
:hidden="!uploadImportState.msg"
:value="uploadImportState.msg"
:auto-size="{ minRows: 2, maxRows: 8 }"
style="background-color: transparent; color: rgba(0, 0, 0, 0.85)"
/>
<a-alert
:message="uploadImportState.msg"
:type="uploadImportState.hasFail ? 'warning' : 'info'"
v-show="uploadImportState.msg.length > 0"
>
<template #action>
<a-button
size="small"
type="link"
danger
@click="fnModalUploadImportFailReason"
v-if="uploadImportState.hasFail"
>
{{ t('views.neUser.auth.importFail') }}
</a-button>
</template>
</a-alert>
</template>
</UploadModal>
</PageContainer>