Files
dvcp_v2_webapp/ui/packages/layout/AiSearchBar.vue
aixianling 3585cceca8 refactor(ui): 优化搜索栏组件的样式和布局
-移除了 AiPullDown 组件的绝对定位样式
- 调整了 AiSearchBar 组件的网格布局和样式
- 优化了展开和收缩功能的实现方式
- 修复了一些潜在的样式冲突和显示问题
2024-12-30 10:29:07 +08:00

88 lines
1.6 KiB
Vue

<template>
<section class="AiSearchBar grid" :class="{bottomBorder,isSingleRow}">
<div class="left">
<div class="flex wrap gridZone">
<slot name="left"/>
</div>
</div>
<div class="right" v-if="$slots.right">
<slot name="right"/>
</div>
<ai-pull-down class="row" v-if="!isSingleRow" v-model="expand"/>
</section>
</template>
<script>
export default {
name: "AiSearchBar",
props: {
bottomBorder: Boolean,
},
computed: {
isSingleRow: v => v.height <= 45
},
data() {
return {
height: 0,
expand: false
}
},
watch: {
expand: {
handler(v) {
this.$el.querySelector(".left").style.height = v ? 'auto' : '33px'
}
}
},
mounted() {
this.height = this.$el.querySelector(".left .gridZone").getBoundingClientRect().height
// 卡浏览器渲染帧,为了避免flex布局溢出后只显示尾部元素,先用auto 高度,再延时一帧再设置为33px
setTimeout(() => {
this.$el.querySelector(".left").style.height = "33px"
},50)
},
}
</script>
<style lang="scss" scoped>
.AiSearchBar {
gap: 10px;
grid-template-columns: 1fr auto;
position: relative;
&.isSingleRow {
padding-bottom: 12px;
}
&.bottomBorder {
border-bottom: 1px solid #eee;
}
.left {
padding-top: 1px;
height: auto;
overflow: hidden;
.gridZone {
gap: 8px;
}
}
:deep(.right ) {
display: flex;
align-items: center;
flex-shrink: 0;
align-self: flex-start;
width: 280px;
.el-input {
width: 280px;
}
}
.el-input {
width: auto;
}
}
</style>