<!-- 测井数据 -->
<template>
    <div class="app-containercj">
        <!-- 自定义全屏加载遮罩 -->
        <div v-if="importing2" class="custom-loading-overlay">
            <div class="loading-content">
                <i class="el-icon-loading"></i>
                <div class="loading-text">导入时间较长，请耐心等待。</div>
                <div class="loading-progress">
                    <el-progress :percentage="displayProgress" :status="displayProgress === 100 ? 'success' : null"
                        :stroke-width="6" :show-text="true"></el-progress>
                </div>
                <div class="loading-status">{{ progressStatusText }}</div>
            </div>
        </div>
        <!-- <el-tabs v-model="activeTab" v-loading="loading">
            <el-tab-pane label="测井数据" name="loggingData"> -->
        <el-form :model="cjqueryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
            label-width="100px">
            <el-form-item label="井号" prop="jh">
                <el-input v-model="cjqueryParams.jh" placeholder="请输入井号" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                <el-button type="primary" @click="handleImport2">导入las文件</el-button>
                <el-button type="primary" @click="handleExport">导出</el-button>
                <el-button type="primary" @click="handleImport">导入Excel</el-button>
                <el-button type="primary" @click="cjsz">设置</el-button>
                <!-- <el-button type="primary" @click="jscs">计算参数</el-button> -->
                <el-button type="primary" @click="js">计算</el-button>
                <el-button type="primary" @click="handleSelectAdjacentWell">邻井数据映射</el-button>
                <!-- <el-button type="primary" @click="jscwxs">计算层位斜深</el-button> -->
                <!-- <el-button type="warning" plain icon="el-icon-download" size="mini"
                            @click="handleExport">导出</el-button> -->
            </el-form-item>

            <right-toolbar :search="false" :show-refresh="false" :showSearch.sync="showSearch"
                @queryTable="handleCjData" :columns="columns" @columns-change="onColumnsChange" />
        </el-form>
        <div style="background-color: #fff;">
            <!-- <el-form style="background-color: #fff" ref="queryForm" size="small" :inline="true" v-show="showSearch"
                label-width="68px">
                <el-form-item style="margin: 5px 0 5px 10px;">

                </el-form-item>
            </el-form> -->
            <el-table border :height="TableHeight()" style="background-color: #fff;margin-top: -5px" :data="cjsjLasList"
                :header-cell-style="{
                    padding: '1px 0',
                    height: '28px',
                    lineHeight: '28px'
                }" :header-cell-class-name="'table-header'" :cell-style="{
                    padding: '1px 0'
                }" :tooltip-effect="'dark'" header-overflow-tooltip v-loading="loading"
                element-loading-text="计算时间较长,请耐心等待...">
                <el-table-column v-if="isColumnVisible('dept')" prop="dept" min-width="90" align="center"
                    show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="井深" placement="top" effect="dark">
                            <span>井深</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('tvd')" prop="tvd" min-width="90" align="center"
                    show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="垂深" placement="top" effect="dark">
                            <span>垂深</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('vdl')" label="声波变密度(微秒/μs)" min-width="100" prop="vdl"
                    align="center" show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="声波变密度(微秒/μs)" placement="top" effect="dark">
                            <span>声波变密度(微秒/μs)</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('sp')" label="自然电位(毫伏/mv)" min-width="100" prop="sp"
                    align="center" show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="自然电位(毫伏/mv)" placement="top" effect="dark">
                            <span>自然电位(毫伏/mv)</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('gr')" label="自然伽马(自然伽马单位/API)" min-width="130" prop="gr"
                    align="center" show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="自然伽马(自然伽马单位/API)" placement="top" effect="dark">
                            <span>自然伽马(自然伽马单位/API)</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('rd')" label="深侧向电阻率" prop="rd" min-width="100" align="center"
                    show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="深侧向电阻率" placement="top" effect="dark">
                            <span>深侧向电阻率</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('rs')" label="浅侧向电阻率" prop="rs" min-width="100" align="center"
                    show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="浅侧向电阻率" placement="top" effect="dark">
                            <span>浅侧向电阻率</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('cnl')" label="补偿中子(百分数/%)" min-width="100" prop="cnl"
                    align="center" show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="补偿中子(百分数/%)" placement="top" effect="dark">
                            <span>补偿中子(百分数/%)</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('den')" label="体积密度(克每立方厘米/g/cm3)" min-width="100" prop="den"
                    align="center" show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="体积密度(克每立方厘米/g/cm3)" placement="top" effect="dark">
                            <span>体积密度(克每立方厘米/g/cm3)</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('ac')" label="声波时差(微秒每英尺/μs/ft)" min-width="120" prop="ac"
                    align="center" show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="声波时差(微秒每英尺/μs/ft)" placement="top" effect="dark">
                            <span>声波时差(微秒每英尺/μs/ft)</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column v-if="isColumnVisible('dzky')" label="单轴抗压强度" prop="dzky" min-width="100"
                    align="center" show-overflow-tooltip>
                    <template slot="header">
                        <el-tooltip content="单轴抗压强度" placement="top" effect="dark">
                            <span>单轴抗压强度</span>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column label="固定规则" align="center">
                    <el-table-column v-if="isColumnVisible('vsh')" label="泥质含量" prop="vsh" align="center"
                        min-width="100" show-overflow-tooltip>
                        <template slot="header">
                            <el-tooltip content="泥质含量" placement="top" effect="dark">
                                <span>泥质含量</span>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column v-if="isColumnVisible('kjqd')" label="抗剪强度" prop="kjqd" align="center"
                        min-width="100" show-overflow-tooltip>
                        <template slot="header">
                            <el-tooltip content="抗剪强度" placement="top" effect="dark">
                                <span>抗剪强度</span>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column v-if="isColumnVisible('yskzxjz')" label="岩石可钻性级值" prop="yskzxjz" align="center"
                        min-width="120" show-overflow-tooltip>
                        <template slot="header">
                            <el-tooltip content="岩石可钻性级值" placement="top" effect="dark">
                                <span>岩石可钻性级值</span>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column v-if="isColumnVisible('ymzs')" label="研磨性系数" prop="ymzs" align="center"
                        min-width="100" show-overflow-tooltip>
                        <template slot="header">
                            <el-tooltip content="研磨性系数" placement="top" effect="dark">
                                <span>研磨性系数</span>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column v-if="isColumnVisible('nmcj')" label="内摩擦角" prop="nmcj" align="center"
                        min-width="100" show-overflow-tooltip>
                        <template slot="header">
                            <el-tooltip content="内摩擦角" placement="top" effect="dark">
                                <span>内摩擦角</span>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column v-if="isColumnVisible('cjzs')" label="均质性系数" prop="cjzs" align="center"
                        min-width="100" show-overflow-tooltip>
                        <template slot="header">
                            <el-tooltip content="均质性系数" placement="top" effect="dark">
                                <span>均质性系数</span>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                    <el-table-column v-if="isColumnVisible('fbit')" label="钻头选型指数" prop="fbit" align="center"
                        min-width="100" show-overflow-tooltip>
                        <template slot="header">
                            <el-tooltip content="钻头选型指数" placement="top" effect="dark">
                                <span>钻头选型指数</span>
                            </el-tooltip>
                        </template>
                    </el-table-column>
                </el-table-column>
                <el-table-column label="操作" width="140" align="center" fixed="right">
                    <template slot-scope="scope">
                        <el-button type="text" size="mini" @click="handleView(scope.row)">查看</el-button>
                        <el-button type="text" size="mini" @click="handleEdit(scope.row)">修改</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination :total="total" :page.sync="cjqueryParams.pageNum" :limit.sync="cjqueryParams.pageSize"
                @pagination="handleCjData" />
        </div>
        <!-- </el-tab-pane> -->

        <!-- </el-tabs> -->

        <!-- 弹窗组件 -->
        <el-dialog title="变量取值范围" :visible.sync="open" width="700px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                <el-row>
                    <el-col :span="4">
                        <div style="line-height: 40px; font-weight: bold; text-align: right; padding-right: 8px;">纵波时差:
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最小值" prop="zbscmin">
                            <el-input v-model="form.zbscmin" placeholder="请输入日期" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最大值" prop="zbscmax">
                            <el-input v-model="form.zbscmax" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                </el-row>

                <!-- <el-row>
                    <el-col :span="4">
                        <div style="line-height: 40px; font-weight: bold; text-align: right; padding-right: 8px;">横波时差:
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最小值" prop="hbscmin">
                            <el-input v-model="form.hbscmin" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最大值" prop="hbscmin">
                            <el-input v-model="form.hbscmin" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                </el-row> -->

                <el-row>
                    <el-col :span="4">
                        <div style="line-height: 40px; font-weight: bold; text-align: right; padding-right: 8px;">伽马:
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最小值" prop="gmmin">
                            <el-input v-model="form.gmmin" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最大值" prop="gmmax">
                            <el-input v-model="form.gmmax" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="4">
                        <div style="line-height: 40px; font-weight: bold; text-align: right; padding-right: 8px;">中子密度:
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最小值" prop="zzmdmin">
                            <el-input v-model="form.zzmdmin" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最大值" prop="zzmdmax">
                            <el-input v-model="form.zzmdmax" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="4">
                        <div style="line-height: 40px; font-weight: bold; text-align: right; padding-right: 8px;">井径:
                        </div>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最小值" prop="jjmin">
                            <el-input v-model="form.jjmin" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="最大值" prop="jjmax">
                            <el-input v-model="form.jjmax" placeholder="请输入" />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">保 存</el-button>
            </div>
        </el-dialog>

        <!-- 计算参数弹窗 -->
        <el-dialog title="计算参数" :visible.sync="openjscs" width="700px" append-to-body>
            <el-form ref="formjscs" :model="formjscs" :rules="rulesjscs" label-width="80px" v-if="formjscs">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="A1" prop="a1" label-width="130px">
                            <el-input v-model="formjscs.a1" placeholder="请输入A1" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="A2" prop="a2">
                            <el-input v-model="formjscs.a2" placeholder="请输入A2" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="A3" prop="a3">
                            <el-input v-model="formjscs.a3" placeholder="请输入A3" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="B1" prop="b1" label-width="130px">
                            <el-input v-model="formjscs.b1" placeholder="请输入B1" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="B2" prop="b2">
                            <el-input v-model="formjscs.b2" placeholder="请输入B2" />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitFormjscs">保 存</el-button>
            </div>
        </el-dialog>

        <!-- 导入弹窗 -->
        <el-dialog title="导入" :visible.sync="uploadOpen" width="520px" append-to-body inline>
            <el-form ref="uploadForm" :model="uploadForm" label-width="70px">
                <el-form-item prop="dataUrl">
                    <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
                        :action="upload.url + '?jh=' + cjqueryParams.jh" :disabled="upload.isUploading"
                        :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false"
                        drag>
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text">
                            将文件拖到此处，或<em>点击上传</em>
                        </div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <div class="mask" v-if="importing">
                <div class="mask-content">
                    <i class="el-icon-loading"></i>
                    <span>正在导入，请稍候...</span>
                </div>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitFileForm">确 定</el-button>
                <el-button @click="cancelFile">取 消</el-button>
            </div>
        </el-dialog>

        <!-- 导入las文件弹窗 -->
        <el-dialog title="导入las文件" :visible.sync="uploadOpen2" width="520px" append-to-body inline>
            <el-form ref="uploadForm2" :model="uploadForm2" label-width="70px">
                <el-form-item prop="dataUrl">
                    <el-upload ref="upload2" :limit="1" accept=".las" :headers="upload2.headers"
                        :action="upload2.url + '?jh=' + cjqueryParams.jh" :disabled="upload2.isUploading"
                        :on-progress="handleFileUploadProgress2" :on-success="handleFileSuccess2" :auto-upload="false"
                        drag>
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text">
                            将文件拖到此处，或<em>点击上传</em>
                        </div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitFileForm2">确 定</el-button>
                <el-button @click="cancelFile2">取 消</el-button>
            </div>
        </el-dialog>

        <!-- 查看详情弹窗 -->
        <el-dialog title="查看" :visible.sync="viewDialogVisible" width="1200px" append-to-body>
            <el-form :model="viewForm" label-width="220px">
                <el-row :gutter="20">
                    <el-col :span="12" v-for="(col, idx) in filteredTableColumns" :key="col.prop || idx">
                        <el-form-item :label="col.label">
                            <el-input v-model="viewForm[col.prop]" readonly />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="viewDialogVisible = false">关 闭</el-button>
            </div>
        </el-dialog>

        <!-- 修改弹窗 -->
        <el-dialog title="修改" :visible.sync="editOpen" width="600px" append-to-body>
            <el-form ref="editForm" :model="editForm" :rules="editRules" label-width="220px">
                <el-form-item label="井号">
                    <el-input v-model="editForm.jh" disabled />
                </el-form-item>
                <el-form-item label="井深">
                    <el-input v-model="editForm.dept" disabled />
                </el-form-item>
                <el-form-item label="自然伽马(自然伽马单位/API)" prop="gr">
                    <el-input v-model="editForm.gr" placeholder="请输入自然伽马" />
                </el-form-item>
                <el-form-item label="声波时差(微秒每英尺/μs/ft)" prop="ac">
                    <el-input v-model="editForm.ac" placeholder="请输入声波时差" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitEditForm">保 存</el-button>
                <el-button @click="editOpen = false">取 消</el-button>
            </div>
        </el-dialog>

        <!-- 选择邻井弹窗 -->
        <el-dialog title="选择邻井" :visible.sync="wellDialogVisible" width="80%" :close-on-click-modal="false"
            class="well-dialog" :z-index="2000" @open="handleWellDialogOpen">
            <!-- 搜索条件 -->
            <el-form :model="wellSearch" inline size="small" style="margin-bottom: 10px;">
                <el-form-item label="井号">
                    <el-input v-model="wellSearch.jh" placeholder="请输入井号" style="width: 160px;" />
                </el-form-item>
                <el-form-item label="区块">
                    <el-select v-model="wellSearch.qk" placeholder="请选择区块" clearable filterable style="width: 160px;">
                        <el-option v-for="opt in blockOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="距离">
                    <el-input v-model="wellSearch.jl" placeholder="请输入距离" style="width: 160px;" />
                </el-form-item>
                <el-form-item label="完井时间">
                    <el-date-picker v-model="wellSearch.wjsjks" type="year" placeholder="开始年份" value-format="yyyy"
                        style="width: 120px;" />
                    <el-date-picker v-model="wellSearch.wjsjjs" type="year" placeholder="结束年份" value-format="yyyy"
                        style="width: 120px;" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="handleWellSearch">搜索</el-button>
                    <el-button @click="resetWellSearch">重置</el-button>
                </el-form-item>
            </el-form>

            <!-- 表格列表 -->
            <el-table :data="wellTableData" border style="width: 100%;height: 400px" max-height="400px"
                v-loading="wellLoading" @selection-change="handleWellSelectionChange" ref="wellTable"
                :row-key="row => row.jh">
                <el-table-column type="selection" width="55" :selectable="checkSelectable" />
                <el-table-column prop="jh" label="井号" align="center" show-overflow-tooltip />
                <el-table-column prop="jx" label="井型" align="center" show-overflow-tooltip />
                <el-table-column prop="wjjs" label="斜深" align="center" show-overflow-tooltip />
                <el-table-column prop="wjczjs" label="垂深" align="center" show-overflow-tooltip />
                <el-table-column prop="wzcw" label="完钻层位" align="center" show-overflow-tooltip />
                <el-table-column prop="kc" label="总开次" align="center" show-overflow-tooltip />
                <el-table-column prop="zjzq" label="钻井周期(天)" align="center" show-overflow-tooltip />
                <el-table-column prop="wjzq" label="钻完周期(天)" align="center" show-overflow-tooltip />
                <el-table-column prop="jkjl" label="井口距离" align="center" show-overflow-tooltip />
                <el-table-column prop="jdjl" label="井底距离" align="center" show-overflow-tooltip />
            </el-table>

            <!-- 分页组件 -->
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="wellPagination.pageNum" :page-sizes="[10, 20, 50, 100]"
                :page-size="wellPagination.pageSize" layout="total, sizes, prev, pager, next, jumper"
                :total="wellPagination.total" style="margin-top: 10px; text-align: right;" />

            <template slot="footer">
                <span class="dialog-footer">
                    <el-button @click="handleWellCancel">取 消</el-button>
                    <el-button type="primary" @click="handleWellSubmit">确 定</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>

<script>
import { listCjsjLas, getCjsjLas, delCjsjLas, addCjsjLas, updateCjsjLas, cjsjBlqzfw, updateCjsjBlqzfw } from "@/api/system/cjsjLas";
import { listjsjh, addJscs, updateJscs, getJs, getJscwxs } from "@/api/geologicalScheme/stratigraphicSequence/stratigraphicInformation";
import { listSjCjsjLas, getSjCjsjLas, delSjCjsjLas, addSjCjsjLas, updateSjCjsjLas } from "@/api/system/sjCjsjLas";
import { getToken } from "@/utils/auth";
import { listSj, ljysByjh } from "@/api/adjacentWell";
import { getQkxl } from "@/api/system/jsaa";
//变量取值范围
import { listSjCjsjBlqzfw, getSjCjsjBlqzfw, delSjCjsjBlqzfw, addSjCjsjBlqzfw, updateSjCjsjBlqzfw } from "@/api/system/sjCjsjBlqzfw";
//转换系数
import { listSjCjsjZhxs, getSjCjsjZhxs, delSjCjsjZhxs, addSjCjsjZhxs, updateSjCjsjZhxs } from "@/api/system/sjCjsjZhxs";

export default {
    name: "LoggingData",
    components: {
    },
    props: {
        wellInfo: {
            type: Object,
            default: () => ({
                jh: '',
                jd: '',
                ytgs: '',
                jhdm: ''
            })
        },
        qkmc: {
            type: String,
            default: ''
        },
    },
    data() {
        return {
            loading: false,
            activeTab: 'loggingData',
            rulesjscs: {},
            formjscs: {
                a1: '',
                a2: '',
                a3: '',
                b1: '',
                b2: ''
            },
            openjscs: false,
            showSearch: true,
            // 显隐列配置（配合 RightToolbar）
            columns: [],
            total: 0,
            cjsjLasList: [],
            form: {},
            open: false,
            cjqueryParams: {
                pageNum: 1,
                pageSize: 20,
                jh: this.wellInfo.jh || this.$route.query.jh
            },
            dialogVisible: false,
            file: null,
            excelData: [],
            upload: {
                open: false,
                title: "",
                isUploading: false,
                updateSupport: 0,
                headers: { Authorization: "Bearer " + getToken() },
                url: `${process.env.VUE_APP_BASE_API}/system/sjCjsjLas/importData`,
            },
            uploadForm: {},
            uploadOpen: false,
            importing: false,
            upload2: {
                open: false,
                title: "",
                isUploading: false,
                updateSupport: 0,
                headers: { Authorization: "Bearer " + getToken() },
                url: `${process.env.VUE_APP_BASE_API}/system/sjCjsjLas/importDataLas`,
            },
            uploadForm2: {},
            uploadOpen2: false,
            importing2: false,
            uploadProgress: 0, // 上传进度 0-100
            isUploadingFile: false, // 是否正在上传文件（区别于接口处理）
            fileUploadComplete: false, // 文件上传是否完成
            rules: {
                jh: [{ required: true, message: "井号不能为空", trigger: "blur" }],
                jhdm: [
                    { required: true, message: "井号代码不能为空", trigger: "blur" },
                ],
            },
            tableColumns: [
                { label: '井号', prop: 'jh', width: 110 },
                { label: '日期', prop: 'rq', width: 90 },
                { label: '井深', prop: 'dept', width: 90 },
                { label: '垂深', prop: 'tvd', width: 90 },
                { label: '井径差值', prop: 'cal0', width: 100 },
                { label: '残余烃密度(克每立方厘米/g/cm3)', prop: 'dhy', },
                { label: '孔隙度(百分数/%)', prop: 'por' },
                { label: '含水孔隙度(百分数/%)', prop: 'porw' },
                { label: '总孔隙度(百分数/%)', prop: 'port' },
                { label: '冲洗带含水孔隙度(百分数/%)', prop: 'porf' },
                { label: '渗透率(毫平方微米/10-3 μm2)', prop: 'perm' },
                { label: '含水饱和度(百分数/%)', prop: 'sw' },
                { label: '冲洗带含水饱和度(百分数/%)', prop: 'sxo' },
                { label: '泥质含量(百分数/%)', prop: 'sh' },
                { label: '磁性定位(毫伏/mv)', prop: 'ccl' },
                { label: '声波幅度(毫伏/mv)', prop: 'cbl' },
                { label: '声波变密度(微秒/μs)', prop: 'vdl' },
                { label: '井径(英寸/in)', prop: 'cal' },
                { label: '双井径1(英寸/in)', prop: 'cal13' },
                { label: '双井径2(英寸/in)', prop: 'cal24' },
                { label: '自然电位(毫伏/mv)', prop: 'sp' },
                { label: '自然伽马(自然伽马单位/API)', prop: 'gr' },
                { label: '井斜角(度/°)', prop: 'dev' },
                { label: '井眼方位角(度/°)', prop: 'azim' },
                { label: '0.4 米电位电阻率', prop: 'r04' },
                { label: '0.5 米电位电阻率', prop: 'r05' },
                { label: '2.5 米底部梯度电阻率', prop: 'r25' },
                { label: '4 米底部梯度电阻率', prop: 'r4' },
                { label: '微电位电阻率', prop: 'rnml' },
                { label: '微梯度电阻率', prop: 'rlml' },
                { label: '深感应电阻率', prop: 'rild' },
                { label: '中感应电阻率', prop: 'rilm' },
                { label: '八侧向电阻率', prop: 'rfoc' },
                { label: '高分辨率深感应电阻率', prop: 'hrid' },
                { label: '高分辨率中感应电阻率', prop: 'hrim' },
                { label: '数字聚焦电阻率', prop: 'rdfl' },
                { label: '深侧向电阻率', prop: 'rd' },
                { label: '浅侧向电阻率', prop: 'rs' },
                { label: '微球形聚焦电阻率', prop: 'msfl' },
                { label: '补偿中子(百分数/%)', prop: 'cnl' },
                { label: '体积密度(克每立方厘米/g/cm3)', prop: 'den' },
                { label: '有效光电吸收截面指数(靶恩每电子/b/e)', prop: 'pe' },
                { label: '声波时差(微秒每英尺/μs/ft)', prop: 'ac' },
                { label: '杨氏模量', prop: 'ysml' },
                { label: '泊松比', prop: 'bsb' },
                { label: '内摩擦系数', prop: 'nmc' },
                { label: '单轴抗压强度', prop: 'dzky' },
                { label: '三压力', prop: 'syl' },
                { label: '钻井液密度', prop: 'zjymd' },
                { label: '横波', prop: 'hb' },
                { label: '纵波', prop: 'zb' },
                { label: '密度', prop: 'md' },
                { label: '浅电阻率', prop: 'qdzl' },
                { label: '深电阻率', prop: 'sdzl' },
                { label: '井径1', prop: 'jj1' },
                { label: '井径2', prop: 'jj2' },
                { label: '中子密度', prop: 'zzmd' },
                { label: '钻头尺寸', prop: 'ztcc' },
                { label: '层位', prop: 'cw' },
                { label: '岩性', prop: 'yx' },
                { label: '岩石可钻性级值', prop: 'yskzxjz' },
                { label: '研磨性系数', prop: 'ymzs' },
                { label: '均质性系数', prop: 'cjzs' },
                { label: '钻头体', prop: 'ztt' },
                { label: '布齿密度', prop: 'bcmd' },
                { label: '刀翼数', prop: 'dys' },
                { label: '冠部轮廓', prop: 'gblk' },
                { label: '切削齿尺寸', prop: 'qxccc' },
                { label: '切削齿后倾角', prop: 'qxchqj' },
                { label: '保径-设计特征', prop: 'bj' },
                { label: '水力设计-设计特征', prop: 'slsj' },
                { label: '平均钻进速度', prop: 'srop' },
                { label: '测量仪组合伽马射线辐射计校正', prop: 'cgrc' },
                { label: '测量仪数据密度', prop: 'dgdd' },
                { label: '15英寸相位电阻率测量值', prop: 'cesp' },
                { label: '39英寸相位电阻率测量值', prop: 'cedp' },
                { label: 'ALD LCRB压实密度', prop: 'sbd2' },
                { label: 'CTN孔隙度', prop: 'tnpl' },
                { label: '温度', prop: 'stem' },
                { label: 'CTN孔隙度', prop: 'tnps' }
            ],
            // 邻井选择
            wellDialogVisible: false,
            wellTableData: [],
            wellLoading: false,
            wellSelection: [],
            wellPagination: {
                pageNum: 1,
                pageSize: 10,
                total: 0
            },
            wellSearch: {
                qk: '',
                jh: '',
                jl: '10000',
                wjsjks: (new Date().getFullYear() - 4).toString(),
                wjsjjs: new Date().getFullYear().toString()
            },
            adjacentWells: '',
            hasSearched: false,
            blockOptions: [],
            // 查看详情相关
            viewDialogVisible: false,
            viewRowData: null,
            viewForm: {},
            editOpen: false,
            editForm: {},
            editRules: {
                gr: [
                    { required: false, message: "请输入自然伽马", trigger: "blur" }
                ],
                ac: [
                    { required: false, message: "请输入声波时差", trigger: "blur" }
                ]
            }
        };
    },
    computed: {
        // 确保 formjscs 始终有正确的结构
        safeFormjscs() {
            return {
                a1: this.formjscs?.a1 || '',
                a2: this.formjscs?.a2 || '',
                a3: this.formjscs?.a3 || '',
                b1: this.formjscs?.b1 || '',
                b2: this.formjscs?.b2 || ''
            };
        },
        // 过滤出可见列供模板渲染，避免 v-for 搭配 v-if
        filteredTableColumns() {
            if (!Array.isArray(this.columns) || this.columns.length === 0) return this.tableColumns;
            return this.tableColumns.filter((_, idx) => this.columns[idx] ? this.columns[idx].visible !== false : true);
        },
        // 显示进度（用于进度条）
        displayProgress() {
            // 如果文件上传完成但接口还在处理，进度条停在90%
            if (this.fileUploadComplete && this.importing2 && this.uploadProgress >= 100) {
                return 90; // 文件上传完成，但接口还在处理，停在90%
            }
            // 如果接口处理完成，显示100%
            if (!this.importing2 && this.uploadProgress >= 100) {
                return 100;
            }
            // 文件上传中，显示实际上传进度（0-90%）
            if (this.isUploadingFile && this.uploadProgress < 100) {
                return Math.floor(this.uploadProgress * 0.9); // 上传进度映射到0-90%
            }
            return 0;
        },
        // 进度状态文本
        progressStatusText() {
            if (this.isUploadingFile && this.uploadProgress < 100) {
                return `正在上传文件: ${this.uploadProgress}%`;
            } else if (this.fileUploadComplete && this.importing2) {
                return '正在处理数据，请稍候...';
            } else if (this.uploadProgress >= 100 && !this.importing2) {
                return '导入完成';
            }
            return '正在导入，请稍候...';
        }
    },
    mounted() {
        console.log('AdjacentWell mounted - qkmc prop:', this.qkmc);
        console.log('AdjacentWell mounted - wellInfo:', this.wellInfo);
        this.cjqueryParams = {
            pageNum: 1,
            pageSize: 20,
            jh: this.wellInfo.jh || this.$route.query.jh
        }
        this.handleCjData();
        // 初始化显隐列（默认全部显示）
        // 定义新的表格字段配置
        const newTableFields = [
            { key: 'dept', label: '井深', visible: true },
            { key: 'tvd', label: '垂深', visible: true },
            { key: 'vdl', label: '声波变密度(微秒/μs)', visible: true },
            { key: 'sp', label: '自然电位(毫伏/mv)', visible: true },
            { key: 'gr', label: '自然伽马(自然伽马单位/API)', visible: true },
            { key: 'rd', label: '深侧向电阻率', visible: true },
            { key: 'rs', label: '浅侧向电阻率', visible: true },
            { key: 'cnl', label: '补偿中子(百分数/%)', visible: true },
            { key: 'den', label: '体积密度(克每立方厘米/g/cm3)', visible: true },
            { key: 'ac', label: '声波时差(微秒每英尺/μs/ft)', visible: true },
            { key: 'dzky', label: '单轴抗压强度', visible: true },
            { key: 'vsh', label: '泥质含量', visible: true },
            { key: 'kjqd', label: '抗剪强度', visible: true },
            { key: 'yskzxjz', label: '岩石可钻性级值', visible: true },
            { key: 'ymzs', label: '研磨性系数', visible: true },
            { key: 'nmcj', label: '内摩擦角', visible: true },
            { key: 'cjzs', label: '均质性系数', visible: true },
            { key: 'fbit', label: '钻头选型指数', visible: true }
        ];
        this.columns = newTableFields;
        this.getBlockOptions().then(() => {
            // 区块选项加载完成后，设置默认区块值
            if (this.qkmc) {
                this.wellSearch.qk = this.qkmc;
                console.log('AdjacentWell mounted - 区块选项加载完成，设置默认值:', this.qkmc);
            }
        });
    },
    watch: {
        activeTab: {
            handler(newVal) {
                if (newVal === 'loggingData') {
                    this.handleCjData();
                }
            },
            immediate: false
        },
        'wellInfo.jh': {
            handler(newVal) {
                if (newVal) {
                    this.cjqueryParams.jh = newVal;
                    this.handleCjData();
                }
            },
            immediate: false
        }
    },
    methods: {
        onColumnsChange({ index, visible }) {
            if (Array.isArray(this.columns) && this.columns[index]) {
                this.$set(this.columns[index], 'visible', visible);
            }
        },
        TableHeight() {
            const windowHeight = window.innerHeight;
            const topBarHeight = 130;
            const componentMargin = 160;
            const tableHeight = windowHeight - topBarHeight - componentMargin;
            return tableHeight;
        },
        // 打开邻井选择
        handleSelectAdjacentWell() {
            this.wellDialogVisible = true;
            // 弹窗打开事件会自动处理所有重置和默认值设置
        },

        // 弹窗打开事件处理
        handleWellDialogOpen() {
            console.log('AdjacentWell handleWellDialogOpen - qkmc:', this.qkmc, 'blockOptions.length:', this.blockOptions.length);

            // 重置搜索条件，但保持区块默认值
            this.wellSearch = {
                qk: this.qkmc || '', // 保持区块默认值
                jh: '', // 井号置空
                jl: '10000', // 距离重置为默认值
                wjsjks: (new Date().getFullYear() - 4).toString(), // 完井开始时间重置为默认值
                wjsjjs: new Date().getFullYear().toString() // 完井结束时间重置为默认值
            };

            // 确保区块选项已加载，然后设置默认区块值
            if (this.blockOptions.length > 0) {
                // 区块选项已加载，直接设置默认值
                this.wellSearch.qk = this.qkmc || '';
                console.log('AdjacentWell handleWellDialogOpen - 直接设置区块默认值:', this.wellSearch.qk);

            } else {
                // 区块选项未加载，先加载再设置默认值
                this.getBlockOptions().then(() => {
                    this.wellSearch.qk = this.qkmc || '';
                    console.log('AdjacentWell handleWellDialogOpen - 加载后设置区块默认值:', this.wellSearch.qk);
                });
            }

            // 重置分页和表格数据
            this.wellPagination.pageNum = 1;
            this.hasSearched = false;
            this.wellTableData = [];
            this.wellPagination.total = 0;
            this.wellSelection = []; // 清空选择
        },

        // 获取区块选项
        getBlockOptions() {
            return getQkxl().then(response => {
                // 过滤掉无效的选项
                this.blockOptions = response.data.filter(item => item && item.qk).map(item => ({
                    label: item.qk,
                    value: item.qk
                }));
                console.log('AdjacentWell blockOptions:', this.blockOptions);
                return this.blockOptions;
            });
        },
        // 获取邻井数据
        fetchWellData() {
            this.wellLoading = true;
            console.log('AdjacentWell fetchWellData - qkmc:', this.qkmc);
            const params = {
                pageNum: this.wellPagination.pageNum,
                pageSize: this.wellPagination.pageSize,
                qk: this.wellSearch.qk,
                jh: this.wellSearch.jh || '',
                jl: this.wellSearch.jl || '10000',
                wjsjks: this.wellSearch.wjsjks || '',
                wjsjjs: this.wellSearch.wjsjjs || ''
            };
            console.log('AdjacentWell fetchWellData - params:', params);
            listSj(params).then(res => {
                this.wellTableData = res.rows || [];
                this.wellPagination.total = res.total || 0;
            }).catch(() => {
                this.$message.error('获取邻井数据失败');
            }).finally(() => {
                this.wellLoading = false;
            });
        },
        // 搜索邻井
        handleWellSearch() {
            this.wellPagination.pageNum = 1;
            this.hasSearched = true;
            this.fetchWellData();
        },
        // 重置邻井搜索
        resetWellSearch() {
            this.wellSearch = {
                qk: this.qkmc || '', // 保持区块默认值
                jh: '',
                jl: '10000',
                wjsjks: (new Date().getFullYear() - 4).toString(),
                wjsjjs: new Date().getFullYear().toString()
            };
            this.wellPagination.pageNum = 1;
            this.hasSearched = false;
            this.wellTableData = [];
            this.wellPagination.total = 0;
        },
        // 分页大小变化
        handleSizeChange(size) {
            this.wellPagination.pageSize = size;
            this.wellPagination.pageNum = 1;
            if (this.hasSearched) {
                this.fetchWellData();
            }
        },
        // 翻页
        handleCurrentChange(page) {
            this.wellPagination.pageNum = page;
            if (this.hasSearched) {
                this.fetchWellData();
            }
        },
        // 限制最多选择1个
        checkSelectable(row) {
            if (this.wellSelection.includes(row.jh)) return true;
            return this.wellSelection.length < 1;
        },
        // 选择变化
        handleWellSelectionChange(selection) {
            this.wellSelection = (selection || []).map(item => item.jh);
            if (this.wellSelection.length > 1) {
                const keep = this.wellSelection.slice(0, 1);
                this.$message.warning('最多只能选择1个邻井');
                this.$nextTick(() => {
                    this.$refs.wellTable.clearSelection();
                    this.wellTableData.forEach(row => {
                        if (keep.includes(row.jh)) {
                            this.$refs.wellTable.toggleRowSelection(row, true);
                        }
                    });
                });
                this.wellSelection = keep;
            }
        },
        // 提交选择
        handleWellSubmit() {
            if (this.wellSelection.length === 0) {
                this.$message.warning('请选择邻井');
                return;
            }
            const ljjh = this.wellSelection[0];
            const jh = this.wellInfo.jh || this.$route.query.jh || this.cjqueryParams.jh || '';
            if (!jh) {
                this.$message.error('缺少主井井号');
                return;
            }
            const params = { jh, ljjh };
            this.loading = true;
            ljysByjh(params).then(res => {
                if (res && res.code === 200) {
                    this.$message.success('提交成功');
                    this.fetchWellData();
                    this.wellDialogVisible = false;
                } else {
                    this.$message.error(res.msg || '提交失败');
                }
            }).catch(() => {
                this.$message.error('提交失败');
            }).finally(() => {
                this.loading = false;
            });
        },
        // 取消
        handleWellCancel() {
            this.wellDialogVisible = false;
        },
        handleCjData() {
            this.loading = true;
            listSjCjsjLas(this.cjqueryParams).then(response => {
                this.cjsjLasList = response.rows;
                // 修改: 确保total被正确设置并触发响应式更新
                this.$set(this, 'total', response.total || 0);
            }).finally(() => {
                this.loading = false;
            });
        },
        jscs() {
            const jh = this.wellInfo.jh || this.$route.query.jh;
            this.loading = true;
            const params = {
                jh: jh,

            }
            listSjCjsjZhxs(params).then(response => {
                // 确保 formjscs 对象结构完整，避免覆盖后丢失属性
                if (response.data && typeof response.data === 'object') {
                    this.formjscs = {
                        a1: response.data.a1 || '',
                        a2: response.data.a2 || '',
                        a3: response.data.a3 || '',
                        b1: response.data.b1 || '',
                        b2: response.data.b2 || ''
                    };
                } else {
                    // 如果 response.data 无效，重置为默认值
                    this.formjscs = {
                        a1: '',
                        a2: '',
                        a3: '',
                        b1: '',
                        b2: ''
                    };
                }
                this.title = "计算参数";
                this.openjscs = true;
            }).catch(error => {
                console.error('获取计算参数失败:', error);
                // 出错时重置为默认值
                this.formjscs = {
                    a1: '',
                    a2: '',
                    a3: '',
                    b1: '',
                    b2: ''
                };
            }).finally(() => {
                this.loading = false;
            });
        },
        submitFormjscs() {
            this.formjscs.jh = this.wellInfo.jh || this.$route.query.jh;
            this.$refs.formjscs.validate(valid => {
                if (valid) {
                    this.loading = true;
                    if (this.formjscs.id != null) {
                        updateSjCjsjZhxs(this.formjscs).then(response => {
                            this.$modal.msgSuccess("修改成功");
                            this.openjscs = false;
                        }).finally(() => {
                            this.loading = false;
                        });
                    } else {
                        addSjCjsjZhxs(this.formjscs).then(response => {
                            this.$modal.msgSuccess("新增成功");
                            this.openjscs = false;
                        }).finally(() => {
                            this.loading = false;
                        });
                    }
                }
            });
        },
        js() {
            this.$confirm('确定要计算吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.loading = true;
                const params = {
                    jh: this.wellInfo.jh
                }
                console.log(params, 'params');
                getSjCjsjLas(params).then(response => {
                    if (response.code === 200) {
                        this.$modal.msgSuccess("计算成功");
                    } else {
                        this.$modal.msgError(response.msg || "计算失败");
                    }
                }).catch(error => {
                    console.error('计算失败:', error);
                    this.$modal.msgError("计算失败");
                }).finally(() => {
                    this.loading = false;
                });
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消计算'
                });
            });
        },
        // jscwxs() {
        //     this.$confirm('确定要计算吗?', '提示', {
        //         confirmButtonText: '确定',
        //         cancelButtonText: '取消',
        //         type: 'warning'
        //     }).then(() => {
        //         this.loading = true;
        //         const params = {
        //             jh: this.jh || this.$route.query.jh
        //         }
        //         getJscwxs(params).then(response => {
        //             if (response.code === 200) {
        //                 this.$modal.msgSuccess("计算成功");
        //             } else {
        //                 this.$modal.msgError(response.msg || "计算失败");
        //             }
        //         }).catch(error => {
        //             console.error('计算失败:', error);
        //             this.$modal.msgError("计算失败");
        //         }).finally(() => {
        //             this.loading = false;
        //         });
        //     }).catch(() => {
        //         this.$message({
        //             type: 'info',
        //             message: '已取消计算'
        //         });
        //     });
        // },
        cjsz() {
            this.loading = true;
            const params = {
                jh: this.wellInfo.jh || this.$route.query.jh
            }
            console.log('设置按钮点击，查询参数:', params);
            listSjCjsjBlqzfw(params).then(response => {
                console.log('设置数据查询结果:', response);
                // 确保form对象有默认结构，避免弹窗内容不显示
                this.form = response.data || {
                    zbscmin: '',
                    zbscmax: '',
                    gmmin: '',
                    gmmax: '',
                    zzmdmin: '',
                    zzmdmax: '',
                    jjmin: '',
                    jjmax: ''
                };
                this.open = true;
            }).catch(error => {
                console.error('获取设置数据失败:', error);
                this.$message.error('获取设置数据失败');
                // 即使获取失败，也提供默认的表单结构
                this.form = {
                    zbscmin: '',
                    zbscmax: '',
                    gmmin: '',
                    gmmax: '',
                    zzmdmin: '',
                    zzmdmax: '',
                    jjmin: '',
                    jjmax: ''
                };
                this.open = true;
            }).finally(() => {
                this.loading = false;
            });
        },
        submitForm() {
            this.loading = true;
            // 设置井号到form对象中
            this.form.jh = this.wellInfo.jh || this.$route.query.jh;
            // 根据井号是否存在判断是新增还是修改
            if (this.form.id != null && this.form.id !== '') {
                // 有井号，执行修改操作
                updateSjCjsjBlqzfw(this.form).then(response => {
                    this.$modal.msgSuccess("修改成功");
                    this.open = false;
                    this.handleCjData();
                }).catch(error => {
                    console.error('修改失败:', error);
                    this.$modal.msgError("修改失败");
                }).finally(() => {
                    this.loading = false;
                });
            } else {
                // 没有井号，执行新增操作
                addSjCjsjBlqzfw(this.form).then(response => {
                    this.$modal.msgSuccess("新增成功");
                    this.open = false;
                    this.handleCjData();
                }).catch(error => {
                    console.error('新增失败:', error);
                    this.$modal.msgError("新增失败");
                }).finally(() => {
                    this.loading = false;
                });
            }
        },
        handleExport() {
            this.download('/system/sjCjsjLas/export', {
                ...this.cjqueryParams
            }, `cjsjLas_${new Date().getTime()}.xlsx`)
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.cjqueryParams.pageNum = 1;
            this.handleCjData();
        },
        /** 重置按钮操作 */
        resetQuery() {
            // 如果是通过 props 传入的 jh，则不清空
            if (!this.wellInfo.jh) {
                this.cjqueryParams.jh = '';
            }
            this.resetForm("queryForm");
            this.handleQuery();
        },
        handleImport() {
            this.uploadOpen = true;
        },
        handleFileUploadProgress(event, file, fileList) {
            this.upload.isUploading = true;
            this.importing = true;
        },
        submitFileForm() {
            this.$refs.upload.submit();
        },
        cancelFile() {
            this.uploadOpen = false;
            this.upload.isUploading = false;
            this.$refs.upload.clearFiles();
        },
        handleFileSuccess(response, file, fileList) {
            this.uploadOpen = false;
            this.upload.isUploading = false;
            this.importing = false;
            this.$refs.upload.clearFiles();
            this.$alert(
                "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
                response.msg +
                "</div>",
                "导入结果",
                { dangerouslyUseHTMLString: true }
            );
            this.handleCjData();
        },
        handleImport2() {
            this.uploadOpen2 = true;
        },
        handleFileUploadProgress2(event, file, fileList) {
            this.upload2.isUploading = true;
            this.importing2 = true;
            // 计算上传进度：event.loaded / event.total * 100
            let progress = 0;
            if (event && event.loaded !== undefined && event.total !== undefined && event.total > 0) {
                progress = Math.floor((event.loaded / event.total) * 100);
            } else if (file && file.percentage !== undefined) {
                // 如果 file 对象有 percentage 属性，使用它
                progress = Math.floor(file.percentage);
            }
            this.uploadProgress = progress;
            // 如果进度达到100%，说明文件上传完成，但接口可能还在处理
            if (progress >= 100) {
                this.fileUploadComplete = true;
                this.isUploadingFile = false;
            } else {
                this.isUploadingFile = true;
                this.fileUploadComplete = false;
            }
        },
        submitFileForm2() {
            this.$refs.upload2.submit();
        },
        cancelFile2() {
            this.uploadOpen2 = false;
            this.upload2.isUploading = false;
            this.importing2 = false;
            this.uploadProgress = 0;
            this.isUploadingFile = false;
            this.fileUploadComplete = false;
            this.$refs.upload2.clearFiles();
        },
        handleFileSuccess2(response, file, fileList) {
            this.uploadProgress = 100;
            this.fileUploadComplete = true;
            setTimeout(() => {
                this.uploadOpen2 = false;
                this.upload2.isUploading = false;
                this.importing2 = false;
                this.uploadProgress = 0;
                this.isUploadingFile = false;
                this.fileUploadComplete = false;
                this.$refs.upload2.clearFiles();
                this.$alert(
                    "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
                    response.msg +
                    "</div>",
                    "导入结果",
                    { dangerouslyUseHTMLString: true }
                );
                this.handleCjData();
            }, 500);
        },
        renderTableHeader(h, { column }) {
            return h('el-tooltip', {
                props: {
                    content: column.label,
                    placement: 'top',
                    effect: 'dark'
                }
            }, [h('span', column.label)])
        },
        // 查看详情
        handleView(row) {
            this.viewRowData = row;
            this.viewForm = { ...row };
            this.viewDialogVisible = true;
        },
        handleEdit(row) {
            this.editForm = { ...row };
            this.editOpen = true;
        },
        submitEditForm() {
            this.$refs.editForm.validate(valid => {
                if (valid) {
                    this.loading = true;
                    // 传递完整的对象数据，但只更新 gr 和 ac 字段
                    const updateData = { ...this.editForm };
                    // 确保只更新可编辑的字段
                    updateData.gr = this.editForm.gr;
                    updateData.ac = this.editForm.ac;

                    updateSjCjsjLas(updateData).then(response => {
                        this.$modal.msgSuccess("修改成功");
                        this.editOpen = false;
                        this.handleCjData();
                    }).catch(error => {
                        console.error('修改失败:', error);
                        this.$modal.msgError("修改失败");
                    }).finally(() => {
                        this.loading = false;
                    });
                }
            });
        },
        // 判断列是否可见
        isColumnVisible(prop) {
            // 根据表格字段配置控制列的显示/隐藏
            if (!Array.isArray(this.columns) || this.columns.length === 0) {
                return true; // 如果没有配置，默认显示
            }

            // 查找对应的列配置
            const columnConfig = this.columns.find(col => col.key === prop || col.prop === prop);
            if (columnConfig) {
                return columnConfig.visible !== false;
            }

            // 如果没有找到配置，默认显示
            return true;
        }
    }
};
</script>

<style lang="scss" scoped>
.app-containercj {
    height: calc(100vh - 150px);
    padding: 10px;
    margin-top: -10px;
}

::v-deep .pagination-container {
    padding: 0px 15px !important;
}

.box {
    background-color: #f3f8ff !important;
    margin: 0 15px;
}

::v-deep.el-dialog__header {
    font-size: 16px;
    font-weight: 400;
}

::v-deep .el-dialog__body {
    font-size: 16px;
    font-weight: 400;
    padding: 0px 10px 10px !important;
}

::v-deep .tooltip {
    position: absolute;
    background: #f9f9f9;
    color: #333;
    border: solid 1px #ccc;
    padding: 8px;
    border-radius: 4px;
    pointer-events: none;
}

::v-deep .el-dialog>.el-dialog__header {
    background-color: #f3f8ff !important;
    padding: 10px !important;
}

::v-deep .el-dialog>.el-dialog__body {
    background-color: #f3f8ff !important;
}

::v-deep .el-dialog>.el-dialog__footer {
    background-color: #f3f8ff !important;
    margin-top: -15px;
}

::v-deep .el-table__cell>.cell {
    font-weight: normal;
}

::v-deep .el-table--medium .el-table__cell {
    padding: 5px 0 !important;
}

::v-deep .el-dialog {
    .el-table__cell>.cell {
        font-weight: normal;
    }

    .el-table--medium .el-table__cell {
        padding: 5px 0 !important;
    }
}

::v-deep .el-dialog {
    .el-table__header-wrapper {
        .el-table__header {
            th.el-table__cell {
                padding: 2px 0 !important;
                height: 30px !important;

                .cell {
                    white-space: nowrap;
                    line-height: 30px;
                }
            }
        }
    }
}
</style>

<style scoped>
.table-header {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.el-table .cell {
    white-space: nowrap !important;
}

.el-table th>.cell {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* 自定义全屏加载遮罩 - 模仿 v-loading 样式 */
.custom-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 0;
    margin: 0;
}

.loading-content i {
    font-size: 50px;
    color: #409eff;
    margin-bottom: 16px;
    animation: rotating 2s linear infinite;
}

@keyframes rotating {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 14px;
    color: #409eff;
    margin-bottom: 16px;
    line-height: 1.5;
}

.loading-progress {
    margin-bottom: 12px;
    width: 280px;
}

.loading-progress ::v-deep .el-progress-bar__outer {
    background-color: #e4e7ed;
    border-radius: 100px;
    height: 6px !important;
}

.loading-progress ::v-deep .el-progress-bar__inner {
    border-radius: 100px;
    background-color: #409eff;
    transition: width 0.3s ease;
}

.loading-progress ::v-deep .el-progress__text {
    font-size: 12px;
    color: #606266;
    line-height: 1;
}

.loading-status {
    font-size: 14px;
    color: #606266;
    margin-top: 8px;
    line-height: 1.5;
}

/* 隐藏弹窗中 el-upload 的进度条，但保留文件名 */
::v-deep .el-dialog .el-upload-list__item .el-progress {
    display: none !important;
}

::v-deep .el-dialog .el-upload-list__item .el-progress-bar {
    display: none !important;
}
</style>
