<template>
    <!-- 仓单贸易 -->
    <section class="forward-section warehouse-trade">
        <div class="conditionIcon icon iconfont icon-saixuantiaojiantubiao"></div>
        <!-- 这里需要加上二级菜单 二级菜单封装在公告组件里面 secondeMenu -->
        <firstMenu :list="list" :value="'value'" @selectMenu="selectMenu" />

        <quoteTable :columns="columns" :dataSource="data" :contextMenuList="contextMenuList" />
        <thirdMenu></thirdMenu>
    </section>
</template>

<script lang="ts">
import { defineComponent, computed, reactive, ref, toRefs, unref, onMounted, onUpdated, onUnmounted, provide, inject } from 'vue';
import { initData } from '@/common/methods';
import firstMenu from '@/common/components/firstMenu/index.vue';
import thirdMenu from '@/common/components/thirdMenu/index.vue';
import quoteTable from '@/common/components/quoteTable/index.vue';
import { MenuItem } from '@/common/components/contextMenu/interface';

const columns = [
    { title: '序号', width: 100, dataIndex: 'name', key: 'name', fixed: 'left', align: 'center' },
    { title: '品种', width: 100, dataIndex: 'age', key: 'age', fixed: 'left', align: 'center' },
    { title: '种类', dataIndex: 'address', key: '1', width: 200, align: 'center' },
    { title: '品牌', dataIndex: 'address', key: '2', width: 200, align: 'center' },
    { title: '数量', dataIndex: 'address', key: '3', width: 200, align: 'center' },
    { title: '价格', dataIndex: 'address', key: '4', width: 200, align: 'center' },
    { title: '仓库', dataIndex: 'address', key: '5', width: 200, align: 'center' },
    { title: '所在地', dataIndex: 'address', key: '6', width: 200, align: 'center' },
    { title: '挂牌方', dataIndex: 'address', key: '7', width: 'auto', align: 'center' },
    // {
    //     title: 'Action',
    //     key: 'operation',
    //     fixed: 'right',
    //     align: 'center',
    //     width: 100,
    //     slots: { customRender: 'action' },
    // },
];

interface DataItem {
    key: number;
    name: string;
    age: number;
    address: string;
}

const data: DataItem[] = [];
for (let i = 0; i < 100; i++) {
    data.push({
        key: i,
        name: `Edrward ${i}`,
        age: 32,
        address: `London Park no. ${i}`,
    });
}

function handleMenu() {
    const list = [
        { key: '1', value: '仓单贸易' },
        { key: '2', value: '拍卖' },
    ];
    function selectMenu(item: any) {}
    return { list, selectMenu };
}

const orderCulums = [
    { title: 'Column 1', dataIndex: 'address', key: '1', width: 156, align: 'center' },
    { title: 'Column 2', dataIndex: 'address', key: '2', width: 156, align: 'center' },
    { title: 'Column 3', dataIndex: 'address', key: '3', width: 156, align: 'center' },
    { title: 'Column 4', dataIndex: 'address', key: '4', width: 200, align: 'center' },
    { title: 'Column 5', dataIndex: 'address', key: '5', width: 200, align: 'center' },
    { title: 'Column 6', dataIndex: 'address', key: '6', width: 200, align: 'center' },
    { title: 'Column 7', dataIndex: 'address', key: '7', width: 200, align: 'center' },
    { title: 'Column 8', dataIndex: 'address', key: '8', width: 200, align: 'center' },
    { title: 'Column 8', dataIndex: 'address', key: '9', width: 200, align: 'center' },
    { title: 'Column 8', dataIndex: 'address', key: '10', width: 200, align: 'center' },
    { title: 'Column 8', dataIndex: 'address', key: '11', width: 200, align: 'center' },
    { title: 'Column 8', dataIndex: 'address', key: '12', width: 200, align: 'center' },
    { title: 'Column 8', dataIndex: 'address', key: '13', width: 200, align: 'center' },
    { title: 'Column 9', dataIndex: 'address', key: '14', width: 200, align: 'center' },
    { title: 'Column 9', dataIndex: 'address', key: '15', width: 200, align: 'center' },
    { title: 'Column 10', dataIndex: 'address', key: '16', width: 200, align: 'center' },
];

export default defineComponent({
    name: 'forward',
    components: {
        firstMenu,
        quoteTable,
        thirdMenu,
    },
    setup() {
        initData(() => {
            // 加载数据在这里
        });
        const { list, selectMenu } = handleMenu();
        const contextMenuList = ref<MenuItem[]>([
            {
                lable: '下单',
                callback: () => {},
            },
        ]);
        return {
            data,
            columns,
            list,
            selectMenu,
            contextMenuList,
            orderCulums,
        };
    },
});
</script>

<style lang="less">
.warehouse-trade {
    height: 100%;
    height: 100%;
    .flex;
    flex-direction: column;
    position: relative;
    .conditionIcon {
        font-size: 18px;
        color: @m-blue0;
        width: 18px;
        height: 18px;
        line-height: 18px;
        cursor: pointer;
        .position(absolute, 8px, 14px, auto, auto);
        &:hover {
            color: @m-blue0-hover;
        }
    }
    .topBar {
        flex: 1;
    }
    .warehouse-trade-order {
        height: 330px;
    }
}
</style
>;
