
<template>
    <div class="detail-popup">
        <popup ref="popupRef" title="项目立项详情" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
            <el-form ref="formRef" :model="formData" label-width="auto">
                <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
                    <el-tab-pane label="概况" name="demo-1">
                        <Overview :formData="formData" v-if="activeName == 'demo-1'"></Overview>
                    </el-tab-pane>

                    <el-tab-pane label="商机" name="demo-2">
                        <Business v-if="activeName == 'demo-2'" :formData="formData" :project_id="project_id"></Business>
                    </el-tab-pane>

                    <el-tab-pane label="投标" name="demo-3">
                        <tender v-if="activeName == 'demo-3'" :project_id="project_id"></tender>
                    </el-tab-pane>

                    <el-tab-pane label="合同" name="demo-4">
                        <contract v-if="activeName == 'demo-4'" :project_id="project_id"></contract>
                    </el-tab-pane>

                    <el-tab-pane label="预算" name="demo-5">
                        <budget v-if="activeName == 'demo-5'" :project_id="project_id"></budget>
                    </el-tab-pane>

                    <el-tab-pane label="采购" name="demo-8">
                        <procurement v-if="activeName == 'demo-8'" :project_id="project_id"></procurement>
                    </el-tab-pane>

                    <el-tab-pane label="分包" name="demo-9">
                        <subcontract v-if="activeName == 'demo-9'" :project_id="project_id"></subcontract>
                    </el-tab-pane>

                    <el-tab-pane label="人力" name="demo-12">
                        <manpower v-if="activeName == 'demo-12'" :project_id="project_id"></manpower>
                    </el-tab-pane>

                    <el-tab-pane label="收款" name="demo-14">
                        <Collection v-if="activeName == 'demo-14'" :project_id="project_id"></Collection>
                    </el-tab-pane>

                    <el-tab-pane label="付款" name="demo-15">
                        <payment v-if="activeName == 'demo-15'" :project_id="project_id"></payment>
                    </el-tab-pane>

                    <el-tab-pane label="文档" name="demo-16">
                        <documentation v-if="activeName == 'demo-16'" :project_id="project_id"></documentation>
                    </el-tab-pane>

                </el-tabs>
            </el-form>
        </popup>
    </div>
</template>

<script lang="ts" setup name="customdetail">

import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiCustomDetail } from '@/api/custom'
import type { PropType } from 'vue'
import type { TabsPaneContext } from 'element-plus'
import Overview from "./components/Overview.vue"
import Business from "./components/Business.vue"
import tender from "./components/tender.vue"
import contract from "./components/contract.vue"
import budget from "./components/budget.vue"
import procurement from "./components/procurement.vue"
import subcontract from "./components/subcontract.vue"
import manpower from "./components/manpower.vue"
import Collection from "./components/Collection.vue"
import payment from "./components/payment.vue"
import documentation from "./components/documentation.vue"


const activeName = ref('demo-1')
const handleClick = (tab: TabsPaneContext, event: Event) => {
    // console.log(tab, event)
}
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()


// 表单数据
const formData = reactive({

})

const project_id = ref(0)


// 获取详情
const setFormData = async (data: Record<any, any>) => {
    project_id.value = data.id
    Object.assign(formData, data)
}

const getDetail = async (row: Record<string, any>) => {
    const data = await apiCustomDetail({
        id: formData.id
    })
    setFormData(data)
}


// 提交按钮
const handleSubmit = async () => {
    popupRef.value?.close()

}

//打开弹窗
const open = () => {
    popupRef.value?.open()
}

// 关闭回调
const handleClose = () => {
    emit('close')
}








defineExpose({
    open,
    setFormData,
    getDetail
})
</script>
<style lang="scss" scoped>
.tit {
    font-size: 1.2em;
    margin-bottom: 10px;
}

:deep(.my-label) {
    width: 150px;
}
</style>
