feat: 参数配置AMF导入Index字段存在更新,不存在默认新增

This commit is contained in:
TsMask
2025-07-21 17:13:10 +08:00
parent b5b9e763aa
commit b5400b0dd8
4 changed files with 11 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ import { addNeConfigData, editNeConfigData } from '@/api/ne/neConfig';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { readSheet } from '@/utils/execl-utils'; import { readSheet } from '@/utils/execl-utils';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { reactive, toRaw } from 'vue'; import { reactive } from 'vue';
import saveAs from 'file-saver'; import saveAs from 'file-saver';
/** /**
@@ -22,23 +22,25 @@ export default function useArrayImport({
imeiWhitelist: { imeiWhitelist: {
filename: 'import_amf_imeiWhitelist_template', filename: 'import_amf_imeiWhitelist_template',
fileetx: '.xlsx', fileetx: '.xlsx',
itemKey: 'imeiPrefixValue', itemKey: 'index',
item: (row: Record<string, any>) => { item: (row: Record<string, any>) => {
const index = row['Index'] || 0;
return { return {
imeiPrefixValue: `${row['IMEI Prefix']}`, imeiPrefixValue: `${row['IMEI Prefix']}`,
index: 0, index: parseInt(index),
}; };
}, },
}, },
whitelist: { whitelist: {
filename: 'import_amf_whitelist_template', filename: 'import_amf_whitelist_template',
fileetx: '.xlsx', fileetx: '.xlsx',
itemKey: 'imsiValue', itemKey: 'index',
item: (row: Record<string, any>) => { item: (row: Record<string, any>) => {
const index = row['Index'] || 0;
return { return {
imsiValue: `${row['IMSI Value']}`, imsiValue: `${row['IMSI Value']}`,
imeiValue: `${row['IMEI Value/Prefix']}`, imeiValue: `${row['IMEI Value/Prefix']}`,
index: 0, index: parseInt(index),
}; };
}, },
}, },
@@ -47,11 +49,12 @@ export default function useArrayImport({
white_list: { white_list: {
filename: 'import_mme_imeiWhitelist_template', filename: 'import_mme_imeiWhitelist_template',
fileetx: '.xlsx', fileetx: '.xlsx',
itemKey: 'imei', itemKey: 'index',
item: (row: Record<string, any>) => { item: (row: Record<string, any>) => {
const index = row['Index'] || 0;
return { return {
imei: `${row['IMEI']}`, imei: `${row['IMEI']}`,
index: 0, index: parseInt(index),
}; };
}, },
}, },
@@ -125,7 +128,7 @@ export default function useArrayImport({
importState.loading = true; importState.loading = true;
for (const row of rows) { for (const row of rows) {
const rowItem = importState.item(row); const rowItem = importState.item(row);
const rowKey = rowItem[importState.itemKey]; const rowKey = rowItem[importState.itemKey] || -1;
let result: any = null; let result: any = null;
// 检查index是否定义 // 检查index是否定义
const has = arrayState.columnsData.find( const has = arrayState.columnsData.find(