<template>
  <!-- 仓单贸易 -->
  <section class="forward-section warehouse-trade">
    <firstMenu :list="list"
               :value="'value'"
               @selectMenu="selectMenu" />
    <quoteTable :columns="columns"
                :dataSource="data"
                :contextMenuList="contextMenuList" />
    <div class="warehouse-trade-order">
      单据
    </div>
  </section>
</template>

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

const columns = [
    { title: 'Full Name', width: 100, dataIndex: 'name', key: 'name', fixed: 'left', align: 'center' },
    { title: 'Age', width: 100, dataIndex: 'age', key: 'age', fixed: 'left', align: 'center' },
    { 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: '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: 'one' },
        { key: '2', value: 'two' },
        { key: '3', value: 'three' },
    ];
    function selectMenu(item: any) {
        console.log(item);
    }
    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,
        orderTable,
    },
    setup() {
        initData(() => {
            // 加载数据在这里
        });
        const { list, selectMenu } = handleMenu();
        const contextMenuList = ref<MenuItem[]>([
            {
                lable: '下单',
                callback: () => {
                    console.log('kkk');
                },
            },
        ]);
        return {
            data,
            columns,
            list,
            selectMenu,
            contextMenuList,
            orderCulums,
        };
    },
});
</script>

<style lang="less">
.warehouse-trade {
    // height: 100%;
    position: relative;
}
</style>;
