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