<template>
    <!-- 结算申请-->
    <div class="app-container">
        <PageHeader
            v-if="isShowComponent !== 'ApplyHome'"
            :pageContent="pageContent"
            @goBack="goBack"
        />
        <keep-alive include="ApplyHome">
            <component
                ref="componentRef"
                :is="isShowComponent"
                :row="rowData"
                @goDetail="goDetail"
                @goBackPage="goBack"
                @isReset="isReset"
            />
        </keep-alive>
    </div>
</template>

<script>
import PageHeader from '@/components/pageHeader'
import ApplyHome from './component/applyHome.vue'
import ApplyDetail from './component/applyDetail.vue'
export default {
    name: 'CostApplyList',
    components: {
        PageHeader,
        ApplyHome,
        ApplyDetail
    },
    data() {
        return {
            isShowComponent: 'ApplyHome',
            pageContent: '',
            rowData: null,
            isView: false,
        }
    },
    methods: {
        // 退料编辑
        goDetail(rowData) {
            console.log('🎯 父组件接收到 goDetail 事件，数据:', rowData);
            this.rowData = rowData;
            this.pageContent = '结算详情';
            this.isShowComponent = 'ApplyDetail';
            console.log('🎯 组件已切换到 ApplyDetail');
        },
        goBack() {
            this.isShowComponent = 'ApplyHome'
        },
        isReset() {
            this.isShowComponent = "ApplyHome"
            this.$nextTick(() => {
                this.$refs.componentRef.getList()
            })
        }
    },
}
</script>
