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 }
}

// 平安 仓库信息 表头
export function pingan_cwarehousecolumn() {
    return [
        {
            key: '9th',
            dataIndex: 'index',
            title: '序号',
            align: 'center',
            slots: {
                customRender: 'index',
            },
            width: 80
        },
        {
            key: '0th',
            dataIndex: 'warehousestatus',
            title: '状态',
            align: 'center',
            slots: {
                customRender: 'warehousestatus',
            },
            width: 120,
        },
        {
            key: '1th',
            dataIndex: 'warehousecode',
            title: '仓库简称',
            align: 'center',
            slots: {
                customRender: 'warehousecode',
            },
            width: 120,
        },
        {
            key: '2th',
            dataIndex: 'warehousetype',
            title: '仓库类型',
            align: 'center',
            slots: {
                customRender: 'warehousetype',
            },
            width: 120,
        },
        {
            key: '3th',
            dataIndex: 'warehousename',
            title: '仓库名称',
            align: 'center',
            slots: {
                customRender: 'warehousename',
            },
            width: 120,
        },
    ];
}