<template>
    <el-card class="box-card" shadow="never">
        <template #header v-if="header">
            <div class="card-header">
                <span class="text-bold">申领列表</span>
                <span class="text-bold">
                    ({{ total }})
                </span>
            </div>
        </template>
        <Index />
        <div class="flex justify-end margin-top" v-if="total > 0">
            <el-button plain @click="clearWarehouseApplyDetails" >清 空</el-button>
            <el-button :disabled="total == 0" type="primary" @click="submit">提 交</el-button>
        </div>
    </el-card>
</template>

<script setup>
import { clearWarehouseApplyDetails } from "@/utils/warehouseApplyDetails";
import Index from "@/components/WarehouseApplyDetails/index";
const store = useStore();
const { ctx } = getCurrentInstance();
const emit = defineEmits(["submit"]);

const props = defineProps({
    header: {
        type: Boolean,
        dafault: true,
    }
});


const total = computed(() => {
    let total = 0;
    Object.values(store.state.data.warehouseApplyDetails).map((item) => {
        total += item.warehouseApplyQuantity;
    });
    return total;
});

function submit() {
    emit("submit", store.state.data.warehouseApplyDetails)
    // ctx.$emit("submit", store.state.data.warehouseApplyDetails);
}

</script>