<!-- 校级隐患清单编辑 -->
<template>
  <div class="schoolHiddenDangerAdd">
    <div class="max-big-top-title-box">
      <p class="title-p">{{newData.deptName}} 实验室安全隐患清单({{newData.hiddenNum}})</p>
      <div class="text-box">
        <p>{{newData.planTitle}}-{{newData.checkName}}</p>
        <p>检查时间：{{newData.checkStartTime}} - {{newData.checkEndTime}}</p>
        <p>共发现隐患{{newData.hiddenCount}}条</p>
      </div>
      <p class="position-left-p" v-if="pageType=='edit'" @click="saveButton">保存</p>
      <p class="position-right-p" @click="submitForApproval(0)" v-if="pageType=='edit'&&newData.flowStatus == 0">提交审批</p>
      <p class="position-right-p" @click="submitForApproval(1)" v-if="pageType=='edit'&&newData.flowStatus == 1">提交审批</p>
      <p class="position-right-p" v-if="pageType=='look'" @click="outButton">关闭</p>
    </div>
    <div class="schoolHiddenDangerAdd-page">
      <div class="max-big-left-box">
        <p class="left-title-p">隐患涉及条款  目录</p>
        <div class="left-for-max-box scrollbar-box" v-if="newData.flowStatus == 0">
          <div @click="leftCheckButton(index)"
             class="left-for-box" :class="checkLeftType == index?'checkLeft':''"
             v-for="(item,index) in leftList" :key="index">
            <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_wc@1x.png" v-if="item.isConfirm == 2&&pageType=='edit'">
            <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_jz@1x.png" v-if="!item.isConfirm != 2&&pageType=='edit'">
            <p>{{item.hazardCheckCode}}</p>
          </div>
        </div>
        <div class="left-for-max-box scrollbar-box" v-if="newData.flowStatus == 1">
          <div @click="leftCheckButton(index)"
             class="left-for-box" :class="checkLeftType == index?'checkLeft':''"
             v-for="(item,index) in leftList" :key="index">
            <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_wc@1x.png" v-if="item.isAdminConfirm == 2&&pageType=='edit'">
            <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_jz@1x.png" v-if="!item.isAdminConfirm != 2&&pageType=='edit'">
            <p>{{item.hazardCheckCode}}</p>
          </div>
        </div>
      </div>
      <div class="max-big-right-box">
        <p class="right-title-p">{{rightTitle}}</p>
        <div class="right-title-box">
          <p>条款号</p>
          <p>实验室</p>
          <p>问题事实描述</p>
          <p :class="pageType=='look'?'for-user-box-all':''">隐患提交人</p>
          <p v-if="pageType=='edit'">操作</p>
        </div>
        <div class="right-for-max-box scrollbar-box">
          <div class="right-for-box" v-for="(item,index) in rightList" :key="index">
            <el-form class="add-form-box" :model="dialogForm" :ref="'dialogForm'+index" :rules="rules" label-width="180px">
              <!--条款号-->
              <div class="for-title-box">
                <p class="null-p"></p>
                <p class="for-title-p" v-if="!item.itemEditType">{{item.hazardCheckCode}}</p>
                <div v-else @click="dialogOpen(item,index)">
                  <span>{{dialogForm.hazardCheckCode}}</span>
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_gd@1x.png" >
                </div>
                <p class="null-p"></p>
              </div>
              <!--实验室/问题描述-->
              <div class="for-text-box">
                <div class="for-text-top-box">
                  <div class="for-text-left-box">
                    <p>
                      {{item.subName}}{{item.roomNum?'('+item.roomNum+')':''}}
                    </p>
                  </div>
                  <div class="for-text-right-box" :class="item.itemEditType?'editClass':''">
                    <p v-if="!item.itemEditType">{{item.hazardDescribe}}</p>
                    <el-form-item  v-else label=""
                                   prop="hazardDescribe"
                                   label-width="0">
                      <el-input placeholder="请输入隐患描述" maxlength='500' type="textarea"
                                style="width:604px;"
                                resize="none" v-model="dialogForm.hazardDescribe"
                                show-word-limit :rows="4"></el-input>
                    </el-form-item>
                  </div>
                </div>
                <div class="for-text-bottom-box">
                  <p class="for-text-bottom-title-p">现场照片：</p>
                  <div v-if="!item.itemEditType">
                    <div class="for-text-bottom-img-box" v-for="(minItem,minIndex) in item.uploadVoList" :key="minIndex">
                      <img class="for-text-bottom-img" @click="fullScreenViewClick(item.uploadVoList,minIndex)" :src="minItem.fileUrl">
                      <!--<img class="for-text-bottom-del" v-if="item.itemEditType" src="@/assets/ZDimages/safetyCheck/icon_yhqd_sctp@1x.png">-->
                    </div>
                  </div>
                  <el-form-item label=""
                                prop="uploadVoList"
                                class="edit-img-max-box"
                                label-width="0" v-else>
                    <div class="for-text-bottom-img-box" v-for="(minItem,minIndex) in dialogForm.uploadVoList" :key="minIndex">
                      <img class="for-text-bottom-img" @click="fullScreenViewClick(dialogForm.uploadVoList,minIndex)" :src="minItem.fileUrl">
                      <img class="for-text-bottom-del" @click="delImg(index,minIndex)" src="@/assets/ZDimages/safetyCheck/icon_yhqd_sctp@1x.png">
                    </div>
                    <el-upload
                      v-if="dialogForm.uploadVoList.length<6"
                      style="display: inline-block;overflow: hidden;height:260px;width:260px;"
                      class="avatar-uploader"
                      :action="uploadImgUrl"
                      :show-file-list="false"
                      :on-success="(res)=>handleAvatarSuccess(res,index)"
                      :headers="headers"
                      :before-upload="(res)=>beforeAvatarUpload(res,index)">
                      <div class="up-box">
                        <p class="el-icon-plus up-img-p"></p>
                        <p class="up-text-p">添加图片</p>
                      </div>
                    </el-upload>
                  </el-form-item>
                </div>
              </div>
              <!--隐患提交人-->
              <div class="for-user-box" :class="pageType=='look'?'for-user-box-all':''">
                <p class="null-p"></p>
                <p class="for-user-p">{{item.checkUserName}}</p>
                <p class="for-user-p">{{item.checkAccount}}</p>
                <p class="null-p"></p>
              </div>
              <!--操作按钮列-->
              <div class="for-button-box" v-if="pageType=='edit' && newData.flowStatus == 0">
                <p class="null-p"></p>
                <div class="for-min-button-1" v-if="item.itemEditType" @click="verifyEditButton(item,index)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_qd@1x.png">
                  <p>确定</p>
                </div>
                <div class="for-min-button-2" v-if="item.itemEditType" @click="editButton(item,index,false)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_sc@1x.png">
                  <p>取消</p>
                </div>
                <div class="for-min-button-3" v-if="item.isConfirm != 1 && !item.itemEditType && !dialogType" @click="editButton(item,index,true)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_bj@1x.png">
                  <p>编辑</p>
                </div>
                <div class="for-min-button-1" v-if="item.isConfirm != 1 && !item.itemEditType && !dialogType" @click="verifyButton(item,index)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_qd@1x.png">
                  <p>确认</p>
                </div>
                <div class="for-min-button-2" v-if="item.isConfirm != 1 && !item.itemEditType && !dialogType" @click="delButton(item,index)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_sc@1x.png">
                  <p>删除</p>
                </div>
                <el-tooltip class="item" effect="dark" content="点击按钮可继续编辑该条隐患内容" placement="top" v-if="item.isConfirm == 1&&!itemEditType">
                  <div class="for-min-button-4" @click="verifyButton(item,index)">
                    <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_yqr@1x.png">
                    <p>已确认</p>
                  </div>
                </el-tooltip>
                <p class="null-p"></p>
              </div>
              <div class="for-button-box" v-if="pageType=='edit' && newData.flowStatus == 1">
                <p class="null-p"></p>
                <div class="for-min-button-1" v-if="item.itemEditType" @click="verifyEditButton(item,index)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_qd@1x.png">
                  <p>确定</p>
                </div>
                <div class="for-min-button-2" v-if="item.itemEditType" @click="editButton(item,index,false)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_sc@1x.png">
                  <p>取消</p>
                </div>
                <div class="for-min-button-3" v-if="item.isAdminConfirm != 1 && !item.itemEditType && !dialogType" @click="editButton(item,index,true)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_bj@1x.png">
                  <p>编辑</p>
                </div>
                <div class="for-min-button-1" v-if="item.isAdminConfirm != 1 && !item.itemEditType && !dialogType" @click="verifyButton(item,index)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_qd@1x.png">
                  <p>确认</p>
                </div>
                <div class="for-min-button-2" v-if="item.isAdminConfirm != 1 && !item.itemEditType && !dialogType" @click="delButton(item,index)">
                  <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_sc@1x.png">
                  <p>删除</p>
                </div>
                <el-tooltip class="item" effect="dark" content="点击按钮可继续编辑该条隐患内容" placement="top" v-if="item.isAdminConfirm == 1&&!itemEditType">
                  <div class="for-min-button-4" @click="verifyButton(item,index)">
                    <img src="@/assets/ZDimages/safetyCheck/icon_yhqd_yqr@1x.png">
                    <p>已确认</p>
                  </div>
                </el-tooltip>
                <p class="null-p"></p>
              </div>
            </el-form>
          </div>
        </div>
      </div>
    </div>
    <!--修改检查项-->
    <el-dialog class="schoolHiddenDangerAdd-dialog-max-box" title="修正隐患对应检查项目条款" width="1000px" append-to-body
               :visible.sync="editShadeType" v-if="editShadeType"
               @close="dialogOff()" :close-on-click-modal="false" :close-on-press-escape="false">
      <div class="schoolHiddenDangerAdd-dialog-big-box scrollbar-box">
        <el-form class="add-form-box" :model="editShadeForm" ref="editShadeForm" label-width="80px">
          <el-form-item label="检查项目" prop="hazardCheckPro">
            <el-cascader
              placeholder="请选择检查项目"
              style="width:840px;"
              v-model="editShadeForm.hazardCheckPro"
              filterable
              @change="hazardCheckProChange"
              :options="cascaderData"
              :props="{ value: 'id', label: 'labelName',emitPath:false }"
            ></el-cascader>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer dialog-footer-box">
        <p class="dialog-footer-button-null"></p>
        <p class="dialog-footer-button-info" @click="dialogOff">取消</p>
        <p class="dialog-footer-button-primary" @click="dialogSubmit()">确定</p>
        <p class="dialog-footer-button-null"></p>
      </div>
    </el-dialog>
    <!--预览图片-->
    <fullScreenView :fullScreenViewProps="fullScreenViewProps" ref="fullScreenView"></fullScreenView>
  </div>
</template>
<script>
  import { getToken } from "@/utils/auth";
  import fullScreenView from "@/components/fullScreenView/fullScreenView.vue";
  import {
    securityCheckHiddenDangerFindCheckHiddenDanger,
    securityCheckSetOptionCheckCommit,
    securityCheckSetOptionClearOptionData,
    securityCheckHiddenDangerUpdate,
    securityCheckOptionSelAllList,
    securityCheckSetOptionUnCheckList,
  } from '@/api/safetyCheck/index'
  export default {
    name: 'addPage',
    components: {
      fullScreenView,
    },
    data () {
      return {
        //上传相关
        uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
        headers: {
          Authorization:getToken(),
        },
        //页面状态
        pageType:null,
        //隐患清单基础信息
        newData:{
          manageId:'',
          deptName:'',
          hiddenNum:'',
          planTitle:'',
          checkName:'',
          checkStartTime:'',
          checkEndTime:'',
          hiddenCount:'',
        },
        //左侧选中状态
        checkLeftType:0,
        //左侧数据列表
        leftList:[],
        //右侧数据
        rightTitle:'',
        //右侧数据列表
        rightList:[],
        rules:{
          hazardDescribe: [
            { required: true, message: "请输入问题事实描述", trigger: "blur" },
            { required: true, message: "请输入问题事实描述", validator: this.spaceJudgment, trigger: "blur" }
          ],
          uploadVoList: [
            { required: true, message: "请上传现场照片", trigger: "blur" },
          ],
        },
        //检查项列表
        cascaderData:[],
        cascaderDataList:[],
        //修改检查项弹窗状态
        editShadeType:false,
        editShadeForm:{
          hazardCheckPro:'',
        },
        //修改数据
        dialogForm:{},
        backupsDialogForm:{},
        dialogType:false,
        //上传图片名臣暂存
        upDataName:'',
        //图片预览数据
        fullScreenViewProps:[],
      }
    },
    created () {
      this.$set(this,'pageType',this.$route.query.type);
      this.securityCheckHiddenDangerFindCheckHiddenDanger();
    },
    mounted () {

    },
    methods: {
      //数据初始化
      securityCheckHiddenDangerFindCheckHiddenDanger(){
        securityCheckHiddenDangerFindCheckHiddenDanger({hiddenId:this.$route.query.hiddenId}).then(response => {
          if(!response.data.hiddenSetOptionVos[0]){
            this.$set(this,'leftList',[]);
            this.$set(this,'rightList',[]);
            this.$set(this,'rightTitle','');
            this.$alert('该清单已无隐患,请刷新上级页面.点击确定后该关闭将页面.', '提交成功', {
              confirmButtonText: '确定',
              callback: action => {
                window.close();
              }
            });
            return
          }
          this.$set(this,'newData',{
            manageId:response.data.manageId,
            deptName:response.data.deptName,
            hiddenNum:response.data.hiddenNum,
            planTitle:response.data.planTitle,
            checkName:response.data.checkName,
            checkStartTime:response.data.checkStartTime,
            checkEndTime:response.data.checkEndTime,
            hiddenCount:response.data.hiddenCount,
            planId:response.data.planId,
            flowStatus:response.data.flowStatus,//0.组长审批 1.管理审批
          });
          this.$set(this,'leftList',response.data.hiddenSetOptionVos);
          if(response.data.hiddenSetOptionVos[this.checkLeftType]){
            this.$set(this,'rightTitle',response.data.hiddenSetOptionVos[this.checkLeftType].hazardCheckCode+' '+response.data.hiddenSetOptionVos[this.checkLeftType].hazardCheckName);
            let list = JSON.parse(JSON.stringify(response.data.hiddenSetOptionVos[this.checkLeftType].checkSetOptionVoList))
            list.forEach((item)=>{
              item.itemEditType = false;
            })
            this.$set(this,'rightList',list);
          }else{
            this.$set(this,'checkLeftType',this.checkLeftType-1);
            this.$set(this,'rightTitle',response.data.hiddenSetOptionVos[this.checkLeftType].hazardCheckCode+' '+response.data.hiddenSetOptionVos[this.checkLeftType].hazardCheckName);
            let list = JSON.parse(JSON.stringify(response.data.hiddenSetOptionVos[this.checkLeftType].checkSetOptionVoList))
            list.forEach((item)=>{
              item.itemEditType = false;
            })
            this.$set(this,'rightList',list);
          }
        })
      },
      // 左侧列表选中方法
      leftCheckButton(index){
        if(this.checkLeftType != index){
          let text = this.leftDetectionButton();
          if(text != null){
            this.$alert('请先提交或取消右侧编辑状态,避免数据丢失.', '警告', {
              confirmButtonText: '确定',
              callback: action => {}
            });
            return
          }
          this.$set(this,'checkLeftType',index);
          this.$set(this,'rightTitle',this.leftList[index].hazardCheckCode+' '+this.leftList[index].hazardCheckName);
          let list = JSON.parse(JSON.stringify(this.leftList[index].checkSetOptionVoList))
          list.forEach((item)=>{
            item.itemEditType = false;
          })
          this.$set(this,'rightList',list);
        }
      },
      //修改检查项开
      dialogOpen(item,index) {
        this.$set(this.editShadeForm,'hazardCheckPro',this.dialogForm.hazardCheckPro);
        this.$set(this, 'editShadeType', true)
      },
      //修改检查项关
      dialogOff() {
        this.$set(this.editShadeForm,'hazardCheckPro','');
        this.$set(this, 'editShadeType', false)
      },
      dialogSubmit(){
        this.$set(this.editShadeForm,'hazardCheckPro','');
        this.$set(this, 'editShadeType', false)
      },
      //编辑开关
      editButton(item,index,type){
        if(type){
          this.$set(this,'backupsDialogForm',JSON.parse(JSON.stringify({
            hazardCheckCode:this.rightList[index].hazardCheckCode,
            subName:this.rightList[index].subName,
            roomNum:this.rightList[index].roomNum,
            hazardDescribe:this.rightList[index].hazardDescribe,
            uploadVoList:this.rightList[index].uploadVoList,
            checkUserName:this.rightList[index].checkUserName,
            checkAccount:this.rightList[index].checkAccount,
            hazardCheckPro:this.rightList[index].hazardCheckPro,
            manageId:this.rightList[index].manageId,
            setOptionId:this.rightList[index].setOptionId,
            checkStatus:this.rightList[index].checkStatus,
            checkFlag:this.rightList[index].checkFlag,
          })));
          this.$set(this,'dialogForm',JSON.parse(JSON.stringify({
            hazardCheckCode:this.rightList[index].hazardCheckCode,
            subName:this.rightList[index].subName,
            roomNum:this.rightList[index].roomNum,
            hazardDescribe:this.rightList[index].hazardDescribe,
            uploadVoList:this.rightList[index].uploadVoList,
            checkUserName:this.rightList[index].checkUserName,
            checkAccount:this.rightList[index].checkAccount,
            hazardCheckPro:this.rightList[index].hazardCheckPro,
            manageId:this.rightList[index].manageId,
            setOptionId:this.rightList[index].setOptionId,
            checkStatus:this.rightList[index].checkStatus,
            checkFlag:this.rightList[index].checkFlag,
          })));
          this.$set(this,'dialogType',true);
          this.securityCheckSetOptionUnCheckList(this.rightList[index]);
        }else{
          this.$set(this.rightList,[index],JSON.parse(JSON.stringify({
            hazardCheckCode:this.backupsDialogForm.hazardCheckCode,
            subName:this.backupsDialogForm.subName,
            roomNum:this.backupsDialogForm.roomNum,
            hazardDescribe:this.backupsDialogForm.hazardDescribe,
            uploadVoList:this.backupsDialogForm.uploadVoList,
            checkUserName:this.backupsDialogForm.checkUserName,
            checkAccount:this.backupsDialogForm.checkAccount,
            hazardCheckPro:this.backupsDialogForm.hazardCheckPro,
            manageId:this.backupsDialogForm.manageId,
            setOptionId:this.backupsDialogForm.setOptionId,
            checkStatus:this.backupsDialogForm.checkStatus,
            checkFlag:this.backupsDialogForm.checkFlag,
          })));
          this.$set(this,'dialogType',false);
        }
        this.$set(this.rightList[index],'itemEditType',type);
      },
      //确认编辑内容
      verifyEditButton(item,index){
        let self = this;
        this.$refs['dialogForm'+index][0].validate(valid => {
          if (valid) {
            this.$confirm(`是否确定修改?`, "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }).then(async () => {
              self.securityCheckSetOptionCheckCommit(1,index)
            }).catch(() => {

            })
          }
        })
      },
      //确认开关
      verifyButton(item,index){
        this.securityCheckSetOptionCheckCommit(2,index,item);
      },
      //修改检查项/确认检查项
      securityCheckSetOptionCheckCommit(type,index,item){
        let obj = {};
        //type 1.编辑 2.确认
        if (type == 1){
          obj = {
            setOptionId:this.dialogForm.setOptionId,
            checkStatus:this.dialogForm.checkStatus,
            checkFlag:this.dialogForm.checkFlag,
            hazardDescribe:this.dialogForm.hazardDescribe,
            photoList:this.dialogForm.uploadVoList,
            hiddenId:this.$route.query.hiddenId,
            source:1,
          }
          if(this.newData.flowStatus == 0){
            obj.isConfirm = 1;
          }else if(this.newData.flowStatus == 1){
            obj.isAdminConfirm = 1;
          }
          if(this.dialogForm.setOptionId != this.backupsDialogForm.setOptionId){
            obj.delSetOptionId = this.backupsDialogForm.setOptionId;
          }
        }else if(type == 2){
          obj = {
            setOptionId:item.setOptionId,
            checkStatus:item.checkStatus,
            checkFlag:item.checkFlag,
            hazardDescribe:item.hazardDescribe,
            photoList:item.uploadVoList,
            hiddenId:this.$route.query.hiddenId,
            source:1,
          }
          if(this.newData.flowStatus == 0){
            obj.isConfirm = item.isConfirm == 1 ? 0 : 1;
          }else if(this.newData.flowStatus == 1){
            obj.isAdminConfirm = item.isAdminConfirm == 1 ? 0 : 1;
          }
        }
        securityCheckSetOptionCheckCommit(obj).then(response => {
          this.msgSuccess(response.message)
          if (type == 1){
            this.securityCheckHiddenDangerFindCheckHiddenDanger();
          }else{
            if(this.newData.flowStatus == 0){
              // this.$set(this.rightList[index],'isConfirm',this.rightList[index].isConfirm == 1?0:1);
              this.securityCheckHiddenDangerFindCheckHiddenDanger();
            }else if(this.newData.flowStatus == 1){
              this.securityCheckHiddenDangerFindCheckHiddenDanger();
              // this.$set(this.rightList[index],'isAdminConfirm',this.rightList[index].isAdminConfirm == 1?0:1);
            }
          }
          this.$set(this,'dialogType',false);
          // self.$set(self.rightList[index],'itemEditType',false);
        })
      },
      //删除按钮
      delButton(item,index){
        console.log('item.setOptionId',item.setOptionId)
        let self = this;
        this.$confirm(`删除后将不可恢复,你确定要删除这条隐患吗?`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(async () => {
          let obj = {
            setOptionId:item.setOptionId,
            hiddenId:this.$route.query.hiddenId,
            source:1,
          }
          securityCheckSetOptionClearOptionData(obj).then(response => {
            self.msgSuccess(response.message)
            self.securityCheckHiddenDangerFindCheckHiddenDanger();
          })
        }).catch(() => {

        })
      },
      outButton(){
        let self = this;
        self.$confirm(`确定退出并关闭页面?`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(async () => {
          window.close();
        }).catch(() => {

        })
      },
      //保存退出
      saveButton(){
        let self = this;
        self.$confirm(`是否保存并关闭页面?`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(async () => {
          window.close();
        }).catch(() => {

        })
      },
      //提交审批
      submitForApproval(val){
        let self = this;
        //提交确认
        self.$confirm(`是否确认提交?`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(async () => {
          self.securityCheckHiddenDangerUpdate(val);
        }).catch(() => {

        })
      },
      //提交审批
      securityCheckHiddenDangerUpdate(val){
        let self = this;
        let obj = {
          hiddenId:this.$route.query.hiddenId,
        }
        if(val == 1){
          obj.adminSubmitStatus = 1;
          obj.flowStatus = 1;
        }else if(val == 0){
          obj.leaderSubmitStatus = 1;
          obj.flowStatus = 1;
        }
        securityCheckHiddenDangerUpdate(obj).then(response => {
          //成功后提示关闭
          self.$alert('点击确定后将关闭页面', '提交成功', {
            confirmButtonText: '确定',
            callback: action => {
              window.close();
            }
          });
        })
      },
      //左侧列表切换检测
      leftDetectionButton(){
        let text = null;
        this.rightList.forEach((item,index)=>{
          if(item.itemEditType){
            text = (index==0?'':',')+text + (index+1)
          }
        })
        return text
      },
      /*==========上传相关==========*/
      handleAvatarSuccess(res,index) {
        if(this.dialogForm.uploadVoList.length>5){
          this.msgError('最多只可上传6张')
          return
        }
        let suffixName= this.upDataName.split('.')[this.upDataName.split('.').length - 2]
        //判断文件名中是否有逗号和分号
        if(suffixName.indexOf(',')==-1 && suffixName.indexOf(';')==-1){
        }else{
          this.msgError('文件名里包含逗号或分号，请修改后重新上传！')
          return
        }
        let obj ={
          fileName:this.upDataName,
          fileUrl:res.data.url,
        };
        this.dialogForm.uploadVoList.push(obj);
        this.$forceUpdate()
      },
      beforeAvatarUpload(file,index) {
        if(this.dialogForm.uploadVoList.length>5){
          this.msgError('最多只可上传6张')
          return false
        }
        let type = false;
        if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/jpg' || file.type == 'image/gif' || file.type == 'image/bmp') {
          if(file.size> 2100000){
            this.msgError('上传图片大小不能超过2M')
            return false
          }
          this.upDataName = file.name;
          type = true;
        }else{
          this.msgError('仅支持jpeg/jpg/png/bmp/gif格式')
          type = false;
        }
        return type;
      },
      //删除照片
      delImg(index,imgIndex){
        this.dialogForm.uploadVoList.splice(imgIndex,1);
        this.$forceUpdate()
      },
      //照片预览
      fullScreenViewClick(list,index){
        let newList = [];
        for(let i=0;i<list.length;i++){
          newList.push(list[i].fileUrl)
        }
        this.$set(this,'fullScreenViewProps',newList);
        this.$refs['fullScreenView'].initialize(index);
      },
      //手动选择检查项目
      hazardCheckProChange(val){
        let self = this;
        if (val){
          for (let i=0;i<self.cascaderDataList.length;i++){
            if(val == self.cascaderDataList[i].hazardCheckPro){
              self.$set(self.dialogForm,'setOptionId',self.cascaderDataList[i].setOptionId);
              self.$set(self.dialogForm,'hazardCheckPro',self.cascaderDataList[i].hazardCheckPro);
              self.$set(self.dialogForm,'hazardCheckCode',self.cascaderDataList[i].hazardCheckCode);
              break
            }
          }
        }
      },
      //未执行过的检查项列表
      securityCheckSetOptionUnCheckList(obj){
        securityCheckOptionSelAllList({}).then(response => {
          let maxList = this.getCascaderData(JSON.parse(JSON.stringify(response.data)),2)
          this.$nextTick(()=>{
            securityCheckSetOptionUnCheckList({
              manageId: obj.manageId,
            }).then(response => {
              let newObj = {
                checkCategory: obj.checkCategory,//检查类别(1校院巡查 2自查)
                checkStatus: obj.checkStatus,//检查状态：0未开始，1已完成，2草稿
                deptId:obj.deptId,// 部门id
                hazardCheckCode: obj.hazardCheckCode,// 三级检查项目code序号
                hazardCheckCode1: obj.hazardCheckCode1,//		 一级项目检查code
                hazardCheckCode2: obj.hazardCheckCode2,//		二级项目检查code
                hazardCheckName: obj.hazardCheckName,//		三级检查名称
                hazardCheckName1: obj.hazardCheckName1,//			一级检查名称
                hazardCheckName2: obj.hazardCheckName2,//			二级检查名称
                hazardCheckPoint: obj.hazardCheckPoint,//  检查要点
                hazardCheckPro: obj.hazardCheckPro,//   三级检查项目id
                hazardCheckPro1: obj.hazardCheckPro1,//		一级项目检查id
                hazardCheckPro2: obj.hazardCheckPro2,//	二级项目检查id
                manageId: obj.manageId,//		检查管理id
                planId: obj.planId,//	计划id
                planSetId: obj.planSetId,//	批次id
                setOptionId: obj.setOptionId,//  检查项id
                subId: obj.subId,//	实验室ID
              }
              response.data.push(newObj);
              this.$set(this,'cascaderDataList',response.data);
              for(let i=0;i<maxList.length;i++){
                for(let o=0;o<maxList[i].children.length;o++){
                  for(let x=0;x<response.data.length;x++){
                    if(maxList[i].children[o].id == response.data[x].hazardCheckPro2){
                      if(maxList[i].children[o].children){
                        maxList[i].children[o].children.push({
                          id: response.data[x].hazardCheckPro,
                          name: response.data[x].hazardCheckName,
                          mainPoint: response.data[x].hazardCheckPoint,
                          hazardLevelName: null,
                          code: response.data[x].hazardCheckCode,
                          parentId: response.data[x].hazardCheckPro2,
                          type: 1,
                          level: 3,
                          hazardReid: null,
                        })
                      }else{
                        maxList[i].children[o].children = [{
                          id: response.data[x].hazardCheckPro,
                          name: response.data[x].hazardCheckName,
                          mainPoint: response.data[x].hazardCheckPoint,
                          hazardLevelName: null,
                          code: response.data[x].hazardCheckCode,
                          parentId: response.data[x].hazardCheckPro2,
                          type: 1,
                          level: 3,
                          hazardReid: null,
                        }]
                      }
                    }
                  }
                }
              }
              let list = this.getCascaderData(JSON.parse(JSON.stringify(maxList)),3)
              this.$nextTick(()=>{
                this.$set(this, 'cascaderData', list)
              })
            })
          })
        })
      },
      //检查项格式处理
      getCascaderData(list,type) {
        let self = this
        for (let i = 0; i < list.length; i++) {
          list[i].labelName = list[i].code ? list[i].code + ' ' + list[i].name : list[i].name
          if(list[i].level == type){
            delete list[i].children
          }else if (list[i].children) {
            if (list[i].children[0]) {
              list[i].children = self.getCascaderData(list[i].children,type)
            } else {
              list.splice(i, 1)
              i--
            }
          } else {
            list.splice(i, 1)
            i--
          }
        }
        for (let i = 0; i < list.length; i++) {
          list[i].labelName = list[i].code ? list[i].code + ' ' + list[i].name : list[i].name
          if(list[i].level == type){
            delete list[i].children
          }else if (list[i].children) {
            if (list[i].children[0]) {
              list[i].children = self.getCascaderData(list[i].children,type)
            } else {
              list.splice(i, 1)
              i--
            }
          } else {
            list.splice(i, 1)
            i--
          }
        }
        for (let i = 0; i < list.length; i++) {
          list[i].labelName = list[i].code ? list[i].code + ' ' + list[i].name : list[i].name
          if(list[i].level == type){
            delete list[i].children
          }else if (list[i].children) {
            if (list[i].children[0]) {
              list[i].children = self.getCascaderData(list[i].children,type)
            } else {
              list.splice(i, 1)
              i--
            }
          } else {
            list.splice(i, 1)
            i--
          }
        }
        return list
      },
    },
  }
</script>
<style scoped lang="scss">
  .schoolHiddenDangerAdd{
    height:100%;
    width:1532px;
    margin:0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom:10px;
    .max-big-top-title-box{
      background: rgba(1,131,250,0.1);
      padding:18px 36px;
      position: relative;
      margin-bottom:18px;
      margin-right:6px;
      .title-p{
        font-weight: 700;
        font-size: 16px;
        color: #333333;
        height:18px;
        line-height: 18px;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-bottom:18px;
      }
      .text-box{
        display: flex;
        p{
          font-weight: 400;
          font-size: 16px;
          color: #333333;
          height:18px;
          line-height: 18px;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
        p:nth-child(1){
          flex:1;
        }
        p:nth-child(2){
          flex:1;
        }
        p:nth-child(3){
          width:140px;
          text-align: right;
        }
      }
      .position-left-p{
        font-size: 14px;
        line-height: 25px;
        width:100px;
        text-align: center;
        position: absolute;
        top:5px;
        right:110px;
        cursor: pointer;
        background-color: #fff;
        border-radius:4px;
        border:1px solid #0045AF;
        color:#0045AF;
      }
      .position-right-p{
        font-size: 14px;
        line-height: 25px;
        width:100px;
        text-align: center;
        position: absolute;
        top:5px;
        right:5px;
        cursor: pointer;
        background-color: #0045AF;
        border-radius:4px;
        border:1px solid #0045AF;
        color:#fff;
      }
      .position-left-p:hover{
        background-color: #0183FA;
        border-radius:4px;
        border:1px solid #0183FA;
        color:#fff;
      }
      .position-right-p:hover{
        background-color: #0183FA;
        border-radius:4px;
        border:1px solid #0183FA;
        color:#fff;
      }
    }
    .schoolHiddenDangerAdd-page{
      flex:1;
      display: flex;
      overflow: hidden;
      .max-big-left-box{
        width:219px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        .left-title-p{
          width:180px;
          height: 70px;
          line-height: 70px;
          font-weight: 700;
          font-size: 16px;
          color: #333333;
          text-align: center;
          font-style: normal;
          text-transform: none;
          border: 1px solid #E0E0E0;
          background: #F5F5F5;
        }
        .left-for-max-box{
          width:186px;
          flex:1;
          .checkLeft{
            background-color: rgba(1,131,250,0.2)!important;
          }
          .left-for-box{
            width:180px;
            display: flex;
            position: relative;
            border:1px solid #E0E0E0;
            border-top:none;
            cursor: pointer;
            background: #F5F5F5;
            img{
              position: absolute;
              top:22px;
              left:28px;
              display: block;
              overflow: hidden;
              height:16px;
              width:16px;
            }
            p{
              width:180px;
              text-align: center;
              line-height: 60px;
            }
          }
        }
      }
      .max-big-right-box{
        flex:1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        .right-title-p{
          padding-left:7px;
          height: 45px;
          font-weight: 700;
          font-size: 16px;
          color: #3D3D3D;
          line-height: 30px;
          font-style: normal;
          text-transform: none;
        }
        .right-title-box{
          background: #F5F5F5;
          border: 1px solid #E0E0E0;
          display: flex;
          height:40px;
          margin-right:6px;
          p{
            border-left:1px solid #E0E0E0;
            text-align: center;
            font-weight: 400;
            font-size: 16px;
            color: #333333;
            line-height: 40px;
            font-style: normal;
            text-transform: none;
          }
          p:nth-child(1){
            border-left:none;
            width:100px;
          }
          p:nth-child(2){
            width:297px;
          }
          p:nth-child(3){
            width:610px;
          }
          p:nth-child(4){
            width:150px;
          }
          p:nth-child(5){
            width:140px;
          }
          .for-user-box-all{
            width:290px!important;
          }
        }
        .right-for-max-box{
          flex:1;
          .right-for-box{
            display: flex;
            overflow: hidden;
            border:1px solid #E0E0E0;
            border-top:none;
            .add-form-box{
              display: flex;
              overflow: hidden;
            }
            //条款号
            .for-title-box{
              width:101px;
              display: flex;
              flex-direction: column;
              overflow: hidden;
              border-right:1px solid #E0E0E0;
              .for-title-p{
                text-align: center;
              }
              div{
                cursor: pointer;
                height:16px;
                line-height:16px;
                font-size:16px;
                overflow: hidden;
                color:#0183FA;
                text-align: center;
                img{
                  display: inline-block;
                  overflow: hidden;
                  width:16px;
                  height:16px;
                  vertical-align: text-bottom;
                }
              }
            }
            //实验室/问题描述
            .for-text-box{
              width:906px;
              display: flex;
              flex-direction: column;
              overflow: hidden;
              .for-text-top-box{
                display: flex;
                .for-text-left-box{
                  width:298px;
                  min-height:94px;
                  display: flex;
                  justify-content: center; /* 水平居中 */
                  align-items: center;     /* 垂直居中 */
                  padding:20px;
                  border-right:1px solid #E0E0E0;
                  p{
                    width: 298px;
                    text-align: center;
                  }
                }
                .for-text-right-box{
                  width:614px;
                  min-height:94px;
                  display: flex;
                  justify-content: center; /* 水平居中 */
                  align-items: center;     /* 垂直居中 */
                  padding:20px;
                  p{
                    width: 614px;
                    text-align: center;
                  }
                  ::v-deep .el-textarea__inner{
                    border:none;
                    background-color:rgba(255,255,255,0)
                  }
                  ::v-deep .el-form-item{
                    margin:0;
                  }
                  ::v-deep .el-form-item__error{
                    margin-top: -25px;
                    margin-left: 15px;
                  }
                  ::v-deep .el-input__count{
                    position: absolute;
                    bottom:0;
                    right:0;
                  }
                  ::v-deep .el-textarea__inner::-webkit-scrollbar{
                    width: 6px!important;     /*高宽分别对应横竖滚动条的尺寸*/
                    height: 6px!important;
                  }
                  ::v-deep .el-textarea__inner::-webkit-scrollbar-thumb{
                    border-radius: 5px!important;
                    -webkit-box-shadow: inset 0 0 5px #E0E0E0!important;
                    background: #E0E0E0!important;
                  }
                  ::v-deep .el-textarea__inner::-webkit-scrollbar-track{
                    -webkit-box-shadow: inset 0 0 5px rgba(255,255,255,0)!important;
                    border-radius: 0!important;
                    background: rgba(255,255,255,0)!important;
                  }
                }
                .editClass{
                  padding:0 !important;
                  background-color:rgba(1,131,250,0.1);
                }
              }
              .for-text-bottom-box{
                border-top:1px solid #E0E0E0;
                .for-text-bottom-title-p{
                  line-height:60px;
                  font-weight: 400;
                  font-size: 16px;
                  color: #333333;
                  text-align: left;
                  font-style: normal;
                  text-transform: none;
                  padding-left:28px;
                }
                .for-text-bottom-img-box{
                  overflow: hidden;
                  display: inline-block;
                  width:260px;
                  height:260px;
                  border-radius:10px;
                  position: relative;
                  margin:0 0 20px 32px;
                  .for-text-bottom-img{
                    display: block;
                    overflow: hidden;
                    width:260px;
                    height:260px;
                    cursor: pointer;
                  }
                  .for-text-bottom-del{
                    position: absolute;
                    top:5px;
                    right:5px;
                    display: block;
                    width:16px;
                    height:16px;
                    cursor: pointer;
                  }
                }
                .edit-img-max-box{
                  margin:0;
                  .for-text-bottom-img-box{
                    overflow: hidden;
                    display: inline-block;
                    width:260px;
                    height:260px;
                    border-radius:10px;
                    position: relative;
                    margin:0 0 11px 32px;
                    .for-text-bottom-img{
                      display: block;
                      overflow: hidden;
                      width:260px;
                      height:260px;
                      cursor: pointer;
                    }
                    .for-text-bottom-del{
                      position: absolute;
                      top:5px;
                      right:5px;
                      display: block;
                      width:16px;
                      height:16px;
                      cursor: pointer;
                    }
                  }
                  .avatar-uploader{
                    overflow: hidden;
                    display: inline-block;
                    width:260px;
                    height:260px;
                    border-radius:10px;
                    margin:0 0 11px 32px;
                    background: rgba(1,131,250,0.05);
                    border-radius: 10px 10px 10px 10px;
                    border: 1px dashed #E0E0E0;
                    cursor: pointer;
                    .up-box{
                      height:260px;
                      width:260px;
                      .up-img-p{
                        width:260px;
                        text-align: center;
                        line-height: 80px;
                        color:#E0E0E0;
                        font-size:62px;
                        font-weight:700;
                        margin-top:80px;
                      }
                      .up-text-p{
                        width:260px;
                        text-align: center;
                        line-height: 40px;
                        color: #333333;
                        font-weight: 400;
                        font-size: 14px;
                        font-style: normal;
                        text-transform: none;
                      }
                    }
                  }
                  ::v-deep .el-form-item__error{
                    margin-left:30px;
                    margin-top:-25px;
                  }
                }
              }
            }
            //隐患提交人
            .for-user-box{
              width:150px;
              display: flex;
              flex-direction: column;
              overflow: hidden;
              border-left:1px solid #E0E0E0;
              .for-user-p{
                text-align: center;
                font-weight: 400;
                font-size: 14px;
                color: #333333;
                line-height: 30px;
                font-style: normal;
                text-transform: none;
              }
            }
            .for-user-box-all{
              width:290px!important;
            }
            //操作按钮列
            .for-button-box{
              width:148px;
              display: flex;
              flex-direction: column;
              overflow: hidden;
              border-left:1px solid #E0E0E0;
              div{
                display: flex;
                width:100px;
                height:40px;
                border-radius:6px;
                overflow: hidden;
                margin:10px auto;
                cursor: pointer;
                img{
                  display: block;
                  height:16px;
                  width:16px;
                  margin:12px 8px 0 15px;
                }
                p{
                  line-height:40px;
                  font-weight: 400;
                  font-size: 14px;
                  text-align: left;
                  font-style: normal;
                  text-transform: none;
                }
              }
              .for-min-button-1{
                background-color:rgba(19,205,63,0.2);
                color: #13CD3F;
              }
              .for-min-button-2{
                background-color:rgba(255,0,0,0.2);
                color: #FF0000;
              }
              .for-min-button-3{
                background-color:rgba(1,131,250,0.2);
                color: #0183FA;
              }
              .for-min-button-4{
                background-color:rgba(0,69,175,0.2);
                color: #0045AF;
              }
            }
            //充填
            .null-p{
              flex:1;
            }
          }
        }
      }
    }
  }
</style>
