<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 { queryPickGoods } from '@/services/go/ermcp/qhj';

export default defineComponent({
    name: 'filter-platinum_pick_query',
    components: { FilterOption },
    setup(props, context) {
        const date = ref<Moment[]>([]);
        const select = ref<SelectList[]>([
            {
                value: undefined,
                key: 'pickupgoodsname',
                placeholder: '选择提货商品',
                list: [],
            },
            {
                value: undefined,
                key: 'takeorderstatus',
                placeholder: '选择提货状态',
                list: [
                    { value: 1, lable: '备货中' },
                    { value: 2, lable: '待取货' },
                    { value: 3, lable: '已取货' },
                    { value: 4, lable: '待收货' },
                    { value: 5, lable: '已收货' },
                    { value: 6, lable: '自动收货' },
                    { value: 7, lable: '已拒绝 ' },
                    { value: 8, lable: '已撤销 ' },
                ],
            },
        ]);
        const input: InputList[] = [{ value: '', placeholder: '模糊搜索商品名称', key: 'goodsname' }];
        // 范围时间内过滤
        const { getFilterRangeTime } = handleTimeFilter('reqtime');

        const { selectList, inputList, fixedBtnList } = handleFilter(select, input, context, getFilterRangeTime(date));
        initData(() => {
            queryPickGoods('1').then((res) => {
                console.log('范围时间内过滤', res);

                select.value[0].list = res.map((e) => {
                    return { value: e.pickupgoodsid, lable: e.pickupgoodsname };
                });
            });
        });
        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>;
