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