mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-11 11:56:46 +08:00
导入去重
This commit is contained in:
@@ -347,6 +347,23 @@ const closeModal = () => {
|
|||||||
state.importId = '',
|
state.importId = '',
|
||||||
state.AMvisible = false
|
state.AMvisible = false
|
||||||
|
|
||||||
|
}
|
||||||
|
// 根据数组id去重
|
||||||
|
const deduplicateArrayById = (arr) => {
|
||||||
|
// 使用 Set 数据结构保存不重复的 id
|
||||||
|
const idSet = new Set();
|
||||||
|
// 使用 map 方法遍历数组,检查并去重对象
|
||||||
|
const deduplicatedArray = arr.filter(obj => {
|
||||||
|
const id = obj.id;
|
||||||
|
if (!idSet.has(id)) {
|
||||||
|
idSet.add(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return deduplicatedArray;
|
||||||
|
|
||||||
}
|
}
|
||||||
//上传文件
|
//上传文件
|
||||||
const handleChange = (info) => {
|
const handleChange = (info) => {
|
||||||
@@ -389,9 +406,7 @@ const handleChange = (info) => {
|
|||||||
state.caseTitleList = caseList
|
state.caseTitleList = caseList
|
||||||
|
|
||||||
state.selectedRowKeys = [...new Set([...caseIdList, ...state.selectedRowKeys])]
|
state.selectedRowKeys = [...new Set([...caseIdList, ...state.selectedRowKeys])]
|
||||||
state.selectedRow = [...new Set([...state.selectedRow, ...caseList].map(t => JSON.stringify(t)))].map(s => JSON.parse(s))
|
state.selectedRow = deduplicateArrayById([...state.selectedRow, ...caseList]);
|
||||||
// state.selectedRow.push(...caseList)
|
|
||||||
// state.selectedRow = Array.from(new Set(state.selectedRow.map(JSON.stringify))).map(JSON.parse);
|
|
||||||
|
|
||||||
console.log(caseList, state.selectedRow);
|
console.log(caseList, state.selectedRow);
|
||||||
//发请求看失败的数据
|
//发请求看失败的数据
|
||||||
|
|||||||
Reference in New Issue
Block a user