iot-ui-vue/src/components/Search/Search.vue

77 lines
1.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<j-search
:target='target'
:columns='processedColumns'
:class='props.class'
style='padding-top: 18px; padding-bottom: 18px;'
@search='searchSubmit'
/>
</template>
<script setup lang='ts' name='ProSearch'>
import { PropType } from 'vue'
import { JColumnsProps } from 'components/Table/types'
import { saveSearchHistory, getSearchHistory, deleteSearchHistory } from '@/api/comm'
interface Emit {
(e: 'search', data: any): void
}
const props = defineProps({
columns: {
type: Array as PropType<JColumnsProps[]>,
default: () => [],
required: true
},
type: {
type: String,
default: 'terms'
},
target: {
type: String,
default: '',
required: true
},
class: {
type: String,
default: ''
}
})
const emit = defineEmits<Emit>()
// 处理列配置为每个带有search的列自动添加defaultValue如果没有的话
const processedColumns = computed(() => {
return props.columns.map(column => {
// 如果列有search配置但没有defaultValue则添加一个空的defaultValue
if (column.search && !column.search.hasOwnProperty('defaultValue')) {
return {
...column,
search: {
...column.search,
defaultValue: null
}
}
}
return column
})
})
/**
* 提交
*/
const searchSubmit = (data: any) => {
console.log("搜索--------",data)
data = {
terms:[{
terms:data
}]
}
emit('search', data)
}
</script>
<style scoped lang='less'>
</style>