import { QueryWareHouse } from '@/services/go/ermcp/warehouse-info/index';
import { ErmcpWareHouseInfo } from '@/services/go/ermcp/warehouse-info/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<ErmcpWareHouseInfo[]>([]);
    function queryTable() {
        QueryWareHouse(type)
            .then((res) => {
                tableList.value = res.map((e, i) => {
                    return { ...e, key: String(i) };
                });
                loading.value = false;
                console.log('查询列表', tableList);
            })
            .catch((err) => {
                message.error(err);
                loading.value = false;
            });
    }
    return { loading, tableList, queryTable }
}


