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

<script lang="ts">
import FilterOption from '@/common/components/filter/index.vue';
import { defineComponent } from 'vue';
import { handleFilter, InputList, SelectList } from '@/common/setup/filter';
import { ref } from 'vue';
import { queryTableList } from '@/common/setup/table/list';
import { initData } from '@/common/methods';
import { queryParentAreaList } from '@/services/go/ermcp/qhj';
import { QhjParentAreaList } from '@/services/go/ermcp/qhj/interface';

export default defineComponent({
    name: 'filter-custom-unsubmit',
    components: { FilterOption },
    setup(props, context) {
        const select = ref<SelectList[]>([
            {
                value: undefined,
                key: 'userinfotype',
                placeholder: '全部客户类型',
                list: [
                    { value: 1, lable: '个人' },
                    { value: 2, lable: '企业' },
                ],
            },
            {
                value: undefined,
                key: 'userid',
                placeholder: '请选择子机构',
                list: [],
            },
        ]);
        const input: InputList[] = [
            { value: '', placeholder: '模糊搜索客户简称', key: 'nickname' },
            { value: '', placeholder: '模糊搜索客户名称', key: 'name' },
            // { value: '', placeholder: '模糊搜索手机号码', key: 'phone' },
        ];
        // 是否包含子级 1-包含
        const includesub = ref<boolean>(false);
        const param = {
            search(result: any) {
                result.includesub = includesub.value ? 1 : 0;
            },
            reset() {
                includesub.value = false;
            },
        };
        const { selectList, inputList, fixedBtnList } = handleFilter(select, input, context, param);
        const { queryTable } = queryTableList<QhjParentAreaList>();
        initData(() => {
            queryTable(queryParentAreaList).then((res) => {
                select.value[1].list = res.map((e) => {
                    return { value: e.userid, lable: e.accountname };
                });
            });
        });

        return {
            selectList,
            includesub,
            inputList,
            fixedBtnList,
        };
    },
});
</script>

<style lang="less">
</style>;
