<!-- 联系我们列表 -->
<template>
    <div class="table-box">
        <div style="padding-bottom: 16px">
            <el-button type="primary" @click="handleExport"> 导出 </el-button>
        </div>

        <ProTable
            ref="proTableRef"
            :formData="dataStore.formData"
            :columns="dataStore.columns"
            :request-api="getBPListApi"
            :init-param="dataStore.initParam"
        >
        </ProTable>
    </div>
</template>

<script setup lang="ts" name="feedbackContactIndex">
import ProTable from "@/components/ProTable/index.vue";
import { useExport } from "@/hooks/useExport";
// import { useUserStore } from "@/stores/modules/user";
// const userStore: any = useUserStore();
//列表接口
import { getBPListExportApi, getBPListApi, getBPInterestedListApi } from "@/api/modules/purchase";
//深拷贝方法
import { cloneDeep } from "lodash-es";
//表格和搜索條件
import { RULE_FORM, FORM_DATA, COLUMNS } from "./constant/index";
// 获取 ProTable 元素，调用其获取刷新数据方法（还能获取到当前查询参数，方便导出携带参数）
const proTableRef = ref<any>(null);

// 数据源
const dataStore = reactive<any>({
    columns: COLUMNS, //列表配置项
    initParam: cloneDeep(RULE_FORM), // 初始化搜索条件|重置搜索条件
    ruleForm: cloneDeep(RULE_FORM), // 搜索參數
    formData: FORM_DATA //搜索配置项
});
const handleExport = () => {
    getBPListExport();
};
//导出
const getBPListExport = async () => {
    const result = await getBPListExportApi({
        ...proTableRef?.value?.searchParam,
        ...proTableRef?.value?.pageable
    });
    await useExport(result);
};
//
const getBPInterestedList = async () => {
    const result = await getBPInterestedListApi();
    if (result?.code === 0) {
        let arr: any = [];
        result?.data.forEach((item: any) => {
            arr.push({
                label: item,
                value: item
            });
        });
        dataStore.formData[1].options = arr;
    }
};
getBPInterestedList();
// watch(
//     () => userStore.languageType,
//     (newVal: any) => {
//         console.log(newVal);

//         getBPInterestedList();
//     },
//     { deep: true, immediate: true }
// );
</script>

<style scoped></style>
