Jelajahi Sumber

添加场景去重

tangning 1 hari lalu
induk
melakukan
8c8de586df
1 mengubah file dengan 2 tambahan dan 27 penghapusan
  1. 2 27
      src/layout/edit/scene-select.vue

+ 2 - 27
src/layout/edit/scene-select.vue

@@ -178,6 +178,7 @@ const rowSelection: any = ref({
 
   hideSelectAll: true,
   onChange: (ids: string[]) => {
+  console.log('ids', ids)
     const key =  typeFilterScenes.value[type.value].map((item: any) => item.num).join('')
     ids = ids.filter(id => !selectIds.value.includes(id))
     if (!cache[type.value]) {
@@ -194,39 +195,13 @@ const rowSelection: any = ref({
         curIds.push(...cache[keyp][key])
       }
     }
-    selects.value =  deduplicateBySuffix(curIds) || []
+    selects.value =  [...new Set(curIds)] || []//去重
 
   },
   getCheckboxProps: (record: Scene) => ({
     disabled: selectIds.value.includes(record.num),
   }),
 });
-/**
- * 根据字符串中----ll----之后的部分进行去重,保留第一次出现的元素
- * @param {string[]} strList - 待去重的字符串列表
- * @returns {string[]} 去重后的字符串列表
- */
-function deduplicateBySuffix(strList: string[]) {
-    // 用对象记录已出现的后缀(key:后缀,value:完整字符串)
-    const seenSuffix = {};
-    
-    // 遍历列表中的每个字符串
-    strList.forEach(str => {
-        // 分割字符串,获取----ll----之后的部分
-        const parts = str.split('----ll----');
-        // 确保分割后有后缀部分
-        if (parts.length >= 2) {
-            const suffix:string = parts[1];
-            // 仅当后缀未出现过时,才记录
-            if (!seenSuffix[suffix]) {
-                seenSuffix[suffix] = str;
-            }
-        }
-    });
-    
-    // 提取对象的value,转为数组返回
-    return Object.values(seenSuffix);
-}
 const cloumns = [
   {
     width: "400px",