import { QueryHedgePlan } from '@/services/go/ermcp/plan';
import { Ermcp3HedgePlan } from '@/services/go/ermcp/plan/interface';
import { message } from 'ant-design-vue';
import { ref } from 'vue';

/**
 * 获取表格列表数据
 * @param type 
 * @returns 
 */
export function queryTableList(type: string) {
    // 加载状态
    const loading = ref<boolean>(false);
    // 表格数据
    const tableList = ref<Ermcp3HedgePlan[]>([]);
    function queryTable() {
        QueryHedgePlan(type)
            .then((res) => {
                tableList.value = res.map((e, i) => {
                    return { ...e, key: String(i) };
                });
                loading.value = false;
            })
            .catch((err) => {
                message.error(err);
                loading.value = false;
            });
    }
    return { loading, tableList, queryTable }
}
