<template>
    <el-dialog
        v-model="dialogFormVisible"
        title="台账模型"
        width="65%"
        :append-to-body="true"
        :before-close="close"
        :close-on-click-modal="false"
        :lazy="true"
        draggable
    >
        <!--终端信息录入   基础信息+终端信息+附件材料 -->
        <!--监测点信息录入 基础信息+监测点信息  监测点信息要有工程名称、用户状态 -->
        <el-tabs class="demo-tabs" v-model="selectFormType" @tab-click="handleClick">
            <el-tab-pane label="终端信息" name="0"></el-tab-pane>
            <el-tab-pane label="监测点信息" name="1"></el-tab-pane>
        </el-tabs>
        <el-form
            :model="form"
            :validate-on-rule-change="false"
            :scroll-to-error="true"
            :rules="rules"
            ref="ruleFormRef"
            label-width="140px"
            label-position="right"
        >
            <el-tabs tab-position="left" class="tabs_form" v-model="activeName">
                <el-tab-pane name="0" label="基础信息" v-if="selectFormType == '0'">
                    <div class="form_tab_item">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="填报人：" prop="reporter">
                                    <el-input
                                        v-model="form.reporter"
                                        autocomplete="off"
                                        place-holder="请输入填报人"
                                        :disabled="true"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="填报日期：" prop="reportDate">
                                    <el-date-picker
                                        :disabled="true"
                                        style="width: 100%"
                                        v-model="form.reportDate"
                                        type="date"
                                        placeholder="请选择填报日期"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="填报部门：" prop="orgId">
                                    <el-input v-model="form.orgId" :disabled="true" autocomplete="off" />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="工程投产日期：" prop="expectedProductionDate">
                                    <el-date-picker
                                        style="width: 100%"
                                        v-model="form.expectedProductionDate"
                                        type="date"
                                        format="YYYY-MM-DD"
                                        value-format="YYYY-MM-DD"
                                        :disabled-date="disabledDate"
                                        placeholder="请选择工程投产日期"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="所属地市：" prop="city">
                                    <el-select
                                        v-model="form.city"
                                        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>
                            </el-col>

                            <!-- <el-col  :span="12">
                                <el-form-item 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-col> -->
                        </el-row>
                        <!-- <el-row>
                            <el-col :span="12">
                                <el-form-item 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>
                            </el-col>
                        </el-row> -->
                    </div>
                </el-tab-pane>
                <el-tab-pane name="1" label="终端信息" v-if="selectFormType == '0'">
                    <div class="form_tab_item">
                        <el-row>
                            <el-col :span="12"></el-col>
                            <el-col :span="12" class="required_position">
                                <span class="required_icon" style="color:#fff">*</span>
                                <el-form-item label="终端台账信息：">
                                    <el-upload
                                        v-model:file-list="form.deviceFilePath"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('deviceFilePath')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="所属供电公司：" prop="powerCompany">
                                    <el-select
                                        v-model="form.powerCompany"
                                        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>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="所属变电站：" prop="substation">
                                    <el-select
                                        v-model="form.substation"
                                        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>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="变电站电压等级：" prop="substationVoltageLevel">
                                    <el-select
                                        v-model="form.substationVoltageLevel"
                                        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>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="检测终端编码：" prop="monitoringTerminalCode">
                                    <el-input
                                        v-model="form.monitoringTerminalCode"
                                        autocomplete="off"
                                        place-holder="请输入监测终端编码"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="检测终端名称：" prop="monitoringTerminalName">
                                    <el-input
                                        v-model="form.monitoringTerminalName"
                                        autocomplete="off"
                                        place-holder="请输入终端名称"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="电压互感器类型：" prop="voltageTransformerType">
                                    <el-select
                                        v-model="form.voltageTransformerType"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择电压互感器类型"
                                    >
                                        <el-option
                                            v-for="item in voltageTransformerTypeList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item
                                    label="终端接线方式类型："
                                    prop="terminalWiringMethodType"
                                    class="label_over_warp"
                                >
                                    <el-select
                                        v-model="form.terminalWiringMethodType"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择终端接线方式类型"
                                    >
                                        <el-option
                                            v-for="item in terminalWiringMethodTypeList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="中性点接线方式：" prop="neutralPointWiringMethod">
                                    <el-select
                                        v-model="form.neutralPointWiringMethod"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择中性点接线方式"
                                    >
                                        <el-option
                                            v-for="item in neutralPointWiringMethodList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="厂家：" prop="manufacturer">
                                    <el-select
                                        v-model="form.manufacturer"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择厂家"
                                    >
                                        <el-option
                                            v-for="item in manufacturerList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="厂家设备编号：" prop="manufacturerDeviceNumber">
                                    <el-input
                                        v-model="form.manufacturerDeviceNumber"
                                        autocomplete="off"
                                        place-holder="请输入厂家设备编号"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="终端IP：" prop="terminalIp">
                                    <el-input
                                        v-model="form.terminalIp"
                                        autocomplete="off"
                                        place-holder="请输入终端IP"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="终端型号：" prop="terminalType">
                                    <el-select
                                        v-model="form.terminalType"
                                        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-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="端口：" prop="terminalPort">
                                    <el-input
                                        v-model="form.terminalPort"
                                        autocomplete="off"
                                        place-holder="请输入端口"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="所属前置机：" prop="frontEndMachine">
                                    <el-select
                                        v-model="form.frontEndMachine"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择所属前置机"
                                    >
                                        <el-option
                                            v-for="item in frontEndMachineList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item
                                    label="本次终端检测时间："
                                    prop="currentTerminalDetectionTime"
                                    class="label_over_warp"
                                >
                                    <el-date-picker
                                        style="width: 100%"
                                        v-model="form.currentTerminalDetectionTime"
                                        type="datetime"
                                        format="YYYY/MM/DD hh:mm:ss"
                                        value-format="YYYY-MM-DD hh:mm:ss"
                                        placeholder="请选择本次终端检测时间"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item
                                    label="下次终端定检时间："
                                    prop="nextTerminalInspectionTime"
                                    class="label_over_warp"
                                >
                                    <el-date-picker
                                        style="width: 100%"
                                        v-model="form.nextTerminalInspectionTime"
                                        type="datetime"
                                        format="YYYY/MM/DD hh:mm:ss"
                                        value-format="YYYY-MM-DD hh:mm:ss"
                                        placeholder="请选择下次终端定检时间"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="识别码：" prop="identificationCode">
                                    <el-input
                                        v-model="form.identificationCode"
                                        autocomplete="off"
                                        place-holder="请输入识别码"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="终端秘钥：" prop="terminalSecretKey">
                                    <el-input
                                        v-model="form.terminalSecretKey"
                                        autocomplete="off"
                                        place-holder="请输入终端秘钥"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="经度：" prop="longitude">
                                    <el-input v-model="form.longitude" autocomplete="off" place-holder="请输入经度" />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="纬度：" prop="latitude">
                                    <el-input v-model="form.latitude" autocomplete="off" place-holder="请输入纬度" />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="终端模型：" prop="terminalModel">
                                    <el-select
                                        v-model="form.terminalModel"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择终端模型"
                                    >
                                        <el-option
                                            v-for="item in terminalModelList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="数据类型：" prop="dataType">
                                    <el-select
                                        v-model="form.dataType"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择数据类型"
                                    >
                                        <el-option
                                            v-for="item in dataTypeList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="通讯状态：" prop="communicationStatus">
                                    <el-select
                                        v-model="form.communicationStatus"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择通讯状态"
                                    >
                                        <el-option
                                            v-for="item in communicationStatusList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="SIM卡号：" prop="simCardNumber">
                                    <el-input
                                        v-model="form.simCardNumber"
                                        autocomplete="off"
                                        place-holder="请输入SIM卡号"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item 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-col>

                            <el-col :span="12">
                                <el-form-item label="数据更新时间：" prop="dataUpdateTime">
                                    <el-date-picker
                                        style="width: 100%"
                                        v-model="form.dataUpdateTime"
                                        type="datetime"
                                        format="YYYY/MM/DD hh:mm:ss"
                                        value-format="YYYY-MM-DD hh:mm:ss"
                                        placeholder="请选择数据更新时间"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item 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-col>

                            <el-col :span="12">
                                <el-form-item label="电镀功能：" prop="electroplatingFunction">
                                    <!-- 默认 关闭 下拉框 -->
                                    <el-select
                                        v-model="form.electroplatingFunction"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择电镀功能"
                                    >
                                        <el-option
                                            v-for="item in electroplatingFunctionList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item
                                    label="监测装置安装位置："
                                    prop="monitoringDeviceInstallationPosition"
                                    class="label_over_warp"
                                >
                                    <!-- 电网侧、用户侧 -->
                                    <el-select
                                        v-model="form.monitoringDeviceInstallationPosition"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择监测装置安装位置"
                                    >
                                        <el-option
                                            v-for="item in monitoringDeviceInstallationPositionList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="召唤标志：" prop="summonFlag">
                                    <el-select
                                        v-model="form.summonFlag"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择召唤标志"
                                    >
                                        <el-option
                                            v-for="item in summonFlagList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item 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-col>

                            <el-col :span="12">
                                <el-form-item label="合同号：" prop="contractNumber">
                                    <el-input
                                        v-model="form.contractNumber"
                                        autocomplete="off"
                                        placeholder="请输入合同号"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                </el-tab-pane>
                <el-tab-pane name="2" label="监测点信息" v-if="selectFormType == '1'">
                    <div class="form_tab_item">
                        <!-- 基础信息 -->
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="填报人：" prop="reporter">
                                    <el-input
                                        v-model="form.reporter"
                                        autocomplete="off"
                                        place-holder="请输入填报人"
                                        :disabled="true"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="填报日期：" prop="reportDate">
                                    <el-date-picker
                                        :disabled="true"
                                        style="width: 100%"
                                        v-model="form.reportDate"
                                        type="date"
                                        format="YYYY-MM-DD"
                                        value-format="YYYY-MM-DD"
                                        placeholder="请选择填报日期"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="填报部门：" prop="orgId">
                                    <el-input v-model="form.orgId" :disabled="true" autocomplete="off" />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="工程投产日期：" prop="expectedProductionDate">
                                    <el-date-picker
                                        style="width: 100%"
                                        v-model="form.expectedProductionDate"
                                        type="date"
                                        format="YYYY-MM-DD"
                                        value-format="YYYY-MM-DD"
                                        :disabled-date="disabledDate"
                                        placeholder="请选择工程投产日期"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="所属地市：" prop="city">
                                    <el-select
                                        v-model="form.city"
                                        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>
                            </el-col>

                            <el-col v-if="selectFormType == '1'" :span="12">
                                <el-form-item 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-col>
                        </el-row>
                        <el-row v-if="selectFormType == '1'">
                            <el-col :span="12">
                                <el-form-item 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>
                            </el-col>
                        </el-row>
                        <!-- 监测点信息 -->
                        <el-row>
                            <el-col :span="12"></el-col>

                            <el-col :span="12" class="required_position">
                                <span class="required_icon" style="color:#fff">*</span>
                                <el-form-item label="监测点台账信息：" prop="lineFilePath">
                                    <el-upload
                                        v-model:file-list="form.lineFilePath"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('lineFilePath')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="监测点名称：" prop="lineName">
                                    <el-input
                                        v-model="form.lineName"
                                        autocomplete="off"
                                        place-holder="请输入监测点名称"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="监测点电压等级：" prop="voltageLevel">
                                    <el-select
                                        v-model="form.voltageLevel"
                                        clearable
                                        style="width: 100%"
                                        placeholder="请选择监测点电压等级"
                                    >
                                        <el-option
                                            v-for="item in voltageLevelList"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="接入母线：" prop="connectedBus">
                                    <el-select
                                        v-model="form.connectedBus"
                                        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>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="短路容量：" prop="shortCapacity">
                                    <el-input
                                        v-model="form.shortCapacity"
                                        autocomplete="off"
                                        placeholder="请输入短路容量"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="协议容量：" prop="dealCapacity">
                                    <el-input
                                        v-model="form.dealCapacity"
                                        autocomplete="off"
                                        placeholder="请输入协议容量"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="设备容量：" prop="devCapacity">
                                    <el-input
                                        v-model="form.devCapacity"
                                        autocomplete="off"
                                        placeholder="请输入设备容量"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="基准容量：" prop="standardCapacity">
                                    <el-input
                                        v-model="form.standardCapacity"
                                        autocomplete="off"
                                        placeholder="请输入基准容量"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="CT变比：" prop="ctRatio">
                                    <el-input v-model="form.ctRatio" autocomplete="off" placeholder="请输入CT变比" />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="PT变比：" prop="ptRatio">
                                    <el-input v-model="form.ptRatio" autocomplete="off" placeholder="请输入PT变比" />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="监测点编码：" prop="lineId">
                                    <el-input v-model="form.lineId" autocomplete="off" placeholder="请输入监测点编码" />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="测量间隔：" prop="timeInterval">
                                    <el-input
                                        v-model="form.timeInterval"
                                        autocomplete="off"
                                        placeholder="请输入测量间隔"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="干扰源类型：" prop="loadType">
                                    <el-select
                                        v-model="form.loadType"
                                        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>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="干扰源类别：" prop="businessType">
                                    <el-select
                                        v-model="form.businessType"
                                        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>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="监测点性质：" prop="pointNature">
                                    <el-select v-model="form.pointNature" placeholder="请选择监测点性质">
                                        <el-option
                                            v-for="(item, index) in pointNatureList"
                                            :label="item.name"
                                            :value="item.id"
                                            :key="index"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="是否参与统计：" prop="isStatistical">
                                    <el-radio-group v-model="form.isStatistical">
                                        <el-radio value="1">是</el-radio>
                                        <el-radio value="0">否</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="对象名称(对端)：" prop="objName">
                                    <el-input
                                        v-model="form.objName"
                                        autocomplete="off"
                                        placeholder="请输入监测点对象名称"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="电网侧变电站：" prop="powerSubstationName">
                                    <el-input
                                        v-model="form.powerSubstationName"
                                        autocomplete="off"
                                        placeholder="请输入电网侧变电站"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="是否并网点：" prop="isGridConnectionPoint">
                                    <el-radio-group v-model="form.isGridConnectionPoint">
                                        <el-radio value="1">是</el-radio>
                                        <el-radio value="0">否</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                        </el-row>

                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="电压偏差上限：" prop="voltageDeviationUpperLimit">
                                    <el-input
                                        v-model="form.voltageDeviationUpperLimit"
                                        autocomplete="off"
                                        placeholder="请输入电压偏差上限"
                                    />
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="电压偏差下限：" prop="voltageDeviationLowerLimit">
                                    <el-input
                                        v-model="form.voltageDeviationLowerLimit"
                                        autocomplete="off"
                                        placeholder="请输入电压偏差下限"
                                    />
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="监测点运行状态：" prop="operationStatus">
                                    <el-select v-model="form.operationStatus" placeholder="请选择运行状态">
                                        <el-option
                                            v-for="(item, index) in operationStatusList"
                                            :label="item.name"
                                            :value="item.id"
                                            :key="index"
                                        />
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12" class="required_position">
                                <span class="required_icon">*</span>
                                <el-form-item label="主接线图：" prop="mainWiringDiagram">
                                    <el-upload
                                        v-model:file-list="form.mainWiringDiagram"
                                        ref="uploadRef"
                                        action=""
                                        accept=".doc,.docx,.xlsx,.xls,.pdf"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('mainWiringDiagram')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                </el-tab-pane>
                <el-tab-pane name="3" label="附件材料" v-if="selectFormType == '0'">
                    <div class="form_tab_item">
                        <el-row>
                            <el-col :span="12" class="required_position">
                                <span class="required_icon">*</span>
                                <el-form-item label="信息安全检测报告：" prop="informationSecurityTestReport">
                                    <el-upload
                                        v-model:file-list="form.informationSecurityTestReport"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('informationSecurityTestReport')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12" class="required_position">
                                <span class="required_icon">*</span>
                                <el-form-item label="验收检验报告单：" prop="acceptanceInspectionReportSingle">
                                    <el-upload
                                        v-model:file-list="form.acceptanceInspectionReportSingle"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('acceptanceInspectionReportSingle')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>

                        <el-row>
                            <el-col :span="12" class="required_position">
                                <span class="required_icon" style="color:#fff">*</span>
                                <el-form-item label="验收检验报告：" prop="acceptanceInspectionReport">
                                    <el-upload
                                        v-model:file-list="form.acceptanceInspectionReport"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('acceptanceInspectionReport')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12"  class="required_position">
                                <span class="required_icon">*</span>
                                <el-form-item label="型式实验报告：" prop="typeExperimentReport" :show-message="false">
                                    <el-upload
                                        v-model:file-list="form.typeExperimentReport"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('typeExperimentReport')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>

                        <el-row>
                            <el-col :span="12" class="required_position">
                                <span class="required_icon">*</span>
                                <el-form-item label="出厂检验报告：" prop="factoryInspectionReport">
                                    <el-upload
                                        v-model:file-list="form.factoryInspectionReport"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('factoryInspectionReport')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12" class="required_position">
                                <span class="required_icon">*</span>
                                <el-form-item label="性能检测报告：" prop="performanceTestReport" :show-message="false">
                                    <el-upload
                                        v-model:file-list="form.performanceTestReport"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('performanceTestReport')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>

                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="其他附件：" class="no_required" prop="otherAttachments">
                                    <el-upload
                                        v-model:file-list="form.otherAttachments"
                                        ref="uploadRef"
                                        action=""
                                        accept=".xls,.xlsx"
                                        :limit="1"
                                        :on-exceed="handleExceed"
                                        :on-change="choose"
                                        :auto-upload="false"
                                        :on-progress="uploadFileName('otherAttachments')"
                                    >
                                        <template #trigger>
                                            <el-button type="primary">上传文件</el-button>
                                        </template>
                                    </el-upload>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                </el-tab-pane>
            </el-tabs>
        </el-form>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="close()">取消</el-button>
                <el-button type="primary" @click="confirmForm()">确定</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 { submitFormData } from '@/api/supervision-boot/interfere/index'
import { addTerminalFormData } from '@/api/supervision-boot/terminal/index.ts'
const emits = defineEmits(['onSubmit'])
const dictData = useDictData()
const dialogFormVisible = ref(false)
const form: any = ref({})
const ruleFormRef = ref(null)
//字典获取所属地市
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 frontEndMachineList = dictData.getBasicData('Front_Type')
//字典获取数据类型
const dataTypeList = dictData.getBasicData('System_Type')
//字典获取监测点电压等级
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 communicationStatusList = [
    {
        id: '0',
        name: '中断'
    },
    {
        id: '1',
        name: '正常'
    }
]
//定义监测装置安装位置下拉框数据
const monitoringDeviceInstallationPositionList = [
    {
        id: '0',
        name: '电网侧'
    },
    {
        id: '1',
        name: '用户侧'
    }
]
//定义召唤标志下拉框数据
const summonFlagList = [
    {
        id: '0',
        name: '周期触发'
    },
    {
        id: '1',
        name: '变为触发'
    }
]
//定义监测点性质下拉框数据
const pointNatureList = [
    {
        id: '0',
        name: '电网侧'
    },
    {
        id: '1',
        name: '非电网侧'
    }
]
//定义监测点运行状态下拉框数据
const operationStatusList = [
    {
        id: '0',
        name: '运行'
    },
    {
        id: '1',
        name: '检修'
    },
    {
        id: '2',
        name: '停运'
    },
    {
        id: '3',
        name: '调试'
    },
    {
        id: '4',
        name: '退运'
    }
]
//定义电镀功能下拉框数据
const electroplatingFunctionList = [
    {
        id: '0',
        name: '关闭'
    },
    {
        id: '1',
        name: '开启'
    }
]

//获取登陆用户姓名和部门
const adminInfo = useAdminInfo()
//定义切换form类型
const selectFormType = ref('')
selectFormType.value = '0'
const resetForm = () => {
    form.value = {
        reporter: '', //填报人
        reportDate: new Date(), //填报日期
        orgId: '', //填报部门
        expectedProductionDate: '', //工程投产日期
        city: areaOptionList[0].name, //所属地市
        userStatus: userStateList[1].id, //用户状态
        userName: '', //工程名称
        userId: '',

        acceptanceInspectionReport: [], //验收检验报告
        acceptanceInspectionReportSingle: [], //验收检验报告单
        deviceFilePath: [], //终端台账信息
        factoryInspectionReport: [], //出厂检验报告
        informationSecurityTestReport: [], //信息安全检测报告
        lineFilePath: [], //监测点台账信息
        otherAttachments: [], //其他附件
        performanceTestReport: [], //性能检测报告
        typeExperimentReport: [], //型式实验报告
        // processInstanceId: '', //流程实例的编号
        // startUserSelectAssignees: {}, //发起人自选审批人 Map
        //终端信息实体
        // supervisionTempDeviceReportParam: {
        alarmFunction: '0', //告警功能
        commissioningTime: '', //投运时间
        communicationStatus: communicationStatusList[0].id, //	通讯状态
        contractNumber: '', //合同号
        currentTerminalDetectionTime: '', //本次终端检测时间
        dataType: dataTypeList[0].id, //数据类型
        dataUpdateTime: '', //	数据更新时间
        electroplatingFunction: electroplatingFunctionList[0].id, //电镀功能
        frontEndMachine: frontEndMachineList[0].id, //所属前置机
        identificationCode: '', //	识别码
        latitude: '0', //纬度
        longitude: '0', //经度
        manufacturer: manufacturerList[0].id, //厂家
        manufacturerDeviceNumber: '', //	厂家设备编号
        monitoringDeviceInstallationPosition: monitoringDeviceInstallationPositionList[0].id, //监测装置安装位置
        monitoringTerminalCode: '', //监测终端编码
        monitoringTerminalName: '', //监测终端名称
        neutralPointWiringMethod: neutralPointWiringMethodList[0].id, //	中性点接线方式
        nextTerminalInspectionTime: '', //	下次终端定检时间
        powerCompany: '', //所属供电公司
        simCardNumber: '', //SIM卡号
        substation: '', //	所属变电站
        substationVoltageLevel: '', //	变电站电压等级
        summonFlag: summonFlagList[0].id, //	召唤标志
        terminalIp: '', //终端IP
        terminalModel: terminalModelList[0].id, //终端模型
        terminalPort: '', //端口
        terminalSecretKey: '', //终端秘钥
        terminalType: terminalTypeList[0].id, //	终端型号
        terminalWiringMethodType: terminalWiringMethodTypeList[0].id, //	终端接线方式类型
        timeSyncFunction: '0', //	对时功能
        voltageTransformerType: voltageTransformerTypeList[0].id, //电压互感器类型
        // },
        //监测点信息实体
        // supervisionTempLineReportParam: {
        businessType: '', //	干扰源类别
        connectedBus: '', //	接入母线
        ctRatio: '0', //CT变比
        dealCapacity: '0', //协议容量
        devCapacity: '0', //设备容量
        isGridConnectionPoint: '0', //是否并网点
        isStatistical: '0', //	是否参与统计
        lineId: '', //	监测点编码
        lineName: '', //	监测点名称
        loadType: '', //干扰源类型
        mainWiringDiagram: [], //	主接线图
        objName: '', //监测点对象名称
        operationStatus: operationStatusList[0].id, //监测点运行状态
        pointNature: pointNatureList[0].id, //监测点性质
        powerSubstationName: '', //电网侧变电站
        ptRatio: '0', //	PT变比
        shortCapacity: '0', //	短路容量
        standardCapacity: '0', //基准容量
        timeInterval: '0', //测量间隔
        voltageDeviationLowerLimit: '0', //电压偏差下限
        voltageDeviationUpperLimit: '0', //	电压偏差上限
        voltageLevel: voltageLevelList[0].id //监测点电压等级
        // },
    }

    form.value.reporter = adminInfo.$state.name
    form.value.orgId = adminInfo.$state.deptName
}
//初始化数据
resetForm()
//终端信息表单格式
const devReportForm = ref({
    reporter: '', //填报人
    reportDate: new Date(), //填报日期
    orgId: '', //填报部门
    expectedProductionDate: '', //工程投产日期
    city: areaOptionList[0].name, //所属地市
    userStatus: userStateList[1].id, //用户状态
    userName: '', //工程名称
    userId: '',

    acceptanceInspectionReport: [], //验收检验报告
    acceptanceInspectionReportSingle: [], //验收检验报告单
    deviceFilePath: [], //终端台账信息
    factoryInspectionReport: [], //出厂检验报告
    informationSecurityTestReport: [], //信息安全检测报告
    lineFilePath: [], //监测点台账信息
    otherAttachments: [], //其他附件
    performanceTestReport: [], //性能检测报告
    typeExperimentReport: [], //型式实验报告
    // processInstanceId: '', //流程实例的编号
    // startUserSelectAssignees: {}, //发起人自选审批人 Map
    //终端信息实体
    supervisionTempDeviceReportParam: {
        alarmFunction: '0', //告警功能
        commissioningTime: '', //投运时间
        communicationStatus: '', //	通讯状态
        contractNumber: '', //合同号
        currentTerminalDetectionTime: '', //本次终端检测时间
        dataType: '', //数据类型
        dataUpdateTime: '', //	数据更新时间
        electroplatingFunction: '', //电镀功能
        frontEndMachine: '', //所属前置机
        identificationCode: '', //	识别码
        latitude: '0', //纬度
        longitude: '0', //经度
        manufacturer: '', //厂家
        manufacturerDeviceNumber: '', //	厂家设备编号
        monitoringDeviceInstallationPosition: monitoringDeviceInstallationPositionList[0].id, //监测装置安装位置
        monitoringTerminalCode: '', //监测终端编码
        monitoringTerminalName: '', //监测终端名称
        neutralPointWiringMethod: '', //	中性点接线方式
        nextTerminalInspectionTime: '', //	下次终端定检时间
        powerCompany: '', //所属供电公司
        simCardNumber: '', //SIM卡号
        substation: '', //	所属变电站
        substationVoltageLevel: '', //	变电站电压等级
        // summonFlag: '', //	召唤标志
        terminalIp: '', //终端IP
        terminalModel: terminalModelList[0].id, //终端模型
        terminalPort: '', //端口
        terminalSecretKey: '', //终端秘钥
        terminalType: '', //	终端型号
        terminalWiringMethodType: '', //	终端接线方式类型
        timeSyncFunction: '0', //	对时功能
        voltageTransformerType: '' //	电压互感器类型
    }
})
//监测点信息表单格式
const monitorPointForm = ref({
    reporter: '', //填报人
    reportDate: new Date(), //填报日期
    orgId: '', //填报部门
    expectedProductionDate: '', //工程投产日期
    city: areaOptionList[0].name, //所属地市
    userStatus: userStateList[1].id, //用户状态
    userName: '', //工程名称
    userId: '',

    acceptanceInspectionReport: [], //验收检验报告
    acceptanceInspectionReportSingle: [], //验收检验报告单
    deviceFilePath: [], //终端台账信息
    factoryInspectionReport: [], //出厂检验报告
    informationSecurityTestReport: [], //信息安全检测报告
    lineFilePath: [], //监测点台账信息
    otherAttachments: [], //其他附件
    performanceTestReport: [], //性能检测报告
    typeExperimentReport: [], //型式实验报告
    // processInstanceId: '', //流程实例的编号
    // startUserSelectAssignees: {}, //发起人自选审批人 Map
    //终端信息实体
    supervisionTempDeviceReportParam: {
        alarmFunction: '0', //告警功能
        commissioningTime: '', //投运时间
        communicationStatus: '', //	通讯状态
        contractNumber: '', //合同号
        currentTerminalDetectionTime: '', //本次终端检测时间
        dataType: '', //数据类型
        dataUpdateTime: '', //	数据更新时间
        electroplatingFunction: '', //电镀功能
        frontEndMachine: '', //所属前置机
        identificationCode: '', //	识别码
        latitude: '0', //纬度
        longitude: '0', //经度
        manufacturer: '', //厂家
        manufacturerDeviceNumber: '', //	厂家设备编号
        monitoringDeviceInstallationPosition: monitoringDeviceInstallationPositionList[0].id, //监测装置安装位置
        monitoringTerminalCode: '', //监测终端编码
        monitoringTerminalName: '', //监测终端名称
        neutralPointWiringMethod: '', //	中性点接线方式
        nextTerminalInspectionTime: '', //	下次终端定检时间
        powerCompany: '', //所属供电公司
        simCardNumber: '', //SIM卡号
        substation: '', //	所属变电站
        substationVoltageLevel: '', //	变电站电压等级
        // summonFlag: '', //	召唤标志
        terminalIp: '', //终端IP
        terminalModel: terminalModelList[0].id, //终端模型
        terminalPort: '', //端口
        terminalSecretKey: '', //终端秘钥
        terminalType: '', //	终端型号
        terminalWiringMethodType: '', //	终端接线方式类型
        timeSyncFunction: '0', //	对时功能
        voltageTransformerType: '' //	电压互感器类型
    },
    supervisionTempLineReportParam: {
        businessType: '', //	干扰源类别
        connectedBus: '', //	接入母线
        ctRatio: '0', //CT变比
        dealCapacity: '0', //协议容量
        devCapacity: '0', //设备容量
        isGridConnectionPoint: '0', //是否并网点
        isStatistical: '0', //	是否参与统计
        lineId: '', //	监测点编码
        lineName: '', //	监测点名称
        loadType: '', //干扰源类型
        mainWiringDiagram: '', //	主接线图
        objName: '', //监测点对象名称
        operationStatus: '', //监测点运行状态
        pointNature: '', //监测点性质
        powerSubstationName: '', //电网侧变电站
        ptRatio: '0', //	PT变比
        shortCapacity: '0', //	短路容量
        standardCapacity: '0', //基准容量
        timeInterval: '0', //测量间隔
        voltageDeviationLowerLimit: '0', //电压偏差下限
        voltageDeviationUpperLimit: '0', //	电压偏差上限
        voltageLevel: '' //监测点电压等级
    }
})

//定义校验规则
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'
        }
    ],

    //终端信息
    powerCompany: [
        {
            required: true,
            message: '请选择所属供电公司',
            trigger: 'change'
        }
    ],
    substation: [
        {
            required: true,
            message: '请选择所属变电站',
            trigger: 'change'
        }
    ],
    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'
        }
    ],
    terminalType: [
        {
            required: true,
            message: '请选择终端型号',
            trigger: 'change'
        }
    ],
    terminalPort: [
        {
            required: false,
            message: '请输入端口',
            trigger: 'blur'
        }
    ],
    frontEndMachine: [
        {
            required: false,
            message: '请选择所属前置机',
            trigger: 'change'
        }
    ],
    currentTerminalDetectionTime: [
        {
            required: true,
            message: '请选择本次终端检测时间',
            trigger: 'change'
        }
    ],
    nextTerminalInspectionTime: [
        {
            required: true,
            message: '请选择下次终端定检时间',
            trigger: 'change'
        }
    ],
    identificationCode: [
        {
            required: true,
            message: '请输入识别码',
            trigger: 'blur'
        }
    ],
    terminalSecretKey: [
        {
            required: true,
            message: '请输入终端秘钥',
            trigger: 'blur'
        }
    ],
    longitude: [
        {
            required: true,
            message: '请输入经度',
            trigger: 'blur'
        }
    ],
    latitude: [
        {
            required: true,
            message: '请输入纬度',
            trigger: 'blur'
        }
    ],
    terminalModel: [
        {
            required: false,
            message: '请选择终端模型',
            trigger: 'change'
        }
    ],
    communicationStatus: [
        {
            required: false,
            message: '请选择通讯状态',
            trigger: 'change'
        }
    ],
    simCardNumber: [
        {
            required: true,
            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'
        }
    ],

    //监测点信息
    lineName: [
        {
            required: true,
            message: '请输入监测点名称',
            trigger: 'blur'
        }
    ],
    voltageLevel: [
        {
            required: true,
            message: '请选择监测点电压等级',
            trigger: 'change'
        }
    ],
    connectedBus: [
        {
            required: true,
            message: '请选择接入母线',
            trigger: 'blur'
        }
    ],
    shortCapacity: [
        {
            required: true,
            message: '请输入短路容量',
            trigger: 'blur'
        }
    ],
    dealCapacity: [
        {
            required: true,
            message: '请输入协议容量',
            trigger: 'blur'
        }
    ],
    devCapacity: [
        {
            required: true,
            message: '请输入设备容量',
            trigger: 'blur'
        }
    ],
    standardCapacity: [
        {
            required: true,
            message: '请输入基准容量',
            trigger: 'blur'
        }
    ],
    ctRatio: [
        {
            required: true,
            message: '请输入CT变化',
            trigger: 'blur'
        }
    ],
    ptRatio: [
        {
            required: true,
            message: '请输入PT变化',
            trigger: 'blur'
        }
    ],
    lineId: [
        {
            required: true,
            message: '请输入监测点编码',
            trigger: 'blur'
        }
    ],
    timeInterval: [
        {
            required: true,
            message: '请输入测量间隔',
            trigger: 'blur'
        }
    ],
    loadType: [
        {
            required: true,
            message: '请选择干扰源类型',
            trigger: 'change'
        }
    ],
    businessType: [
        {
            required: true,
            message: '请选择干扰源类别',
            trigger: 'change'
        }
    ],
    pointNature: [
        {
            required: true,
            message: '请选择监测点性质',
            trigger: 'change'
        }
    ],
    isStatistical: [
        {
            required: true,
            message: '请选择是否参与统计',
            trigger: 'change'
        }
    ],
    objName: [
        {
            required: true,
            message: '请输入监测点对象名称',
            trigger: 'blur'
        }
    ],
    powerSubstationName: [
        {
            required: false,
            message: '请选择电网侧变电站',
            trigger: 'change'
        }
    ],
    isGridConnectionPoint: [
        {
            required: true,
            message: '请选择是否并网点',
            trigger: 'change'
        }
    ],
    operationStatus: [
        {
            required: true,
            message: '请选择监测点运行状态',
            trigger: 'change'
        }
    ],
    mainWiringDiagram: [
        {
            required: false,
            message: '请上传主接线图',
            trigger: 'change'
        }
    ],
    voltageDeviationUpperLimit: [
        {
            required: false,
            message: '请输入电压偏差上限',
            trigger: 'blur'
        }
    ],
    voltageDeviationLowerLimit: [
        {
            required: false,
            message: '请输入电压偏差下限',
            trigger: 'blur'
        }
    ]
})
watch(
    () => form.value,
    (val, oldVal) => {
        //form数据变化时处理格式，根据tab切换判断处理的对象实体
        //终端信息
        if (selectFormType.value == '0' && 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(form.value.reportDate, 'yyyy-MM-dd');
            // console.log('处理好的表单++++++++++>',devReportForm.value)
        }
        //监测点信息
        else {

        }
    },
    {
        deep: true,
        immediate: true
    }
)
const open = () => {
    dialogFormVisible.value = true
}
const close = () => {
    //重置表单内容
    //取消表单校验状态
    ruleFormRef.value && ruleFormRef.value.resetFields()
    dialogFormVisible.value = false
    emits('onSubmit')
    resetForm()
}
// 切换终端信息/监测点信息
const handleClick = (tab: any, event: any) => {
    //终端信息
    if (tab.index == '0') {
        activeName.value = '0'
    }
    //监测点信息
    else {
        activeName.value = '2'
    }
}
onMounted(() => {
    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 deviceFilePath = ref('')
//监测点台账信息
const lineFilePath = 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 == 'lineFilePath') {
            lineFilePath.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 activeName = ref('0')
//提交
const confirmForm = () => {
    console.log(form.value, '打印form对象')
    // 先判断提交终端信息与监测点信息

    // 提交终端信息
    if (selectFormType.value == '0') {
        ruleFormRef.value.validate(valid => {
            if (valid) {
                //整理上传文件的数据
                // userType==0,1
                devReportForm.value.reporter = adminInfo.$state.id
                devReportForm.value.orgId = adminInfo.$state.deptId
                let confirmFormData = JSON.parse(JSON.stringify(devReportForm.value))

                //1.判断是否上传
                // if (!deviceFilePath.value) {
                //     activeName.value = '1'
                //     return ElMessage({
                //         message: '请上传终端台账信息',
                //         type: 'warning'
                //     })
                // }
                // if (!lineFilePath.value) {
                //     activeName.value = '2'
                //     return ElMessage({
                //         message: '请上传监测点台账信息',
                //         type: 'warning'
                //     })
                // }
                if (!acceptanceInspectionReportSingle.value) {
                    return ElMessage({
                        message: '请上传验收检验报告单',
                        type: 'warning'
                    })
                }
                if (!acceptanceInspectionReport.value) {
                    return ElMessage({
                        message: '请上传验收检验报告',
                        type: 'warning'
                    })
                }
                if (!typeExperimentReport.value) {
                    return ElMessage({
                        message: '请上传型式实验报告',
                        type: 'warning'
                    })
                }
                if (!factoryInspectionReport.value) {
                    return ElMessage({
                        message: '请上传出厂检验报告',
                        type: 'warning'
                    })
                }
                if (!performanceTestReport.value) {
                    return ElMessage({
                        message: '请上传性能检测报告',
                        type: 'warning'
                    })
                }
                if (!informationSecurityTestReport.value) {
                    return ElMessage({
                        message: '请上传信息安全检测报告',
                        type: 'warning'
                    })
                }
                //提交终端信息
                confirmFormData={
                    ...confirmFormData,
                    acceptanceInspectionReport: acceptanceInspectionReport.value, //验收检验报告
                    acceptanceInspectionReportSingle: acceptanceInspectionReportSingle.value, //验收检验报告单
                    deviceFilePath: deviceFilePath?.value, //终端台账信息
                    factoryInspectionReport: factoryInspectionReport.value, //出厂检验报告
                    informationSecurityTestReport:informationSecurityTestReport.value , //信息安全检测报告
                    lineFilePath: lineFilePath?.value, //监测点台账信息
                    performanceTestReport:performanceTestReport.value , //性能检测报告
                    typeExperimentReport: typeExperimentReport.value, //型式实验报告
                    otherAttachments: otherAttachments?.value, //其他附件
                }
                console.log(confirmFormData,"打印提交表单111111111111")
                addTerminalFormData(confirmFormData).then(res => {
                    console.log(res,"打印提交结果222222222222+++++++++")
                    ruleFormRef.value.resetFields()
                    resetForm()
                    close()
                })
            } else {
                console.log('表单验证失败')
                return false
            }
        })
    }
    //提交监测点信息
    else {
    }
}
defineExpose({ open })
</script>
<style lang="scss" scoped>
.el-form {
    // width: 96%;
    height: 400px;
    margin: 0 auto;
    // overflow-y: auto;
    padding-top: 20px;
}

/* 调整标签的换行行为 */
.label_over_warp::v-deep .el-form-item__label {
    // white-space: pre-line !important;
    line-height: 16px !important;
}
::v-deep .el-form-item {
    padding: 0 10px;
    height: auto !important;
}
::v-deep .el-form-item__label {
    justify-content: flex-start !important;
}
.form-label-left-align {
    text-align: left;
}
::v-deep .el-input-number .el-input__inner {
    text-align: left;
}
.no_required::v-deep .el-form-item__label {
    padding-left: 10px !important;
}

//表单tab容器
.form_tab_item {
    height: 400px;
    overflow-y: auto;
}
::v-deep .el-input {
    width: 200px !important;
}
::v-deep .el-select {
    width: 200px !important;
}
::v-deep .required_position {
    position: relative;
    .required_icon {
        position: absolute;
        left: -10px;
        margin-top: 8px;
        color: #f56c6c;
        margin-left: 20px;
    }
    .required_text {
        // padding-left: 20px;
    }
    .el-form-item__label {
        margin-left: 10px;
    }
}
// ::v-deep .tabs_form{
//     height:300px !important;
// }
</style>
