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

This commit is contained in:
TsMask
2025-07-21 17:12:19 +08:00
parent d37fd4deae
commit f8bc9fc622
4 changed files with 10 additions and 7 deletions

View File

@@ -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(