<template>
  <el-container id="dept" style="height: 90vh;">
    <el-aside :width="'240px'" id="drag-dept-left">
      <div class="dept-left-btn">
        <el-button type="primary" size="mini">模板下载</el-button>
        <el-button type="primary" size="mini">导入</el-button>
        <el-button type="primary" size="mini">导出</el-button>
      </div>
      <div class="dept-left-input">
        <el-input v-model="keyword" clearable placeholder="请输入关键词" prefix-icon="el-icon-search" size="small" />
      </div>
      <div class="dept-left-tree overview_scroll">
        <el-tree ref="tree" :data="treeMenus" :props="defaultProps" node-key="uuid" highlight-curren
          :show-checkbox="false" :expand-on-click-node="true" :default-expanded-keys="[currentuuid]"
          :default-checked-keys="[currentNode]" :current-node-key="currentNode" accordion
          :filter-node-method="filterNode" @node-click="handleNodeClick">
          <span class="span-ellipsis" slot-scope="{node}">
            <span class="title" :title="node.label">{{ node.label }}</span>
          </span>
        </el-tree>
      </div>
    </el-aside>
    <!--分隔条-->
    <div id="drag-dept"><i></i> <i></i></div>
    <el-main id="drag-dept-right">
      <!--改变页面状态的按钮-->
      <div class="main-btn">
        <el-button size="mini" class="el-icon-plus" type="success" @click="add">新 增</el-button>
        <el-button size="mini" class="el-icon-edit" type="primary" @click="update">修 改</el-button>
        <el-button size="mini" class="el-icon-close" type="danger" @click="remove">删 除</el-button>
        <el-button style="margin-left: 2%;" size="mini" class="el-icon-right" type="primary" @click="next"
          v-if="nodeLevel <= 600 && pageStatus == 2">下一步</el-button>
        <el-button size="mini" type="info" @click="black" class="el-icon-back"
          v-if="nodeLevel <= 700 && (pageStatus == 2 || pageStatus == 3)">撤 销</el-button>
        <el-button size="mini" text-align="center" class="el-icon-check" type="success" v-if="pageStatus == 2"
          @click="onsubmit">确认提交</el-button>
        <el-button size="mini" text-align="center" class="el-icon-check" type="success" v-if="pageStatus == 3"
          @click="onsubmit">修改提交</el-button>

        <div style="margin-left: 55%;margin-top:10px; position:absolute;">
          <el-breadcrumb separator-class="el-icon-arrow-right" style="cursor: pointer;">
            <el-breadcrumb-item>台账管理</el-breadcrumb-item>
            <el-breadcrumb-item v-if="level >= 100" @click.native="topath('#id100', 0)"><a
                :style="changeSelectStyle == 0 ? 'color:rgb(8, 213, 240);cursor: pointer;' : ''">{{ title100 }}</a></el-breadcrumb-item>
            <el-breadcrumb-item v-if="level >= 200" @click.native="topath('#id200', 1)"><a
                :style="changeSelectStyle == 1 ? 'color:rgb(8, 213, 240);cursor: pointer;' : ''">{{ title200 }}</a></el-breadcrumb-item>
            <el-breadcrumb-item v-if="level >= 300" @click.native="topath('#id300', 2)"><a
                :style="changeSelectStyle == 2 ? 'color:rgb(8, 213, 240);cursor: pointer;' : ''">{{ title300 }}</a></el-breadcrumb-item>
            <el-breadcrumb-item v-if="level >= 400" @click.native="topath('#id400', 3)"><a
                :style="changeSelectStyle == 3 ? 'color:rgb(8, 213, 240);cursor: pointer;' : ''">{{ title400 }}</a></el-breadcrumb-item>
            <el-breadcrumb-item v-if="level >= 500" @click.native="topath('#id500', 4)"><a
                :style="changeSelectStyle == 4 ? 'color:rgb(8, 213, 240);cursor: pointer;' : ''">{{ title500 }}</a></el-breadcrumb-item>
            <el-breadcrumb-item v-if="level >= 600" @click.native="topath('#id600', 5)"><a
                :style="changeSelectStyle == 5 ? 'color:rgb(8, 213, 240);cursor: pointer;' : ''">{{ title600 }}</a></el-breadcrumb-item>
            <el-breadcrumb-item v-if="level >= 700" @click.native="topath('#id700', 6)"><a
                :style="changeSelectStyle == 6 ? 'color:rgb(8, 213, 240);cursor: pointer;' : ''">{{ title700 }}</a></el-breadcrumb-item>
          </el-breadcrumb>
        </div>
      </div>
      <!--页面查看 回显 编辑 删除-->
      <el-form class="main-form overview_scroll" :label-position="'right'" :model="AddProjectBO" label-width="120px"
        ref="mainForm" style="height: 78vh; overflow-y: scroll;">
        <div class="form-top flex">
          <!--项目名称((pageStatus != 3 && (nodeLevel > 0 && (nodeLevel &lt; 700 || pageStatus == 2))) || (pageStatus == 3 && nodeLevel == 100))-->
          <el-form-item id='id100' class="form-item"
            v-if="AddProjectBO.projectBO &&
              ((pageStatus != 3 && (nodeLevel > 0 && (nodeLevel &lt; 700 || pageStatus == 2))) || (nodeLevel > 0 && (nodeLevel &lt; 700 || pageStatus == 3)))"
            label="项目名称:" :prop="'projectBO.name'" :rules="{ required: true, message: '请输入项目名称', trigger: 'blur', }">
            <!-- <el-input v-model="AddProjectBO.projectBO.name" :disabled="pageStatus == 1" ></el-input> -->
            <el-select v-model="AddProjectBO.projectBO.name" placeholder="请选择项目类型"
              :disabled="nodeLevel > 100 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
              <el-option v-for="item in project" :key="item.name" :label="item.name" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <!--行政区域 ((pageStatus != 3 && (nodeLevel > 100 && (nodeLevel &lt; 700 || pageStatus == 2))) || (pageStatus == 3 && nodeLevel == 200))-->
          <el-form-item id='id200' class="form-item"
            v-if="AddProjectBO.provinceBO &&
              ((pageStatus != 3 && (nodeLevel > 100 && (nodeLevel &lt; 700 || pageStatus == 2))) || (nodeLevel > 0 && (nodeLevel &lt; 700 || pageStatus == 3)))"
            label="行政区域:" :prop="'provinceBO.name'"
            :rules="[{ required: true, message: '请选择行政区域', trigger: 'change' },]">
            <el-select v-model="AddProjectBO.provinceBO.name" @change="change(AddProjectBO.provinceBO.name)"
              placeholder="请选择行政区域"
              :disabled="nodeLevel > 200 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
              <el-option v-for="item in city" :key="item.name" :label="item.dicName" :value="item.dicIndex"></el-option>
            </el-select>
          </el-form-item>
          <!--供电公司 ((pageStatus != 3 && (nodeLevel > 200 && (nodeLevel &lt; 700 || pageStatus == 2))) || (pageStatus == 3 && nodeLevel == 300))-->
          <el-form-item id='id300' class="form-item"
            v-if="AddProjectBO.gdInformationBO &&
              ((pageStatus != 3 && (nodeLevel > 200 && (nodeLevel &lt; 700 || pageStatus == 2))) || (nodeLevel > 0 && (nodeLevel &lt; 700 || pageStatus == 3)))"
            label="供电公司:" :prop="'gdInformationBO.name'"
            :rules="[{ required: true, message: '请输入供电公司', trigger: 'blur' },]">
            <el-input v-model="AddProjectBO.gdInformationBO.name"
              :disabled="nodeLevel > 300 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-input>
          </el-form-item>
        </div>
        <!--变电站((pageStatus != 3 &&(nodeLevel > 300 && (nodeLevel &lt; 700 || pageStatus == 2))) || (pageStatus == 3 && nodeLevel == 400))-->
        <div id="id400" class="form-zhan"
          v-if="AddProjectBO.subStationBO &&
            ((pageStatus != 3 && (nodeLevel > 300 && (nodeLevel &lt; 700 || pageStatus == 2))) || (nodeLevel > 0 && (nodeLevel &lt; 700 || pageStatus == 3)))">
          <!-- <div class="form-tag">
            <el-tag type="warning" style="width:100%;border-color: #abbec26c;">变电站:</el-tag> 
          </div> -->
          <div class="flex">
            <el-form-item class="form-item" label="变电站:" :prop="'subStationBO.name'"
              :rules="{ required: true, message: '请输入变电站名称', trigger: 'blur', }">
              <el-input v-model="AddProjectBO.subStationBO.name"
                :disabled="nodeLevel > 400 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-input>
            </el-form-item>
            <el-form-item class="form-item" label="经度:" :prop="'subStationBO.latitude'"
              :rules="[{ required: true, message: '请输入经度', trigger: 'blur' },]">
              <el-input v-model="AddProjectBO.subStationBO.latitude"
                :disabled="nodeLevel > 400 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-input>
            </el-form-item>
            <el-form-item class="form-item" label="纬度:" :prop="'subStationBO.longitude'"
              :rules="[{ required: true, message: '请输入维度', trigger: 'blur' },]">
              <el-input v-model="AddProjectBO.subStationBO.longitude"
                :disabled="nodeLevel > 400 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-input>
            </el-form-item>
            <el-form-item class="form-item" label="电压等级:" :prop="'subStationBO.scale'"
              :rules="[{ required: true, message: '选中电压等级', trigger: 'change' },]">
              <el-select v-model="AddProjectBO.subStationBO.scale" placeholder="请选择电压等级"
                :disabled="nodeLevel > 400 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                <el-option v-for="item in voltageLevelArr" :key="item.name" :label="item.dicName"
                  :value="item.dicIndex"></el-option>
              </el-select>
            </el-form-item>
          </div>
        </div>
        <!--终端设备-->
        <div id="id500" class="form-device" v-if="((pageStatus != 3 && (nodeLevel > 300 && (nodeLevel &lt; 700 || pageStatus == 2)))|             (pageStatus == 3 && 400 < nodeLevel && nodeLevel &lt;= 700))">
          <!-- <div class="form-tag">
            <el-tag style="width:100%;border-color: #04738a6c;">终端设备:</el-tag>
          </div> -->
          <el-tabs v-if="AddProjectBO.deviceBO && AddProjectBO.deviceBO.length" v-model="deviceIndex" type="card"
            :editable="pageStatus != 1" @edit="handleDeviceTabsEdit" @tab-click="tabChange('deviceIndex')">
            <el-tab-pane v-for="(item, index) in AddProjectBO.deviceBO" :key="index"
              :label="item.name ? item.name : '新建终端' + index" :name="index + ''">
              <div class="flex">
                <el-form-item class="form-item" label="名称:" :prop="'deviceBO.' + index + '.name'"
                  :rules="[{ required: true, message: '请输入名称', trigger: 'blur' },]">
                  <el-input v-model="item.name"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"
                    placeholder="请输入名称"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="通讯状态:" :prop="'deviceBO.' + index + '.status'"
                  :rules="[{ required: true, message: '请选择通讯状态', trigger: 'change', },]">
                  <el-select v-model="item.status" placeholder="请选择通讯状态"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in comStatusArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="终端模型:" :prop="'deviceBO.' + index + '.devModel'"
                  :rules="[{ required: true, message: '请选择终端模型', trigger: 'change', },]">
                  <el-select v-model="item.devModel" placeholder="请选择终端模型"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in terminalModelArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="数据模型:" :prop="'deviceBO.' + index + '.dataType'"
                  :rules="[{ required: true, message: '请选择数据模型', trigger: 'change', },]">
                  <el-select v-model="item.dataType" placeholder="请选择数据模型"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in dataModelArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="厂家:" :prop="'deviceBO.' + index + '.manufacturer'"
                  :rules="[{ required: true, message: '请选择厂家', trigger: 'change', },]">
                  <el-select v-model="item.manufacturer" placeholder="请选择厂家"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in factoryArr" :key="option.dicIndex" :label="option.dicName"
                      :value="option.dicIndex"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="所属前置机:" :prop="'deviceBO.' + index + '.nodeIndex'"
                  :rules="[{ required: true, message: '请选择所属前置机', trigger: 'change', },]">
                  <el-select v-model="item.nodeIndex" placeholder="请选择所属前置机"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in affiliatiedFrontArr" :key="option.name" :label="option.nodeName"
                      :value="option.nodeIndex"></el-option>
                  </el-select> <el-button type="primary" icon="el-icon-share" circle size="mini"
                    style="position:absolute;margin-top:3px"></el-button>
                </el-form-item>
                <el-form-item class="form-item" label="召唤标志:" :prop="'deviceBO.' + index + '.callFlag'" :rules="[{ required: true, message: '请选择召唤标志', trigger: 'change', },
                ]">
                  <el-select v-model="item.callFlag" placeholder="请选择召唤标志"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in summonSignArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="识别码:" :prop="'deviceBO.' + index + '.devSeries'"
                  :rules="[{ required: true, message: '请输入识别码', trigger: 'blur', },]">
                  <el-input v-model="item.devSeries"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"
                    show-password placeholder="请输入识别码"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="密钥:" :prop="'deviceBO.' + index + '.devKey'"
                  :rules="[{ required: true, message: '请输入密钥', trigger: 'change', },]">
                  <el-input v-model="item.devKey"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"
                    show-password placeholder="请输入密钥"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="电度功能" :prop="'deviceBO.' + index + '.electroplate'"
                  :rules="[{ required: true, message: '请选择电度功能', trigger: 'change', },]">
                  <el-select v-model="item.electroplate" placeholder="请选择电度功能"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in electroplateCanArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="投运时间:">
                  <el-date-picker type="date" placeholder="选择日期" format=yyyy-MM-dd value-format=yyyy-MM-dd
                    v-model="deviceBODetail.logTime"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-date-picker>
                </el-form-item>
                <el-form-item class="form-item" label="本次定检时间:">
                  <el-date-picker type="date" placeholder="选择日期" format=yyyy-MM-dd value-format=yyyy-MM-dd
                    v-model="deviceBODetail.thisTime"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-date-picker>
                </el-form-item>
                <el-form-item class="form-item" label="下次定检时间:">
                  <el-date-picker type="date" placeholder="选择日期" format=yyyy-MM-dd value-format=yyyy-MM-dd
                    v-model="deviceBODetail.nextTime"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-date-picker>
                </el-form-item>
                <el-form-item class="form-item" label="数据更新时间:">
                  <el-date-picker type="date" placeholder="选择日期" format=yyyy-MM-dd value-format=yyyy-MM-dd
                    v-model="deviceBODetail.updTime"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-date-picker>
                </el-form-item>
                <el-form-item class="form-item" label="设备型号:" :prop="'deviceBO.' + index + '.devType'"
                  :rules="[{ required: true, message: '请选择设备型号', trigger: 'change', },]">
                  <el-select v-model="item.devType" placeholder="请选择设备型号"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in typeArr" :key="option.devType" :label="option.dicName"
                      :value="option.dicIndex"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="IP/MAC地址:" :prop="'deviceBO.' + index + '.ip'"
                  :rules="[{ required: true, validator: validateIPAddress, trigger: 'blur', },]">
                  <el-input v-model="item.ip"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"
                    placeholder="请输入IP地址"></el-input>
                </el-form-item>
                <!-- <el-form-item class="form-item" label="供电公司:" :prop="'deviceBO.' + index + '.gdName'"
                    :rules="[{required: true, message: '请输入供电公司', trigger: 'blur',},]"
                >
                  <el-input v-model="item.gdName" :disabled="pageStatus == 1" placeholder="请输入供电公司" ></el-input>
                </el-form-item> -->
                <!-- <el-form-item class="form-item" label="所属变电站:">
                  <el-input v-model="item.zhan" :disabled="pageStatus == 1" placeholder="请输入所属变电站" ></el-input>
                </el-form-item> -->
                <el-form-item class="form-item" label="端口号:" :prop="'deviceBO.' + index + '.portId'"
                  :rules="[{ required: true, message: '请输入端口号', trigger: 'blur', },]">
                  <el-input v-model="item.portId" placeholder="请输入端口号"
                    :disabled="nodeLevel > 500 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-input>
                </el-form-item>
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
        <!--母线-->
        <div id="id600" class="form-bus" v-if="((pageStatus != 3 && (nodeLevel > 400 && (nodeLevel &lt;= 700 || pageStatus == 2)))              (pageStatus == 3 && 400 < nodeLevel && nodeLevel &lt;= 700))">
          <!-- <div class="form-tag">
           <el-tag type="danger" style="width:100%; background-color:#996a7048;border-color: #7e3a3a5e;">母线:</el-tag> 
          </div> -->
          <el-tabs v-if="AddProjectBO.deviceBO && AddProjectBO.deviceBO.length && AddProjectBO.deviceBO[deviceIndex] &&
            AddProjectBO.deviceBO[deviceIndex].subVoltage &&
            AddProjectBO.deviceBO[deviceIndex].subVoltage.length
          " v-model="busBarIndex" type="card" :editable="pageStatus != 1" @edit="handleBusBarTabsEdit"
            @tab-click="tabChange('busBarIndex')">
            <el-tab-pane v-for="(busItem, bIndex) in AddProjectBO.deviceBO[deviceIndex].subVoltage" :key="bIndex"
              :label="busItem.name ? busItem.name : '新建母线' + bIndex" :name="bIndex + ''">
              <div class="flex">
                <el-form-item class="form-item" label="母线名称:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + bIndex + '.name'"
                  :rules="{ required: true, message: '请输入母线名称', trigger: 'blur', }">
                  <el-input v-model="busItem.name" placeholder="请输入母线名称"
                    :disabled="nodeLevel > 600 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="母线编号:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + bIndex + '.subvNum'"
                  :rules="{ required: true, message: '请输入母线编号', trigger: 'blur', }">
                  <el-select v-model="busItem.subvNum" placeholder="请选择母线编号"
                    :disabled="nodeLevel > 600 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in optionarr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                  <!-- <el-input v-model="busItem.subvNum" placeholder="请输入母线编号" :disabled="pageStatus == 1"></el-input> :value="{label:option.dicName,value:option.dicIndex}" -->
                </el-form-item>
                <el-form-item class="form-item" label="电压等级:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + bIndex + '.scale'"
                  :rules="{ required: true, message: '请选择电压等级', trigger: 'blur', }">
                  <el-select v-model="busItem.scale" placeholder="请选择电压等级"
                    :disabled="nodeLevel > 600 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1"
                    @change="selectChanged">
                    <el-option v-for="option in voltageLevelArr" :key="option.dicName" :label="option.dicName"
                      :value="option.dicIndex"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="母线类型:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + bIndex + '.subvModel'"
                  :rules="{ required: true, message: '请选择母线类型', trigger: 'blur', }">
                  <el-select v-model="busItem.subvModel" placeholder="请选择母线类型"
                    :disabled="nodeLevel > 600 && (pageStatus == 3 || pageStatus == 2) ? pageStatus == 3 || pageStatus == 2 : pageStatus == 1">
                    <el-option v-for="option in busBarType" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
        <!--监测点-->
        <div id="id700" class="form-point"
          v-if="((pageStatus != 3 && (nodeLevel > 400 && (nodeLevel &lt;= 700 || pageStatus == 2))) || (pageStatus == 3 && 400 < nodeLevel && nodeLevel &lt;= 700))">
          <!-- <div class="form-tag">
           <el-tag type="success" style="width:100%;background-color: #83b49b93;border-color: #62b1a65e;">监测点:</el-tag>
          </div> -->
          <el-tabs v-if="AddProjectBO.deviceBO && AddProjectBO.deviceBO.length && AddProjectBO.deviceBO[deviceIndex] &&
            AddProjectBO.deviceBO[deviceIndex].subVoltage &&
            AddProjectBO.deviceBO[deviceIndex].subVoltage.length &&
            AddProjectBO.deviceBO[deviceIndex].subVoltage[busBarIndex] &&
            AddProjectBO.deviceBO[deviceIndex].subVoltage[busBarIndex].line &&
            AddProjectBO.deviceBO[deviceIndex].subVoltage[busBarIndex].line.length
          " v-model="lineIndex" :editable="pageStatus != 1" @edit="handleLineTabsEdit" type="card"
            @tab-click="tabChange('lineIndex')">
            <el-tab-pane v-for="(lineItem, lIndex) in AddProjectBO.deviceBO[deviceIndex].subVoltage[busBarIndex].line"
              :key="lIndex" :label="lineItem.name ? lineItem.name : '新建监测点' + lIndex" :name="lIndex + ''">
              <div class="flex">
                <el-form-item class="form-item" label="监测点名称:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.name'"
                  :rules="{ required: true, message: '请输入监测点名称', trigger: 'blur', }">
                  <el-input v-model="lineItem.name" :disabled="pageStatus == 1" placeholder="请输入监测点名称"></el-input>
                </el-form-item>
                <!-- <el-form-item class="form-item" label="所属部门:"
                 :prop="'deviceBO.'+[deviceIndex]+'.subVoltage.' + [busBarIndex] + '.line.'+lIndex+'.deptIndex'"
                :rules="{ required: true,message: '请选择部门', trigger: 'blur',}">
                  <el-select v-model="lineItem.deptIndex" placeholder="请选择部门" :disabled="pageStatus == 1">
                    <el-option v-for="option in departmentArr"
                        :key="option.dicIndex"
                        :label="option.deptsName"
                        :value="option.deptsIndex"
                    ></el-option>
                  </el-select>
                </el-form-item> -->
                <el-form-item class="form-item" label="监测点序号:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.lineNum'"
                  :rules="{ required: true, message: '请选择监测点序号', trigger: 'blur', }">
                  <el-select v-model="lineItem.lineNum" placeholder="请选择序号" :disabled="pageStatus == 1">
                    <el-option v-for="option in pointNumArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <!-- <el-form-item class="form-item" label="电压等级:"
                 :prop="'deviceBO.'+[deviceIndex]+'.subVoltage.' + [busBarIndex] + '.line.'+lIndex+'.scale'"
                :rules="{ required: true,message: '请选择电压等级', trigger: 'blur',}">
                  <el-select v-model="monitorPointDetail.scale" placeholder="请选择电压等级" :disabled="pageStatus == 1"  @change="selectChanged">
                    <el-option v-for="option in voltageLevelArr"
                        :key="option.dicIndex"
                        :label="option.dicName"
                        :value="{value:option.dicIndex,label:option.dicName}"
                    ></el-option>
                  </el-select>
                </el-form-item> -->
                <!-- :prop="'deviceBO.'+[deviceIndex]+'.subVoltage.' + [busBarIndex] + '.line.'+lIndex+'.jzCmp'"
                :rules="{ required: true,message: '请输入基准量', trigger: 'blur',}" -->
                <el-form-item class="form-item" label="基准容量:">
                  <el-input v-model="monitorPointDetail.jzCmp" :disabled="pageStatus == 1"
                    placeholder="请输入基准容量"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="短路容量:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.dlCmp'"
                  :rules="{ required: true, message: '请输入短路容量', trigger: 'blur', }">
                  <el-input v-model="monitorPointDetail.dlCmp" :disabled="pageStatus == 1"
                    placeholder="请输入短路容量"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="设备容量:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.devCmp'"
                  :rules="{ required: true, message: '请输入设备容量', trigger: 'blur', }">
                  <el-input v-model="lineItem.devCmp" :disabled="pageStatus == 1" placeholder="请输入设备容量"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="协议容量:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.xyCmp'"
                  :rules="{ required: true, message: '请输入协议容量', trigger: 'blur', }">
                  <el-input v-model="lineItem.xyCmp" :disabled="pageStatus == 1" placeholder="请输入协议容量"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="测量点间隔:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.tinterval'"
                  :rules="{ required: true, message: '请选择测点间隔', trigger: 'blur', }">
                  <el-select v-model="lineItem.tinterval" placeholder="请选择测量点间隔" :disabled="pageStatus == 1">
                    <el-option v-for="option in lineSpaceArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="PT变化:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.pt1'"
                  :rules="{ required: true, message: '请输入pt', trigger: 'blur', }">
                  <div class="flex" style="justify-content:space-between">
                    <el-input style="width: 48%;" v-model="monitorPointDetail.pt1"
                      :disabled="pageStatus == 1"></el-input>
                    <el-input style="width: 48%;" v-model="monitorPointDetail.pt2"
                      :disabled="pageStatus == 1"></el-input>
                  </div>
                </el-form-item>
                <el-form-item class="form-item" label="CT变化:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.ct1'"
                  :rules="{ required: true, message: '请输入ct', trigger: 'blur', }">
                  <div class="flex" style="justify-content:space-between">
                    <el-input style="width: 48%;" v-model="lineItem.ct1" :disabled="pageStatus == 1"></el-input>
                    <el-input style="width: 48%;" v-model="lineItem.ct2" :disabled="pageStatus == 1"></el-input>
                  </div>
                </el-form-item>
                <el-form-item class="form-item" label="接线类型:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.ptType'"
                  :rules="{ required: true, message: '请选择接线类型', trigger: 'blur', }">
                  <el-select v-model="lineItem.ptType" placeholder="请选择接线类型" :disabled="pageStatus == 1">
                    <el-option v-for="option in wiringTypeArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="负荷类型:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.loadType'"
                  :rules="{ required: true, message: '请选择负荷类型', trigger: 'blur', }">
                  <el-select v-model="lineItem.loadType" placeholder="请选择负荷类型" :disabled="pageStatus == 1">
                    <el-option v-for="option in loadTypeArr" :key="option.dicIndex" :label="option.dicName"
                      :value="option.dicIndex"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="行业类型:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.businessType'"
                  :rules="{ required: true, message: '请选择行业类型', trigger: 'blur', }">
                  <el-select v-model="lineItem.businessType" placeholder="请选择行业类型" :disabled="pageStatus == 1">
                    <el-option v-for="option in industryTypeArr" :key="option.dicIndex" :label="option.dicName"
                      :value="option.dicIndex"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="谐波监测号:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.monitorId'"
                  :rules="{ required: true, message: '请输入网公司谐波监测号', trigger: 'blur', }">
                  <el-input v-model="lineItem.monitorId" :disabled="pageStatus == 1"
                    placeholder="请输入网公司谐波监测号"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="电压下偏差:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.uvoltageDev'"
                  :rules="{ required: true, message: '请输入电压下偏差', trigger: 'blur', }">
                  <el-input v-model="lineItem.uvoltageDev" :disabled="pageStatus == 1"
                    placeholder="请输入电压下偏差"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="对象名称:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.objName'"
                  :rules="{ required: true, message: '请输入对象名称', trigger: 'blur', }">
                  <el-input v-model="lineItem.objName" :disabled="pageStatus == 1" placeholder="请输入对象名称"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="测量点性质:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.powerId'"
                  :rules="{ required: true, message: '请选择测量点性质', trigger: 'blur', }">
                  <el-select v-model="lineItem.powerId" placeholder="请选择测量点性质" :disabled="pageStatus == 1">
                    <el-option v-for="option in lineNatureArr" :key="option.name" :label="option.name"
                      :value="option.value"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item class="form-item" label="电压上偏差:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.voltageDev'"
                  :rules="{ required: true, message: '请输入电压上偏差', trigger: 'blur', }">
                  <el-input v-model="lineItem.voltageDev" :disabled="pageStatus == 1" placeholder="请输入电压上偏差"></el-input>
                </el-form-item>
                <el-form-item class="form-item" label="备注:"
                  :prop="'deviceBO.' + [deviceIndex] + '.subVoltage.' + [busBarIndex] + '.line.' + lIndex + '.remark'"
                  :rules="{ required: true, message: '请输入备注', trigger: 'blur', }">
                  <el-input v-model="lineItem.remark" :disabled="pageStatus == 1" placeholder="请输入备注"></el-input>
                </el-form-item>
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
      </el-form>
      <!-- <el-button size="mini" type="primary" @click="next" v-if="nodeLevel <= 600 && pageStatus == 2">下一步</el-button>
       <el-button size="mini" type="info" @click="black" v-if="nodeLevel <= 700 && (pageStatus == 2 || pageStatus ==3)">撤  销</el-button>
      <el-button size="mini" text-align="center" type="success" v-if="pageStatus == 2" @click="onsubmit">确认提交</el-button>
      <el-button size="mini" text-align="center" type="success" v-if="pageStatus == 3" @click="onsubmit">修改提交</el-button> -->
    </el-main>
  </el-container>
</template>
<script>
//import http from "@/request";
import api from '@/api/Terminal/decive'
export default {
  data() {
    return {
      /**树结构 */
      treeMenus: [],
      /**树配置选项 */
      defaultProps: {
        children: "children",
        label: "name",
      },
      optionarr: [{ name: '1号母线', value: 1 }, { name: '2号母线', value: 2 }, { name: '3号母线', value: 3 }, { name: '4号母线', value: 4 }, { name: '5号母线', value: 5 }, { name: '6号母线', value: 6 }],
      /**搜索关键字 */
      keyword: "",
      /**项目名称 */
      project: [{ name: '在线项目', value: 0 }, { name: '普测项目', value: 1 }],
      projectBO: { name: "", },
      /**城市列表 */
      city: [],
      /**行政区域 */
      provinceBO: { name: "8f49dc63-f5f9-4bb4-9019-b4d6f051a4c1", },
      /**供电公司 */
      gdInformationBO: { name: "", },
      /**变电站 */
      subStationBO: {
        /**名称 */
        name: "",
        /**经度 */
        longitude: "0",
        /**纬度 */
        latitude: "0",
        /**电压等级 */
        scale: "7c968e45-d427-4b0e-af98-954b03f60337",
      },
      /**设备数组 */
      deviceBO: [],
      /**设备详情 */
      deviceBODetail: {
        /**名称 */
        name: "",
        /**设备id*/
        devIndex: '',
        /**设备型号 */
        devType: 'e66f038f-e3c9-4aec-b5e9-857f9141b4e8',
        /**ip */
        ip: "255.255.255.255",
        /**通讯状态 */
        status: 0,
        /**投运时间 */
        logTime: "",
        /**数据更新时间 */
        updTime: "",
        /**所属变电站 */
        zhan: "",
        /**所属前置机 */
        nodeIndex: 1,
        /**终端模型 */
        devModel: 0,
        /**本次定检时间 */
        thisTime: "",
        /**下次定检时间 */
        nextTime: "",
        /**厂家 */
        manufacturer: '4b5719d1-4a01-4816-900b-c499a0e9d203',
        /**数据模型 */
        dataType: 0,
        /**端口号 */
        portId: 102,
        /**电镀功能 */
        electroplate: 0,
        /**识别码 */
        devSeries: "",
        /**召唤标志 */
        callFlag: 0,
        /**密钥 */
        devKey: "",
        /**母线*/
        subVoltage: [],
        /**供电公司 */
        gdName: this.currentGdName
      },
      /**通讯状态选项 */
      comStatusArr: [{ name: "中断", value: 0 }, { name: "正常", value: 1 },],
      /**终端模型选项 */
      terminalModelArr: [{ name: "实际终端", value: 0 }, { name: "虚拟终端", value: 1 }, { name: "离线终端", value: 2 }],
      /**电镀功能选项 */
      electroplateCanArr: [{ name: "开启", value: 0 }, { name: "关闭", value: 1 },],
      /**数据模型选项 */
      dataModelArr: [{ name: "暂降系统", value: 0 }, { name: "稳态系统", value: 1 }, { name: "双系统", value: 2 }],
      /**召唤标志选项 */
      summonSignArr: [{ name: "变位触发", value: 0 }, { name: "周期触发", value: 1 },],
      /**厂家选项 */
      factoryArr: [],
      /**型号选项 */
      typeArr: [],
      /**所属前置机选项 */
      affiliatiedFrontArr: [],
      /**所属变电站选项 */
      affiliatedSubstationArr: [{ name: "测试变电站1", value: "0" }, { name: "测试变电站2", value: "1" }, { name: "测试变电站3", value: "2" },],
      /**母线详情 */
      busBarDetail: {
        /**母线名称 */
        name: "",
        /**母线编号 */
        subvNum: 0,
        /**电压等级 */
        scale: "9e1d86ea-986c-4dfb-a30e-a0f3e29a2c4e",
        /**母线类型 */
        subvModel: 0,
        /**母线id */
        subvIndex: '',
        /**监测点 */
        line: [],
      },
      /**电压等级选项 */
      voltageLevelArr: [],
      /**母线类型 */
      busBarType: [{ name: "实际母线", value: 1 }, { name: "虚拟母线", value: 0 },],
      /**监测点详情 */
      monitorPointDetail: {
        /**行业类型 */
        businessType: "24afb5d9-7509-413b-88f0-84fd790a54c1",
        /**CT变比 */
        ct1: 300,
        /**CT变比 */
        ct2: 5,
        /**所属部门 */
        deptIndex: "483e2fc7-c343-4df1-9f87-5634dcd28c9f",
        /**设备容量 */
        devCmp: 10,
        /**短路容量 */
        dlCmp: 7000,
        /**基准容量 */
        jzCmp: 7000,
        /**监测点id */
        lineIndex: '',
        /**监测点序号 */
        lineNum: 0,
        /**负荷类型 */
        loadType: "bd7e101a-cc33-4377-a65c-0be337eead1f",
        /**网公司监测号 */
        monitorId: "",
        /**监测点名称 */
        name: "",
        /**对象名称 */
        objName: "",
        /**监测点性质 */
        powerId: 0,
        /**PT比 */
        pt1: 0,
        /**PT比 */
        pt2: 0,
        /**接线类型 */
        ptType: 0,
        /**测点间隔 */
        tinterval: 1,
        /**协议容量 */
        xyCmp: 10,
        /**电压等级 */
        scale: '7c968e45-d427-4b0e-af98-954b03f60337',
        /**备注 */
        remark: "",
        /**电压上偏差 */
        voltageDev: 10,
        /**电压下偏差 */
        uvoltageDev: 10,
        /**供电公司 */
        gdName: this.currentGdName,
      },
      /**所属部门选项 */
      departmentArr: [],
      /**监测点序号 */
      pointNumArr: [{ name: "1", value: 1 }, { name: "2", value: 2 }, { name: "3", value: 3 }, { name: "4", value: 4 }, { name: "5", value: 5 }, { name: "6", value: 6 },],
      /**接线类型选项 */
      wiringTypeArr: [{ name: "星型接线", value: 0 }, { name: "三角型接线", value: 1 },],
      /**负荷类型选项 */
      loadTypeArr: [],
      /**行业类型选项 */
      industryTypeArr: [],
      /**监测点间隔 */
      lineSpaceArr: [{ name: "1分钟", value: 0 }, { name: "3分钟", value: 1 }, { name: "5分钟", value: 2 }, { name: "10分钟", value: 3 },],
      /**监测点性质 */
      lineNatureArr: [{ name: "电网侧", value: 0 }, { name: "非电网侧", value: 1 }],
      /**项目数据 */
      AddProjectBO: {
        /**项目Id */
        projectIndex: 0,
        /**行政区域Id */
        provinceIndex: 0,
        /**供电公司Id*/
        gdIndex: 0,
        /**变电站Id*/
        subIndex: 0,
        /**设备Id */
        devIndex: 0,
        /**母线ID */
        subvIndex: 0,
        /**项目名称 */
        projectBO: null,
        /**行政区域 */
        provinceBO: null,
        /**供电公司 */
        gdInformationBO: null,
        /**变电站 */
        subStationBO: null,
        /**终端设备   母线  母线下面subVoltage是监测点*/
        deviceBO: null,
      },
      /**修改项目对象 */
      updateProject: null,
      /**当前选中的节点 */
      nodeData: {},
      /**当前点击节点level,跟节点0*/
      nodeLevel: 0,
      /**状态 1查看 2新增 3修改*/
      pageStatus: 1,
      /**项目Id */
      projectId: 0,
      /**行政区域Id*/
      provinceId: 0,
      /**供电公司Id*/
      gdId: 0,
      /**变电站Id */
      subId: 0,
      /**设备Id */
      devId: 0,
      /**母线Id */
      busBarId: 0,
      /**监测点Id*/
      lineId: 0,
      /**当前选中设备的Index */
      deviceIndex: '0',
      /**当前选中母线的Index */
      busBarIndex: '0',
      /**当选选中监测点的Index */
      lineIndex: '0',
      /**当前供电公司名字 */
      currentGdName: "",
      treeClickCount: '',
      navgatorIndex: 0,
      currentNode: '',
      currentNodeKey: '',
      currentuuid: 0,
      parentId: null,
      trdata: null,
      trnode: null,
      title100: '',
      title200: '',
      title300: '',
      title400: '',
      title500: '',
      title600: '',
      title700: '',
      level: '',
      changeSelectStyle: null,
      /**IP验证器 */
      validateIPAddress: (rule, value, callback) => {
        let regexp = /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/;

        // let regexp =/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/;
        //let regex=/[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}:[A-F\d]{2}/; 
        var isCorrect = regexp.test(value);

        //var isMac = regex.test(value)
        if (value == "") {
          return callback(new Error("请输入IP地址"));
        } else if (!isCorrect) {
          callback(new Error("请输入正确的IP地址"));
        } else {
          callback();
        }
      },
    };
  },
  watch: {
    /**根据名称筛选树 */
    keyword(val) {
      this.$refs.tree.filter(val);
    },
    currentNodeKey(uuid) {
      // Tree 内部使用了 Node 类型的对象来包装用户传入的数据，用来保存目前节点的状态。可以用 $refs 获取 Tree 实例
      if (uuid.toString()) {
        this.$refs["tree"].setCurrentKey(uuid);
      } else {
        this.$refs["tree"].setCurrentKey(null);
      }
    }
  },
  created() {
    this.treedata();
  },
  mounted() {
    /**
     * 获取下拉选项
     * 注意后端返回数据的格式
     * 除city外-> this.city
     * 定义格式均为[{name: string, value: string}]
     * 如后端返回数据不一样 请自行修改
     */
    this.getFactory();
    this.getDeviceType();
    this.getdayValue();
    this.getAffiliatiedFront();
    this.getScale();
    this.getLoadType();
    this.getIndustryType();
    this.getArea();
    this.getDepartment();
    this.getLineSpace();
    this.getLineNature();
    this.getLineNum();
    this.bindResize();
  },
  methods: {
    topath(selector, val) {
      // console.log(this.$el.querySelector(selector))
      this.$el.querySelector(selector).scrollIntoView({
        behavior: "smooth", // 平滑过渡
        block: "start" // 上边框与视窗顶部平齐
      });
      this.changeSelectStyle = val;
    },
    /**筛选节点 */
    filterNode(value, data) {
      if (!value) return true;
      return data.name.indexOf(value) !== -1;
    },
    /**
     * 缩放条拖动进而改变左侧div宽度方法
     */
    bindResize() {
      /**开始坐标 */
      let startX;
      /**开始宽度 */
      let startWidth = getScalableDivWidth();

      document.querySelector("#drag-dept").addEventListener("mousedown", startDrag);

      function startDrag(e) {
        startX = e.clientX;
        startWidth = getScalableDivWidth();

        document.documentElement.addEventListener("mousemove", onDrag);
        document.documentElement.addEventListener("mouseup", stopDrag);
      }

      function onDrag(e) {
        let newWidth = startWidth + e.clientX - startX;
        document.querySelector("#drag-dept-left").style.width = newWidth + "px";
      }

      function stopDrag() {
        document.documentElement.removeEventListener("mousemove", onDrag);
        document.documentElement.removeEventListener("mouseup", stopDrag);
      }

      /**获取宽度 */
      function getScalableDivWidth() {
        return parseInt(
          window.getComputedStyle(document.querySelector("#drag-dept-left")).width, 10);
      }
    },
    /**
     * 获取树结构
     */
    treedata() {
      api.tree().then(response => {
        var treeMenus = []
        this.$refs["tree"].setCurrentKey(this.currentNode);
        //let node=  this.$refs.tree.getNode()
        //this.handleNodeClick(data, node)
        window.uuid = 0
        treeMenus = response.data;
        this.test_parse(treeMenus)
        // console.log(treeMenus)
        this.treeMenus = treeMenus
        if (this.trnode) {
          this.handleNodeClick(this.trdata, this.trnode)
        } else {
          return;
        }

      })
    },

    test_parse(treeMenus) {
      for (var key in treeMenus) {
        // console.log(treeMenus[key])  
        treeMenus[key].uuid = uuid++
        if (treeMenus[key].children) {
          this.test_parse(treeMenus[key].children)
        }
      }
    },
    /**
     * 点击节点回调
     * @param data 传递给 data 属性的数组中该节点所对应的对象
     * @param node 节点对应的 Node
     */
    handleNodeClick(data, node) {
      this.trdata = data
      this.trnode = node
      // data为被点击节点数据
      // 记录点树节点击次数
      this.treeClickCount++
      if (this.treeClickCount > 2) return
      setTimeout(() => {
        if (this.treeClickCount == 1) {
          // 进行单击事件处理
          // console.log('单击事件', data)
          // 进行双击事件处理

          if (this.pageStatus == 2 || this.pageStatus == 3) {
            if (this.pageStatus == 3 || this.pageStatus == 2) {
              this.$message({
                type: "warning",
                message: "请先提交,再做操作",
              });
            }
            return;
          }
          this.currentNode = 0
          this.pageStatus = 1;
          this.nodeData = node;
          this.level = node.data.level
          if (node.data.level == 0) {
            this.title0 = node.data.name
          } else if (node.data.level == 100) {
            this.title100 = node.data.name
            // this.title200=node.parent.data.name
          } else if (node.data.level == 200) {
            this.title200 = node.data.name
            this.title100 = node.parent.data.name
          } else if (node.data.level == 300) {
            this.title300 = node.data.name
            this.title200 = node.parent.data.name
            this.title100 = node.parent.parent.data.name
          } else if (node.data.level == 400) {
            this.title400 = node.data.name
            this.title300 = node.parent.data.name
            this.title200 = node.parent.parent.data.name
            this.title100 = node.parent.parent.parent.data.name
          } else if (node.data.level == 500) {
            this.title500 = node.data.name
            this.title400 = node.parent.data.name
            this.title300 = node.parent.parent.data.name
            this.title200 = node.parent.parent.parent.data.name
            this.title100 = node.parent.parent.parent.parent.data.name
          } else if (node.data.level == 600) {
            this.title600 = node.data.name
            this.title500 = node.parent.data.name
            this.title400 = node.parent.parent.data.name
            this.title300 = node.parent.parent.parent.data.name
            this.title200 = node.parent.parent.parent.parent.data.name
            this.title100 = node.parent.parent.parent.parent.parent.data.name
          } else if (node.data.level == 700) {
            this.title700 = node.data.name
            this.title600 = node.parent.data.name
            this.title500 = node.parent.parent.data.name
            this.title400 = node.parent.parent.parent.data.name
            this.title300 = node.parent.parent.parent.parent.data.name
            this.title200 = node.parent.parent.parent.parent.parent.data.name
            this.title100 = node.parent.parent.parent.parent.parent.parent.data.name
          }

          this.currentNode = node.data.uuid
          this.currentuuid = node.data.uuid
          // this.parentId =node.data.parentId
          this.nodeLevel = data.level;
          //8-17
          this.AddProjectBO.projectBO = null;
          this.AddProjectBO.provinceBO = null;
          this.AddProjectBO.gdInformationBO = null;
          this.AddProjectBO.subStationBO = null;
          this.AddProjectBO.deviceBO = null;

          this.evaluate(node);
          if (data.level > 400) {
            this.getNodeIndex(node, data.level);
          }
          /**不是根节点请求数据 */
          if (this.nodeLevel) {
            this.queryNodeContent();
          } else {
            /**清空数据 */
            this.initAddProjectBo();
            this.initAddProjectBoId();
          }
        } else if (this.treeClickCount == 2) {
          //console.log('双击事件', data)
        }
        this.treeClickCount = 0
      }, 500)


      // this.navgatorIndex =  this.nodeLevel;

      // this.$el.querySelector(`#id${ this.nodeLevel}`).scrollIntoView({
      //   behavior: "smooth",  // 平滑过渡
      //   block:    "start"  // 上边框与视窗顶部平齐。默认值
      // });



    },
    black() {
      this.pageStatus = 1;
    },
    /**
     * 选中回调
     * @param string type
     * deviceIndex 设备切换
     * busBarIndex 母线切换
     * lineIndex 监测点切换
     */
    tabChange(type) {
      if (type == "deviceIndex") {
        this.busBarIndex = '0';
        this.lineIndex = '0';
        //this.busBarIndex = 0;
        // this.lineIndex = 0;
      } else if (type == "busBarIndex") {
        this.lineIndex = '0';
        // this.lineIndex = 0;
      }
    },
    /**
     * 根据节点获取在设备 母线 监测点的Index
     * @param object node  节点
     * @param object level 节点等级
     */
    getNodeIndex(node, level) {
      // if (level == 500) {
      //   this.deviceIndex = node.parent.data.children.findIndex((item) => item.id == node.data.id) + "";
      // //this.deviceIndex = node.parent.data.children.findIndex((item) => item.id == node.data.id);
      // }
      // if (level == 600) {
      //   this.busBarIndex = node.parent.data.children.findIndex((item) => item.id == node.data.id) + "";
      //  // this.busBarIndex = node.parent.data.children.findIndex((item) => item.id == node.data.id);
      //  // this.getNodeIndex(node.parent, node.parent.data.level);
      // }
      // if (level == 700) {
      //   this.lineIndex = node.parent.data.children.findIndex((item) => item.id == node.data.id) + "";
      //   //this.lineIndex = node.parent.data.children.findIndex((item) => item.id == node.data.id);
      //   this.getNodeIndex(node.parent, node.parent.data.level);
      // }

      this.deviceIndex = '0';
      this.busBarIndex = '0';
      this.lineIndex = '0';
    },
    /**
     * 递归赋值父节点Id
     */
    evaluate(node) {
      switch (node.data.level) {
        case 100:
          this.projectId = node.data.id;
          break;
        case 200:
          this.provinceId = node.data.id;
          break;
        case 300:
          this.gdId = node.data.id;
          break;
        case 400:
          this.subId = node.data.id;
          break;
        case 500:
          this.devId = node.data.id;
          break;
        case 600:
          this.busBarId = node.data.id;
          break;
        case 700:
          this.lineId = node.data.id;
          break;
      }
      if (node.parent) {
        this.evaluate(node.parent);
      }
    },
    /**查询节点内容 */
    queryNodeContent() {
      let data = {
        id: this.nodeData.data.id,
        level: this.nodeLevel
      }
      api.query(data).then((res) => {
        // console.log("内容详情", res);
        if (this.nodeLevel === 500) {
          var data = res.data
          /**假数据 */
          var arr = []
          var arr1 = []
          //取设备
          for (var i = 0; i < data.deviceDTO.length; i++) {
            //判断母线是否存在
            if (data.deviceDTO[0].subVoltageDTOList != null) {
              //存在
              for (var j = 0; j < data.deviceDTO[0].subVoltageDTOList.length; j++) {
                //取出已经使用母线编号
                arr.push(data.deviceDTO[0].subVoltageDTOList[j].subvNum)
                //过滤已经使用的母线编号
                for (var z = 0; z < this.optionarr.length; z++) {
                  for (var h = 0; h < arr.length; h++) {
                    if (this.optionarr[z].value == arr[h]) {
                      this.optionarr.splice(i, 1)
                    }
                  }
                }
                //判断监测点是否存在 
                if (data.deviceDTO[0].subVoltageDTOList[j].lineDTO != null) {
                  //存在
                  for (var p = 0; p < data.deviceDTO[0].subVoltageDTOList[j].lineDTO.length; p++) {
                    //取出已经使用的监测点号
                    arr1.push(data.deviceDTO[0].subVoltageDTOList[j].lineDTO[p].lineNum)
                  }
                  //  console.log(this.pointNumArr.length)
                  for (var i = 0; i < this.pointNumArr.length; i++) {
                    for (var j = 0; j < arr1.length; j++) {
                      if (this.pointNumArr[i].value === arr1[j]) {
                        this.pointNumArr.splice(i, 1)
                      }
                    }
                  }
                } else {
                  this.pointNumArr = [
                    { name: "1", value: 1 },
                    { name: "2", value: 2 },
                    { name: "3", value: 3 },
                    { name: "4", value: 4 },
                    { name: "5", value: 5 },
                    { name: "6", value: 6 }]
                }
              }
            } else {
              this.optionarr = [
                { name: '1号母线', value: 1 },
                { name: '2号母线', value: 2 },
                { name: '3号母线', value: 3 },
                { name: '4号母线', value: 4 },
                { name: '5号母线', value: 5 },
                { name: '6号母线', value: 6 }]
            }
          }

          //alert(arr)

        }
        /**对接口再放开 */
        this.AddProjectBO.projectIndex = res.data.project && res.data.project.projectIndex ? res.data.project.projectIndex : 0;
        this.AddProjectBO.provinceIndex = res.data.province && res.data.province.provinceIndex ? res.data.province.provinceIndex : 0;
        this.AddProjectBO.gdIndex = res.data.gdInformation && res.data.gdInformation.gdIndex ? res.data.gdInformation.gdIndex : 0;
        this.AddProjectBO.subIndex = res.data.subStationDTO && res.data.subStationDTO.subIndex ? res.data.subStationDTO.subIndex : 0;

        this.AddProjectBO.projectBO = {
          name: res.data.project.name
        }

        if (this.nodeLevel > 100) {
          this.AddProjectBO.provinceBO = {
            name: res.data.province.name
          }
        }

        if (this.nodeLevel > 200) {
          this.AddProjectBO.gdInformationBO = {
            name: res.data.gdInformation.name
          }
          this.currentGdName = res.data.gdInformation.name;
        }

        if (this.nodeLevel > 300) {
          this.AddProjectBO.subStationBO = this.removeRefer(res.data.subStationDTO);
          let deviceBO = this.removeRefer(res.data.deviceDTO);
          deviceBO.forEach(item => {
            item.subVoltage = item.subVoltageDTOList ? item.subVoltageDTOList : [];
            delete item.subVoltageDTOList;
            item.subVoltage.forEach(litem => {
              litem.line = litem.lineDTO ? litem.lineDTO : [];
              delete litem.lineDTO;
            })
          });
          this.AddProjectBO.deviceBO = this.removeRefer(deviceBO);
          deviceBO = null;
          // this.goToAnchor('#id'+this.nodeLevel)
        }
        //  console.log(this.AddProjectBO);
        //  console.log(this.deviceIndex);

        // this.currentGdName = this.AddProjectBO.gdInformationBO.name;
      });
    },
    /**
     * 新增
     */
    add() {
      // if (Object.keys(this.nodeData).length == 0) {
      //   this.$message({
      //     type: "warning",
      //     message: "没有选中节点",
      //   });
      //   return;
      // }
      if (this.pageStatus == 2 || this.pageStatus == 3) {
        if (this.pageStatus == 3) {
          this.$message({
            type: "warning",
            message: "请先提交修改,再新增",
          });
        }
        return;
      }
      this.pageStatus = 2;
      /**删除Id属性 */
      delete this.AddProjectBO.projectIndex;
      delete this.AddProjectBO.provinceIndex;
      delete this.AddProjectBO.gdIndex;
      delete this.AddProjectBO.subIndex;
      delete this.AddProjectBO.devIndex;
      delete this.AddProjectBO.subvIndex;
      // switch (this.nodeData.data.level) {
      switch (this.nodeLevel) {
        case 0:
          this.addProject();
          break;
        case 100:
          this.initAddProjectBo();
          this.AddProjectBO.projectIndex = this.projectId;
          this.addProvince();
          break;
        case 200:
          this.initAddProjectBo();
          this.AddProjectBO.projectIndex = this.projectId;
          this.AddProjectBO.provinceIndex = this.provinceId;
          this.addGdInformation();
          break;
        case 300:
          this.initAddProjectBo();
          this.AddProjectBO.projectIndex = this.projectId;
          this.AddProjectBO.provinceIndex = this.provinceId;
          this.AddProjectBO.gdIndex = this.gdId;
          this.addSubStation();
          break;
        case 400:
          this.initAddProjectBo();
          this.AddProjectBO.projectIndex = this.projectId;
          this.AddProjectBO.provinceIndex = this.provinceId;
          this.AddProjectBO.gdIndex = this.gdId;
          this.AddProjectBO.subIndex = this.subId;
          this.addDevice();
          break;
        case 500:
          this.AddProjectBO.projectIndex = this.projectId;
          this.AddProjectBO.provinceIndex = this.provinceId;
          this.AddProjectBO.gdIndex = this.gdId;
          this.AddProjectBO.subIndex = this.subId;
          this.AddProjectBO.devIndex = this.devId;
          this.AddProjectBO.projectBO = null;
          this.AddProjectBO.provinceBO = null;
          this.AddProjectBO.gdInformationBO = null;
          this.AddProjectBO.subStationBO = null;
          this.addSubVoltage();
          break;
        case 600:
          this.AddProjectBO.projectIndex = this.projectId;
          this.AddProjectBO.provinceIndex = this.provinceId;
          this.AddProjectBO.gdIndex = this.gdId;
          this.AddProjectBO.subIndex = this.subId;
          this.AddProjectBO.devIndex = this.devId;
          this.AddProjectBO.subvIndex = this.busBarId;
          this.AddProjectBO.projectBO = null;
          this.AddProjectBO.provinceBO = null;
          this.AddProjectBO.gdInformationBO = null;
          this.AddProjectBO.subStationBO = null;
          this.addLine();
          break;
      }
    },
    /**新增项目 */
    addProject() {
      this.nodeLevel = 100;
      this.AddProjectBO.projectBO = this.removeRefer(this.projectBO);
    },
    /**
     * 新增行政区域
     */
    addProvince() {
      this.nodeLevel = 200;
      this.AddProjectBO.provinceBO = this.removeRefer(this.provinceBO);
    },
    /**
     * 新增供电公司
     */
    addGdInformation() {
      this.nodeLevel = 300;
      this.AddProjectBO.gdInformationBO = this.removeRefer(this.gdInformationBO);
    },
    /**
     * 新增变电站
     */
    addSubStation() {
      this.nodeLevel = 400;
      this.AddProjectBO.subStationBO = this.removeRefer(this.subStationBO);
    },
    /**
     * 新增设备
     */
    addDevice() {
      this.nodeLevel = 500;
      // 不存在，赋值
      if (!this.AddProjectBO.deviceBO) {
        this.AddProjectBO.deviceBO = this.removeRefer(this.deviceBO);
      }

      const device = this.removeRefer(this.deviceBODetail);
      device.gdName = this.currentGdName;


      this.AddProjectBO.deviceBO.push(this.removeRefer(device));
      this.deviceIndex = this.AddProjectBO.deviceBO.length - 1 + "";
      //this.deviceIndex = this.AddProjectBO.deviceBO.length - 1;
    },
    /**
     * 新增母线
     */
    addSubVoltage() {
      this.nodeLevel = 600;
      this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.push(this.removeRefer(this.busBarDetail));
      this.busBarIndex = this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.length - 1 + "";
      //7-30
      // this.AddProjectBO.deviceBO.forEach(item => {
      // if (!item.subVoltageDTOList) {
      //   item.subVoltage=[]
      //    delete item.subVoltageDTOList;
      // }})
      //7-30
      // this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.push(this.removeRefer(this.busBarDetail));
      //this.busBarIndex = this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.length - 1 + "";
      // this.busBarIndex = this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.length - 1;
    },
    /**
     * 新增监测点
     */
    addLine() {
      this.nodeLevel = 700;
      //7-30
      //  this.AddProjectBO.deviceBO.forEach(item => {
      //       if (!item.subVoltageDTOList) {
      //          delete item.subVoltageDTOList;
      //         item.subVoltage = []
      //           item.subVoltage.forEach(lineItem => {
      //             if (!lineItem.lineDTO) {
      //             delete lineItem.lineDTO;
      //               lineItem.line = []
      //            }
      //         })
      //       }
      //     })
      //7-30
      this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line.push(this.removeRefer(this.monitorPointDetail));
      //this.lineIndex = this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line.length - 1 + "";
      this.lineIndex = this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line.length - 1 + '';
    },
    /**
     * 下一步
     */
    next() {
      switch (this.nodeLevel) {
        case 100:

          this.addProvince();
          this.title100 = this.trnode.data.name
          break;
        case 200:

          this.addGdInformation();
          this.title200 = this.trnode.data.name
          break;
        case 300:

          this.addSubStation();
          this.title300 = this.trnode.data.name
          break;
        case 400:

          this.addDevice();
          this.title400 = this.trnode.data.name

          break;
        case 500:

          this.addSubVoltage();
          this.title500 = this.trnode.data.name

          break;
        case 600:
          this.addLine();
          this.title600 = this.trnode.data.name

          break;
      }
    },
    /**
     * 修改
     */
    update() {
      if (Object.keys(this.nodeData).length == 0) {
        this.$message({
          type: "warning",
          message: "没有选中节点",
        });
        return;
      }
      if (this.nodeData.data.level == 0) {
        this.$message({
          type: "warning",
          message: "不能修改根节点",
        });
        return;
      }
      if (this.pageStatus == 2 || this.pageStatus == 3) {
        if (this.pageStatus == 2) {
          this.$message({
            type: "warning",
            message: "请先新增完成在修改",
          });
        }
        return;
      }

      this.pageStatus = 3;

    },
    /**
     * 修改项目
     */
    updateProjectF() {
      this.updateProject = {
        updateProjectBO: {
          name: this.AddProjectBO.projectBO.name,
          projectIndex: this.projectId,
          updateFlag: 1,
        },
      };
    },
    /**
     * 修改行政区域
     */
    updateProvince() {
      this.updateProject = {
        updateProvinceBO: {
          name: this.AddProjectBO.provinceBO.name,
          provinceIndex: this.provinceId,
          updateFlag: 1,
        },
      };
    },
    /**
     * 修改供电公司
     */
    updateGdInformation() {
      this.updateProject = {
        updateGdInformationBO: {
          name: this.AddProjectBO.gdInformationBO.name,
          gdIndex: this.gdId,
          updateFlag: 1,
        },
      };
    },
    /**
     * 修改变电站
     */
    updateSubStation() {
      this.updateProject = {
        updateSubStationBO: {
          name: this.AddProjectBO.subStationBO.name,
          latitude: this.AddProjectBO.subStationBO.latitude,
          longitude: this.AddProjectBO.subStationBO.longitude,
          scale: this.AddProjectBO.subStationBO.scale,
          subIndex: this.subId,
          updateFlag: 1,
        },
      };
    },
    /**
     * 修改变设备/母线/监测点
     */
    updateDevice() {
      /**生成数据 */
      const devices = this.removeRefer(this.AddProjectBO.deviceBO);
      devices.forEach((item) => {
        item.updateFlag = 1;
        item.updateSubVoltageBO = item.subVoltage;
        delete item.subVoltage;
        item.updateSubVoltageBO.forEach((bus) => {
          bus.updateFlag = 1;
          bus.updateLineBO = bus.line;
          delete bus.line;
          bus.updateLineBO.forEach((line) => {
            line.updateFlag = 1;
          });
        });
      });
      this.updateProject = {
        updateDeviceBO: devices,
      };
    },
    /**
     * 确认提交
     */
    onsubmit() {
      this.$refs["mainForm"].validate((valid) => {
        /**验证通过 */
        if (valid) {
          if (this.pageStatus == 2) {
            // 新增
            this.submitData();
          } else {
            // 修改
            switch (this.nodeLevel) {
              case 100:
                this.updateProjectF();
                break;
              case 200:
                this.updateProvince();
                break;
              case 300:
                this.updateGdInformation();
                break;
              case 400:
                this.updateSubStation();
                break;
              case 500:
              case 600:
              case 700:
                this.updateDevice();
                break;
            }
            this.updateDate();
          }
        } else {
          return false;
        }
      });
    },
    /**
     * 提交数据
     */
    submitData() {
      const project = this.removeRefer(this.AddProjectBO);
      // let data={
      //     AddProjectBO: project,
      //   }
      project: JSON.stringify(project)
      api.add(project).then((res) => {
        this.$message({
          type: "success",
          message: res.message,
        });
        this.reaseStatus();
        this.initAddProjectBo();
        this.initAddProjectBoId();
        this.treedata();
      });
    },
    /**
     * 修改数据
     */
    updateDate() {
      // console.log("updateProject:", this.updateProject);
      let data = this.updateProject
      api.updateTerminal(data).then((res) => {
        this.$message({
          type: "success",
          message: res.message,
        });
        this.pageStatus = 1;
        this.treedata();
      });
    },
    /**
     * 删除
     */
    remove() {
      if (Object.keys(this.nodeData).length == 0) {
        this.$message({
          type: "warning",
          message: "没有选中节点",
        });
        return;
      }
      if (this.nodeData.data.level == 0) {
        this.$message({
          type: "error",
          message: "无法删除根节点",
        });
        return;
      }
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        let data = {
          id: this.nodeData.data.id,
          level: this.nodeData.data.level,
        }
        api.deleteById(data).then((res) => {
          this.$message({
            type: "success",
            message: res.message,
          });
          this.reaseStatus();
          this.initAddProjectBo();
          this.initAddProjectBoId();
          this.treedata();
        });
      }).catch(() => {
        this.$message({
          type: "info",
          message: "已取消删除",
        });
      });
    },
    /**
     * 新增/删除设备
     */
    handleDeviceTabsEdit(targetName, action) {
      // console.log(targetName);
      /**新增 */
      if (action === "add") {
        this.addDevice();
      }
      /**删除 */
      if (action === "remove") {
        this.$confirm("此操作将永久删除, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          if (this.AddProjectBO.deviceBO[this.deviceIndex].devIndex) {
            let data = {
              id: this.AddProjectBO.deviceBO[this.deviceIndex].devIndex,
              level: 500,
            }
            api.deleteById(data).then((res) => {
              this.$message({
                type: "success",
                message: res.message,
              });
              this.reaseStatus();
              this.initAddProjectBo();
              this.initAddProjectBoId();
              this.treedata();
            });
          } else {
            this.AddProjectBO.deviceBO.splice(this.deviceIndex, 1);
            this.deviceIndex = this.AddProjectBO.deviceBO.length ? this.AddProjectBO.deviceBO.length - 1 + "" : "0";
            this.busBarIndex = '0';
            this.lineIndex = '0';
            this.$message({
              type: "success",
              message: "删除成功",
            });
          }
        }).catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
      }
    },
    /**
     * 新增/删除母线
     */
    handleBusBarTabsEdit(targetName, action) {
      // console.log(targetName);
      /**新增 */
      if (action === "add") {
        this.addSubVoltage();
      }
      /**删除 */
      if (action === "remove") {
        this.$confirm("此操作将永久删除, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            if (this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].subvIndex) {
              let data = {
                id: this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].subvIndex,
                level: 600,
              }
              api.deleteById(data).then((res) => {
                this.$message({
                  type: "success",
                  message: res.message,
                });
                this.reaseStatus();
                this.initAddProjectBo();
                this.initAddProjectBoId();
                this.treedata();
              });
            } else {
              this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.splice(this.busBarIndex, 1);
              this.busBarIndex = this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.length ? this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage.length - 1 + "" : "0";
              this.lineIndex = '0';
              this.$message({
                type: "success",
                message: "删除成功",
              });
            }
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      }
    },
    /**
     * 新增/删除监测点
     */
    handleLineTabsEdit(targetName, action) {
      // console.log("targetName:", targetName);
      /**新增 */
      if (action === "add") {
        if (this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line.length == 6) {
          this.$message({
            type: "warning",
            message: "不能新增更多的监测点了",
          });
          return;
        }

        this.addLine();
      }
      /**删除 */
      if (action === "remove") {
        this.$confirm("此操作将永久删除, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          if (this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line[this.lineIndex].lineIndex) {
            let data = {
              id: this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line[this.lineIndex].lineIndex,
              level: 700,
            }
            api.deleteById(data).then((res) => {
              this.$message({
                type: "success",
                message: res.message,
              });
              this.reaseStatus();
              this.initAddProjectBo();
              this.initAddProjectBoId();
              this.treedata();
            });
          } else {
            this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line.splice(this.lineIndex, 1);
            this.lineIndex = this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line.length ? this.AddProjectBO.deviceBO[this.deviceIndex].subVoltage[this.busBarIndex].line.length - 1 + "" : "0";
            this.$message({
              type: "success",
              message: "删除成功",
            });
          }
        })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      }
    },


    selectChanged(value) {
      this.$confirm("此操作将修改监测点相关配置, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$message({
          type: "success",
          message: '操作电压等级成功',
        });
      }).catch(() => {
        this.$message({
          type: "info",
          message: "已取消操作",
        });
      });
      // const { value, label } = params
      // console.log(value)
      //0.38kv
      if (value === '9e1d86ea-986c-4dfb-a30e-a0f3e29a2c4e') {
        this.monitorPointDetail.jzCmp = 10
        this.monitorPointDetail.pt1 = 0.38 * 1000
        this.monitorPointDetail.pt2 = 0.38 * 100
        this.monitorPointDetail.dlCmp = 10
        //750kv
      } else if (value === 'fd1b97d4-78d0-4915-ba39-845fc958efb0') {
        this.monitorPointDetail.jzCmp = 7000
        this.monitorPointDetail.pt1 = 750 * 1000
        this.monitorPointDetail.pt2 = 750 * 100
        this.monitorPointDetail.dlCmp = 7000
        //6kv
      } else if (value === '1902a5fb-d551-4f8d-a351-8cdb9ffa8c29') {
        this.monitorPointDetail.jzCmp = 100
        this.monitorPointDetail.pt1 = 6 * 1000
        this.monitorPointDetail.pt2 = 6 * 100
        this.monitorPointDetail.dlCmp = 100
        //10kv
      } else if (value === '7c968e45-d427-4b0e-af98-954b03f60337') {
        this.monitorPointDetail.jzCmp = 100
        this.monitorPointDetail.pt1 = 10 * 1000
        this.monitorPointDetail.pt2 = 10 * 100
        this.monitorPointDetail.dlCmp = 100
        //20kv
      } else if (value === 'efa337b-3a51-478e-a8f5-304acbbd5a6d') {
        this.monitorPointDetail.jzCmp = 200
        this.monitorPointDetail.pt1 = 20 * 1000
        this.monitorPointDetail.pt2 = 20 * 100
        this.monitorPointDetail.dlCmp = 200
        //35kv
      } else if (value === '5a09949a-3659-4ddc-80de-e1000ae57ba0') {
        this.monitorPointDetail.jzCmp = 250
        this.monitorPointDetail.pt1 = 35 * 1000
        this.monitorPointDetail.pt2 = 35 * 100
        this.monitorPointDetail.dlCmp = 250
        //66kv
      } else if (value === '0072d055-6b0b-489e-a4f3-780629350883') {
        this.monitorPointDetail.jzCmp = 500
        this.monitorPointDetail.pt1 = 66 * 1000
        this.monitorPointDetail.pt2 = 66 * 100
        this.monitorPointDetail.dlCmp = 500
        //110kv
      } else if (value === '00a95bb0-b51c-44bd-892e-9e6d60c0548e') {
        this.monitorPointDetail.jzCmp = 750
        this.monitorPointDetail.pt1 = 110 * 1000
        this.monitorPointDetail.pt2 = 110 * 100
        this.monitorPointDetail.dlCmp = 750
        //220kv
      } else if (value === '36404ee3-57b9-4aa7-bb3d-279abe1cfb55') {
        this.monitorPointDetail.jzCmp = 2000
        this.monitorPointDetail.pt1 = 220 * 1000
        this.monitorPointDetail.pt1 = 220 * 100
        this.monitorPointDetail.dlCmp = 2000
        //330kv 
      } else if (value === '87f3b0f1-5dcf-4fd8-81a2-1fafd1d13997') {
        this.monitorPointDetail.jzCmp = 3000
        this.monitorPointDetail.pt1 = 330 * 1000
        this.monitorPointDetail.pt2 = 330 * 100
        this.monitorPointDetail.dlCmp = 3000
        //500kv
      } else if (value === 'ebc16a84-29c6-4070-8644-1d0106553471') {
        this.monitorPointDetail.jzCmp = 4500
        this.monitorPointDetail.pt1 = 500 * 1000
        this.monitorPointDetail.pt2 = 500 * 100
        this.monitorPointDetail.dlCmp = 4500
        //1000kv
      } else if (value === '3e8809c9-7db9-47ed-b232-c592b7e906e2') {
        this.monitorPointDetail.jzCmp = 9000
        this.monitorPointDetail.pt1 = 1000 * 1000
        this.monitorPointDetail.pt2 = 1000 * 100
        this.monitorPointDetail.dlCmp = 9000
      } else {
        this.monitorPointDetail.jzCmp = 10
        this.monitorPointDetail.dlCmp = 10
      }
    },
    //时间格式
    getdayValue() {
      this.deviceBODetail.thisTime = new Date()
      this.deviceBODetail.logTime = new Date()
      this.deviceBODetail.updTime = new Date()
      var date = new Date()
      var mymonth = date.getMonth();
      var myweekday = date.getDate() - 1;
      this.deviceBODetail.nextTime = new Date(2023, mymonth, myweekday);
    },
    /**
     * 获取厂家
     */
    getFactory() {
      let data = {
        dictypeName: "制造厂商",
      }
      api.chanjia(data).then((res) => {
        // console.log("厂家", res);
        this.factoryArr = res.data;
      });
    },
    /**
     * 获取设备型号
     */
    getDeviceType() {
      let data = {
        dictypeName: "装置类型",
      }
      api.xinhao(data).then((res) => {
        // console.log("设备型号", res);
        this.typeArr = res.data;
      });
    },
    /**
     * 获取前置机
     */
    getAffiliatiedFront() {

      api.ssqzj().then((res) => {
        // console.log("前置机", res);
        this.affiliatiedFrontArr = res.data;
      });
    },
    /**
     * 获取电压等级
     */
    getScale() {
      let data = {
        dictypeName: "电压等级",
      }
      api.dydj(data).then((res) => {
        // console.log("电压等级", res);
        this.voltageLevelArr = res.data;
        this.busBarDetail.scale = res.data[0].dicName
      });
    },
    /**
     * 获取负荷类型
     */
    getLoadType() {
      let data = {
        dictypeName: "负荷类型",
      }
      api.fhlx(data).then((res) => {
        // console.log("负荷类型", res);
        this.loadTypeArr = res.data;
      });
    },
    /**
     * 获取行业类型
     */
    getIndustryType() {
      let data = {
        dictypeName: "行业类型",
      }
      api.hylx(data).then((res) => {
        // console.log("行业类型", res);
        this.industryTypeArr = res.data;
      });
    },
    /**
     * 获取行政区域
     */
    getArea() {
      let data = {
        dictypeName: "行政区域",
      }
      api.city(data).then((res) => {
        // console.log("行政区域", res);
        this.city = res.data;
      });
    },
    /**
     * 获取部门
     */
    change(value) {
      //alert(value)
      let id = value
      this.getDepartment(id)
    },
    getDepartment(id) {
      api.dept(id).then((res) => {
        // console.log("部门", res);
        this.departmentArr = res.data;
      });
    },
    /**
     * 获取测量点序号
     */
    getLineNum() {
      // http({
      //   url: "/device-boot/terminalTree/getTerminalTree",
      //   method: "get",
      //   data: {
      //     dictypeName: "序号",
      //   },
      // }).then((res) => {
      //   console.log("序号", res);
      // this.pointNumArr = res.data;
      // });
    },
    /**
     * 获取测量点间隔
     */
    getLineSpace() {
      // http({
      //   url: "/device-boot/terminalTree/getTerminalTree",
      //   method: "get",
      //   data: {
      //     dictypeName: "间隔",
      //   },
      // }).then((res) => {
      //   console.log("间隔", res);
      // this.lineSpaceArr = res.data;
      // });
    },
    /**
     * 获取测量点性质
     */
    getLineNature() {
      // http({
      //   url: "/device-boot/terminalTree/getTerminalTree",
      //   method: "get",
      //   data: {
      //     dictypeName: "性质",
      //   },
      // }).then((res) => {
      //   console.log("性质", res);
      // this.lineNatureArr = res.data;
      //  });
    },
    /**
     * 重置初始状态
     */
    reaseStatus() {
      this.nodeData = {};
      this.nodeLevel = 0;
      this.pageStatus = 1;
      this.projectId = 0;
      this.provinceId = 0;
      this.gdId = 0;
      this.subId = 0;
      this.devId = 0;
      this.busBarId = 0;
      this.lineId = 0;
      this.deviceIndex = "0";
      this.busBarIndex = "0";
      this.lineIndex = "0";
      this.currentGdName = "";
    },
    /**
     * AddProjectBo的内容恢复初始状态
     */
    initAddProjectBo() {
      //this.AddProjectBO.projectBO = null;
      //this.AddProjectBO.provinceBO = null;
      //this.AddProjectBO.gdInformationBO = null;
      //this.AddProjectBO.subStationBO = null;
      this.AddProjectBO.deviceBO = null;
    },
    /**AddProjectBo的Id恢复初始状态 */
    initAddProjectBoId() {
      /**项目Id */
      this.AddProjectBO.projectIndex = 0;
      this.AddProjectBO.provinceIndex = 0;
      this.AddProjectBO.gdIndex = 0;
      this.AddProjectBO.subIndex = 0;
    },
    /**
     * 去除引用
     */
    removeRefer(obj) {
      return JSON.parse(JSON.stringify(obj));
    },
  },
};
</script>
<style>
/**左侧样式 */
.el-aside {
  background: #04345800;
  box-sizing: border-box;
  padding: 10px 15px;
  line-height: 32px;
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  /* color: #08fcfc; */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100%;
}

.dept-left-btn {
  width: 100%;
  margin-top: 5px;
  display: flex;
  justify-content: space-between;
}

.dept-left-input {
  width: 100%;
  margin-top: 15px;
}

.el-input__inner {
  /* background-color: #114e7f0c;
  border-color: #0f5d9900; */
}

/**拖拽条样式 */
#drag-dept {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  background-color: #04607c2a;
  box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.35);
  cursor: col-resize;
}

.overview_scroll::-webkit-scrollbar {
  width: 4px;
  height: 1px;
  background: rgba(6, 70, 122, 0.013);
}

#drag-dept i {
  display: inline-block;
  height: 14px;
  width: 1px;
  background-color: #e9e9e9;
  margin: 0 1px;
}

.span-ellipsis {
  width: 100%;
  /* overflow: hidden; */
  white-space: nowrap;
  text-overflow: ellipsis;
  display: block;

  /* overflow: auto;
  overflow-x: auto; */
}

.title {
  /* color: #08fcfc;  */
  font-size: 16px;
}

#drag-dept-left {
  min-width: 220px;
  max-width: 40%;
}

.dept-left-tree {
  position: relative;
  /* background: #0a3647; */
  color: #f8fafa;
  margin-top: 15px;
  height: calc(100vh - 115px);
  overflow-y: auto;

}

.el-tree {
  height: 100%;
  background-color: transparent;
}

.el-tree-node__label {
  /* color: #07ffff; */
  font-size: 16px;
}

.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content,
.el-tree-node__content:hover {
  background-color: #0598bdbb;
}

.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content .el-tree-node__label,
.el-tree-node__content:hover .el-tree-node__label {
  color: #11de4d;
}

/**右侧主内容容器样式 */
.el-main {
  /* background-color: #055777f8; */
  padding: 15px;
}

.main-btn {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 15px;
}

.main-form .el-form-item__label {}

.main-form .el-input__inner {
  color: #08a4c0;
}

.main-form .el-select,
.main-form .el-date-editor {
  width: 100%;
}

.overview_scroll::-webkit-scrollbar-thumb {
  border-radius: 4px;
  margin-right: 5px;
  -webkit-box-shadow: inset 0 0 2px #0090b411;
  background: #03c1cf0e;
}

/*定义滚动条所在轨道的样式。有圆角和阴影以及淡色系的背景色*/
.overview_scroll::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 2px #e6faf31c;
  border-radius: 4px;
  background: #056e8810;
}

.form-item {
  width: calc(33% - 30px);
}

.flex {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.form-tag,
.form-add {
  display: flex;
  justify-content: flex-start;
  margin-top: 15px;
  margin-bottom: 10px;
}

.el-tabs__item {
  color: #04606d;

}

.el-tabs__new-tab {
  float: right;
  border: 1px solid #06626ead;
  height: 18px;
  width: 18px;
  line-height: 18px;
  margin: 12px 0 9px 10px;
  border-radius: 3px;
  text-align: center;
  font-size: 12px;
  color: #06626ead;
  cursor: pointer;
  -webkit-transition: all 0.15s;
  transition: all 0.15s;
}

.el-input.is-disabled .el-input__inner {
  /* background-color: #597a800c; */
  border-color: #0e378834;
  color: #313030d3;
  cursor: not-allowed;
}

.main-form .el-form-item__label,
.main-form .el-input__inner {
  /* color: #07dcf5; */
}

.el-input__inner {
  /* background-color: #1463a5; */
  border-color: #0d9ebf81;

}

.el-tree-node.is-current>.el-tree-node__content {
  background-color: rgba(13, 119, 151, 0.623) !important;
}

.el-tabs--card>.el-tabs__header .el-tabs__item.is-active {
  border-bottom-color: #03e2f7;
  /* border-top-color: 1px solid rgb(233, 235, 236); */
}

.changeStyle {
  font-size: 40rpx;
  font-weight: bold;
  color: rgb(8, 213, 240);

}

.el-breadcrumb__separator[class*=icon] {
  margin: 0 1px;
  font-weight: 400;

}
</style>
