一些issue修复
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="TableSetting">
|
||||
<d-button @click.stop="toggleColumnList" class="output-btn" icon="icon-form-settings" variant="text">设置</d-button>
|
||||
<!-- 多选列表 -->
|
||||
<div v-if="showColumnList" class="column-list">
|
||||
<div v-if="showColumnList" ref="columnListRef" class="column-list">
|
||||
<div class="column-list-header">
|
||||
<span class="title1">展示列设置</span>
|
||||
<a class="title2">恢复默认</a>
|
||||
@@ -20,7 +20,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, defineProps, defineEmits } from 'vue';
|
||||
import { ref, defineProps, defineEmits,onMounted,onUnmounted } from 'vue';
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
@@ -42,6 +42,29 @@ const toggleColumnList = () => {
|
||||
const newValue = !props.showColumnList;
|
||||
emits('update:show-column-list', newValue); // 触发事件,更新父组件的 showColumnList
|
||||
};
|
||||
|
||||
// 关闭多选列表
|
||||
const closeColumnList = () => {
|
||||
emits('update:show-column-list', false);
|
||||
};
|
||||
|
||||
// 监听点击事件
|
||||
const columnListRef = ref<HTMLElement | null>(null);
|
||||
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
if (columnListRef.value && !columnListRef.value.contains(event.target as Node)) {
|
||||
closeColumnList();
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('click', handleClickOutside);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('click', handleClickOutside);
|
||||
});
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.TableSetting {
|
||||
|
||||
Reference in New Issue
Block a user