<template>
  <!-- 过滤 -->
  <div class="filterTable">
    <a-range-picker v-model:value="date"
                    class="commonPicker"
                    style="width: 200px"
                    :show-time="{hideDisabledOptions: true}"
                    format="YYYY-MM-DD" />
    <FilterOption :selectList="selectList"
                  :inputList="inputList"
                  :fixedBtnList="fixedBtnList" />
    <slot></slot>
  </div>
</template>

<script lang="ts">
import FilterOption from '@/common/components/filter/index.vue';
import { defineComponent, ref } from 'vue';
import { handleFilter, handleTimeFilter, InputList, SelectList } from '@/common/setup/filter';
import { Moment } from 'moment';
import { initData } from '@/common/methods';
import { getGoodsList } from '@/services/bus/goods';

export default defineComponent({
    name: 'filter-platinum_pick_query',
    components: { FilterOption },
    setup(props, context) {
        const date = ref<Moment[]>([]);
        const select = ref<SelectList[]>([
            {
                value: undefined,
                key: 'goodsid',
                placeholder: '选择商品',
                list: [],
            },
            {
                value: undefined,
                key: 'scfcontracttype',
                placeholder: '合同类型',
                list: [
                    { value: 1, lable: '仓单回购' },
                    { value: 2, lable: '仓单质押' },
                    { value: 3, lable: '合作套保' },
                    { value: 4, lable: '资金贷款' },
                    { value: 5, lable: '融资单' },
                ],
            },
        ]);
        const input: InputList[] = [{ value: '', placeholder: '模糊搜索账号', key: 'account' }];
        // 范围时间内过滤
        const { getFilterRangeTime } = handleTimeFilter('contractconfirmtime');

        const { selectList, inputList, fixedBtnList } = handleFilter(select, input, context, getFilterRangeTime(date));
        initData(() => {
            // 选择商品
            select.value[0].list = getGoodsList().map((e) => {
                return { value: e.goodsid, lable: e.goodsname };
            });
        });
        return {
            date,
            selectList,
            inputList,
            fixedBtnList,
        };
    },
});
</script>

<style lang="less">
.filterTable {
    .commonPicker.ant-calendar-picker {
        display: inline-flex;
        padding-top: 9px;
        padding-bottom: 6px;
        margin-right: 10px;
        .ant-input {
            border: 0;
            background: @m-grey9;
        }
    }
}
</style>;
