chat-app/src/components/custom-input/custom-input.vue

86 lines
1.7 KiB
Vue
Raw Normal View History

<template>
2025-03-10 01:57:21 +00:00
<div class="custom-input">
<tm-input
class="search-input"
placeholder="请输入…"
color="#F9F9FD"
:round="1"
prefix="tmicon-search"
prefixColor="#46299D"
:prefixLabel="props?.first_talk_record_infos?.receiver_name"
v-model.lazy="state.searchText"
@input="inputSearchText"
:showClear="true"
@clear="clearInput"
placeholderStyle="color:#BABABA"
2025-03-10 01:57:21 +00:00
:disabled="props?.disabled"
></tm-input>
2025-03-10 01:57:21 +00:00
<div v-if="props?.disabled" class="custom-input-disabled"></div>
</div>
</template>
<script setup>
import { defineProps, defineEmits, reactive, watch } from 'vue'
const props = defineProps({
searchText: {
type: String,
default: ''
},
first_talk_record_infos: {
type: Object,
default(){
return {}
}
},
disabled: {
type: Boolean,
default: false
},
})
const state = reactive({
searchText: '', //搜索内容
})
const emits = defineEmits(['inputSearchText'])
watch(
() => props.searchText,
(newSearchText) => {
state.searchText = newSearchText
},
)
//清除输入的搜索内容
const clearInput = () => {
inputSearchText('')
}
//输入搜索文本
const inputSearchText = (e) => {
emits('inputSearchText', e)
}
</script>
<style scoped lang="scss">
2025-03-10 01:57:21 +00:00
.custom-input {
width: 100%;
2025-03-10 01:57:21 +00:00
position: relative;
.search-input {
width: 100%;
}
::v-deep .noNvueBorder > .noNvueBorder > .noNvueBorder {
2025-03-10 01:57:21 +00:00
background: #f9f9fd !important;
border-radius: 8rpx !important;
2025-03-10 01:57:21 +00:00
}
.search-input::v-deep .tmicon-times-circle-fill::before {
content: '\e82a';
color: #d2d2d5;
}
2025-03-10 01:57:21 +00:00
.custom-input-disabled {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
}
</style>