<template>
  <div class="page-container addSubject">
    <div class="page-top-title-box">
      <p class="page-top-title-name-p">{{form.infoId?'编辑':'新增'}}</p>
      <p class="page-top-title-out-p" @click="backPage">返回</p>
      <p class="page-top-title-submit-p" @click="upData">提交</p>
    </div>
    <div class="content-box scrollbar-box">
      <el-form ref="form" :model="form" label-width="120px" :rules="rules" >
        <div class="title-box">
          <p class="left-title">基本信息</p>
        </div>
        <el-form-item label="实验室名称" prop="subName" class="form-item">
          <el-input
            style="width:320px;"
            maxlength="30"
            v-model="form.subName"
            placeholder="请输实验室名称"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item label="实验室类型"  prop="moldId" class="form-item">
          <el-select v-model="form.moldId" placeholder="请选择类型" clearable style="width:320px;">
            <el-option
              v-for="dict in labMoldList"
              :key="dict.moldId"
              :label="dict.moldName"
              :value="dict.moldId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="二级单位"  prop="deptId"  class="form-item">
          <el-select v-model="form.deptId" placeholder="请选择类型" clearable style="width:320px;">
            <el-option
              v-for="item in deptOptions"
              :key="item.deptId"
              :label="item.deptName"
              :value="item.deptId"
            ></el-option>
          </el-select>
        </el-form-item>
        <div style="display: inline-block;">
          <el-form-item label="安全分级"  prop="levelId" class="form-item">
            <el-input
              disabled
              style="width:220px;"
              v-model="form.titleName"
              placeholder="请选择安全分级"
              clearable
              size="small"
            />
          </el-form-item>
          <p class="page-reset-common-style-button" @click="LevelClick()" style="margin-left:12px;margin-bottom:20px;width:90px;">分级配置</p>
        </div>
        <div style="display: inline-block;">
          <el-form-item label="安全分类"  prop="typeId" class="form-item">
            <el-input
              disabled
              style="width:220px;"
              v-model="form.subType"
              placeholder="请选择安全分类"
              clearable
              size="small"
            />
          </el-form-item>
          <p class="page-reset-common-style-button" @click="classifyClick()" style="margin-left:12px;margin-bottom:20px;width:90px;">分类配置</p>
        </div>
        <el-form-item label="实验室面积" prop="subArea" class="form-item">
          <el-input
            style="width:320px;"
            v-model="form.subArea"
            placeholder="请输入面积"
            oninput="value=value.replace(/[^0-9.]/g,'')"
            maxlength="4"
            size="small">
            <template slot="append">M²</template>
          </el-input>
        </el-form-item>
<!--        <el-form-item label="动态评级" class="form-item" style="width:440px;">
          <div class="tableListPaginationSwitch">
            <el-switch
              class="switch captcha-img"
              v-model="form.dynamicLeveling"
              :active-value="true"
              :inactive-value="false"
              active-text="开"
              inactive-text="关">
            </el-switch>
            <i class="el-icon-warning tip-img"></i>
            <i class="tip-content">如需人工评定，请关闭动态评级</i>
          </div>
        </el-form-item>-->
        <el-form-item label="楼栋"  prop="buildId" class="form-item">
          <el-select v-model="form.buildId" placeholder="请选择楼栋"
                     @change="changeBuild" style="width:320px;">
            <el-option
              v-for="dict in buildings"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="楼层" prop="floorId" class="form-item">
          <el-select v-model="form.floorId"  placeholder="请选择层数"
                     @change="changeFloor" style="width:320px;">
            <el-option
              v-for="dict in floors"
              :key="dict.id"
              :label="dict.name"
              :value="dict.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="房间号" prop="roomId" class="form-item">
          <el-select v-model="form.roomId"  placeholder="请选择房间" style="width:320px;">
            <el-option
              v-for="dict in rooms"
              :key="dict.roomId"
              :label="dict.roomNum"
              :value="dict.roomId"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="准入设备"  class="form-item">
          <el-select v-model="form.hardwareType" placeholder="请选择整改类型" style="width:320px;" @change="hardwareTypeFun()" >
            <el-option label="无"  :value="0" />
            <el-option label="海康智能门禁" :value="1" />
            <el-option label="电子信息牌" :value="2" />
          </el-select>
        </el-form-item>
        <div class="bottom-form-max-box">
          <div class="title-button-box">
            <div class="title-min-button-box checkButtonBox">
              <p @click="clickButtonType(2)">安全信息牌</p>
              <p></p>
            </div>
            <div class="title-null-div">
              <p></p>
              <p></p>
            </div>
          </div>
          <!--安全信息牌-->
          <div class="bottom-form-box">
            <div class="top-form-box">
              <el-form-item label="实验室负责人" prop="adminId" class="form-item" label-width="150px">
                <el-select
                  style="width:500px;"
                  v-model="form.adminId"
                  filterable
                  remote
                  clearable
                  reserve-keyword
                  placeholder="请输入至少2个字符搜索相关人员"
                  :remote-method="userSelectList"
                  :loading="loading">
                  <el-option
                    v-for="item in optionsUser"
                    :key="item.userId"
                    :label="item.userName"
                    :value="item.userId">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="安全员" prop="safeUserId" class="form-item" label-width="150px">
                <el-select
                  style="width:500px;"
                  v-model="form.safeUserId"
                  :multiple-limit="2"
                  multiple
                  filterable
                  remote
                  clearable
                  reserve-keyword
                  placeholder="请输入至少2个字符搜索相关人员"
                  :remote-method="userSelectListOne"
                  :loading="loading">
                  <el-option
                    v-for="item in optionsUserOne"
                    :key="item.userId"
                    :label="item.userName"
                    :value="item.userId">
                  </el-option>
                </el-select>
              </el-form-item>
            </div>
            <div class="bottom-form-box">
              <el-form-item v-if="item.publicList.length>0" :label="item.brandName" prop="safeSigns" class="form-item"
                            v-for="(item,index) in  safetyInfoList" label-width="150px">
                <el-select v-if="item.publicList.length>0" v-model="item.privateList" filterable
                           multiple collapse-tags placeholder="请选择" style="width:500px;">
                  <el-option
                    v-for="dict in item.publicList"
                    :key="dict.detailId"
                    :label="dict.infoName"
                    :value="dict.detailId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </div>
          </div>
        </div>
        <div class="title-box">
          <p class="left-title">实验室简介</p>
        </div>
        <div class="rich-text">
          <UEditor ref="UEditor" :content="form.details" :min-height="192" />
        </div>
      </el-form>
    </div>
    <el-dialog title="分级配置" :visible.sync="dialogLevelVisible" width="970px" append-to-body>
      <div class="tabs">
        <div class="tabs-li" v-for="(item,index) in tabsList" @click="tabsClick(index)" :class="tabsIndex==index?'color-B':'color-A'">{{item}}</div>
      </div>

      <div class="level" style="height: 500px;overflow-y: auto;">
        <!-- 分类依据-->
        <div class="level-box" v-for="(item,index) in levelBasisList" :key="index" v-if="tabsIndex==0">
          <div class="level-title" :style="'background:'+item.color">{{item.name}}</div>
          <div class="level-thead">
            <i>选择</i>
            <i>序号</i>
            <i>内容</i>
          </div>
          <div class="level-li" v-for="(item2,index2) in item.list" :key="index2">
            <i><el-checkbox v-model="item2.selected"></el-checkbox></i>
            <i>{{index2+1}}</i>
            <i>{{item2.content}}</i>
          </div>
          <div class="level-li2">{{item.remark}}</div>
        </div>
        <!-- 风险评价-->
        <div class="level-box" v-for="(item,index) in levelEvaluateList" :key="index" v-if="tabsIndex==1">
          <div class="level-title">{{item.name}}</div>
          <div class="level-thead">
            <i>选择</i>
            <i>序号</i>
            <i>内容</i>
          </div>
          <div class="level-li" v-for="(item2,index2) in item.list" :key="index2">
            <i><el-checkbox v-model="item2.selected"></el-checkbox></i>
            <i>{{index2+1}}</i>
            <i>{{item2.content}}</i>
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer dialog-footer-box">
        <p class="dialog-footer-button-null"></p>
        <p class="dialog-footer-button-primary" @click="levelSubmitForm">确认</p>
        <p class="dialog-footer-button-null"></p>
      </div>
    </el-dialog>
    <el-dialog title="分类配置" :visible.sync="dialogClassifyVisible" width="970px" append-to-body>
      <div class="classify">
        <div class="classify-thead">
          <i>选择</i>
          <i>实验室分类</i>
          <i>分类参考依据</i>
        </div>
        <div class="classify-li" v-for="(item,index) in classifyList">
          <i @click="radioClick(item,index)"><el-radio v-model="item.selected" :label="true" ><span></span></el-radio></i>
          <i>{{item.subType}}</i>
          <i>{{item.typeBasis}}</i>
        </div>
      </div>
      <div slot="footer" class="dialog-footer dialog-footer-box">
        <p class="dialog-footer-button-null"></p>
        <p class="dialog-footer-button-primary" @click="classifySubmitForm">确认</p>
        <p class="dialog-footer-button-null"></p>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  getDeptDropList, systemBuildingGetOptList, laboratoryClassMoldGetList,
   systemRoomInfoGetList,systemUserDropAuthList
} from '@/api/commonality/permission'
import {
  laboratoryInfoBrandGetClassifyBySubId, laboratoryLevelConfigGetCalculateByData, laboratoryLevelConfigGetList,
  laboratorySubRelInfoAdd,
  laboratorySubRelInfoUpdate, laboratoryTypeConfigGetList
} from '@/api/integratedManagement/index'
import { chemicalMsdsEdit } from '@/api/chemicalManage'
    export default {
      name: "addSubject",
      props:{
        subjectData:{},
      },
      data() {
        return {
          loading:false,
          deptOptions:[],
          buildings:[],
          floors:[],
          rooms:[],
          layoutLists:[],
          optionsUser:[],
          optionsUserOne:[],
          //安全标识
          safetyWarning:[],
          //主要危险类别
          hazardCategory:[],
          //风险防控措施
          riskMeasure:[],
          //灭火要点
          extinguishingKeyPoints:[],
          //安全信息牌列表信息存储
          safetyInfoList:[],
          roomId:null,
          form:{
            details:"",
            hardwareType:0,
          },
          hardwareTypeTow:0,//临时存储准入设备状态
          // 表单校验
          rules: {
            subName:[
              {required: true, message: '请输实验室名称', trigger: 'blur'},
              { required: true, message: "请输实验室名称", validator: this.spaceJudgment, trigger: "blur" }
            ],
            moldId:[
              {required: true, message: '请选择类型', trigger: 'blur'}
            ],
            typeId:[
              {required: true, message: '请选择安全分类', trigger: 'blur'}
            ],
            levelId:[
              {required: true, message: '请选择安全分级', trigger: 'blur'}
            ],
            deptId:[
              {required: true, message: '请选择学院', trigger: 'blur'}
            ],
            buildId:[
              {required: true, message: '请选择楼栋', trigger: 'blur'}
            ],
            adminId:[
              {required: true, message: '请选择实验室负责人', trigger: 'blur'}
            ],

            floorId:[
              {required: true, message: '请选择层数', trigger: 'blur'}
            ],
            // roomId:[
            //   {required: true, message: '请输入房间号', trigger: 'blur'}
            // ],
            layoutId:[
              {required: true, message: '请选择详细位置', trigger: 'blur'}
            ],

          },
          labMoldList:[],
          //一体机/电子信息牌状态切换
          checkButtonType:1,
          tabsList:['分级依据','风险评级'],
          tabsIndex:0,
          dialogLevelVisible:false,
          dialogClassifyVisible:false,
          levelBasisList:[],
          levelEvaluateList:[],
          classifyList:[],

        }
      },
      created() {
      },
      mounted(){
        //数据初始化
        this.getInitializeData();
        if(!this.subjectData.subId){
          this.laboratoryInfoBrandGetClassifyBySubId();
        }else{
          this.$set(this.form,'infoId',this.subjectData.infoId)
          this.$set(this.form,'subId',this.subjectData.subId)
          this.$set(this.form,'subName',this.subjectData.subName)
          this.$set(this.form,'moldId',this.subjectData.moldId)
          this.$set(this.form,'typeId',this.subjectData.typeId)
          this.$set(this.form,'subType',this.subjectData.typeName)
          this.$set(this.form,'levelId',this.subjectData.levelId)
          this.$set(this.form,'titleName',this.subjectData.levelName)
          this.$set(this.form,'deptId',this.subjectData.deptId)
          this.$set(this.form,'buildId',this.subjectData.buildId)
          this.$set(this.form,'floorId',this.subjectData.floorId)
          this.$set(this.form,'subArea',this.subjectData.subArea != 0 ? this.subjectData.subArea:'')
          //根据楼栋获取楼层
          this.systemBuildingGetOptList(3,this.form.buildId);
          if(this.subjectData.roomId){
            this.$set(this.form,'roomId',this.subjectData.roomId)
            this.$set(this,'roomId',this.subjectData.roomId)
            //根据楼层获取房间
            this.systemRoomInfoGetList(this.form.floorId);
          }
          //准入设备
          this.$set(this.form,'hardwareType',this.subjectData.hardwareType==null?0:this.subjectData.hardwareType)
          this.$set(this,'hardwareTypeTow',this.subjectData.hardwareType==null?0:this.subjectData.hardwareType)
          //安全警示标识
          if(this.subjectData.safeSigns){
            this.$set(this.form,'safeSigns',this.subjectData.safeSigns.split(','))
          }
          //风控防控措施
          if(this.subjectData.riskMeasure){
            this.$set(this.form,'riskMeasure',this.subjectData.riskMeasure.split(','))
          }
          //主要危险类别
          if(this.subjectData.hazardCategory){
            this.$set(this.form,'hazardCategory',this.subjectData.hazardCategory.split(','))
          }
          //灭火要点
          if(this.subjectData.outFire){
            this.$set(this.form,'outFire',this.subjectData.outFire.split(','))
          }
          //实验室负责人
          if(this.subjectData.adminId){
            this.$set(this.form,'adminId',this.subjectData.adminId)
            this.userSelectList(this.subjectData.adminName);
          }
          //实验室安全员
          if(this.subjectData.safeUserList[0]){
            let list = [];
            this.subjectData.safeUserList.forEach((item)=>{
              let obj = {
                userName:item.safeUserName,
                userId:item.safeUserId,
              };
              list.push(obj)
            })
            this.$set(this.form, 'safeUserId', this.subjectData.safeUserId);
            this.$set(this, 'optionsUserOne', list);
          }
          //安全信息牌
          if(this.subjectData.labInfoBrandModels){
            //循环取安全信息牌信息
            let list = JSON.parse(JSON.stringify(this.subjectData.labInfoBrandModels))
            for(let i=0;i<list.length;i++){
              let list2=[];
              if(list[i].privateList.length>0){
                for(let b=0;b<list[i].privateList.length;b++){
                  list2.push(list[i].privateList[b].detailId)
                }
                list[i].privateList=list2
              }
            }
            this.$set(this,'safetyInfoList',list);
          }
          //实验室简介
          this.$set(this.form,'details',this.subjectData.details)
          this.$refs.UEditor.text=unescape(this.subjectData.details)
        }
      },
      methods:{
        LevelClick(){
          this.$set(this,'dialogLevelVisible',true);
        },
        classifyClick(){
          this.$set(this,'dialogClassifyVisible',true);
        },
        tabsClick(index){
          this.tabsIndex=index;
        },
        radioClick(row,index){
          this.classifyList.forEach(function(item) {
            item.selected=false;
          })
          this.classifyList[index].selected=true;
        },
        //初始化数据查询
        getInitializeData(){
          //学院
          this.getDeptDropList();
          //楼栋
          this.systemBuildingGetOptList(2);
          //类型
          this.laboratoryClassMoldGetList();
          //安全标识字典
          this.getDicts("sys_safety_warning").then(response => {
            this.$set(this,'safetyWarning',response.data);
          });
          //主要危险类别
          this.getDicts("sys_hazard_category").then(response => {
            this.$set(this,'hazardCategory',response.data);
          });
          //风险防控措施
          this.getDicts("sys_risk_measure").then(response => {
            this.$set(this,'riskMeasure',response.data);
          });
          //灭火要点
          this.getDicts("sys_extinguishing_key_points").then(response => {
            this.$set(this,'extinguishingKeyPoints',response.data);
          });
          //分级配置列表
          this.laboratoryLevelConfigGetList();
          this.laboratoryLevelConfigGetListTow();
          //分类配置列表
          this.laboratoryTypeConfigGetList();
        },
        //查询学院下拉列表
        getDeptDropList(){
          getDeptDropList({deptName:'',level:2,deptType:''}).then(response => {
            this.$set(this,'deptOptions',response.data);
          });
        },
        //查询楼栋/楼层下拉列表
        systemBuildingGetOptList(type,id){
          systemBuildingGetOptList({ type:type, id:id?id:'' }).then(response => {
            if(type == 2){
              this.$set(this,'buildings',response.data);
            }else if(type == 3){
              this.$set(this,'floors',response.data);
            }
          });
        },
        //查询楼层下房间下拉列表
        systemRoomInfoGetList(id){
          systemRoomInfoGetList({floorId:id,roomId:this.roomId,}).then(response => {
            this.$set(this,'rooms',response.data);
          });
        },
        //查询实验室类型下拉列表
        laboratoryClassMoldGetList(){
          laboratoryClassMoldGetList({}).then(response => {
            this.$set(this,'labMoldList',response.data);
          });
        },
        //一体机/电子信息牌切换
        clickButtonType(type){
          if(type != this.checkButtonType){
            this.$set(this,'checkButtonType',type);
          }
        },
        hardwareTypeFun(){
          if(this.hardwareTypeTow==1 && this.subjectData.hKCount>0){
            this.msgError("删除现有准入设备后，才能更改准入设备类型!");
            this.form.hardwareType=this.hardwareTypeTow
          }else if(this.hardwareTypeTow==2 && this.subjectData.cardInfoCount>0){
            this.msgError("删除现有准入设备后，才能更改准入设备类型!");
            this.form.hardwareType=this.hardwareTypeTow
          }else{

          }
        },
        upData(){
          let self = this;
          this.$set(this.form,'details',this.$refs.UEditor.text);
          this.$refs["form"].validate(valid => {
            if (valid) {
              self.$confirm('是否确认提交?', "", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
              }).then(function() {
                if(self.form.hazardCategory) {
                  self.form.hazardCategory = self.form.hazardCategory.join() ;
                }
                if(self.form.outFire) {
                  self.form.outFire = self.form.outFire.join() ;
                }
                if(self.form.riskMeasure) {
                  self.form.riskMeasure = self.form.riskMeasure.join() ;
                }
                if(self.form.safeSigns) {
                  self.form.safeSigns = self.form.safeSigns.join() ;
                }
                if(self.form.safeUserId) {
                  self.form.safeUserId = self.form.safeUserId.join() ;
                }
                //循环取安全信息牌信息

                let list=[]
                for(let i=0;i<self.safetyInfoList.length;i++){
                  let list2=[];
                  if(self.safetyInfoList[i].privateList && self.safetyInfoList[i].privateList.length>0){
                    for(let b=0;b<self.safetyInfoList[i].privateList.length;b++){
                      list2.push({detailId:self.safetyInfoList[i].privateList[b]})
                    }
                    list.push({brandId:self.safetyInfoList[i].brandId,labInfoBrandDetailModelList:list2})
                  }
                }
                self.form.labInfoBrandModels=list
                if(self.form.infoId){
                  self.laboratorySubRelInfoUpdate();
                }else{

                  self.laboratorySubRelInfoAdd();
                }
              }).then(() => {}).catch(() => {});
            }
          })
        },
        //新增实验室
        laboratorySubRelInfoAdd(){
          this.form.details = escape(this.form.details);
          laboratorySubRelInfoAdd(this.form).then(response => {
            this.msgSuccess("新增成功");
            this.$parent.clickPage(1);
          });
        },
        //修改实验室
        laboratorySubRelInfoUpdate(){
          this.form.details = escape(this.form.details);
          laboratorySubRelInfoUpdate(this.form).then(response => {
            this.msgSuccess("修改成功");
            this.$parent.clickPage(1,'');
          });
        },
        backPage(){
          this.$parent.clickPage(1,'');
        },
        //分级配置列表
        laboratoryLevelConfigGetList(){
          let obj={
            levelType:'1', //1分级依据 2风险评价
          }
          laboratoryLevelConfigGetList(obj).then(response => {
            if (this.subjectData.levelRecord){
              let list = this.subjectData.levelRecord.split(',');
              response.data.forEach(function(item) {
                item.list.forEach(function(item2) {
                  item2.selected=false;
                  list.forEach(function(item3) {
                    if (item2.configId==item3){
                      item2.selected=true;
                    }
                  })
                })
              })
            }else{
              response.data.forEach(function(item) {
                item.list.forEach(function(item2) {
                  item2.selected=false;
                })
              })
            }

            this.$set(this, 'levelBasisList',response.data)
          });
        },
        //分级配置列表
        laboratoryLevelConfigGetListTow(){
          let obj={
            levelType:'2', //1分级依据 2风险评价
          }
          laboratoryLevelConfigGetList(obj).then(response => {
              if (this.subjectData.levelRecord){
                let list = this.subjectData.levelRecord.split(',');
                response.data.forEach(function(item) {
                  item.list.forEach(function(item2) {
                    item2.selected=false;
                    list.forEach(function(item3) {
                      if (item2.configId==item3){
                        item2.selected=true;
                      }
                    })
                  })
                })
              }else{
                response.data.forEach(function(item) {
                  item.list.forEach(function(item2) {
                    item2.selected=false;
                  })
                })
              }

            this.$set(this, 'levelEvaluateList',response.data)
          });
        },
        //分类配置列表
        laboratoryTypeConfigGetList(){
          let self=this;
          laboratoryTypeConfigGetList().then(response => {
            if (this.subjectData.typeId){
              response.data.forEach(function(item) {
                item.selected=false;
              })
              response.data.forEach(function(item) {
                if (item.typeId==self.subjectData.typeId){
                  item.selected=true;
                }
              })
            }else{
              response.data.forEach(function(item) {
                item.selected=false;
              })
            }

            this.$set(this, 'classifyList',response.data)
          });
        },

        /** 查询楼栋列表  */
        getBuildings(id) {
          if(id) {
            this.$set(this.form, 'buildId', '');//楼栋
            this.buildings = [];
            this.$set(this.form, 'floorId', '');//楼层
            this.floors = [];
            // this.$set(this.form, 'layoutId', '');//房间
            this.layoutLists = [];
            buildFloorGetlist({type:2}).then(response => {
              this.buildings = response.rows;
            });
          }
        },
        //查询楼栋下的楼层列表
        changeBuild(id) {
          this.$set(this.form,'floorId','');
          this.$set(this.form,'roomId','');
          this.$set(this,'rooms',[]);
          this.systemBuildingGetOptList(3,id);
        },
        //查询楼层下的房间列表
        changeFloor(id) {
          this.$set(this.form,'roomId','');
          this.systemRoomInfoGetList(id);
        },
        //获取电子信息牌下拉列表数据
        laboratoryInfoBrandGetClassifyBySubId(){
          laboratoryInfoBrandGetClassifyBySubId().then(response=>{
            this.$set(this,'safetyInfoList',response.data);
          });
        },
        /** 下列人员-懒加载 */
        userSelectList(query) {
          if (query !== '' && query.length>1) {
            systemUserDropAuthList({"userName":query,'userType':'1'}).then(response => {
              this.$set(this,'optionsUser',response.data);
            });
          } else {
            this.$set(this,'optionsUser',[]);
          }
        },
        userSelectListOne(query) {
          if (query !== '' && query.length>1) {
            systemUserDropAuthList({"userName":query,'userType':''}).then(response => {
              this.$set(this,'optionsUserOne',response.data);
            });
          } else {
            this.$set(this,'optionsUserOne',[]);
          }
        },
        //分级确定
        levelSubmitForm(){
          let self=this;
          let list=[]
          let listId=[]
          let list2=[]
          let listId2=[]

          this.levelBasisList.forEach(function(item) {
            item.list.forEach(function(item2) {
              if (item2.selected){
                list.push(item2)
                listId.push(item2.configId)
              }
            })
          })
          this.levelEvaluateList.forEach(function(item) {
            item.list.forEach(function(item2) {
              if (item2.selected){
                list2.push(item2)
                listId2.push(item2.configId)
              }
            })
          })

          if (this.tabsIndex==0 && !list[0]){
            self.msgError("请选择分级评定依据!");
            return
          }
          if (this.tabsIndex==1 && !list2[0]){
            self.msgError("请选择风险评价!");
            return
          }
          list = list.concat(list2);
          listId = listId.concat(listId2);
          this.$set(this.form, 'levelRecord',listId.join(','))
          laboratoryLevelConfigGetCalculateByData(list).then( response => {
              this.$set(this.form, 'levelId',response.data.levelId)
              this.$set(this.form, 'titleName',response.data.titleName)
              this.$set(this, 'dialogLevelVisible',false)

          });

        },
        //分类确定
        classifySubmitForm(){
          let self=this;

          this.classifyList.forEach(function(item) {
            if (item.selected){
              self.$set(self.form, 'typeId',item.typeId)
              self.$set(self.form, 'subType',item.subType)
              self.$set(self, 'dialogClassifyVisible',false)
            }
          })
          if (!self.form.typeId){
            self.msgError("请选择实验室分类!");
          }
        },
      }
    }
</script>

<style scoped lang="scss">
  .addSubject{
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius:10px!important;
    margin:5px 20px 20px 10px!important;
    box-shadow: 0 0 8px 1px rgba(0, 0, 0, 0.1) !important;
    .title-box{
      display: flex;
      margin:0 20px 30px;
      border-bottom:1px solid #E0E0E0;
      .left-title{
        flex:1;
        height:60px;
        line-height:60px;
        color:#0045AF;
        font-size:15px;
        padding-left:10px;
      }
      .right-button{
        margin:20px 0;
      }
    }
    .title-button-box{
      display: flex;
      padding:0 20px 30px 20px;
      .title-min-button-box{
        p:nth-child(1){
          cursor: pointer;
          text-align: center;
          font-size:15px;
          color:#999;
          line-height:60px;
          height:60px;
          padding-right:40px;
          padding-left:10px;
        }
        p:nth-child(2){
          height:1px;
          background-color: #dedede;
        }
        .checkButtonBox{
          color:#0045AF;
        }
      }
      .checkButtonBox{
        p:nth-child(1){
          color:#0045AF!important;
        }
      }
      .title-null-div{
        flex:1;
        p:nth-child(1){
          height:60px;
        }
        p:nth-child(2){
          height:1px;
          background-color: #dedede;
        }
      }
    }
    .form-item{
      display: inline-block;
      overflow: hidden;
      min-height:60px;
      margin-bottom:0;
    }
    .bottom-form-box{
      /*display: flex;*/
      .top-form-box{
        /*width:650px;*/
      }
      .bottom-form-box{
        /*width:650px;*/
      }
      .form-item{
        display: inline-block;
        overflow: hidden;
        min-height:40px;
        margin-bottom:30px;
      }
    }
    .bottom-form-box-one{
      display: flex;
      .left-form-box{
        width:650px;
      }
      .right-form-box{
        width:650px;
      }
      .form-item{
        display: inline-block;
        overflow: hidden;
        min-height:40px;
        margin-bottom:30px;
      }
    }
    .rich-text{
      margin: 20px;
    }
    .page-bottom-button-box{
      margin-bottom:20px;
      p:nth-child(2){
        margin-right:20px;
      }
    }
  }
  .tabs{
    display: flex;
    justify-content: flex-start;
    margin-left: 42px;
    .tabs-li{
      font-weight: 400;
      font-size: 16px;
      color: #333333;
      padding-bottom: 20px;
      box-sizing: border-box;
      margin-right: 40px;
      cursor: pointer;
    }
    .color-A{
      color: #333333;
    }
    .color-B{
      color: #043581;
      border-bottom: 4px solid #043581;
    }
  }
  .level{
    border: 1px solid #E0E0E0;
    width: 820px;
    margin-left: 40px;
    .level-box{
      .level-title{
        background: #E0E0E0;
        font-weight: 400;
        font-size: 16px;
        color: #FFFFFF;
        line-height: 40px;
        height: 40px;
        padding-left: 14px;

      }
      .level-thead{
        background: #F5F5F5;
        border-bottom: 1px solid #E0E0E0;
        height: 40px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        >i{
          font-style: normal;
          display: inline-block;
          text-align: center;
          font-weight: 400;
          font-size: 16px;
          line-height: 40px;
          color: #333333;
        }
        >i:nth-of-type(1){
          width: 50px;
          border-right: 1px solid #E0E0E0;
        }
        >i:nth-of-type(2){
          width: 132px;
          border-right: 1px solid #E0E0E0;
        }
        >i:nth-of-type(3){
          width: 636px;
        }
      }
      .level-li{
        display: flex;
        justify-content: flex-start;
        height: auto;
        border-bottom: 1px solid #E0E0E0;
        >i{
          font-style: normal;
          text-align: center;
          font-weight: 400;
          font-size: 16px;
          color: #333333;
          height: auto;
          padding:8px 16px;
          box-sizing: border-box;
          display: flex;
          justify-content: center;
          align-items: center;
        }
        >i:nth-of-type(1){
          width: 50px;
          border-right: 1px solid #E0E0E0;
        }
        >i:nth-of-type(2){
          width: 132px;

          border-right: 1px solid #E0E0E0;
        }
        >i:nth-of-type(3){
          width: 636px;
          text-align: left;
          display: flex;
          justify-content: flex-start;
        }
      }
      .level-li:nth-child(2n){
        background: #F5F5F5;
      }
      .level-li:last-child{
        border:none;
      }
      .level-li2{
        font-weight: 400;
        font-size: 14px;
        color: #333333;
        line-height: 40px;
        text-align: center;
      }
    }

  }
  .classify{
    border: 1px solid #E0E0E0;
    width: 820px;
    margin-left: 40px;
    .classify-thead{
      background: #F5F5F5;
      border-bottom: 1px solid #E0E0E0;
      height: 40px;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      >i{
        font-style: normal;
        display: inline-block;
        text-align: center;
        font-weight: 400;
        font-size: 16px;
        line-height: 40px;
        color: #333333;
      }
      >i:nth-of-type(1){
        width: 50px;
        border-right: 1px solid #E0E0E0;
      }
      >i:nth-of-type(2){
        width: 132px;
        border-right: 1px solid #E0E0E0;
      }
      >i:nth-of-type(3){
        width: 636px;
      }
    }
    .classify-li{
      display: flex;
      justify-content: flex-start;
      height: auto;
      border-bottom: 1px solid #E0E0E0;
      >i{
        font-style: normal;
        text-align: center;
        font-weight: 400;
        font-size: 16px;
        color: #333333;
        height: auto;
        padding:8px 16px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
      }
      >i:nth-of-type(1){
        width: 50px;
        border-right: 1px solid #E0E0E0;
      }
      >i:nth-of-type(2){
        width: 132px;
        border-right: 1px solid #E0E0E0;
        display: flex;
        justify-content: center;
      }
      >i:nth-of-type(3){
        width: 636px;
        text-align: left;
      }
    }
    .classify-li:nth-child(2n+1){
      background: #F5F5F5;
    }
    .classify-li:last-child{
      border:none;
    }
  }
  ::v-deep .tableListPaginationSwitch{
    height: 40px;
    display: flex;
    align-items: center;
    .tableListPaginationSwitchL, .tableListPaginationSwitchR{
      flex:1;
    }
    .tip-img{
      color: #E6A23C;
      margin: 0 9px 0 12px;
    }
    .tip-content{
      font-style: normal;
      font-weight: 400;
      font-size: 14px;
      color: #999999;
    }
    .switch .el-switch__label {
      position: absolute;
      display: none;
      color: #fff !important;
    }
    .switch .el-switch__label--right {
      z-index: 1;
    }
    .switch .el-switch__label--right span{
      margin-left: 10px;
    }
    .switch .el-switch__label--left {
      z-index: 1;
    }
    .switch .el-switch__label--left span{
      margin-left: 24px;
    }
    .switch .el-switch__label.is-active {
      display: block;
      text-align: left!important;
    }
    .switch.el-switch .el-switch__core,
    .el-switch .el-switch__label {
      width: 64px !important;
      margin: 0;
    }
  }
</style>
