duy 1 anno fa
parent
commit
ae5b551642

+ 8 - 7
src/views/transfer/components/table-collect.vue

@@ -25,18 +25,15 @@
         <div v-loading="totalLoaing" class="h-screen">
             <div v-for="(item) in totalData" :key="item.unitInfo">
                 <div class="hc-card-table-title">{{ item.unitInfo }}</div>
-                <template v-for="(item1) in item.nodeLists" :key="item1.nodeInfo">
+                <template v-for="(item1, index1) in item.nodeLists" :key="item1.nodeInfo">
                     <HcCardItem v-if="item1.list && item1.list.length > 0" ui="h-half">
                         <template #header>
-                            <span>{{ item1.nodeInfo }}</span>
+                            <el-checkbox v-model="item1.checkedval" label="全选" size="large" @change="clickAll($event, index1)" /> 
+                            <span class="ml-1">{{ item1.nodeInfo }}</span>
+                           
                             <!-- <span class="text-gray">(238卷)</span> -->
                         </template>
                         <div :style="`height: ${item1.list !== null && item1.list.length > 9 ? '300px' : 'auto'};`">
-                            <!-- <HcTable
-                                ref="tableRef" :column="tableColumn" :datas="item1.list" :loading="tableLoading"
-                                is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
-                                @selection-change="tableSelection"
-                            /> -->
                             <visualTable ref="visuatable" :table-data="item1.list " @getTableKeys="getTableKeys" />
                         </div>
                     </HcCardItem>
@@ -153,6 +150,10 @@ const tableKeys = ref([])
 const getTableKeys = (val)=>{
     tableKeys.value = val
 }
+
+const clickAll = (val, index)=>{
+    visuatable.value[index].tableSelectAll(val)
+}
 const reportIds = ref('')
 const reportTaskName = ref('')
 const reportDatas = ref([])

+ 19 - 4
src/views/transfer/components/visual-table.vue

@@ -4,12 +4,12 @@
         ref="tableRef"
         :column="tableColumn" :datas="tableData" :loading="tableLoaing"
         is-new :index-style="{ width: 60 }" :is-check="isCheck" :check-style="{ width: 29 }"
-        @selection-change="tableSelection" @select-all="tableSelectAll"
+        @selection-change="tableSelection"
     />
 </template>
 
 <script setup>
-import { onMounted, onUnmounted, ref, watch } from 'vue'
+import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
 const props = defineProps({
     tableData: {
         type: Array,
@@ -33,12 +33,23 @@ const tableSelection = (rows) => {
     tableKeys.value = rows
     emit('getTableKeys', rows)
 }
-const tableSelectAll = (rows)=>{
-  if (rows.length > 0) {
+const tableSelectAll = (val)=>{
+  if (val) {
+      allData.value.forEach((ele1)=>{
+        nextTick(()=>{
+          tableRef.value.toggleRowSelection( ele1, true )
+        })
+      })
+
     tableKeys.value = allData.value 
     emit('getTableKeys', allData.value )
+  } else {
+    tableRef.value.clearSelection()
+    tableKeys.value = []
+    emit('getTableKeys', tableKeys.value )
   }
   
+  
 }
 //表头
 const tableRef = ref(null)
@@ -109,6 +120,10 @@ const scrollBehavior = async (e)=>{
         }
       }
 }
+// 暴露出去
+defineExpose({
+  tableSelectAll,
+})
 </script>
 
 <style lang='scss' scoped>