<template>

    <ele-pro-table :columns="columns" :datasource="List" cache-key="tgDetails" height="calc(100vh - 350px)"
        :need-page="false" :cache-key="`${activeName}produceOrderTable`" :selection.sync="selection">

        <template v-slot:categoryCode="{ row }">
            {{ row.orderInfoList[0].code }}
        </template>

        <template v-slot:workCode="{ row }">
            {{ row.orderInfoList[0].bomDetailDTOS[0].categoryCode }}
        </template>

        <template v-slot:categoryName="{ row }">
            {{ row.orderInfoList[0].bomDetailDTOS[0].categoryName }}
        </template>

        <template v-slot:status="{ row }">
            {{ ['未领料', '领料中', '已出库', '已驳回'][row.status]}}
        </template>
        
        <template v-slot:demandQuantity="{ row }">
            {{ row.orderInfoList[0].bomDetailDTOS[0].demandQuantity }}
        </template>
        

        <template v-slot:packingCount="{ row }">
            {{ row.orderInfoList[0].bomDetailDTOS[0].warehouseName  }}(审核人:{{ row.orderInfoList[0].bomDetailDTOS[0].warehouseLeaderName }} )
        </template>


    </ele-pro-table>

</template>

<script>

import { pickorderList } from '@/api/workOrderList'

export default {


    computed: {
        clientEnvironmentId() {
            return this.$store.state.user.info.clientEnvironmentId;
        },
    },
    data() {
        return {
            visible: false,
            List: [],
            selection: [],
            row: {},
        };
    },
    created() {
        this.workorderList();
    },
    computed: {

        clientEnvironmentId() {
            return this.$store.state.user.info.clientEnvironmentId;
        },
        columns() {
            return [

                {
                    label: '序号',
                    type: 'index',
                    width: 55,
                    align: 'center'
                },
                {
                    label: '领料单号',
                    prop: 'code',
                    width: 150,
                },
                {
                    label: '领料状态',
                    prop: 'status',
                    slot: 'status',
                },

                {
                    label: '工单编号',
                    slot: 'workCode',
                    prop: 'workCode'
                },

                {
                    label: '编码',
                    prop: 'categoryCode',
                    slot: 'categoryCode',
                },
                {
                    label: '名称',
                    prop: 'categoryName',
                    slot: 'categoryName',
                },

                {
                    label: '数量',
                    prop: 'demandQuantity',
                    slot: 'demandQuantity',
                },

                {
                    label: '领料仓库',
                    prop: 'packingCount',
                    slot: 'packingCount',
                    width: 240,
                },

                {
                    label: '库存可用量',
                    prop: 'packingUnit',
                    show: this.clientEnvironmentId == 21
                },

            ]
        },

    },
    props: {
        routeObj: {
            type: Object,
            default: () => { }
        },
        activeName: {
            type: String,
            default: ''
        }

    },
    methods: {


        // 获取领料列表

        workorderList() {

            pickorderList([this.routeObj.id]).then((res) => {
                console.log(res, '99999');
                this.List = res.data;
                console.log(res);
            });
        },

    }
};
</script>