mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-12 16:00:33 +00:00
50 lines
1.1 KiB
Vue
50 lines
1.1 KiB
Vue
<template>
|
|
<div>
|
|
<div class="search-button">
|
|
<el-input
|
|
clearable
|
|
v-model="searchInfo"
|
|
@clear="search()"
|
|
suffix-icon="Search"
|
|
@change="search()"
|
|
:disabled="props.disabled"
|
|
:placeholder="props.placeholder || $t('commons.button.search')"
|
|
></el-input>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, watch } from 'vue';
|
|
defineOptions({ name: 'TableSearch' });
|
|
|
|
const emit = defineEmits(['search', 'update:searchName']);
|
|
const searchInfo = ref();
|
|
const props = defineProps({
|
|
placeholder: String,
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
searchName: {
|
|
type: [String, Number],
|
|
default: undefined,
|
|
},
|
|
});
|
|
|
|
watch(
|
|
() => props.searchName,
|
|
(newVal) => {
|
|
if (searchInfo.value !== newVal) {
|
|
searchInfo.value = newVal;
|
|
}
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
|
|
const search = () => {
|
|
emit('update:searchName', searchInfo.value);
|
|
emit('search');
|
|
};
|
|
</script>
|