<template>
  <!-- 过滤客户资料表格 -->
  <div class="filterTable">
    <FilterOption :selectList="selectList" :inputList="inputList" :buttonList="buttonList" />
    <slot></slot>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { useRoute } from 'vue-router';
import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
import { useFilter } from '@/common/components/filter/setup';
import FilterOption from '@/common/components/filter/index.vue';

export default defineComponent({
  components: {
    FilterOption
  },
  setup(props, context) {
    const { name: routeName } = useRoute();
    const { selectList, inputList, buttonList, search } = useFilter<Ermcp3ContractRsp>(context);

    selectList.value = [
      {
        key: 'pricetype',
        selectedValue: 0,
        options: [
          { label: '全部定价类型', value: 0 },
          { label: '一口价', value: 1 },
          { label: '点价', value: 2 },
          { label: '暂定价', value: 3 }
        ],
        onChange: search
      },
    ]

    if (routeName === 'contract_checkpending' || routeName === 'contract_performance') {
      selectList.value.unshift(
        {
          key: 'contracttype',
          selectedValue: 0,
          options: [
            { label: '全部合同类型', value: 0 },
            { label: '采购', value: 1 },
            { label: '销售', value: -1 }
          ],
          onChange: search
        }
      )
    }

    inputList.value = [
      { keys: ['contractno'], value: '', placeholder: '模糊搜索合同编号' },
      { keys: ['sellnickname', 'buynickname'], alias: 'negative', value: '', placeholder: '模糊搜索对手方' },
    ]

    return {
      selectList,
      inputList,
      buttonList,
    }
  }
})
</script>