<template>
    <el-dialog v-model="dialogFormVisible" :title="title" width="65%" :append-to-body="true" :before-close="close"
        :close-on-click-modal="false" :lazy="true" draggable>
        <!-- <el-anchor :container="containerRef" direction="vertical" type="default" :offset="30" @click="handleClick">
            <el-anchor-link href="#part1" title="基础信息" />
            <el-anchor-link href="#part2" title="终端信息" />
            <el-anchor-link href="#part3" title="附件材料" />
        </el-anchor> -->
        <!--终端信息录入   基础信息+终端信息+附件材料 -->
        <el-form :model="form" :validate-on-rule-change="false" :scroll-to-error="true" :rules="rules" ref="ruleFormRef"
            label-width="auto" class="form-two">
            <!-- <el-tabs tab-position="left" class="tabs_form" v-model="activeName"> -->
            <el-divider content-position="left">基础信息</el-divider>
            <!-- <div id="part1" class="form-two"> -->
            <el-form-item for="-" label="填报人：" prop="reporter">
                <el-input v-model="form.reporter" autocomplete="off" placeholder="请输入填报人" :disabled="true" />
            </el-form-item>
            <el-form-item for="-" label="填报日期：" prop="reportDate">
                <el-date-picker :disabled="true" style="width: 100%" v-model="form.reportDate" type="date"
                    placeholder="请选择填报日期" />
            </el-form-item>
            <el-form-item for="-" label="填报部门：" prop="orgId">
                <el-input v-model="form.orgId" :disabled="true" autocomplete="off" />
            </el-form-item>
            <el-form-item for="-" label="工程投产日期：" prop="expectedProductionDate">
                <el-date-picker style="width: 100%" v-model="form.expectedProductionDate" type="date"
                    format="YYYY-MM-DD" value-format="YYYY-MM-DD" placeholder="请选择工程投产日期" />
            </el-form-item>
            <el-form-item for="-" label="所在地市：" prop="city">
                <el-select v-model="form.city" clearable style="width: 100%" placeholder="请选择所在地市" filterable>
                    <el-option v-for="item in areaOptionList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <!-- <el-col  :span="12">
                                 <el-form-item for="-" label="用户状态：" prop="userStatus">
                                    <el-select
                                        v-model="form.userStatus"
                                        placeholder="请选择用户状态"
                                        style="width: 100%"
                                    >
                                        <el-option
                                            v-for="(item, index) in userStateList"
                                            :label="item.name"
                                            :value="item.id"
                                            :disabled="item.name != '建设'"
                                            :key="index"
                                        />
                                    </el-select>
                                </el-form-item>
                             -->
            <!-- 
                                 <el-form-item for="-" label="用户名称：" prop="userName">
                                    <el-select
                                        v-model="form.userName"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择用户名称"
                                    >
                                        <el-option
                                            v-for="item in areaOptionList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                           -->
            <!-- </div> -->
            <el-divider content-position="left">终端信息</el-divider>
            <!-- <div id="part2" class="form-two"> -->
            <div class="fixed_upload" v-if="false">
                <el-upload v-model:file-list="form.deviceFilePath" ref="uploadRef" action="" :accept="acceptType"
                    :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('deviceFilePath')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">终端台账信息</el-button>
                    </template>
                </el-upload>
            </div>
            <el-form-item for="-" label="系统电站：" prop="customSubstationFlag">
                <!-- 默认值 开启 -->
                <el-radio-group v-model="form.customSubstationFlag" @change="changeSubstationFlag">
                    <el-radio :value="0">是</el-radio>
                    <el-radio :value="1">否</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item for="-" label="所属供电公司：" prop="powerCompany">
                <el-select v-model="form.powerCompany" clearable style="width: 100%" placeholder="请选择所属供电公司"
                    @change="findSubstationVoltageLevel" filterable>
                    <el-option v-for="item in powerCompanyList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" v-if="form.customSubstationFlag == 0" label="并网变电站：" prop="substation">
                <el-select v-model="form.substation" clearable style="width: 100%" placeholder="请选择并网变电站" filterable
                    @change="changeSubstation" >
                    <el-option v-for="item in substationList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" v-if="form.customSubstationFlag == 1" label="并网变电站：" prop="substationName">
                <el-input v-model="form.substationName" autocomplete="off" placeholder="请输入并网变电站" />
            </el-form-item>
            <el-form-item for="-" label="变电站电压等级：" prop="substationVoltageLevel">
                <el-select v-model="form.substationVoltageLevel" clearable style="width: 100%" placeholder="请选择变压站电压等级" filterable>
                    <el-option v-for="item in voltageLevelList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="经度：" prop="longitude">
                <el-input v-model="form.longitude" :disabled="form.customSubstationFlag == 0" type="text"
                    placeholder="请输入经度" />
            </el-form-item>
            <el-form-item for="-" label="纬度：" prop="latitude">
                <el-input v-model="form.latitude" :disabled="form.customSubstationFlag == 0" type="text"
                    placeholder="请输入纬度" />
            </el-form-item>
            <el-form-item for="-" label="终端型号：" prop="terminalType">
                <el-select v-model="form.terminalType" filterable clearable style="width: 100%" placeholder="请选择终端型号" >
                    <el-option v-for="item in terminalTypeList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>

            <el-form-item for="-" label="终端名称：" prop="monitoringTerminalName">
                <el-input v-model="form.monitoringTerminalName" autocomplete="off" placeholder="请输入终端名称" maxlength="32" show-word-limit clearable/>
            </el-form-item>
            <el-form-item for="-" label="通讯类型：">
                <el-select v-model="form.frontType" clearable style="width: 100%" placeholder="请选择通讯类型" filterable>
                    <el-option v-for="item in frontTypeList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="终端编码：" prop="monitoringTerminalCode">
                <el-input v-model="form.monitoringTerminalCode" autocomplete="off" placeholder="请输入终端编码"
                    @change="encode" maxlength="32" show-word-limit clearable/>
            </el-form-item>
            <el-form-item v-if="false" for="-" label="通讯状态：" prop="communicationStatus">
                <el-select v-model="form.communicationStatus" clearable style="width: 100%" placeholder="请选择通讯状态"
                    :disabled="true" filterable>
                    <el-option v-for="item in communicationStatusList" :key="item.id" :label="item.name"
                        :value="item.id" :disabled="item.id == '1'"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="终端IP：" prop="terminalIp">
                <el-input oninput="value=value.replace(/[^0-9.]/g,'')" v-model="form.terminalIp" autocomplete="off"
                    placeholder="请输入终端IP" />
            </el-form-item>
            <el-form-item for="-" label="端口：" prop="terminalPort">
                <el-input oninput="value=value.replace(/[^0-9.]/g,'')" v-model="form.terminalPort" autocomplete="off"
                    placeholder="请输入端口" />
            </el-form-item>
            <el-form-item for="-" label="投运时间：" prop="commissioningTime">
                <el-date-picker style="width: 100%" v-model="form.commissioningTime" type="datetime"
                    format="YYYY/MM/DD hh:mm:ss" value-format="YYYY-MM-DD hh:mm:ss" placeholder="请选择投运时间" />
            </el-form-item>
            <el-form-item for="-" label="数据更新时间：" prop="dataUpdateTime">
                <el-date-picker :disabled="true" style="width: 100%" v-model="form.dataUpdateTime" type="datetime"
                    placeholder="请选择数据更新时间" />
            </el-form-item>
            <el-form-item for="-" label="所属前置机：" prop="frontEndMachine">
                <el-select v-model="form.frontEndMachine" clearable style="width: 100%" placeholder="请选择所属前置机" filterable>
                    <el-option v-for="item in frontEndMachineList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="监测终端安装位置：" prop="monitoringDeviceInstallationPosition" class="label_over_warp">
                <!-- 电网侧、用户侧 -->
                <el-select v-model="form.monitoringDeviceInstallationPosition" clearable style="width: 100%"
                    placeholder="请选择监测终端安装位置" filterable>
                    <el-option v-for="item in monitoringDeviceInstallationPositionList" :key="item.id"
                        :label="item.name" :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="识别码：" prop="identificationCode">
                <el-input v-model="form.identificationCode" autocomplete="off" placeholder="请输入识别码" />
            </el-form-item>
            <el-form-item for="-" label="终端秘钥：" prop="terminalSecretKey">
                <el-input v-model="form.terminalSecretKey" autocomplete="off" placeholder="请输入终端秘钥" />
            </el-form-item>
            <el-form-item for="-" label="终端模型：" prop="terminalModel">
                <el-select v-model="form.terminalModel" clearable style="width: 100%" placeholder="请选择终端模型" filterable>
                    <el-option v-for="item in terminalModelList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="数据类型：" prop="dataType">
                <el-select v-model="form.dataType" clearable style="width: 100%" placeholder="请选择数据类型" filterable>
                    <el-option v-for="item in dataTypeList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="终端接线方式类型：" prop="terminalWiringMethodType" class="label_over_warp">
                <el-select v-model="form.terminalWiringMethodType" clearable style="width: 100%"
                    placeholder="请选择终端接线方式类型" filterable>
                    <el-option v-for="item in terminalWiringMethodTypeList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="厂家：" prop="manufacturer">
                <el-select v-model="form.manufacturer" clearable style="width: 100%" placeholder="请选择厂家" filterable>
                    <el-option v-for="item in manufacturerList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="本次终端检测时间：" prop="currentTerminalDetectionTime" class="label_over_warp">
                <el-date-picker style="width: 100%" v-model="form.currentTerminalDetectionTime" type="datetime"
                    placeholder="请选择本次终端检测时间" :disabled-date="disableStartDate" />
            </el-form-item>
            <el-form-item for="-" label="下次终端定检时间：" prop="nextTerminalInspectionTime" class="label_over_warp">
                <el-date-picker style="width: 100%" v-model="form.nextTerminalInspectionTime" type="datetime"
                    placeholder="请选择下次终端定检时间" :disabled-date="disableEndDate" />
            </el-form-item>

            <el-form-item for="-" label="电压互感器类型：" prop="voltageTransformerType">
                <el-select v-model="form.voltageTransformerType" clearable style="width: 100%" placeholder="请选择电压互感器类型" filterable>
                    <el-option v-for="item in voltageTransformerTypeList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="中性点接线方式：" prop="neutralPointWiringMethod">
                <el-select v-model="form.neutralPointWiringMethod" clearable style="width: 100%"
                    placeholder="请选择中性点接线方式" filterable>
                    <el-option v-for="item in neutralPointWiringMethodList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="厂家终端编号：" prop="manufacturerDeviceNumber">
                <el-input v-model="form.manufacturerDeviceNumber" autocomplete="off" placeholder="请输入厂家终端编号" />
            </el-form-item>

            <el-form-item for="-" label="SIM卡号：" prop="simCardNumber">
                <el-input v-model="form.simCardNumber" autocomplete="off" placeholder="请输入SIM卡号" />
            </el-form-item>
            <el-form-item for="-" label="对时功能：" prop="timeSyncFunction">
                <!-- 默认值 开启 -->
                <el-radio-group v-model="form.timeSyncFunction">
                    <el-radio :value="1">开启</el-radio>
                    <el-radio :value="0">关闭</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item for="-" label="电度功能：" prop="electroplatingFunction">
                <!-- 默认 关闭 下拉框 -->
                <el-select v-model="form.electroplatingFunction" clearable style="width: 100%" placeholder="请选择电度功能" filterable>
                    <el-option v-for="item in electroplatingFunctionList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="召唤标志：" prop="summonFlag">
                <el-select v-model="form.summonFlag" clearable style="width: 100%" placeholder="请选择召唤标志" filterable>
                    <el-option v-for="item in summonFlagList" :key="item.id" :label="item.name"
                        :value="item.id"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item for="-" label="告警功能：" prop="alarmFunction">
                <el-radio-group v-model="form.alarmFunction">
                    <el-radio value="1">是</el-radio>
                    <el-radio value="0">否</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item for="-" label="合同号：" prop="contractNumber">
                <el-input v-model="form.contractNumber" autocomplete="off" placeholder="请输入合同号" />
            </el-form-item>
            <!-- </div> -->
            <el-divider content-position="left">附件材料</el-divider>
            <el-form-item for="-" label="信息安全检测报告：" class="uploadFile" prop="informationSecurityTestReport">
                <el-upload v-model:file-list="form.informationSecurityTestReport" ref="uploadRef" action=""
                    :accept="acceptType" :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('informationSecurityTestReport')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">上传文件</el-button>
                    </template>
                </el-upload>
            </el-form-item>
            <el-form-item v-if="false" for="-" label="验收检验报告单：" class="uploadFile"
                prop="acceptanceInspectionReportSingle">
                <el-upload v-model:file-list="form.acceptanceInspectionReportSingle" ref="uploadRef" action=""
                    :accept="acceptType" :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('acceptanceInspectionReportSingle')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">上传文件</el-button>
                    </template>
                </el-upload>
            </el-form-item>
            <el-form-item for="-" label="验收检验报告：" class="uploadFile" prop="acceptanceInspectionReport">
                <el-upload v-model:file-list="form.acceptanceInspectionReport" ref="uploadRef" action=""
                    :accept="acceptType" :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('acceptanceInspectionReport')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">上传文件</el-button>
                    </template>
                </el-upload>
            </el-form-item>
            <el-form-item for="-" label="型式实验报告：" class="uploadFile" prop="typeExperimentReport">
                <el-upload v-model:file-list="form.typeExperimentReport" ref="uploadRef" action="" :accept="acceptType"
                    :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('typeExperimentReport')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">上传文件</el-button>
                    </template>
                </el-upload>
            </el-form-item>
            <el-form-item for="-" label="出厂检验报告：" class="uploadFile" prop="factoryInspectionReport">
                <el-upload v-model:file-list="form.factoryInspectionReport" ref="uploadRef" action=""
                    :accept="acceptType" :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('factoryInspectionReport')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">上传文件</el-button>
                    </template>
                </el-upload>
            </el-form-item>
            <el-form-item for="-" label="性能检测报告：" class="uploadFile" prop="performanceTestReport">
                <el-upload v-model:file-list="form.performanceTestReport" ref="uploadRef" action="" :accept="acceptType"
                    :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('performanceTestReport')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">上传文件</el-button>
                    </template>
                </el-upload>
            </el-form-item>
            <el-form-item for="-" label="其他附件：" class="uploadFile" prop="otherAttachments">
                <el-upload v-model:file-list="form.otherAttachments" ref="uploadRef" action="" :accept="acceptType"
                    :limit="1" :on-exceed="handleExceed" :on-change="choose" :auto-upload="false"
                    :on-progress="uploadFileName('otherAttachments')" :on-remove="removeFile">
                    <template #trigger>
                        <el-button type="primary">上传文件</el-button>
                    </template>
                </el-upload>
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="close()">取消</el-button>
                <el-button type="primary" @click="confirmForm(true)" :loading="loading">保存</el-button>
                <el-button type="primary" @click="confirmForm(false)" :loading="loading"
                    v-if="importType != 1">提交审批</el-button>
            </div>
        </template>
    </el-dialog>
</template>
<script lang="ts" setup>
import { ref, onMounted, reactive, defineExpose, defineProps, defineEmits, watch, onUnmounted } from 'vue'
// import { upload, insertTerminal, updateTerminal } from '@/api/process-boot/terminal'
import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus'
import { genFileId, ElMessage } from 'element-plus'
import { useDictData } from '@/stores/dictData'
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
import { queryByAllCode } from '@/api/system-boot/dictTree'
import { useAdminInfo } from '@/stores/adminInfo'
import { uploadFile } from '@/api/system-boot/file'
import {
    addTerminalFormData,
    getSubstationVoltageLevel,
    updateTerminalFormData
} from '@/api/supervision-boot/terminal/index'
import { getAllDeptList } from '@/api/common'
import { getTerminalDetailsById } from '@/api/supervision-boot/terminal/index'
import { nodeAllList } from '@/api/device-boot/Business'
import { getDeviceTypeList } from '@/api/device-boot/modelManage'
const emits = defineEmits(['onSubmit'])
const dictData = useDictData()
const dialogFormVisible = ref(false)
const form: any = ref({})
const ruleFormRef: any = ref(null)
const title = ref('')
const loading = ref(false)
// acceptType .xls,.xlsx
const acceptType = ''
//字典获取所在地市
const areaOptionList = dictData.getBasicData('jibei_area')
//字典获取电压互感器类型
const voltageTransformerTypeList = dictData.getBasicData('Voltage_Transformer')
//字典获取终端接线方式类型
const terminalWiringMethodTypeList = dictData.getBasicData('Dev_Connect')
//字典获取中性点接线方式
const neutralPointWiringMethodList = dictData.getBasicData('Neutral_Point')
//字典获取厂家
const manufacturerList = dictData.getBasicData('Dev_Manufacturers')
//字典获取终端型号
//const terminalTypeList = dictData.getBasicData('Dev_Type')
const terminalTypeList = ref([])
//字典获取数据类型
const dataTypeList = [
    {
        id: '0',
        name: '暂态系统'
    },
    {
        id: '1',
        name: '稳态系统'
    },
    {
        id: '2',
        name: '两个系统'
    }
]
//字典获取电压等级
const voltageLevelList = dictData.getBasicData('Dev_Voltage_Stand')
//用户状态数组
const userStateList = reactive([
    {
        name: '可研',
        id: '0'
    },
    {
        name: '建设',
        id: '1'
    },
    {
        name: '运行',
        id: '2'
    },
    {
        name: '退运',
        id: '3'
    }
])
//定义终端模型下拉框数据
const terminalModelList = [
    {
        id: '0',
        name: '虚拟终端'
    },
    {
        id: '1',
        name: '实际终端'
    },
    {
        id: '2',
        name: '离线'
    }
]
const substationList: any = ref([])
//字典获取通讯类型
const frontTypeList = dictData.getBasicData('Front_Type', ['CLD', '61850'])
//console.log("🚀 ~ frontTypeList:", frontTypeList)
//定义通讯状态下拉框数据
const communicationStatusList = [
    {
        id: '0',
        name: '中断'
    },
    {
        id: '1',
        name: '正常'
    }
]
//定义监测终端安装位置下拉框数据
const monitoringDeviceInstallationPositionList = [
    {
        id: '0',
        name: '电网侧'
    },
    {
        id: '1',
        name: '用户侧'
    }
]
//定义召唤标志下拉框数据
const summonFlagList = [
    {
        id: '0',
        name: '周期触发'
    },
    {
        id: '1',
        name: '变位触发'
    }
]
//定义电镀功能下拉框数据
const electroplatingFunctionList = [
    {
        id: 0,
        name: '关闭'
    },
    {
        id: 1,
        name: '开启'
    }
]
//开始时间不能大于结束时间
const disableStartDate = (time: any) => {
    if (time && form.value.nextTerminalInspectionTime) {
        return time.getTime() > new Date(form.value.nextTerminalInspectionTime).getTime()
    } else {
        return false
    }
}
//结束时间不能小于开始时间
const disableEndDate = (time: any) => {
    if (time && form.value.currentTerminalDetectionTime) {
        return time.getTime() <= new Date(form.value.currentTerminalDetectionTime).getTime() - 8.64e7
    } else {
        return false
    }
}
//获取登陆用户姓名和部门
const adminInfo = useAdminInfo()
//获取所属前置机数据
const frontEndMachineList: any = ref([])
const getFrontEndMachineList = () => {
    nodeAllList().then(res => {
        frontEndMachineList.value = res.data
        form.value.frontEndMachine = res.data[0].id
    })
}
const changeSubstationFlag = () => {
    //处理并网变电站手都输入/下拉数据
    if (form.value.customSubstationFlag == 0) {
        form.value.substationName = substationList.value.find((item: any) => {
            return form.value.substation == item.id
        })?.name

    } else {
        form.value.substation = ''
        form.value.substationName = ''
        form.value.substationVoltageLevel = voltageLevelList[0].id
       
    }
}
watch(
    () => form.value.substation,
    (val, oldVal) => {
        if (val) {
            form.value.substationName = substationList.value.find((item: any) => {
                return form.value.substation == item.id
            })?.name
        }
    },
    {
        immediate: true,
        deep: true
    }
)
getFrontEndMachineList()
//定义所属供电公司数据
const powerCompanyList: any = ref([])
//获取所属供电公司，区域列表第三层数据
const getPowerCompanyList = async (flag: any) => {
    getAllDeptList().then(res => {
        powerCompanyList.value = res.data[0].children[0].children
        if (flag) {

            getSubstationVoltageLevel({
                orgIds: [
                    powerCompanyList.value.find(
                        item => item.name == form.value.supervisionTempDeviceReport.powerCompany
                    ).id
                ]
            }).then(res => {
                substationList.value = res.data
            })
        } else {
            form.value.powerCompany = powerCompanyList.value[0]?.id
            findSubstationVoltageLevel()
            setTimeout(() => {
                changeSubstation()
            }, 100)
        }
    })
}
//根据所选供电公司查询所选获取变电站与变电站电压等级

const findSubstationVoltageLevel = async () => {
    getSubstationVoltageLevel({ orgIds: [form.value.powerCompany] }).then(res => {
        substationList.value = res.data
        form.value.latitude = substationList.value[0]?.lat
        form.value.longitude = substationList.value[0]?.lng
        form.value.substation = substationList.value[0]?.id
        form.value.substationVoltageLevel = substationList.value[0]?.voltageLevel
    })
}
//变电站选择的时候切换变电站电压等级
const changeSubstation = async () => {
    let obj = substationList.value.find((item: any) => item.id == form.value.substation)

    form.value.latitude = obj?.lat
    form.value.longitude = obj?.lng
    form.value.substationVoltageLevel = obj?.voltageLevel
}
const resetForm: any = async () => {
    form.value = {
        reporter: '', //填报人
        reportDate: new Date(), //填报日期
        orgId: '', //填报部门
        expectedProductionDate: '', //工程投产日期
        city: areaOptionList[0].id, //所在地市
        userStatus: userStateList[1].id, //用户状态
        userName: '', //用户名称
        userId: '',
        customSubstationFlag: 0, //电站类型
        acceptanceInspectionReport: [], //验收检验报告
        // acceptanceInspectionReportSingle: [], //验收检验报告单
        deviceFilePath: [], //终端台账信息
        factoryInspectionReport: [], //出厂检验报告
        informationSecurityTestReport: [], //信息安全检测报告
        otherAttachments: [], //其他附件
        performanceTestReport: [], //性能检测报告
        typeExperimentReport: [], //型式实验报告
        alarmFunction: '0', //告警功能
        commissioningTime: '', //投运时间
        communicationStatus: communicationStatusList[0].id, //	通讯状态
        frontType: frontTypeList[1].id, ///通讯类型
        contractNumber: '', //合同号
        dataType: dataTypeList[2].id, //数据类型
        dataUpdateTime: new Date(), //	数据更新时间
        electroplatingFunction: electroplatingFunctionList[0].id, //电镀功能
        frontEndMachine: frontEndMachineList.value[0]?.id, //所属前置机
        identificationCode: '', //	识别码
        latitude: '', //纬度
        longitude: '', //经度
        manufacturer: manufacturerList[0].id, //厂家
        manufacturerDeviceNumber: '', //	厂家终端编号
        monitoringDeviceInstallationPosition: monitoringDeviceInstallationPositionList[0].id, //监测终端安装位置
        monitoringTerminalCode: '', //终端编码
        monitoringTerminalName: '', //终端名称
        neutralPointWiringMethod: neutralPointWiringMethodList[0].id, //	中性点接线方式
        currentTerminalDetectionTime: new Date(), //本次终端检测时间
        nextTerminalInspectionTime: new Date().getTime() + 365 * 5 * 24 * 3600 * 1000, //	下次终端定检时间
        powerCompany: powerCompanyList[0]?.value.id, //所属供电公司
        simCardNumber: '', //SIM卡号
        substation: '', //	并网变电站
        substationVoltageLevel: voltageLevelList[0].id, //	变电站电压等级
        summonFlag: summonFlagList[0].id, //	召唤标志
        terminalIp: '', //终端IP
        terminalModel: terminalModelList[1].id, //终端模型
        terminalPort: '102', //端口
        terminalSecretKey: '', //终端秘钥
        terminalType: terminalTypeList[0]?.id, //	终端型号
        terminalWiringMethodType: terminalWiringMethodTypeList[0].id, //	终端接线方式类型
        timeSyncFunction: 0, //	对时功能
        voltageTransformerType: voltageTransformerTypeList[0].id //电压互感器类型
    }
    form.value.reporter = adminInfo.$state.name
    form.value.orgId = adminInfo.$state.deptName
    changeSubstationFlag()
}
//初始化数据
// resetForm()
//终端信息表单格式
const devReportForm: any = ref({
    reporter: '', //填报人
    reportDate: new Date(), //填报日期
    orgId: '', //填报部门
    expectedProductionDate: '', //工程投产日期
    city: areaOptionList[0].name, //所在地市
    userStatus: userStateList[1].id, //用户状态
    userName: '', //用户名称
    userId: '',
    acceptanceInspectionReport: [], //验收检验报告
    // acceptanceInspectionReportSingle: [], //验收检验报告单
    deviceFilePath: [], //终端台账信息
    factoryInspectionReport: [], //出厂检验报告
    informationSecurityTestReport: [], //信息安全检测报告
    otherAttachments: [], //其他附件
    performanceTestReport: [], //性能检测报告
    typeExperimentReport: [], //型式实验报告
    //终端信息实体
    supervisionTempDeviceReportParam: {
        customSubstationFlag: 0, //电站类型
        substationName: '', //并网变电站名称
        alarmFunction: '0', //告警功能
        commissioningTime: '', //投运时间
        communicationStatus: communicationStatusList[0].id, //	通讯状态
        frontType: frontTypeList[1].id, ///通讯类型
        contractNumber: '', //合同号
        currentTerminalDetectionTime: '', //本次终端检测时间
        dataType: dataTypeList[2].id, //数据类型
        dataUpdateTime: new Date(), //	数据更新时间
        electroplatingFunction: electroplatingFunctionList[0].id, //电镀功能
        frontEndMachine: frontEndMachineList.value[0]?.id, //所属前置机
        identificationCode: '', //	识别码
        latitude: '', //纬度
        longitude: '', //经度
        manufacturer: manufacturerList[0].id, //厂家
        manufacturerDeviceNumber: '', //	厂家终端编号
        monitoringDeviceInstallationPosition: monitoringDeviceInstallationPositionList[0].id, //监测终端安装位置
        monitoringTerminalCode: '', //终端编码
        monitoringTerminalName: '', //终端名称
        neutralPointWiringMethod: neutralPointWiringMethodList[0].id, //	中性点接线方式
        nextTerminalInspectionTime: '', //	下次终端定检时间
        powerCompany: powerCompanyList.value[0]?.id, //所属供电公司
        simCardNumber: '', //SIM卡号
        substation: '', //	并网变电站
        substationVoltageLevel: voltageLevelList[0].id, //	变电站电压等级
        summonFlag: summonFlagList[0].id, //	召唤标志
        terminalIp: '', //终端IP
        terminalModel: terminalModelList[1].id, //终端模型
        terminalPort: '', //端口
        terminalSecretKey: '', //终端秘钥
        terminalType: terminalTypeList[0]?.id, //	终端型号
        terminalWiringMethodType: terminalWiringMethodTypeList[0].id, //	终端接线方式类型
        timeSyncFunction: 0, //	对时功能
        voltageTransformerType: voltageTransformerTypeList[0].id //电压互感器类型
    }
})
// 经度正则表达式
const longitudeReg = /^[-+]?((180(\.0{1,10})?)|(1[0-7][0-9](\.\d{1,10})?)|([1-9]?\d(\.\d{1,10})?)|(0(\.\d{1,10})?))$/

// 纬度正则表达式
const latitudeReg = /^[-+]?((90(\.0{1,10})?)|([1-8]?\d(\.\d{1,10})?)|(0(\.\d{1,10})?))$/
//定义校验规则
const rules = ref({
    //基础信息
    reporter: [
        {
            required: true,
            message: '请输入填报人',
            trigger: 'blur'
        }
    ],
    reportDate: [
        {
            required: true,
            message: '请选择填报日期',
            trigger: 'change'
        }
    ],
    orgId: [
        {
            required: true,
            message: '请选择填报部门',
            trigger: 'change'
        }
    ],
    expectedProductionDate: [
        {
            required: true,
            message: '请选择工程投产日期',
            trigger: 'change'
        }
    ],
    city: [
        {
            required: true,
            message: '请选择所在地市',
            trigger: 'change'
        }
    ],
    userStatus: [
        {
            required: true,
            message: '请选择用户状态',
            trigger: 'change'
        }
    ],
    userName: [
        {
            required: true,
            message: '请选择用户名称',
            trigger: 'change'
        }
    ],
    //终端信息
    customSubstationFlag: [
        {
            required: true,
            message: '请选择电站类型',
            trigger: 'change'
        }
    ],
    powerCompany: [
        {
            required: true,
            message: '请选择所属供电公司',
            trigger: 'change'
        }
    ],
    substation: [
        {
            required: true,
            message: '请选择并网变电站',
            trigger: 'change'
        }
    ],
    substationName: [
        {
            required: true,
            message: '请输入并网变电站',
            trigger: 'blur'
        }
    ],
    substationVoltageLevel: [
        {
            required: true,
            message: '请选择变电站电压等级',
            trigger: 'change'
        }
    ],
    monitoringTerminalCode: [
        {
            required: true,
            message: '请输入终端编码',
            trigger: 'blur'
        }
    ],
    monitoringTerminalName: [
        {
            required: true,
            message: '请输入监测名称',
            trigger: 'blur'
        }
    ],
    voltageTransformerType: [
        {
            required: true,
            message: '请选择电压互感器类型',
            trigger: 'change'
        }
    ],
    terminalWiringMethodType: [
        {
            required: true,
            message: '请选择终端接线方式类型',
            trigger: 'change'
        }
    ],
    neutralPointWiringMethod: [
        {
            required: true,
            message: '请选择中性点接线方式',
            trigger: 'change'
        }
    ],
    manufacturer: [
        {
            required: true,
            message: '请选择厂家',
            trigger: 'change'
        }
    ],
    manufacturerDeviceNumber: [
        {
            required: true,
            message: '请输入厂家终端编号',
            trigger: 'blur'
        }
    ],
    terminalIp: [
        {
            required: true,
            message: '请输入终端IP',
            trigger: 'blur'
        }
    ],
    terminalPort: [
        {
            required: true,
            message: '请输入端口',
            trigger: 'blur'
        }
    ],
    terminalType: [
        {
            required: true,
            message: '请选择终端型号',
            trigger: 'change'
        }
    ],
    frontEndMachine: [
        {
            required: true,
            message: '请选择所属前置机',
            trigger: 'change'
        }
    ],
    currentTerminalDetectionTime: [
        {
            required: true,
            message: '请选择本次终端检测时间',
            trigger: 'change'
        }
    ],
    nextTerminalInspectionTime: [
        {
            required: true,
            message: '请选择下次终端定检时间',
            trigger: 'change'
        }
    ],
    identificationCode: [
        {
            required: false,
            message: '请输入识别码',
            trigger: 'blur'
        }
    ],
    terminalSecretKey: [
        {
            required: false,
            message: '请输入终端秘钥',
            trigger: 'blur'
        }
    ],
    longitude: [
        {
            required: true,
            message: '请输入经度',
            trigger: 'blur'
        },
        {
            validator: (rule, value, callback) => {
                if (!longitudeReg.test(value)) {
                    callback(new Error('请输入有效的经度'))
                } else {
                    callback()
                }
            },
            trigger: 'change'
        }
    ],
    latitude: [
        {
            required: true,
            message: '请输入纬度',
            trigger: 'blur'
        },
        {
            validator: (rule, value, callback) => {
                if (!latitudeReg.test(value)) {
                    callback(new Error('请输入有效的纬度'))
                } else {
                    callback()
                }
            },
            trigger: 'change'
        }
    ],
    terminalModel: [
        {
            required: false,
            message: '请选择终端模型',
            trigger: 'change'
        }
    ],
    communicationStatus: [
        {
            required: false,
            message: '请选择通讯状态',
            trigger: 'change'
        }
    ],
    simCardNumber: [
        {
            required: false,
            message: '请输入SIM卡号',
            trigger: 'blur'
        }
    ],
    commissioningTime: [
        {
            required: true,
            message: '请选择投运时间',
            trigger: 'change'
        }
    ],
    dataUpdateTime: [
        {
            required: false,
            message: '请选择数据更新时间',
            trigger: 'change'
        }
    ],
    timeSyncFunction: [
        {
            required: false,
            message: '请选择对时功能',
            trigger: 'change'
        }
    ],
    electroplatingFunction: [
        {
            required: false,
            message: '请选择电度功能',
            trigger: 'change'
        }
    ],
    monitoringDeviceInstallationPosition: [
        {
            required: true,
            message: '请选择监测终端安装位置',
            trigger: 'change'
        }
    ],
    summonFlag: [
        {
            required: false,
            message: '请选择召唤标志',
            trigger: 'change'
        }
    ],
    alarmFunction: [
        {
            required: false,
            message: '请选择告警功能',
            trigger: 'change'
        }
    ],
    contractNumber: [
        {
            required: false,
            message: '请输入合同号',
            trigger: 'blur'
        }
    ],
    informationSecurityTestReport: [
        {
            required: true,
            message: '请上传信息安全检测报告',
            trigger: 'change'
        }
    ],
    acceptanceInspectionReportSingle: [
        {
            required: true,
            message: '请上传验收检验报告单',
            trigger: 'change'
        }
    ],
    acceptanceInspectionReport: [
        {
            required: true,
            message: '请上传验收检验报告',
            trigger: 'change'
        }
    ],
    typeExperimentReport: [
        {
            required: true,
            message: '请上传型式实验报告',
            trigger: 'change'
        }
    ],
    factoryInspectionReport: [
        {
            required: true,
            message: '请上传出厂检验报告',
            trigger: 'change'
        }
    ],
    performanceTestReport: [
        {
            required: true,
            message: '请上传性能检测报告',
            trigger: 'change'
        }
    ],
    otherAttachments: [
        {
            required: false,
            message: '请上传其他附件',
            trigger: 'change'
        }
    ]
})
watch(
    () => form.value,
    (val, oldVal) => {
        //form数据变化时处理格式，根据tab切换判断处理的对象实体
        //终端信息
        if (val) {
            for (let key in val) {
                if (devReportForm.value.hasOwnProperty(key)) {
                    devReportForm.value[key] = val[key] // 对相同的key进行赋值
                } else if (devReportForm.value.supervisionTempDeviceReportParam.hasOwnProperty(key)) {
                    devReportForm.value.supervisionTempDeviceReportParam[key] = val[key]
                }
            }
            //处理填报日期
            devReportForm.value.reportDate = window.XEUtils.toDateString(val.reportDate, 'yyyy-MM-dd')
            //处理本次/下次终端检测时间/数据更新时间格式
            devReportForm.value.supervisionTempDeviceReportParam = {
                ...devReportForm.value.supervisionTempDeviceReportParam,
                currentTerminalDetectionTime: window.XEUtils.toDateString(
                    val.currentTerminalDetectionTime,
                    'yyyy-MM-dd HH:mm:ss'
                ),
                nextTerminalInspectionTime: window.XEUtils.toDateString(
                    val.nextTerminalInspectionTime,
                    'yyyy-MM-dd HH:mm:ss'
                ),
                dataUpdateTime: window.XEUtils.toDateString(val.dataUpdateTime, 'yyyy-MM-dd HH:mm:ss')
            }
        }
    },
    {
        deep: true,
        immediate: true
    }
)
onMounted(() => {
    //初始化数据
    resetForm()
    console.log()
})
// 上传报告
const uploadRef = ref()
const handleExceed: UploadProps['onExceed'] = files => {
    uploadRef.value!.clearFiles()
    const file = files[0] as UploadRawFile
    file.uid = genFileId()
    uploadRef.value!.handleStart(file)
}
let uploadName = ref('')
//上传报告字段名称
const uploadFileName = val => {
    uploadName.value = val
}
//移除文件上传
const removeFile = (file: any, uploadFiles: any) => {
    console.log(file, uploadFiles)
}

// 终端台账信息
const deviceFilePath = ref('')
//验收检验报告单
// const acceptanceInspectionReportSingle = ref('')
//验收检验报告
const acceptanceInspectionReport = ref('')
//型式实验报告
const typeExperimentReport = ref('')
//出厂检验报告
const factoryInspectionReport = ref('')
//性能检测报告
const performanceTestReport = ref('')
//信息安全检测报告
const informationSecurityTestReport = ref('')
//其他附件
const otherAttachments = ref('')
const choose = (e: any) => {
    uploadFile(e.raw, '/supervision/').then(res => {
        //终端台账信息
        if (uploadName.value == 'deviceFilePath') {
            deviceFilePath.value = res.data.name
        }
        //验收检验报告单
        // else if (uploadName.value == 'acceptanceInspectionReportSingle') {
        //     acceptanceInspectionReportSingle.value = res.data.name
        // }
        //验收检验报告
        else if (uploadName.value == 'acceptanceInspectionReport') {
            acceptanceInspectionReport.value = res.data.name
        }
        //型式实验报告
        else if (uploadName.value == 'typeExperimentReport') {
            typeExperimentReport.value = res.data.name
        }
        //出厂检验报告
        else if (uploadName.value == 'factoryInspectionReport') {
            factoryInspectionReport.value = res.data.name
        }
        //性能检测报告
        else if (uploadName.value == 'performanceTestReport') {
            performanceTestReport.value = res.data.name
        }
        //信息安全检测报告
        else if (uploadName.value == 'informationSecurityTestReport') {
            informationSecurityTestReport.value = res.data.name
        }
        //其他附件
        else if (uploadName.value == 'otherAttachments') {
            otherAttachments.value = res.data.name
        }
    })
}
//设置工程投产日期时间选择范围不能<今天
const disabledDate = time => {
    return time.getTime() < Date.now() - 8.64e7 // 8.64e7 毫秒数代表一天
}
const importType = ref(null)
const resendId = ref('')
const open = async (row: any) => {
   
    let flag = row.row ? true : false
    importType.value = null
    if (!flag) await getPowerCompanyList(false)
    title.value = row.title
    dialogFormVisible.value = true

    const params = {
        pageNum: 1,
        pageSize: 100,
        searchState: '',
        searchValue: ''
    }
     await getDeviceTypeList(params).then((res: any) => {
        terminalTypeList.value = res.data.records.map((item: any) => ({
                id: item.id,
                name: item.name
        }))
     })

    if (row.row) {
        resendId.value = row.row.id
        importType.value = row.row.importType
        await getTerminalDetailsById({ id: row.row.id }).then((res: any) => {
            form.value = { customSubstationFlag: 0, ...res.data, ...res.data.supervisionTempDeviceReport }
            getPowerCompanyList(true)
            let list = [
                'deviceFilePath',
                // 'acceptanceInspectionReportSingle',
                'acceptanceInspectionReport',
                'typeExperimentReport',
                'factoryInspectionReport',
                'performanceTestReport',
                'informationSecurityTestReport',
                'otherAttachments'
            ]
            for (let k of list) {
                if (res.data[k]) {
                    form.value[k] = [
                        {
                            name: res.data[k].split('/')[2]
                        }
                    ]
                } else {
                    form.value[k] = []
                }
            }
            form.value.id = row.row.id
            deviceFilePath.value = res.data.deviceFilePath || ''
            // acceptanceInspectionReportSingle.value = res.data.acceptanceInspectionReportSingle
            acceptanceInspectionReport.value = res.data.acceptanceInspectionReport || ''
            typeExperimentReport.value = res.data.typeExperimentReport || ''
            factoryInspectionReport.value = res.data.factoryInspectionReport || ''
            performanceTestReport.value = res.data.performanceTestReport || ''
            informationSecurityTestReport.value = res.data.informationSecurityTestReport || ''
            otherAttachments.value = res.data.otherAttachments || ''
            form.value.reporter = adminInfo.$state.name
            form.value.orgId = adminInfo.$state.deptName
        })
    }
}
const close = async () => {
    //重置表单内容
    //取消表单校验状态
    ruleFormRef.value && ruleFormRef.value.resetFields()
    dialogFormVisible.value = false
    emits('onSubmit')
    resetForm()
}
//提交
const confirmForm = async (flag: boolean) => {
    loading.value = true
    if (flag) {
        // 提交终端信息

        //整理上传文件的数据
        devReportForm.value.reporter = adminInfo.$state.id
        devReportForm.value.orgId = adminInfo.$state.deptId
        let confirmFormData = JSON.parse(JSON.stringify(devReportForm.value))
        //提交终端信息 form.value
        confirmFormData = {
            ...confirmFormData,
            acceptanceInspectionReport:
                form.value.acceptanceInspectionReport.length == 0 ? '' : acceptanceInspectionReport.value, //验收检验报告
            // acceptanceInspectionReportSingle: acceptanceInspectionReportSingle.value, //验收检验报告单
            deviceFilePath: form.value.deviceFilePath.length == 0 ? '' : deviceFilePath?.value, //终端台账信息
            factoryInspectionReport:
                form.value.factoryInspectionReport.length == 0 ? '' : factoryInspectionReport.value, //出厂检验报告
            informationSecurityTestReport:
                form.value.informationSecurityTestReport.length == 0 ? '' : informationSecurityTestReport.value, //信息安全检测报告
            performanceTestReport: form.value.performanceTestReport.length == 0 ? '' : performanceTestReport.value, //性能检测报告
            typeExperimentReport: form.value.typeExperimentReport.length == 0 ? '' : typeExperimentReport.value, //型式实验报告
            otherAttachments: form.value.otherAttachments.length == 0 ? '' : otherAttachments?.value //其他附件
        }

        confirmFormData.saveOrCheckflag = '1'
        confirmFormData.reporter = adminInfo.$state.id
        confirmFormData.orgId = adminInfo.$state.deptId
        confirmFormData.importType = importType.value
        confirmFormData.supervisionTempDeviceReportParam.commissioningTime =
            confirmFormData?.supervisionTempDeviceReportParam?.commissioningTime?.replace('T', ' ') || ''

        let powerCompanID = powerCompanyList.value.filter(item => item.name == form.value.powerCompany)[0]?.id
        confirmFormData.supervisionTempDeviceReportParam.terminalIp = form.value.terminalIp
        confirmFormData.supervisionTempDeviceReportParam.powerCompany = powerCompanID
            ? powerCompanID
            : form.value.powerCompany

        if (title.value != '终端信息') confirmFormData.id = resendId.value

        await addTerminalFormData(confirmFormData).then((res: any) => {
            if (res.code == 'A0000') {
                ElMessage({
                    message: '保存成功!',
                    type: 'success'
                })
                ruleFormRef.value.resetFields()
                resetForm()
                close()
            }
        }).catch(() => {
            loading.value = false
        })
    } else {
        // 提交终端信息
        ruleFormRef.value.validate(async (valid) => {
            if (valid) {
                //整理上传文件的数据
                devReportForm.value.reporter = adminInfo.$state.id
                devReportForm.value.orgId = adminInfo.$state.deptId
                let confirmFormData = JSON.parse(JSON.stringify(devReportForm.value))
                //提交终端信息
                confirmFormData = {
                    ...confirmFormData,
                    acceptanceInspectionReport:
                        form.value.acceptanceInspectionReport.length == 0 ? '' : acceptanceInspectionReport.value, //验收检验报告
                    // acceptanceInspectionReportSingle: acceptanceInspectionReportSingle.value, //验收检验报告单
                    deviceFilePath: form.value.deviceFilePath.length == 0 ? '' : deviceFilePath?.value, //终端台账信息
                    factoryInspectionReport:
                        form.value.factoryInspectionReport.length == 0 ? '' : factoryInspectionReport.value, //出厂检验报告
                    informationSecurityTestReport:
                        form.value.informationSecurityTestReport.length == 0 ? '' : informationSecurityTestReport.value, //信息安全检测报告
                    performanceTestReport:
                        form.value.performanceTestReport.length == 0 ? '' : performanceTestReport.value, //性能检测报告
                    typeExperimentReport: form.value.typeExperimentReport.length == 0 ? '' : typeExperimentReport.value, //型式实验报告
                    otherAttachments: form.value.otherAttachments.length == 0 ? '' : otherAttachments?.value //其他附件
                }
                confirmFormData.saveOrCheckflag = '2'
                confirmFormData.importType = importType.value
                if (title.value == '终端信息') {
                    await addTerminalFormData(confirmFormData).then((res: any) => {
                        if (res.code == 'A0000') {
                            ElMessage({
                                message: '新增成功',
                                type: 'success'
                            })
                            ruleFormRef.value.resetFields()
                            resetForm()
                            close()
                        }
                    }).catch(() => {
            loading.value = false
        })
                } else {
                    confirmFormData.reporter = adminInfo.$state.id
                    confirmFormData.orgId = adminInfo.$state.deptId
                    confirmFormData.supervisionTempDeviceReportParam.commissioningTime =
                        confirmFormData.supervisionTempDeviceReportParam.commissioningTime.replace('T', ' ')
                    confirmFormData.id = resendId.value
                    await updateTerminalFormData(confirmFormData).then((res: any) => {
                        if (res.code == 'A0000') {
                            ElMessage({
                                message: '重新发起成功',
                                type: 'success'
                            })
                            ruleFormRef.value.resetFields()
                            resetForm()
                            close()
                        }
                    }).catch(() => {
            loading.value = false
        })
                }
            } else {
                console.log('表单验证失败')
                return false
            }
        })
    }
    await setTimeout(() => {
        loading.value = false
    }, 0)
}


// 编码改动
const encode = (e: string) => {
    
        form.value.monitoringTerminalName = e.replace(/:/g, '')
    
   
}
defineExpose({ open })
</script>
<style lang="scss" scoped>
.fixed_upload {
    width: 100%;
    height: auto;
    display: flex;
    justify-content: flex-end;
}

.el-divider {
    margin: 20px 0;
}

::v-deep .el-divider__text {
    font-size: 16px !important;
}
</style>
