
<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">
                    <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'" :project="formData"></Business>
                    </el-tab-pane>

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

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

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

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

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

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

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

                    <el-tab-pane label="付款" name="demo-15">
                        <payment v-if="activeName == 'demo-15'" :project="formData"></payment>
                    </el-tab-pane>
                    <el-tab-pane label="文档" name="demo-16">
                        <documentation v-if="activeName == 'demo-16'" :project="formData"></documentation>
                    </el-tab-pane>

                    <el-tab-pane label="统计" name="demo-17">
                        <Statistics v-if="activeName == 'demo-17'" :project_id="project_id"></Statistics>
                    </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 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"
import Statistics from "./components/Statistics.vue"

const activeName = ref('demo-1')

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>
