<template>
  <div class="tilt-photo-management-search">
    <BasicSearch
      ref="basicSearchRef"
      :searchList="searchList"
      :initial-values="initSearchData"
      @reset="handleReset"
      @finish="onSearchFinish"
      @values-change="onValuesChange"
    >
      <template #actions>
        <a-tooltip title="新增倾斜摄影">
          <a-button @click="props.handleAdd" type="primary">
            新增倾斜摄影
          </a-button>
        </a-tooltip>
      </template>
    </BasicSearch>
  </div>
</template>

<script lang="ts" setup>
import { ref, computed, onMounted } from 'vue';
import BasicSearch from '@/components/BasicSearch/index.vue';

interface Props {
  handleAdd: () => void;
}

const props = defineProps<Props>();

const emit = defineEmits<{
  (e: 'reset', values: any): void;
  (e: 'searchFinish', values: any): void;
}>();

const initSearchData = {
  projectName: ''
};

const searchData = ref<any>({ ...initSearchData });
const searchList: any = computed(() => [
  {
    type: 'Input',
    name: 'projectName',
    label: '项目名称',
    fieldProps: {
      allowClear: true
    }
  }
]);

const onSearchFinish = (values: any) => {
  emit('searchFinish', values);
};

const onValuesChange = (changedValues: any, allValues: any) => {
  searchData.value = { ...searchData.value, ...allValues };
};

const handleReset = () => {
  emit('reset', initSearchData);
};

onMounted(() => {
  emit('searchFinish', initSearchData);
});
</script>
<style lang="scss"></style>
