duy 1 рік тому
батько
коміт
345c82fcdd

+ 16 - 0
src/views/debit-pay/admin/components/middlepay/addModal.vue

@@ -157,6 +157,7 @@ import { getHeader } from 'hc-vue3-ui'
 import unitApi from '~api/project/debit/contract/unit'
 import mainApi from '~api/debit-pay/admin/middlepay'
 
+
 const props = defineProps({
     projectId: {
         type: [String, Number],
@@ -665,6 +666,20 @@ const closeQual = ()=>{
 }
 const finishModal = (rows)=>{
     console.log(rows, 'rows')
+    
+    // 使用reduce方法进行去重
+    const uniqueArray = rows.reduce((acc, current) => {
+    // 检查当前对象的某个字段是否已存在于累积数组中
+    const x = acc.find(item => item.selectId === current.selectId)
+    
+    // 如果不存在,则将其添加到累积数组中
+    if (!x) {
+        return acc.concat([current])
+    } else {
+        return acc
+    }
+    }, [])
+    rows = uniqueArray
     let fileList = []
     rows.forEach(ele => {
         const isPush = isArrIndex( baseForm.value.fileList, 'selectId', ele.selectId)
@@ -694,5 +709,6 @@ if (rows.length < baseForm.value.fileList.length) {
 }
 
    selectId.value = arrToKey( baseForm.value.fileList, 'selectId', ',')
+
 }
 </script>