<template>
    <div class="app-container">
        <el-dialog :title="title" :visible.sync="dialogVisible" width="70%" :before-close="handleClose">
            <!-- 公告信息 -->
            <div class="detail-section">
                <h3 class="section-title">公告信息</h3>
                <el-form :model="formData" label-width="130px" size="small" class="detail-form">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="公告标题">
                                {{ formData.announcementTitle || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="公告类型">
                                {{ formData.announcementType || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="发布时间">
                                {{ formData.publishTime ? new Date(formData.publishTime).toLocaleString() : '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="信息匹配词">
                                {{ formData.matchKeywords || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="是否相关">
                                <span class="bool-value"
                                    :class="{ true: formData.isRelevant === 1, false: formData.isRelevant === 0, 'duplicate': formData.isRelevant === 2 }">
                                    {{ formData.isRelevant === 1 ? '是' : formData.isRelevant === 0 ? '否' :formData.isRelevant === 2 ? '重复': '-' }}
                                </span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="数据来源">
                                {{ formData.dataSource || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="公告地址">
                                <a v-if="formData.announcementUrl" :href="formData.announcementUrl" target="_blank"
                                    class="link-text">{{ formData.announcementUrl }}</a>
                                <span v-else>-</span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="购买标书截止时间">
                                {{ formData.bidDocumentDeadline ? new
                                    Date(formData.bidDocumentDeadline).toLocaleString() : '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                   

                </el-form>
            </div>

            <!-- 采购信息 -->
            <div class="detail-section">
                <h3 class="section-title">采购信息</h3>
                <el-form :model="formData" label-width="130px" size="small" class="detail-form">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="采购单位">
                                {{ formData.purchaseUnit || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="最终使用客户">
                                {{ formData.finalUser || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="客户群">
                                {{ formData.customerGroup || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="预算（万元）">
                                {{ formData.budget || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="对应自然客户ID">
                                {{ formData.fmNaturalCustomerId || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="行业">
                                {{ formData.industry || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="业务类型">
                                {{ formData.businessCategory || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="业务需求">
                                {{ formData.businessDemand || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="招标信息发布时间">
                                {{ formData.tenderInfoPublishTime ? new
                                    Date(formData.tenderInfoPublishTime).toLocaleString() : '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="开标日期">
                                {{ formData.bidOpeningDate ? new Date(formData.bidOpeningDate).toLocaleString() : '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>

                </el-form>
            </div>

            <!-- 项目信息 -->
            <div class="detail-section">
                <h3 class="section-title">项目信息</h3>
                <el-form :model="formData" label-width="130px" size="small" class="detail-form">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="项目编号">
                                {{ formData.projectCode || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="项目名称">
                                {{ formData.projectName || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="招标代理">
                                {{ formData.tenderAgent || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="招标代理联系电话">
                                {{ formData.tenderAgentPhone || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>


                </el-form>
            </div>

            <!-- 扩展信息 -->
            <div class="detail-section">
                <h3 class="section-title">扩展信息</h3>
                <el-form :model="formData" label-width="130px" size="small" class="detail-form">
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="分公司">
                                {{ formData.branchCompany || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="分类">
                                {{ formData.category || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="商机编号">
                                {{ formData.opportunityCode || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="是否知晓">
                                <span class="bool-value"
                                    :class="{ true: formData.isAware === 1, false: formData.isAware === 0 }">
                                    {{ formData.isAware === 1 ? '是' : formData.isAware === 0 ? '否' : '-' }}
                                </span>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="是否参与">
                                <span class="bool-value"
                                    :class="{ true: formData.isParticipate === 1, false: formData.isParticipate === 0 }">
                                    {{ formData.isParticipate === 1 ? '是' : formData.isParticipate === 0 ? '否' : '-' }}
                                </span>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="不参与原因">
                                {{ formData.notParticipateReason || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="红黄绿牌">
                               {{formData.rbgLabel||'-'}}
                            </el-form-item>
                        </el-col>
                          <el-col :span="12">
                            <el-form-item label="弃标审批单号">
                                {{ formData.discardApprovalNumber || '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="商机ID">
                                {{ formData.opportunityId || '-' }}
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="创建时间">
                                {{ formData.createTime ? new Date(formData.createTime).toLocaleString() : '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="更新时间">
                                {{ formData.updateTime ? new Date(formData.updateTime).toLocaleString() : '-' }}
                            </el-form-item>
                        </el-col>
                    </el-row> -->
                </el-form>
            </div>

            <span slot="footer" class="dialog-footer">
                <el-button @click="handleClose">关 闭</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    props: {
        dialogVisible: {
            type: Boolean,
            default: false
        },
        formData: {
            type: Object,
            default: () => ({})
        },
        title: {
            type: String,
            default: '详情'
        }
    },
    data() {
        return {
        };
    },
    methods: {
        handleClose() {
            this.$emit('update:dialogVisible', false);
        }
    }
}
</script>

<style scoped>
.app-container {
    padding: 0;
}

/* 详情区域整体样式优化 */
.detail-section {
    margin-bottom: 24px;
    padding: 20px;
    border: 1px solid #ebeef5;
    border-radius: 8px;
    background-color: #ffffff;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

/* 悬停效果 */
.detail-section:hover {
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.08);
    border-color: #dcdfe6;
}

/* 标题样式优化 */
.section-title {
    margin: 0 0 20px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #409eff;
    font-size: 16px;
    font-weight: bold;
    color: #303133;
    display: flex;
    align-items: center;
}

/* 标题前添加图标 */
.section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background-color: #409eff;
    margin-right: 8px;
    border-radius: 2px;
}

.detail-form {
    margin: 0;
}

/* 表单行间距优化 */
.el-row {
    margin-bottom: 16px;
}

/* 表单列间距优化 */
.el-col {
    margin-bottom: 0;
}

/* 表单内容样式优化 */
.el-form-item {
    margin-bottom: 0;
}

/* 标签样式增强 */
.el-form-item__label {
    font-weight: 500;
    color: #606266;
}

/* 表单内容区域 */
.el-form-item__content {
    word-break: break-all;
    color: #303133;
    line-height: 1.5;
}

/* 公告正文样式优化 */
.content-box {
    max-height: 250px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid #ebeef5;
    border-radius: 6px;
    background-color: #fafafa;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 14px;
    color: #303133;
}

/* 滚动条样式 */
.content-box::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.content-box::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.content-box::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 3px;
}

.content-box::-webkit-scrollbar-thumb:hover {
    background: #909399;
}

/* 链接样式优化 */
.link-text {
    color: #409eff;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: 100%;
    transition: all 0.3s ease;
    padding: 2px 0;
}

.link-text:hover {
    color: #66b1ff;
    text-decoration: underline;
}

/* 对话框底部按钮居中 */
.dialog-footer {
    text-align: center;
    padding-top: 20px;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .detail-section {
        padding: 15px;
        margin-bottom: 16px;
    }

    .section-title {
        font-size: 14px;
        margin-bottom: 15px;
    }

    .content-box {
        max-height: 200px;
        padding: 12px;
    }

    .el-form-item__label {
        font-size: 13px;
    }

    .el-form-item__content {
        font-size: 13px;
    }
}

/* 数据为空时的占位样式 */
.el-form-item__content:empty::after {
    content: '-';
    color: #c0c4cc;
}

/* 布尔值样式优化 */
.bool-value {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}
.duplicate {
    background-color: #fef0f0;
    color: #f56c6c;
}
.bool-value.true {
    background-color: #f0f9eb;
    color: #67c23a;
}

.bool-value.false {
    background-color: #fef0f0;
    color: #f56c6c;
}
</style>