<template>
    <div>
        <div class="headers">
            <div class="headers-left">
                <div class="imgs">
                    <img v-if="enterpriseLogo" :src="enterpriseLogo" alt="企业LOGO" class="enterprise-logo-img" />
                </div>
                <div class="img-right">
                    <div class="name-title">微育科技</div>
                    <div class="right-name">数智科创 · 通达未来 </div>
                </div>
            </div>
            <div class="headers-right">
                <div class="rights">
                  

                    校企合作信息编辑
                   

                </div>
            </div>
        </div>
        
        <div class="contents">
            <div class="content-left">
                
                <div class="content-lefts">
                    <div class="leftss">

                        

                        <div class="leftss-header">
                            <div>校企合作协议信息编辑</div>
                            <div > <el-button size="small"
                                @click="btnEdint"
                                    style="background-color: #5165f7;color:white;">保存提交</el-button>
                                    <el-button size="small"
                                    @click="closeguan"
                                    style="width: 82px;">取消</el-button>
                            </div>
                        </div>
                        <div class="table-area">
                            <div class="table-header">
                                <div class="names">
                                    <span class="times">上传凭证｜ </span>
                                </div>
                             
                                
                            </div>
                           <div class="tab-area">

                            <el-table :data="tableData2" border style="width: 97%">
                                <el-table-column prop="date" label="合同（协议）材料（签章扫描件）" align="center">
                                    <template>
                                        <el-upload
                                            ref="upload0"
                                            class="upload-demo"
                                            :class="{ 'hide-upload': fileListMap[0].length > 0 }"
                                            action="#"
                                            list-type="picture-card"
                                            :http-request="handleUpload0"
                                            :file-list="fileListMap[0]"
                                            :on-preview="handlePictureCardPreview"
                                            :on-remove="(file) => handleRemove(file, 0)"
                                            :auto-upload="true"
                                            :limit="1">
                                            <i class="el-icon-plus"></i>
                                            <div class="shangchuang">上传材料</div>
                                        </el-upload>
                                    </template>
                                </el-table-column>
                               
                                <el-table-column prop="name" label="协议Word文档（选传）" align="center">
                                    <template>
                                        <el-upload
                                            ref="upload1"
                                            class="upload-demo"
                                            :class="{ 'hide-upload': fileListMap[1].length > 0 }"
                                            action="#"
                                            list-type="picture-card"
                                            :http-request="handleUpload1"
                                            :file-list="fileListMap[1]"
                                            :on-preview="handlePictureCardPreview"
                                            :on-remove="(file) => handleRemove(file, 1)"
                                            :auto-upload="true"
                                            :limit="1">
                                            <i class="el-icon-plus"></i>
                                            <div class="shangchuang">上传材料</div>
                                        </el-upload>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <!-- 图片预览对话框 -->
                            <el-dialog :visible.sync="dialogVisible" :destroy-on-close="true" :append-to-body="true">
                                <img width="100%" :src="dialogImageUrl" alt="">
                            </el-dialog>
                           </div>
                        </div>
                        
                        <div class="table-area" style="margin-top: 30px;">
                            <div class="table-header">
                                <div>
                                    <span class="times"> 协议信息｜   </span>
                                </div>
                               
                            </div>
                        </div>
                    </div>
                    <div class="content-table">
                       <div class="content-areas">
                         <div class="contents-left">
                           <span style="margin-left: 20px;">合作项目名称</span>
                         </div>
                         <div class="contents-right">
                            <span style="margin-left: 20px;"><el-input v-model="formData.project_name" placeholder="请输入合作项目名称"></el-input></span>
                         </div>
                       </div>
                      
                       <div class="content-areas content-areas2" style="top: 2px;">
                         <div class="contents-left" style="border-top: none;">
                           <span class="table-name">学校名称</span>
                         </div>
                         <div class="contents-right" style="border: none;">
                            <div class="rightss rightss1"><span class="table-name">
                                <el-input v-model="formData.school_name" placeholder="请输入学校名称" style="width: 88%;"></el-input>
                            </span></div>
                            <div class="rightss rightss2" style="border-top: none;"><span class="table-name">合同编号</span></div>
                            <div class="rightss rightss3"><span class="table-name">
                                <el-input v-model="formData.contract_no" placeholder="请输入合同编号" style="width: 88%;"></el-input>
                            </span></div>
                         </div>
                       </div>
                       <div class="content-areas content-areas2" style="top: 4px;">
                         <div class="contents-left" style="border-top: none;">
                           <span class="table-name">合同金额（元）</span>
                         </div>
                         <div class="contents-right" style="border: none;">
                            <div class="rightss rightss1"><span class="table-name">
                                <el-input v-model="formData.contract_amount" placeholder="请输入合同金额" style="width: 88%;"></el-input>
                            </span></div>
                            <div class="rightss rightss2" style="border-top: none;"><span class="table-name">合同签订日期</span></div>
                            <div class="rightss rightss3"><span class="table-name">
                                <el-date-picker
                                    v-model="formData.sign_date"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    placeholder="选择日期"
                                    style="width: 88%;">
                                </el-date-picker>
                            </span></div>
                         </div>
                       </div>
                       
                       <div class="content-areas content-areas2" style="top: 5px;">
                         <div class="contents-left" style="border-top: none;">
                           <span class="table-name">签订地点</span>
                         </div>
                         <div class="contents-right" style="border: none;">
                            <div class="rightss rightss1" style="width: 100%;"><span class="table-name">
                                <el-input v-model="formData.sign_location" placeholder="请输入签订地点" style="width: 94%;"></el-input>
                            </span></div>
                         </div>
                       </div>
                    </div>
                    
                </div>
             
            </div>
            <div class="content-right">

                <div class="leftss-header right-header">
                    <div class="header-area">
                        <div class="area-name" v-for="(item,index) in listDate" 
                        :key="index"
                        @click="btnNmae(index)"
                        :class="{'active':active ==index}"
                        >
                            {{item.name }}
                        </div>
                      
                    </div>
                    <div> <el-button size="small" style="color:#5165f7;">
                           解析中</el-button>
                    </div>
                </div>
                <div class="right-area">
                    <div class="preview-images" v-if="currentFileList.length > 0">
                        <div class="image-item" v-for="(file, index) in currentFileList" :key="index" @click="handlePictureCardPreview(file)">
                            <img :src="file.url" alt="预览图片" />
                        </div>
                    </div>
                    <div class="no-image-tip" v-else>暂无图片</div>
                </div>

            </div>
        </div>

        <!-- 保存成功弹框 -->
        <el-dialog :visible.sync="saveSuccessDialog" width="400px" :show-close="false" center :destroy-on-close="true" :append-to-body="true">
            <div class="success-dialog-content">
                <img src="@/assets/succes.png" alt="成功" class="success-icon" />
                <div class="success-title">提交保存成功</div>
                <div class="success-message">您的信息已提交成功，请耐心等待审核结果</div>
                <el-button type="primary" @click="closeSuccessDialog" style="background-color: #5165f7; margin-top: 20px;">知道了</el-button>
            </div>
        </el-dialog>

        <!-- 保存失败弹框 -->
        <el-dialog :visible.sync="saveFailDialog" width="400px" :show-close="false" center :destroy-on-close="true" :append-to-body="true">
            <div class="fail-dialog-content">
                <img src="@/assets/err.png" alt="失败" class="fail-icon" />
                <div class="fail-title">保存失败</div>
                <div class="fail-message">{{ errorMessage }}</div>
                <el-button type="primary" @click="closeFailDialog" style="background-color: #5165f7; margin-top: 20px;">知道了</el-button>
            </div>
        </el-dialog>

    </div>
</template>
<script>
import { getEnterpriseLogo } from '@/utils/auth'
import { images } from '@/api/public'
import { save, Details } from '@/api/resource/Schoolenterprise/Schoolenterprise'

export default {
    data() {
        return {
            enterpriseLogo: '',
            active: 0,
            dialogVisible: false,
            dialogImageUrl: '',
            // 文件列表（按类型分）
            fileListMap: {
                0: [], // 合同（协议）材料
                1: []  // 协议Word文档
            },
            listDate: [
                { name: '合同材料' },
                { name: 'Word文档' }
            ],
            // 表单数据
            formData: {
                project_name: '',      // 合作项目名称
                school_name: '',       // 学校名称
                contract_amount: '',   // 合同金额（元）
                contract_no: '',       // 合同编号
                sign_date: '',         // 合同签订日期
                sign_location: ''      // 签订地点
            },
            // 保存弹框
            saveSuccessDialog: false,
            saveFailDialog: false,
            errorMessage: '',
            // 编辑模式
            isEdit: false,
            editId: '',
            // 是否正在保存（用于
            // 时阻止错误提示）
            isSaving: false,
            tableData2: [
                { date: "2025", name: "年度审计报告及财务情况说明书", address: "7500" }
            ]
        }
    },

    computed: {
        // 根据当前 tab 返回对应的文件列表
        currentFileList() {
            return this.fileListMap[this.active] || []
        }
    },

    created() {
        this.loadEnterpriseLogo()
        // 检查是否为编辑模式
        if (this.$route.query.id) {
            this.isEdit = true
            this.editId = this.$route.query.id
            this.fetchDetail()
        }
    },

    beforeDestroy() {
        this.dialogVisible = false
        this.saveSuccessDialog = false
        this.saveFailDialog = false
        this.errorMessage = ''
    },

    methods: {
        // 加载企业LOGO
        loadEnterpriseLogo() {
            const logo = getEnterpriseLogo()
            if (logo) {
                this.enterpriseLogo = logo
            }
        },
        // 获取详情（编辑模式）
        async fetchDetail() {
            try {
                const res = await Details(this.editId)
                if (res && res.code === 1 && res.data) {
                    const data = res.data.data || res.data
                    // 处理日期格式（如果是时间戳，转换为日期字符串）
                    let signDate = data.sign_date || ''
                    if (signDate) {
                        // 如果是Unix时间戳（秒），转换为日期字符串
                        if (typeof signDate === 'number' || (typeof signDate === 'string' && /^\d+$/.test(signDate))) {
                            const timestamp = typeof signDate === 'string' ? parseInt(signDate) : signDate
                            const date = new Date(timestamp * 1000)
                            if (!isNaN(date.getTime())) {
                                const year = date.getFullYear()
                                const month = String(date.getMonth() + 1).padStart(2, '0')
                                const day = String(date.getDate()).padStart(2, '0')
                                signDate = `${year}-${month}-${day}`
                            }
                        } else if (typeof signDate === 'string' && signDate.includes('T')) {
                            // 如果是ISO格式，只取日期部分
                            signDate = signDate.split('T')[0]
                        }
                    }
                    // 填充表单数据
                    this.formData = {
                        project_name: data.project_name || '',
                        school_name: data.school_name || '',
                        contract_amount: data.contract_amount || '',
                        contract_no: data.contract_no || '',
                        sign_date: signDate,
                        sign_location: data.sign_location || ''
                    }
                    // 填充附件
                    // 使用双重 $nextTick 确保 el-upload 组件完全渲染后再设置文件列表
                    this.$nextTick(() => {
                        this.$nextTick(() => {
                            // 处理合同材料（扫描件）- 对应 fileListMap[0]
                            if (data.scan_file_path) {
                                const scanUrl = data.scan_file_path.trim() // 去除可能的空格
                                // 创建文件对象，格式与 handleUpload 完全一致
                                const scanFile = {
                                    uid: Date.now() + Math.random(),
                                    name: scanUrl.split('/').pop() || '合同材料',
                                    url: scanUrl,
                                    path: scanUrl, // 添加 path 属性，与 handleUpload 保持一致
                                    status: 'success'
                                }
                                // 使用 $set 替换整个数组，与 handleUpload 保持一致
                                this.$set(this.fileListMap, 0, [scanFile])
                                console.log('✅ 填充合同材料文件列表:', scanFile)
                                console.log('✅ fileListMap[0] 内容:', JSON.parse(JSON.stringify(this.fileListMap[0])))
                                console.log('✅ 图片URL:', scanUrl)
                                
                                // 使用 ref 手动设置 el-upload 组件的文件列表
                                this.$nextTick(() => {
                                    if (this.$refs.upload0) {
                                        this.$refs.upload0.fileList = [scanFile]
                                        this.$refs.upload0.$forceUpdate()
                                    }
                                })
                            } else {
                                this.$set(this.fileListMap, 0, [])
                            }
                            
                            // 处理Word文档 - 对应 fileListMap[1]
                            if (data.word_file_path) {
                                const wordUrl = data.word_file_path.trim() // 去除可能的空格
                                // 创建文件对象，格式与 handleUpload 完全一致
                                const wordFile = {
                                    uid: Date.now() + Math.random() + 1,
                                    name: wordUrl.split('/').pop() || 'Word文档',
                                    url: wordUrl,
                                    path: wordUrl, // 添加 path 属性，与 handleUpload 保持一致
                                    status: 'success'
                                }
                                // 使用 $set 替换整个数组，与 handleUpload 保持一致
                                this.$set(this.fileListMap, 1, [wordFile])
                                console.log('✅ 填充Word文档文件列表:', wordFile)
                                console.log('✅ fileListMap[1] 内容:', JSON.parse(JSON.stringify(this.fileListMap[1])))
                                
                                // 使用 ref 手动设置 el-upload 组件的文件列表
                                this.$nextTick(() => {
                                    if (this.$refs.upload1) {
                                        this.$refs.upload1.fileList = [wordFile]
                                        this.$refs.upload1.$forceUpdate()
                                    }
                                })
                            } else {
                                this.$set(this.fileListMap, 1, [])
                            }
                        })
                    })
                }
            } catch (error) {
                console.error('获取详情失败:', error)
                this.$message.error('获取详情失败')
            }
        },
        // 图片预览
        handlePictureCardPreview(file) {
            // 确保获取正确的图片URL
            const imageUrl = file.url || file.response?.url || file.path
            if (imageUrl) {
                this.dialogImageUrl = imageUrl
                this.dialogVisible = true
            }
        },
        // 图片删除
        handleRemove(file, tabIndex) {
            const index = this.fileListMap[tabIndex].findIndex(item => item.uid === file.uid)
            if (index > -1) {
                this.fileListMap[tabIndex].splice(index, 1)
                // 确保响应式更新
                this.$set(this.fileListMap, tabIndex, [...this.fileListMap[tabIndex]])
            }
        },
        // 合同材料上传
        handleUpload0(options) {
            this.handleUpload(options, 0)
        },
        // Word文档上传
        handleUpload1(options) {
            this.handleUpload(options, 1)
        },
        // 自定义上传
        async handleUpload(options, tabIndex) {
            console.log('开始上传，tabIndex:', tabIndex, '文件:', options.file)
            const formData = new FormData()
            formData.append('image', options.file)
            try {
                console.log('调用上传接口...')
                const res = await images(formData)
                console.log('上传接口响应:', res)
                if (res && res.code === 1) {
                    let imageUrl = ''
                    let imagePath = ''  // 相对路径，用于传给后台
                    if (res.data && res.data.data) {
                        const data = res.data.data
                        imageUrl = data.fullURL || (data.host + data.path) || data.url
                        imagePath = data.path || ''
                    } else if (res.data) {
                        imageUrl = res.data.fullURL || res.data.url || res.data
                        imagePath = res.data.path || ''
                    }
                    
                    // 如果 imageUrl 是相对路径，需要拼接基础URL
                    if (imageUrl && !imageUrl.startsWith('http://') && !imageUrl.startsWith('https://')) {
                        const baseUrl = process.env.VUE_APP_BASE_API || 'http://api.sg199.net'
                        imageUrl = baseUrl + (imageUrl.startsWith('/') ? imageUrl : '/' + imageUrl)
                    }
                    
                    console.log('解析后的图片URL:', imageUrl, '图片路径:', imagePath)
                    
                    if (imageUrl) {
                        const newFile = {
                            uid: Date.now() + Math.random(),
                            name: options.file.name,
                            url: imageUrl,
                            path: imagePath,
                            status: 'success'
                        }
                        
                        // 如果上传的是合同材料（tabIndex=0），自动切换到合同材料标签
                        if (tabIndex === 0) {
                            this.active = 0
                        }
                        // 如果上传的是Word文档（tabIndex=1），自动切换到Word文档标签
                        else if (tabIndex === 1) {
                            this.active = 1
                        }
                        
                        // 使用 $set 确保响应式更新，由于 limit=1，直接替换文件列表
                        this.$set(this.fileListMap, tabIndex, [newFile])
                        
                        // 强制更新视图
                        this.$nextTick(() => {
                            console.log('上传成功，文件列表:', this.fileListMap)
                            console.log('当前选中的标签:', this.active)
                            console.log('当前文件列表:', this.currentFileList)
                            console.log('文件URL:', newFile.url)
                        })
                        
                        this.$message.success('上传成功')
                    } else {
                        console.error('图片URL为空，上传响应:', res)
                        this.$message.error('获取图片URL失败')
                    }
                } else {
                    console.error('上传失败，响应:', res)
                    this.$message.error(res?.msg || '上传失败')
                }
            } catch (error) {
                console.error('上传失败:', error)
                this.$message.error('上传失败: ' + (error.message || '网络错误'))
            }
        },
        // 日期格式化
        formatDate(date) {
            if (!date) return ''
            if (typeof date === 'string' && date.includes('T')) {
                return date.split('T')[0]
            }
            if (date instanceof Date) {
                const year = date.getFullYear()
                const month = String(date.getMonth() + 1).padStart(2, '0')
                const day = String(date.getDate()).padStart(2, '0')
                return `${year}-${month}-${day}`
            }
            return date
        },
        // 取消
        closeguan() {
            // 标记为取消状态，阻止保存操作显示错误
            this.isSaving = false
            // 立即关闭所有弹框和对话框
            this.dialogVisible = false
            this.saveFailDialog = false
            this.saveSuccessDialog = false
            this.errorMessage = ''
            // 使用 nextTick 确保状态更新后再跳转
            this.$nextTick(() => {
                setTimeout(() => {
                    this.$router.go(-1)
                }, 50)
            })
        },
        // 切换tab
        btnNmae(e) {
            this.active = e
        },
        // 保存提交
        async btnEdint() {
            // 验证必填字段
            if (!this.formData.project_name) {
                this.$message.warning('请输入合作项目名称')
                return
            }
            
            // 标记为正在保存
            this.isSaving = true
            
            try {
                // 获取文件路径
                const scanFilePath = this.fileListMap[0].length > 0 ? (this.fileListMap[0][0].path || this.fileListMap[0][0].url) : ''
                const wordFilePath = this.fileListMap[1].length > 0 ? (this.fileListMap[1][0].path || this.fileListMap[1][0].url) : ''
                
                // 构建保存数据
                const saveData = {
                    project_name: this.formData.project_name,
                    school_name: this.formData.school_name,
                    contract_amount: this.formData.contract_amount,
                    contract_no: this.formData.contract_no,
                    sign_date: this.formatDate(this.formData.sign_date),
                    sign_location: this.formData.sign_location,
                    scan_file_path: scanFilePath,
                    word_file_path: wordFilePath
                }
                
                // 编辑模式时添加 id
                if (this.isEdit && this.editId) {
                    saveData.id = this.editId
                }
                
                const res = await save(saveData)
                // 如果已经取消，不显示错误提示
                if (!this.isSaving) {
                    return
                }
                
                if (res.code === 1) {
                    this.saveSuccessDialog = true
                } else {
                    this.errorMessage = res.msg || '保存失败，请重试'
                    this.saveFailDialog = true
                }
            } catch (error) {
                // 如果已经取消，不显示错误提示
                if (!this.isSaving) {
                    return
                }
                console.error('保存失败:', error)
                this.errorMessage = error.message || '网络错误，请重试'
                this.saveFailDialog = true
            } finally {
                this.isSaving = false
            }
        },
        // 关闭成功弹框
        closeSuccessDialog() {
            this.saveSuccessDialog = false
            setTimeout(() => {
                this.$router.go(-1)
            }, 100)
        },
        // 关闭失败弹框
        closeFailDialog() {
            this.saveFailDialog = false
            this.errorMessage = ''
        },
        btnShang() {
            this.$router.push('/annual')
        }
    }
}
</script>
<style>
.el-tooltip__popper.is-dark {
    color: #F04B4B !important;
    background: #FCF1EB !important;
}

.el-tooltip__popper .popper__arrow {
    border-top-color: #FCF1EB !important;
    /* 上方箭头 */
}

.el-tooltip__popper .popper__arrow::after {
    border-top-color: #FCF1EB !important;
}

/* 其他方向的箭头（按需添加） */
.el-tooltip__popper[x-placement^='bottom'] .popper__arrow {
    border-bottom-color: #FCF1EB !important;
}

.el-tooltip__popper[x-placement^='left'] .popper__arrow {
    border-left-color: #FCF1EB !important;
}

.el-tooltip__popper[x-placement^='right'] .popper__arrow {
    border-right-color: #FCF1EB !important;
}
</style>
<style scoped>
.area-name{
margin-left: 30px;
cursor: pointer;
}
.active{
   
    border-bottom: 3px solid #5165f7;
    height: 45px;
}
.header-area{
    display: flex;
    position: relative;
    left: -30px;
}
.rightss3{
    border-right: none;
    border-left: none;
}
.table-name{
    margin-left: 20px;
}
.rightss2{
    background: #EDEFFE;
}
.rightss1{
    border-left: none !important;
    border-right: none !important;
   
}
.rightss{
    height: 100%;
    border: 1px solid #DCE0FD;
    width: 100%;
    border-top: none;

}
.content-areas2{
    position: relative;
    top: 1px;

}
.contents-right{
    flex: 1;
    border: 1px solid #DCE0FD;
    line-height: 50px;
    font-size: 14px;
    color: #363636;
    display: flex
}
.contents-left{
    width: 30%;
    border: 1px solid #DCE0FD;
    background: #EDEFFE;;
    line-height: 50px;
    font-size: 14px;
    color: #363636;
    
}
.content-areas{
    display: flex;
    height: 50px;
    flex-wrap: wrap;
}
.tab-area{
    margin-top: 24px;
}
.namess{
    color: #5B5E72;
    font-size: 13px;
    margin-left: 12px;
}
.names{
    font-size: 14px;
    color: #363636;
}
:deep .el-tooltip__popper.is-dark {
    color: #F04B4B !important;
}

.right-area {
    width: 90%;
    margin: 0 auto;
    height: 80vh;
    background: #f8f8f8;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-y: auto;
}

.preview-images {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.image-item {
    width: 200px;
    height: 200px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #5165f7;
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
}

.no-image-tip {
    color: #999;
    font-size: 14px;
    margin-top: 100px;
}

/* 隐藏上传按钮 */
.hide-upload ::v-deep .el-upload--picture-card {
    display: none;
}

.right-header {
    width: 90%;
    margin: 0 auto;
}

.ths {
    text-align: center;
    background: #DCE0FD !important;
    color: #363636;
}

.tou {
    height: 30px;
    line-height: 30px;
    color: #606266;
    text-align: center;
}

.financial-table {
    width: 100%;
    border-collapse: collapse;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.financial-table th,
.financial-table td {
    border: 1px solid #ddd;
    padding: 8px 7px;
    text-align: center;
}

.financial-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.financial-table .nested-label {
   
    text-align: center;
    vertical-align: middle;
    font-weight: bold;
}

.table-right {
    flex: 1;
}

.table-left {
    flex: 1;
}

.content-table {
   
    width: 90%;
    margin: 0 auto;
    margin-top: 14px;
}

/* 默认情况（有效）左边圆角 */
.left-radius {
    border-bottom-left-radius: 16px !important;
    border-top-left-radius: 16px !important;
}

/* 无效情况右边圆角 */
.right-radius {
    border-bottom-right-radius: 16px !important;
    border-top-right-radius: 16px !important;
}

.yuan-left {
    flex: 1;
    text-align: center;
    line-height: 30px;
    background: #f8f8f8;
    /* border-bottom-left-radius: 16px;
    border-top-left-radius: 16px; */
    cursor: pointer;
}

.yuanright {
    flex: 1;
    background: #5165f7;
    color: white;

    /* border-bottom-right-radius: 16px;
    border-top-right-radius: 16px;  */
    text-align: center;
    line-height: 30px;
    cursor: pointer;

}

.youxiaos {
    position: relative;
    top: 6px;
    left: -12px;
    cursor: pointer;
}

/* 修改.yuan的样式，移除外层圆角 */
.yuan {
    width: 100px;
    height: 30px;
    background: white;
    display: flex;
    font-size: 14px;
    overflow: hidden;
    /* 关键：确保内部div的圆角效果不被截断 */
}

/* 默认状态下两个按钮的外侧圆角 */
.yuan-left:first-child {
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
}

.yuan-left:last-child {
    border-top-right-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* 选中状态样式 */
.yuanright {
    background: #5165f7;
    color: white;
}

/* 选中"有效"时的样式 */
.yuan-left.left-radius {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

/* 选中"无效"时的样式 */
.yuan-left.right-radius {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}


.times {
    position: relative;
    top: 3px;
}

.youxiao {
    color: #5B5D76;
    font-size: 13px;
}

.table-header {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
}

.table-area {
    margin-top: 12px;
    font-size: 15px;
}

.leftss-header {
    display: flex;
    height: 60px;
    line-height: 60px;
    border-bottom: 1px solid #3333;
    font-weight: bold;
    justify-content: space-between;
}

.leftss {
    width: 90%;
    margin: 0 auto;
}

.content-lefts {
    background: white;
    height: 100%;
    width: 100%;
}

.content-left {
    flex: 1;
    height: 100%;
}

.content-right {
    width: 600px;
    height: 100%;
    background: white;
}

.contents {
    width: 100%;
    height: 92vh;
    background: #f8f8f8;
    display: flex;
    margin-top: 6px;
    /* flex-wrap: wrap */
}


.shu {
    width: 3px;
    height: 18px;
    background: #5165f7;
    position: relative;
    display: inline-block;
    top: 7px;
}

::v-deep .el-table thead {
    background-color: #DCE0FD !important;
    color: #363636 !important;
    font-weight: bold;
}

::v-deep .el-table__header th {
    background-color: #DCE0FD !important;
    color: #363636 !important;
    font-weight: bold;
}




.shu{
  width: 10px;
    height: 20px;
    background: #5165f7;
    position: relative;
    top: -24px;
    left: 40%;
}
.active{
    color: #5165f7 !important;
}
.rights-names{
    margin-left: 32px;
    cursor: pointer;
}
.rights{
    width: 100%;
    height: 100%;
    line-height: 94px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.name-title{
    position: relative;
    top: -6px;
    font-weight: bold;
}
.right-name{
    font-size: 12px;
}
.img-right{
    font-size: 14px;
    position: relative;
    top: 40px;
    height: 40px;
    margin-left: 12px;
}
.imgs{
    width: 42px;
    height: 40px;
    border-radius: 6px;
    position: relative;
    top: 26px;
    margin-left: 24px;
    overflow: hidden;
}

.enterprise-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}
.headers-right{
    flex: 1;
    background: white;
  
}
.headers-left{
    width: 222px;
    height: 100%;
    display: flex;
    background: white;
    border-right: 1px solid #EDEFFE;
}
.headers{
  width: 100%;
    height: 90px;
    display: flex
;
    border-bottom: 1px solid #EDEFFE;
}




.patent-container {
      max-width: 1000px;
      margin: 0 auto;
      background: white;
      border-radius: 8px;
      box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
      overflow: hidden;
    }
    .patent-header {
      background: linear-gradient(135deg, #6a5acd, #8a7dff);
      color: white;
      padding: 20px 30px;
      text-align: center;
    }
    .patent-header h1 {
      font-size: 24px;
      margin-bottom: 10px;
      font-weight: 600;
    }
    .patent-header p {
      opacity: 0.9;
      font-size: 14px;
    }
    .search-box {
      padding: 15px 30px;
      background-color: #f8f9fa;
      border-bottom: 1px solid #eaeaea;
    }
    .search-box input {
      width: 100%;
      padding: 10px 15px;
      border: 1px solid #ddd;
      border-radius: 4px;
      font-size: 14px;
      transition: border-color 0.3s;
    }
    .search-box input:focus {
      outline: none;
      border-color: #8a7dff;
      box-shadow: 0 0 0 2px rgba(138, 125, 255, 0.2);
    }
    .patent-table {
      width: 100%;
      border-collapse: collapse;
    }
    .patent-table th {
      background-color: #f0e6ff;
      color: #5a4fcf;
      padding: 12px 15px;
      text-align: left;
      font-weight: 600;
      border-bottom: 1px solid #ddd;
    }
    .patent-table td {
      padding: 12px 15px;
      border-bottom: 1px solid #f0f0f0;
      transition: background-color 0.2s;
    }
    .patent-table tr:hover td {
      background-color: #f9f7ff;
    }
    .patent-table tr:last-child td {
      border-bottom: none;
    }
    .status-badge {
      display: inline-block;
      padding: 4px 8px;
      border-radius: 4px;
      font-size: 12px;
      font-weight: 500;
    }
    .status-paid {
      background-color: #e8f5e9;
      color: #2e7d32;
    }
    .patent-footer {
      padding: 15px 30px;
      text-align: center;
      color: #777;
      font-size: 14px;
      border-top: 1px solid #eaeaea;
      background-color: #fafafa;
    }

/* 成功弹框样式 */
.success-dialog-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.success-icon {
    margin-bottom: 16px;
}

.success-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
}

.success-message {
    font-size: 14px;
    color: #666;
    text-align: center;
}

/* 失败弹框样式 */
.fail-dialog-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.fail-icon {
    margin-bottom: 16px;
}

.fail-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
}

.fail-message {
    font-size: 14px;
    color: #666;
    text-align: center;
}

</style>