<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="申请部门" prop="applyDept">
        <el-input
          v-model="queryParams.applyDept"
          placeholder="请输入申请部门"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开始时间" prop="applyWorkStartTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.applyWorkStartTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="applyWorkEndTime">
        <el-date-picker clearable size="small"
                        v-model="queryParams.applyWorkEndTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="申请单状态" prop="applyStatus">
        <el-select v-model="queryParams.applyStatus" placeholder="请选择申请单状态" clearable size="small">
          <el-option
            v-for="dict in certificateStatus"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:permit:add']"
        >新增</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="permitList">
      <el-table-column label="申请部门" align="center" prop="applyDept" />
      <el-table-column label="申请人" align="center" prop="linkMan" :formatter="applyNameFormate"/>
      <el-table-column label="联系电话" align="center" prop="linkPhone" />
      <el-table-column label="设备名称" align="center" prop="deviceName" />
      <el-table-column label="设备编号" align="center" prop="deviceNum" />
      <el-table-column label="开始时间" align="center" prop="applyWorkStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyWorkStartTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="applyWorkEndTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.applyWorkEndTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="申请单状态" align="center" prop="applyStatus" :formatter="applyStatusFormate"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="certificateDetail(scope.row)"
          >
            详情
          </el-button>
          <el-button
            v-if="scope.row.applyStatus =='0'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:permit:remove']"
          >删除</el-button>
          <el-button
            v-if="scope.row.operator=='safeAnalyse'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="safeAnalyse(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >安全分析</el-button>
          <el-button
            v-if="scope.row.operator=='approval'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="certificateApproval(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >作业证审核</el-button>
          <el-button
            v-if="scope.row.operator=='workPermit'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="certificateApprovalApply(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >作业证申请</el-button>
          <el-button
            v-if="scope.row.operator=='review'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="certificateApprovalApply(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >作业证审批</el-button>
          <el-button
            v-if="scope.row.operator=='check'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="certificateCheck(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >事前检查</el-button>
          <el-button
            v-if="scope.row.operator=='working'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="certificateWorking(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >作业中</el-button>
          <el-button
            v-if="scope.row.operator=='close'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="closeCertificate(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >关闭作业单</el-button>
          <el-button
            v-if="scope.row.applyStatus=='7'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="dangerousAppraise(scope.row)"
            v-hasPermi="['system:permit:edit']"
          >风险评价</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改作业许可证对话框 -->
    <el-dialog :title="title" :rules="rules" :visible.sync="open" width="880px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="申请部门" prop="applyDept">
              <el-input v-model="form.applyDept" placeholder="请输入申请部门" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人" prop="linkMan">
              <el-input v-model="form.linkMan" disabled placeholder="请输入申请人" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="联系电话" prop="linkPhone">
              <el-input v-model="form.linkPhone" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工作范围" prop="workBound">
              <el-input v-model="form.workBound" placeholder="请输入工作范围" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备名称" prop="deviceName">
              <el-input v-model="form.deviceName" placeholder="请输入设备名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备编号" prop="deviceNum">
              <el-input v-model="form.deviceNum" placeholder="请输入设备编号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始时间" prop="applyWorkStartTime">
              <el-date-picker clearable size="small"
                              v-model="form.applyWorkStartTime"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择开始时间"
                              style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结束时间" prop="applyWorkEndTime">
              <el-date-picker clearable size="small"
                              v-model="form.applyWorkEndTime"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择结束时间"
                              style="width: 100%">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="工作内容" prop="workContent">
              <el-input v-model="form.workContent" type="textarea"  placeholder="请输入工作内容" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="承包商" prop="contractor">
              <el-select v-model="form.contractor" placeholder="请选择承包商" clearable size="small" style="width: 100%">
                <el-option
                  v-for="dict in allContractorInfo"
                  :key="dict.id"
                  :label="dict.contractorName"
                  :value="dict.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="批准人" prop="ratifier">
              <el-select v-model="form.ratifier" placeholder="请选择批准人" clearable size="small" style="width: 100%">
                <el-option
                  v-for="dict in approvalList"
                  :key="dict.userId"
                  :label="dict.userName"
                  :value="dict.userId"
                />
              </el-select>

            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <WorkPermit
      :permitOpen.sync = "permitOpen"
      :workPermitTitle = "workPermitTitle"
      :certificateData="certificateData"
      @getList = "getList"
    />

    <!-- 作业许可证申请 审核 -->
    <el-dialog :title="approvalTitle" :visible.sync="certificateApprovalApplyOpen" append-to-body :close-on-click-modal="false" :before-close="cancelCertificateApply">
      <div class="tags_box">
        <div v-for="item in tags" class="tags">
          <div :class="{isActive:item.name==active}" @click="handelToogel(item.name)">{{item.name}}</div>
        </div>
      </div>
      <div class="con_box">
        <div v-for="item in tags" v-if="active == item.name">
          <BlindPlate v-if="item.mark == 'blindPlate'"
                       :applyStatus="item.status"
                       :post="item.post"
                       @suggestion="suggestion"
                       :blindPlate = "item.data.specialWorkData"/>
          <BreakGround v-if="item.mark == 'breakGround'"
                       :applyStatus="item.status"
                       :post="item.post"
                       @suggestion="suggestion"
                       :breakGround = "item.data.specialWorkData" />
          <ElectricityUse v-if="item.mark == 'electricityUse'"
                       :applyStatus="item.status"
                       :post="item.post"
                       @suggestion="suggestion"
                       :electricityUse="item.data.specialWorkData"/>
          <FlareUp v-if="item.mark == 'flareUp'"
                       :applyStatus="item.status"
                       :post="item.post"
                       @suggestion="suggestion"
                       :flareUp="item.data.specialWorkData"/>
          <HeightWork v-if="item.mark == 'heightWork'"
                       :applyStatus="item.status"
                       :post="item.post"
                       @suggestion="suggestion"
                       :heightWork="item.data.specialWorkData"/>
          <HoistingWork v-if="item.mark == 'hoisting'"
                       :applyStatus="item.status"
                       :post="item.post"
                       @suggestion="suggestion"
                       :hoisting="item.data.specialWorkData"/>
          <LimitSpace v-if="item.mark == 'limitSpace'"
                       :applyStatus="item.status"
                       :post="item.post"
                       @suggestion="suggestion"
                       :limitSpace="item.data.specialWorkData"/>
          <Ray v-if="item.mark == 'ray'"
                       :applyStatus="item.status"
                       :ray="ray"/>
        </div>
      </div>
      <div style="text-align: right;margin-top: 10px" v-if="applyStatus == '2'">
        <el-button type="primary" @click="submitCertificateApply">确定</el-button>
        <el-button @click="cancelCertificateApply">取消</el-button>
      </div>
    </el-dialog>

    <!-- 风险评价 -->
    <el-dialog title="风险评价" :visible.sync="dangerousAppraiseOpen" append-to-body :close-on-click-modal="false" :before-close="cancleDangerousAppraise">
      <editor v-model="dangerousAppraiseForm.workContent" :min-height="300"/>
      <div style="text-align: right;margin-top: 20px">
        <el-button type="primary" @click="submitDangerousAppraise">确定</el-button>
        <el-button @click="cancleDangerousAppraise">取消</el-button>
      </div>
    </el-dialog>
    <!-- 详情 -->
    <WorkPermitDetail
      :permitDetailOpen.sync = "permitDetailOpen"
      :certificateData="certificateData"
    />
  </div>
</template>

<script>
  import { listPermit, getPermit, delPermit, addPermit, updatePermit, exportPermit } from "@/api/workPermit/permit";
  import { addBatchSpecialPermit, getSpecialWorkPermitByWorkPermitId,updateSpecialWorkStatus } from "@/api/workPermit/specialPermit";
  import Editor from '@/components/Editor';
  import BlindPlate from '@/components/SaftyWork/BlindPlate';
  import BreakGround from '@/components/SaftyWork/BreakGround';
  import ElectricityUse from '@/components/SaftyWork/ElectricityUse';
  import FlareUp from '@/components/SaftyWork/FlareUp';
  import HeightWork from '@/components/SaftyWork/HeightWork';
  import HoistingWork from '@/components/SaftyWork/HoistingWork';
  import LimitSpace from '@/components/SaftyWork/LimitSpace';
  import Ray from '@/components/SaftyWork/Ray';
  import WorkPermit from '@/components/DangerousMark/WorkPermit';
  import WorkPermitDetail from '@/components/DangerousMark/WorkPermitDetail';
  import { listAll } from "@/api/contractor/contractorInfo";
  import { getAllUserName } from "@/api/system/user";
  export default {
    name: "Permit",
    components: {
      Editor,
      BlindPlate,
      BreakGround,
      ElectricityUse,
      FlareUp,
      HeightWork,
      LimitSpace,
      HoistingWork,
      Ray,
      WorkPermit,
      WorkPermitDetail
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 作业许可证表格数据
        permitList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          applyDept: null,
          linkMan: null,
          linkPhone: null,
          workBound: null,
          deviceName: null,
          deviceNum: null,
          applyWorkStartTime: null,
          applyWorkEndTime: null,
          workContent: null,
          contractor: null,
          ratifier: null,
          mainDangerousMark: null,
          dangerousMarkDetial: null,
          licenceInfo: null,
          relationSign: null,
          produceComfirm: null,
          workDeal: null,
          applyStatus: null,
          remarks: null
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          applyDept: [
            { required: true, message: "申请人不能为空", trigger: "blur" }
          ],
          linkPhone: [
            { required: true, message: "联系电话不能为空", trigger: "blur" }
          ],
          workBound: [
            { required: true, message: "工作范围不能为空", trigger: "blur" }
          ],
          deviceName: [
            { required: true, message: "设备名称不能为空", trigger: "blur" }
          ],
          deviceNum: [
            { required: true, message: "设备编号不能为空", trigger: "blur" }
          ],
          applyWorkStartTime: [
            { required: true, message: "开始时间不能为空", trigger: "blur" }
          ],
          applyWorkEndTime: [
            { required: true, message: "结束时间不能为空", trigger: "blur" }
          ],
          workContent: [
            { required: true, message: "工作内容不能为空", trigger: "blur" }
          ],
          contractor: [
            { required: true, message: "请选择承包商", trigger: "change" }
          ],
          ratifier: [
            { required: true, message: "请选择审批人", trigger: "change" }
          ],
        },
        //安全分析
        permitOpen:false,
        //安全措施
        dangerousFlag:false,
        //作业许可证申请
        certificateApprovalApplyOpen: false,
        tags:[],
        active:"",
        certificateData:{},
        approvalTitle:"",
        //作业许可证状态
        applyStatus:"",
        //盲板
        blindPlate:{
          applyUnit:"",
          proposer:"",
          licenceNum:"",
          pipeName:"",
          medium:"",
          temperature:"",
          pressure:"",
          material:"",
          specifications:"",
          quantity:"",
          num:"",
          workContent:"",
          otherLicenceNum:"",
          workStartTime:"",
          workEndTime:"",
          workLeader:"",
          guarder:"",
          worker:"",
          block:false,
          draw:false,
          blindDefect:false,
          blindDefectDetail:"",
          harmful:false,
          harmfulDetail:"",
          fireSoruce:false,
          fireSourceDetail:"",
          other:false,
          otherDetail:"",
          atmosphericPressure:{
            isChecked:false,
            comfire:""
          },
          protectiveTools:{
            isChecked:false,
            comfire:""
          },
          nonSparkingTools:{
            isChecked:false,
            comfire:""
          },
          thirtyMeter:{
            isChecked:false,
            comfire:""
          },
          corrosionProtection:{
            isChecked:false,
            comfire:""
          },
          antiScalding:{
            isChecked:false,
            comfire:""
          },
          thanTwo:{
            isChecked:false,
            comfire:""
          },
          otherSafetyMeasures:"",
          educator:"",
          auditing:{
            deptLeader:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            professionalMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            safeDept:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            factory:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            produce:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            complete:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            }
          }
        },
        //动火
        flareUp:{
          applyUnit:"",
          proposer:"",
          licenceNum:"",
          flareUpSpecialType:false,
          flareUpFirstType:false,
          flareUpSecondType:false,
          otherLicenceNum:"",
          flareUpLocation:"",
          flareUpWorkContent:"",
          flareUpByWeld:false,
          flareUpByPolish:false,
          flareUpByCut:false,
          flareUpBySandBlast:false,
          flareUpByOther:false,
          flareUpByOtherDetail:"",
          flareUpStartTime:"",
          flareUpEndTime:"",
          leader:"",
          guardian:"",
          flareUpPerson:"",
          flareUpWorkNum:"",
          firstFlareUpAnalyse:{
            date:"",
            location:"",
            analyseData:"",
            person:""
          },
          secondFlareUpAnalyse:{
            date:"",
            location:"",
            analyseData:"",
            person:""
          },
          thirdFlareUpAnalyse:{
            date:"",
            location:"",
            analyseData:"",
            person:""
          },
          fourthFlareUpAnalyse:{
            date:"",
            location:"",
            analyseData:"",
            person:""
          },
          fifthFlareUpAnalyse:{
            date:"",
            location:"",
            analyseData:"",
            person:""
          },
          sixthFlareUpAnalyse:{
            date:"",
            location:"",
            analyseData:"",
            person:""
          },
          seventhFlareUpAnalyse:{
            date:"",
            location:"",
            analyseData:"",
            person:""
          },
          combustible:false,
          combustibleDetail:"",
          combustibleGas:false,
          combustibleGasDetail:"",
          reactant:false,
          reactantDetail:"",
          oxidant:false,
          oxidantDetail:"",
          fireSource:false,
          fireSourceDetail:"",
          dangerous:false,
          dangerousDetail:"",
          other:false,
          otherDetail:"",
          condition:{
            isChecked:false,
            comfire:""
          },
          blindPlate:{
            block:"",
            isChecked:false,
            comfire:""
          },
          isolated:{
            isChecked:false,
            comfire:""
          },
          dehydration:{
            isChecked:false,
            comfire:""
          },
          remove:{
            isChecked:false,
            comfire:""
          },
          height:{
            isChecked:false,
            comfire:""
          },
          gasCylinder:{
            isChecked:false,
            comfire:""
          },
          elestic:{
            isChecked:false,
            comfire:""
          },
          device:{
            root:"",
            platform:"",
            grasp:"",
            block:"",
            isChecked:false,
            comfire:""
          },
          otherSafetyMeasures:"",
          educator:"",
          auditing:{
            apply:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            major:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            safeDept:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            factory:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            produce:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            complete:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            }
          }
        },
        //高空作业
        heightWork:{
          applyUnit:"",
          proposer:"",
          licenceNum:"",
          heightFirstType:false,
          heightSecondType:false,
          heighttThirdType:false,
          heightSuperType:false,
          otherLicenceNum:"",
          heightLocation:"",
          height:"",
          workDescribe:"",
          workStartTime:"",
          workEndTime:"",
          workLeader:"",
          guarder:"",
          worker:"",
          scaffolding:false,
          scaffoldingDetail:false,
          ladder:false,
          ladderDetail:"",
          guardrail:false,
          guardrailDetail:"",
          crossWork:false,
          crossDetail:"",
          ladderTruck:false,
          ladderTruckDetail:"",
          danger:false,
          dangerDetail:"",
          other:false,
          otherDetail:"",
          bodyCondition:{
            isChecked:false,
            comfire:""
          },
          ppe:{
            isChecked:false,
            comfire:""
          },
          elestic:{
            isChecked:false,
            comfire:""
          },
          safetyBelt:{
            isChecked:false,
            comfire:""
          },
          safetyRope:{
            isChecked:false,
            comfire:""
          },
          birth:{
            isChecked:false,
            comfir:""
          },
          regulations:{
            isChecked:false,
            comfir:""
          },
          vertical:{
            isChecked:false,
            comfir:""
          },
          ladderAndRope:{
            isChecked:false,
            comfir:""
          },
          weight:{
            isChecked:false,
            comfir:""
          },
          stage:{
            isChecked:false,
            comfir:""
          },
          light:{
            isChecked:false,
            comfir:""
          },
          tools:{
            isChecked:false,
            comfir:""
          },
          otherSafetyMeasures:"",
          educator:"",
          auditing:{
            factoryMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            safeDept:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            factory:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            produce:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            complete:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            }
          }
        },
        //动土
        breakGround:{
          applyUnit:"",
          proposer:"",
          licenceNum:"",
          breakGroundlocation:"",
          breakGroundDevice:"",
          driverNum:"",
          breakGroundContent:"",
          startTime:"",
          endTime:"",
          workUnit:"",
          workLeader:"",
          guardian:"",
          isSplit:false,
          notSplit:false,
          otherLicenceNum:"",
          underLine:false,
          underLineDetail:"",
          push:false,
          pushDetail:"",
          collapse:false,
          collapseDetail:"",
          seepage:false,
          seepageDetail:"",
          poisonous:false,
          poisonousDetail:"",
          export:false,
          exportDetail:"",
          fail:false,
          failDetail:"",
          other:false,
          otherDetail:"",
          education:{
            isChecked:false,
            comfire:""
          },
          elestic:{
            isChecked:false,
            comfir:""
          },
          protect:{
            isChecked:false,
            comfir:""
          },
          tools:{
            isChecked:false,
            comfir:""
          },
          finshWork:{
            isChecked:false,
            comfir:""
          },
          road:{
            isChecked:false,
            comfir:""
          },
          fire:{
            isChecked:false,
            comfir:""
          },
          breakGroundRange:{
            isChecked:false,
            comfir:""
          },
          safeDistance:{
            isChecked:false,
            comfir:""
          },
          digging:{
            isChecked:false,
            comfir:""
          },
          drainage:{
            isChecked:false,
            comfir:""
          },
          exportMeasure:{
            choice:"",
            comfir:""
          },
          noPerson:{
            isChecked:false,
            comfir:""
          },
          protective:{
            isChecked:false,
            comfir:""
          },
          safeMeasure:{
            choice:"",
            comfir:""
          },
          warnLight:{
            isChecked:false,
            comfir:""
          },
          light:{
            choice:"",
            comfir:""
          },
          enclosure:{
            isChecked:false,
            comfir:""
          },
          air:{
            isChecked:false,
            comfir:""
          },
          otherSafetyMeasures:"",
          educator:"",
          auditing:{
            leader:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            professionalMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            safeDept:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            factoryMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            produce:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            complete:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            }
          }
        },
        //临时用电
        electricityUse:{
          applyUnit:"",
          proposer:"",
          licenceNum:"",
          otherLicenceNum:"",
          electricityUseLocation:"",
          power:"",
          device:"",
          voltage:"",
          content:"",
          startTime:"",
          endTime:"",
          leader:"",
          guardian:"",
          worker:"",
          elesticNum:"",
          electricalLoad:false,
          electricalLoadDetail:"",
          insulation:false,
          insulationDetail:"",
          shortCircuit:false,
          shortCircuitDetail:"",
          damage:false,
          damageDetail:"",
          socket:false,
          socketDetail:"",
          phaseLine:false,
          phaseLineDetail:"",
          operator:{
            isChecked:false,
            comfir:""
          },
          level:{
            isChecked:false,
            comfir:""
          },
          fivePhase:{
            isChecked:false,
            comfir:""
          },
          low:{
            isChecked:false,
            comfir:""
          },
          overhead:{
            isChecked:false,
            comfir:""
          },
          deep:{
            isChecked:false,
            comfir:""
          },
          rain:{
            isChecked:false,
            comfir:""
          },
          protect:{
            isChecked:false,
            comfir:""
          },
          capacity:{
            isChecked:false,
            comfir:""
          },
          otherSafetyMeasures:"",
          educator:"",
          auditing:{
            professionalMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            electicMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            produce:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            factory:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            complete:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            }
          }
        },
        //吊装
        hoisting:{
          applyUnit:"",
          proposer:"",
          licenceNum:"",
          firstWorkType:false,
          secondWorkType:false,
          thirdWorkType:false,
          otherLicenceNum:"",
          hoistingLocation:"",
          hoistingWight:"",
          hoistingToolsName:"",
          personNum:"",
          commondNum:"",
          content:"",
          startTime:"",
          endTime:"",
          leader:"",
          guardian:"",
          worker:"",
          qualifications:false,
          qualificationsDetail:"",
          brace:false,
          braceDetail:"",
          load:false,
          loadDetail:"",
          hoistingStatus:false,
          hoistingStausDetail:"",
          hoistingSafeDistance:false,
          hoistingSafeDistanceDetail:"",
          importantDevice:false,
          importantDeviceDetail:"",
          other:false,
          otherDetail:"",
          quality:{
            isChecked:false,
            comfir:""
          },
          post:{
            isChecked:false,
            comfir:""
          },
          protect:{
            isChecked:false,
            comfir:""
          },
          signal:{
            isChecked:false,
            comfir:""
          },
          warnMark:{
            isChecked:false,
            comfir:""
          },
          weather:{
            isChecked:false,
            comfir:""
          },
          check:{
            isChecked:false,
            comfir:""
          },
          command:{
            isChecked:false,
            comfir:""
          },
          approval:{
            isChecked:false,
            comfir:""
          },
          safeDistance:{
            isChecked:false,
            comfir:""
          },
          measure:{
            isChecked:false,
            comfir:""
          },
          pipe:{
            isChecked:false,
            comfir:""
          },
          underHosting:{
            isChecked:false,
            comfir:""
          },
          overLoad:{
            isChecked:false,
            comfir:""
          },
          rope:{
            isChecked:false,
            comfir:""
          },
          corners:{
            isChecked:false,
            comfir:""
          },
          loseMeasure:{
            isChecked:false,
            comfir:""
          },
          standerOperator:{
            isChecked:false,
            comfir:""
          },
          process:{
            isChecked:false,
            comfir:""
          },
          leak:{
            isChecked:false,
            comfir:""
          },
          clean:{
            isChecked:false,
            comfir:""
          },
          licence:{
            isChecked:false,
            comfir:""
          },
          underElestic:{
            isChecked:false,
            comfir:""
          },
          hoistingRange:{
            weight:"",
            isChecked:false,
            comfir:""
          },
          hoistingHeight:{
            isChecked:false,
            comfir:""
          },
          warnSetting:{
            isChecked:false,
            comfir:""
          },
          swivelArm:{
            isChecked:false,
            comfir:""
          },
          export:{
            choice:"",
            comfir:""
          },
          flameout:{
            isChecked:false,
            comfir:""
          },
          light:{
            choice:"",
            comfir:""
          },
          otherSafetyMeasures:"",
          educator:"",
          auditing:{
            factoryMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            professionalMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            safeDept:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            major:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            produce:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            complete:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            }
          }
        },
        //受限空间
        limitSpace:{
          applyUnit:"",
          proposer:"",
          licenceNum:"",
          beyongSpace:"",
          spaceName:"",
          spaceLevel:"",
          workContent:"",
          medium:"",
          otherLicenceNum:"",
          startTime:"",
          endTime:"",
          leader:"",
          guardian:"",
          worker:"",
          firstSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          secondSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          thirdSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          fourthSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          fifthSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          sixthSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          seventhSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          eighthSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          ninethSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          tenthSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          elevenSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          twelfthSpaceAnalyse:{
            date:"",
            name:"",
            analyseData:"",
            person:""
          },
          poisonous:false,
          poisonousDetail:"",
          combustible:false,
          combustibleDetail:"",
          oxygen:"",
          oxygenDetail:"",
          hit:false,
          hitDetail:"",
          elestic:false,
          elesticDetail:"",
          drop:false,
          dropDetail:"",
          foreignMatter:false,
          foreignMatterDetail:"",
          danger:false,
          dangerDetail:"",
          other:false,
          otherDetail:"",
          dangerousAnalyse:{
            isChecked:false,
            comfir:""
          },
          blindPlate:{
            isChecked:false,
            comfir:""
          },
          deviceDeal:{
            isChecked:false,
            comfir:""
          },
          air:{
            isChecked:false,
            comfir:""
          },
          cutPower:{
            isChecked:false,
            comfir:""
          },
          proof:{
            isChecked:false,
            comfir:""
          },
          obstacle:{
            isChecked:false,
            comfir:""
          },
          contents:{
            isChecked:false,
            comfir:""
          },
          otherDangerous:{
            isChecked:false,
            comfir:""
          },
          guardianMeasure:{
            fire:"",
            gas:"",
            oxygen:"",
            isChecked:false,
            comfir:""
          },
          otherSafetyMeasures:"",
          educator:"",
          auditing:{
            professionalMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            safeDept:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            factoryMajor:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            produce:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            },
            complete:{
              opinion:"",
              // 0待审核 1审核通过 2驳回
              status:"0",
              sign:"",
              date:""
            }
          }
        },
        //射线
        ray:{
          workRange:"",
          workLocation:"",
          licenceNum:"",
          rayX:false,
          rayY:false,
          otherRay:false,
          range:"",
          otherLicenceNum:"",
          applyPerson:"",
          applyDept:"",
          leader:"",
          guardian:"",
          worker:"",
          startTime:"",
          endTime:"",
          dangerMark:"",
          qualifications:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          protect:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          warn:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          guard:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          light:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          safeLine:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          clean:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          vigilance:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          plane:{
            yes:false,
            no:false,
            noSuit:false,
            remark:""
          },
          otherSafetyMeasures:"",
          otherSafetyMeasuresRemark:"",
          apply:{
            sign:"",
            date:""
          },
          influence:{
            firstSign:"",
            firstDate:"",
            secondSign:"",
            secondDate:"",
            thirdSign:"",
            thirdDate:"",
            fourthSign:"",
            fourthDate:"",
            fifthSign:"",
            fifthDate:""
          },
          jointlySign:{
            firstSign:"",
            firstDate:"",
            secondSign:"",
            secondDate:"",
            thirdSign:"",
            thirdDate:"",
            fourthSign:"",
            fourthDate:"",
            fifthSign:"",
            fifthDate:""
          },
          approved:{
            sign:"",
            date:""
          },
          finish:{
            person:"",
            date:""
          },
          close:{
            person:"",
            date:""
          }
        },
        //特殊作业单
        specialWorkList:[],
        //承包商信息
        allContractorInfo:[],
        approvalList:[],
        workPermitTitle:"",
        dangerousAppraiseOpen:false,
        dangerousAppraiseForm:{},
        permitDetailOpen:false,
        certificateStatus:[]
      };
    },
    created() {
      this.getList();
      this.getAllContractorInfo();
      this.getApproval();
      this.getDicts("certificateStatus").then(response => {
          this.certificateStatus = response.data;
      });

    },
    methods: {
      /** 查询作业许可证列表 */
      getList() {
        this.loading = true;
        listPermit(this.queryParams).then(response => {
          this.permitList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          workPermitId: null,
          applyDept: null,
          linkMan: null,
          linkPhone: null,
          workBound: null,
          deviceName: null,
          deviceNum: null,
          applyWorkStartTime: null,
          applyWorkEndTime: null,
          workContent: null,
          contractor: null,
          ratifier: null,
          mainDangerousMark: null,
          dangerousMarkDetial: null,
          licenceInfo: null,
          relationSign: null,
          produceComfirm: null,
          workDeal: null,
          applyStatus: "0",
          createTime: null,
          updateTime: null,
          remarks: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.workPermitId)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加作业许可证";
        this.form.linkMan = this.$store.state.user.name;
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const workPermitId = row.workPermitId || this.ids
        getPermit(workPermitId).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改作业许可证";
         });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.workPermitId != null) {
              updatePermit(this.form).then(response => {
                this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
            } else {
              this.form.linkMan = this.$store.state.user.userId;
              addPermit(this.form).then(response => {
                this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const workPermitIds = row.workPermitId || this.ids;
        this.$confirm('是否确认删除作业许可证编号为"' + workPermitIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delPermit(workPermitIds);
        }).then(() => {
          this.getList();
        this.msgSuccess("删除成功");
      }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有作业许可证数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
        return exportPermit(queryParams);
      }).then(response => {
          this.download(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
      },
      //安全分析
      safeAnalyse(row){
        this.permitOpen=true;
        this.workPermitTitle = "安全分析";
        const workPermitId = row.workPermitId;
        getPermit(workPermitId).then(response => {
          this.certificateData = response.data;
          this.certificateData.linkMan = this.applyNameFormate(response.data);
        })
      },
      certificateApproval(row){
        this.permitOpen=true;
        this.workPermitTitle = "作业证审批";
        const workPermitId = row.workPermitId;
        getPermit(workPermitId).then(response => {
            this.certificateData = response.data;
            this.certificateData.linkMan = this.applyNameFormate(response.data);
        })
      },
      //关闭许可证
      cancelCertificateApply(){
        this.resetLinseceData();
        this.certificateApprovalApplyOpen = false;
      },
      //提交作业申请单
      submitCertificateApply(){
        const param = {};
        param.tWorkPermit = {workPermitId:this.tags[0].data.workPermitId,applyStatus:"3"};
        param.specialWorkPermits=[];
        for(var i = 0;i < this.tags.length;i++){
          var data = JSON.parse(JSON.stringify(this.tags[i].data));
          data.licenceNum = data.specialWorkData.licenceNum;
          data.specialWorkData = JSON.stringify(data.specialWorkData);
          param.specialWorkPermits.push(data);
        }
        addBatchSpecialPermit(param).then(res =>{
          this.msgSuccess("作业单申请成功！");
          this.certificateApprovalApplyOpen = false;
          this.getList();
        })
      },
      certificateApprovalApply(row){
        const workPermitId = row.workPermitId;
        getSpecialWorkPermitByWorkPermitId({workPermitId:workPermitId}).then(res =>{
          if(res.code == 200){
            this.certificate = JSON.parse(res.data.tWorkPermit.licenceInfo);
            this.applyStatus = res.data.tWorkPermit.applyStatus;
            if(this.applyStatus == '2'){
              this.approvalTitle = "作业许可证申请";
            }
            if(this.applyStatus == '3'){
              this.approvalTitle = "作业许可证审核";
            }
            //作业许可单
            var specialWorkPermits = res.data.specialWorkPermits;
            this.tags = [];
            for(var key in this.certificate){
              if(specialWorkPermits.length > 0){
                this.specialWorkList = JSON.parse(JSON.stringify(specialWorkPermits));
                specialWorkPermits.forEach(specialWorkPermit =>{
                  if(key !="jsa" && key != "specialLicence" && key != "lockListing"){
                    if(this.certificate[key].isChecked){
                      if(key == specialWorkPermit.specialWorkType){
                        var specialWorkData = JSON.parse(specialWorkPermit.specialWorkData);
                        var status = "";
                        if("0" == this.certificate[key].status){
                          status = "待审核";
                        }
                        if("1" == this.certificate[key].status){
                          status = "审核通过";
                        }
                        if("2" == this.certificate[key].status){
                          specialWorkData.auditing = this.$data[key].auditing;
                          status = "驳回"
                        }
                        this.tags.push({name:this.getTagName(key)+"("+ status +")",mark:key,post:res.data.postIds,status:this.certificate[key].status,data:{specialWorkPermitId:specialWorkPermit.specialWorkPermitId,workPermitId:workPermitId,specialWorkType:key,specialWorkData:specialWorkData}});
                      }
                    }
                  }
                })
              }else{
                if(key !="jsa" && key != "specialLicence" && key != "lockListing"){
                  if(this.certificate[key].isChecked){
                    this.tags.push({name:this.getTagName(key),mark:key,post:res.data.postIds,status:this.certificate[key].status,data:{workPermitId:workPermitId,specialWorkType:key,specialWorkData:this.combineData(key,this.certificate[key].num)}});
                  }
                }
              }
            }
            this.active = this.tags[0].name;
            this.certificateApprovalApplyOpen = true;
          }
        })
      },
      //作业前检查
      certificateCheck(row){
        this.permitOpen=true;
        this.workPermitTitle = "事前检查";
        const workPermitId = row.workPermitId;
        getPermit(workPermitId).then(response => {
            this.certificateData = response.data;
            this.certificateData.linkMan = this.applyNameFormate(response.data);
        })
      },
      //作业中
      certificateWorking(row){
        this.permitOpen=true;
        this.workPermitTitle = "作业中";
        const workPermitId = row.workPermitId;
        getPermit(workPermitId).then(response => {
            this.certificateData = response.data;
            this.certificateData.linkMan = this.applyNameFormate(response.data);
        })
      },
      //关闭作业单
      closeCertificate(row){
        this.permitOpen=true;
        this.workPermitTitle = "关闭作业单";
        const workPermitId = row.workPermitId;
        getPermit(workPermitId).then(response => {
            this.certificateData = response.data;
            this.certificateData.linkMan = this.applyNameFormate(response.data);
        })
      },
      //详情
      certificateDetail(row){
        this.permitDetailOpen = true;
        const workPermitId = row.workPermitId;
        getPermit(workPermitId).then(response => {
            this.certificateData = response.data;
            this.certificateData.linkMan = this.applyNameFormate(response.data);
        })
      },
      //获取tag名称
      getTagName(key){
        switch(key){
          case "blindPlate":
            return "盲板抽堵作业许可";
          case "flareUp":
            return "动火作业许可证";
          case "heightWork":
            return "高处作业许可证";
          case "breakGround":
            return "动土作业许可证";
          case "hoisting":
            return "吊装作业许可证";
          case "limitSpace":
            return "受限空间作业许可证";
          case "electricityUse":
            return "临时用电许可证";
          case "ray":
            return "射线探伤许可证";
          default:
            return "";
        }
      },
      //组装作业单数据
      combineData(key,num){
        switch(key){
          case "blindPlate":
            if(num){
              this.blindPlate.licenceNum = num;
            }
            return this.blindPlate;
          case "flareUp":
            if(num){
              this.flareUp.licenceNum = num;
            }
            return this.flareUp;
          case "heightWork":
            if(num){
              this.heightWork.licenceNum = num;
            }
            return this.heightWork;
          case "breakGround":
            if(num){
              this.breakGround.licenceNum = num;
            }
            return this.breakGround;
          case "hoisting":
            if(num){
              this.hoisting.licenceNum = num;
            }
            return this.hoisting;
          case "limitSpace":
            if(num){
              this.limitSpace.licenceNum = num;
            }
            return this.limitSpace;
          case "electricityUse":
            if(num){
              this.electricityUse.licenceNum = num;
            }
            return this.electricityUse;
          case "ray":
            if(num){
              this.ray.licenceNum = num;
            }
            return this.ray;
          default:
            return "";
        }
      },
      handelToogel(item) {
        this.active = item;
      },
      //重置作业单
      resetLinseceData(){
        this.blindPlate = {
          applyUnit:"",
            proposer:"",
            licenceNum:"",
            pipeName:"",
            medium:"",
            temperature:"",
            pressure:"",
            material:"",
            specifications:"",
            quantity:"",
            num:"",
            workContent:"",
            otherLicenceNum:"",
            workStartTime:"",
            workEndTime:"",
            workLeader:"",
            guarder:"",
            worker:"",
            block:false,
            draw:false,
            blindDefect:false,
            blindDefectDetail:"",
            harmful:false,
            harmfulDetail:"",
            fireSoruce:false,
            fireSourceDetail:"",
            other:false,
            otherDetail:"",
            atmosphericPressure:{
            isChecked:false,
              comfire:""
          },
          protectiveTools:{
            isChecked:false,
              comfire:""
          },
          nonSparkingTools:{
            isChecked:false,
              comfire:""
          },
          thirtyMeter:{
            isChecked:false,
              comfire:""
          },
          corrosionProtection:{
            isChecked:false,
              comfire:""
          },
          antiScalding:{
            isChecked:false,
              comfire:""
          },
          thanTwo:{
            isChecked:false,
              comfire:""
          },
          otherSafetyMeasures:"",
            educator:"",
            deptLeader:{
            opinion:"",
              sign:"",
              date:""
          },
          professionalMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          safeDept:{
            opinion:"",
              sign:"",
              date:""
          },
          factory:{
            opinion:"",
              sign:"",
              date:""
          },
          produce:{
            opinion:"",
              sign:"",
              date:""
          },
          complete:{
            opinion:"",
              sign:"",
              date:""
          }
        };
        //动火
        this.flareUp = {
          applyUnit:"",
            proposer:"",
            licenceNum:"",
            flareUpSpecialType:false,
            flareUpFirstType:false,
            flareUpSecondType:false,
            otherLicenceNum:"",
            flareUpLocation:"",
            flareUpWorkContent:"",
            flareUpByWeld:false,
            flareUpByPolish:false,
            flareUpByCut:false,
            flareUpBySandBlast:false,
            flareUpByOther:false,
            flareUpByOtherDetail:"",
            flareUpStartTime:"",
            flareUpEndTime:"",
            leader:"",
            guardian:"",
            flareUpPerson:"",
            flareUpWorkNum:"",
            firstFlareUpAnalyse:{
            date:"",
              location:"",
              analyseData:"",
              person:""
          },
          secondFlareUpAnalyse:{
            date:"",
              location:"",
              analyseData:"",
              person:""
          },
          thirdFlareUpAnalyse:{
            date:"",
              location:"",
              analyseData:"",
              person:""
          },
          fourthFlareUpAnalyse:{
            date:"",
              location:"",
              analyseData:"",
              person:""
          },
          fifthFlareUpAnalyse:{
            date:"",
              location:"",
              analyseData:"",
              person:""
          },
          sixthFlareUpAnalyse:{
            date:"",
              location:"",
              analyseData:"",
              person:""
          },
          seventhFlareUpAnalyse:{
            date:"",
              location:"",
              analyseData:"",
              person:""
          },
          combustible:false,
            combustibleDetail:"",
            combustibleGas:false,
            combustibleGasDetail:"",
            reactant:false,
            reactantDetail:"",
            oxidant:false,
            oxidantDetail:"",
            fireSource:false,
            fireSourceDetail:"",
            dangerous:false,
            dangerousDetail:"",
            other:false,
            otherDetail:"",
            condition:{
            isChecked:false,
              comfire:""
          },
          blindPlate:{
            block:"",
              isChecked:false,
              comfire:""
          },
          isolated:{
            isChecked:false,
              comfire:""
          },
          dehydration:{
            isChecked:false,
              comfire:""
          },
          remove:{
            isChecked:false,
              comfire:""
          },
          height:{
            isChecked:false,
              comfire:""
          },
          gasCylinder:{
            isChecked:false,
              comfire:""
          },
          elestic:{
            isChecked:false,
              comfire:""
          },
          device:{
            root:"",
              platform:"",
              grasp:"",
              block:"",
              isChecked:false,
              comfire:""
          },
          otherSafetyMeasures:"",
            educator:"",
            apply:{
            opinion:"",
              sign:"",
              date:""
          },
          major:{
            opinion:"",
              sign:"",
              date:""
          },
          safeDept:{
            opinion:"",
              sign:"",
              date:""
          },
          factory:{
            opinion:"",
              sign:"",
              date:""
          },
          produce:{
            opinion:"",
              sign:"",
              date:""
          },
          complete:{
            opinion:"",
              sign:"",
              date:""
          }
        };
        //高空作业
        this.heightWork = {
          applyUnit:"",
            proposer:"",
            licenceNum:"",
            heightFirstType:false,
            heightSecondType:false,
            heighttThirdType:false,
            heightSuperType:false,
            otherLicenceNum:"",
            heightLocation:"",
            height:"",
            workDescribe:"",
            workStartTime:"",
            workEndTime:"",
            workLeader:"",
            guarder:"",
            worker:"",
            scaffolding:false,
            scaffoldingDetail:false,
            ladder:false,
            ladderDetail:"",
            guardrail:false,
            guardrailDetail:"",
            crossWork:false,
            crossDetail:"",
            ladderTruck:false,
            ladderTruckDetail:"",
            danger:false,
            dangerDetail:"",
            other:false,
            otherDetail:"",
            bodyCondition:{
            isChecked:false,
              comfire:""
          },
          ppe:{
            isChecked:false,
              comfire:""
          },
          elestic:{
            isChecked:false,
              comfire:""
          },
          safetyBelt:{
            isChecked:false,
              comfire:""
          },
          safetyRope:{
            isChecked:false,
              comfire:""
          },
          birth:{
            isChecked:false,
              comfir:""
          },
          regulations:{
            isChecked:false,
              comfir:""
          },
          vertical:{
            isChecked:false,
              comfir:""
          },
          ladderAndRope:{
            isChecked:false,
              comfir:""
          },
          weight:{
            isChecked:false,
              comfir:""
          },
          stage:{
            isChecked:false,
              comfir:""
          },
          light:{
            isChecked:false,
              comfir:""
          },
          tools:{
            isChecked:false,
              comfir:""
          },
          otherSafetyMeasures:"",
            educator:"",
            factoryMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          safeDept:{
            opinion:"",
              sign:"",
              date:""
          },
          factory:{
            opinion:"",
              sign:"",
              date:""
          },
          produce:{
            opinion:"",
              sign:"",
              date:""
          },
          complete:{
            opinion:"",
              sign:"",
              date:""
          }
        };
        //动土
        this.breakGround = {
          applyUnit:"",
            proposer:"",
            licenceNum:"",
            breakGroundlocation:"",
            breakGroundDevice:"",
            driverNum:"",
            breakGroundContent:"",
            startTime:"",
            endTime:"",
            workUnit:"",
            workLeader:"",
            guardian:"",
            isSplit:false,
            notSplit:false,
            otherLicenceNum:"",
            underLine:false,
            underLineDetail:"",
            push:false,
            pushDetail:"",
            collapse:false,
            collapseDetail:"",
            seepage:false,
            seepageDetail:"",
            poisonous:false,
            poisonousDetail:"",
        export:false,
            exportDetail:"",
            fail:false,
            failDetail:"",
            other:false,
            otherDetail:"",
            education:{
            isChecked:false,
              comfire:""
          },
          elestic:{
            isChecked:false,
              comfir:""
          },
          protect:{
            isChecked:false,
              comfir:""
          },
          tools:{
            isChecked:false,
              comfir:""
          },
          finshWork:{
            isChecked:false,
              comfir:""
          },
          road:{
            isChecked:false,
              comfir:""
          },
          fire:{
            isChecked:false,
              comfir:""
          },
          breakGroundRange:{
            isChecked:false,
              comfir:""
          },
          safeDistance:{
            isChecked:false,
              comfir:""
          },
          digging:{
            isChecked:false,
              comfir:""
          },
          drainage:{
            isChecked:false,
              comfir:""
          },
          exportMeasure:{
            choice:"",
              comfir:""
          },
          noPerson:{
            isChecked:false,
              comfir:""
          },
          protective:{
            isChecked:false,
              comfir:""
          },
          safeMeasure:{
            choice:"",
              comfir:""
          },
          warnLight:{
            isChecked:false,
              comfir:""
          },
          light:{
            choice:"",
              comfir:""
          },
          enclosure:{
            isChecked:false,
              comfir:""
          },
          air:{
            isChecked:false,
              comfir:""
          },
          otherSafetyMeasures:"",
            educator:"",
            leader:{
            opinion:"",
              sign:"",
              date:""
          },
          professionalMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          safeDept:{
            opinion:"",
              sign:"",
              date:""
          },
          factoryMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          produce:{
            opinion:"",
              sign:"",
              date:""
          },
          complete:{
            opinion:"",
              sign:"",
              date:""
          }

        };
        //临时用电
        this.electricityUse = {
          applyUnit:"",
            proposer:"",
            licenceNum:"",
            otherLicenceNum:"",
            electricityUseLocation:"",
            power:"",
            device:"",
            voltage:"",
            content:"",
            startTime:"",
            endTime:"",
            leader:"",
            guardian:"",
            worker:"",
            elesticNum:"",
            electricalLoad:false,
            electricalLoadDetail:"",
            insulation:false,
            insulationDetail:"",
            shortCircuit:false,
            shortCircuitDetail:"",
            damage:false,
            damageDetail:"",
            socket:false,
            socketDetail:"",
            phaseLine:false,
            phaseLineDetail:"",
            operator:{
            isChecked:false,
              comfir:""
          },
          level:{
            isChecked:false,
              comfir:""
          },
          fivePhase:{
            isChecked:false,
              comfir:""
          },
          low:{
            isChecked:false,
              comfir:""
          },
          overhead:{
            isChecked:false,
              comfir:""
          },
          deep:{
            isChecked:false,
              comfir:""
          },
          rain:{
            isChecked:false,
              comfir:""
          },
          protect:{
            isChecked:false,
              comfir:""
          },
          capacity:{
            isChecked:false,
              comfir:""
          },
          otherSafetyMeasures:"",
            educator:"",
            professionalMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          electicMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          produce:{
            opinion:"",
              sign:"",
              date:""
          },
          factory:{
            opinion:"",
              sign:"",
              date:""
          },
          complete:{
            opinion:"",
              sign:"",
              date:""
          }
        };
        //吊装
        this.hoisting = {
          applyUnit:"",
            proposer:"",
            licenceNum:"",
            firstWorkType:false,
            secondWorkType:false,
            thirdWorkType:false,
            otherLicenceNum:"",
            hoistingLocation:"",
            hoistingWight:"",
            hoistingToolsName:"",
            personNum:"",
            commondNum:"",
            content:"",
            startTime:"",
            endTime:"",
            leader:"",
            guardian:"",
            worker:"",
            qualifications:false,
            qualificationsDetail:"",
            brace:false,
            braceDetail:"",
            load:false,
            loadDetail:"",
            hoistingStatus:false,
            hoistingStausDetail:"",
            hoistingSafeDistance:false,
            hoistingSafeDistanceDetail:"",
            importantDevice:false,
            importantDeviceDetail:"",
            other:false,
            otherDetail:"",
            quality:{
            isChecked:false,
              comfir:""
          },
          post:{
            isChecked:false,
              comfir:""
          },
          protect:{
            isChecked:false,
              comfir:""
          },
          signal:{
            isChecked:false,
              comfir:""
          },
          warnMark:{
            isChecked:false,
              comfir:""
          },
          weather:{
            isChecked:false,
              comfir:""
          },
          check:{
            isChecked:false,
              comfir:""
          },
          command:{
            isChecked:false,
              comfir:""
          },
          approval:{
            isChecked:false,
              comfir:""
          },
          safeDistance:{
            isChecked:false,
              comfir:""
          },
          measure:{
            isChecked:false,
              comfir:""
          },
          pipe:{
            isChecked:false,
              comfir:""
          },
          underHosting:{
            isChecked:false,
              comfir:""
          },
          overLoad:{
            isChecked:false,
              comfir:""
          },
          rope:{
            isChecked:false,
              comfir:""
          },
          corners:{
            isChecked:false,
              comfir:""
          },
          loseMeasure:{
            isChecked:false,
              comfir:""
          },
          standerOperator:{
            isChecked:false,
              comfir:""
          },
          process:{
            isChecked:false,
              comfir:""
          },
          leak:{
            isChecked:false,
              comfir:""
          },
          clean:{
            isChecked:false,
              comfir:""
          },
          licence:{
            isChecked:false,
              comfir:""
          },
          underElestic:{
            isChecked:false,
              comfir:""
          },
          hoistingRange:{
            weight:"",
              isChecked:false,
              comfir:""
          },
          hoistingHeight:{
            isChecked:false,
              comfir:""
          },
          warnSetting:{
            isChecked:false,
              comfir:""
          },
          swivelArm:{
            isChecked:false,
              comfir:""
          },
        export:{
            choice:"",
              comfir:""
          },
          flameout:{
            isChecked:false,
              comfir:""
          },
          light:{
            choice:"",
              comfir:""
          },
          otherSafetyMeasures:"",
            educator:"",
            factoryMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          professionalMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          safeDept:{
            opinion:"",
              sign:"",
              date:""
          },
          major:{
            opinion:"",
              sign:"",
              date:""
          },
          produce:{
            opinion:"",
              sign:"",
              date:""
          },
          complete:{
            opinion:"",
              sign:"",
              date:""
          }
        };
        //受限空间
        this.limitSpace = {
          applyUnit:"",
            proposer:"",
            licenceNum:"",
            beyongSpace:"",
            spaceName:"",
            spaceLevel:"",
            workContent:"",
            medium:"",
            otherLicenceNum:"",
            startTime:"",
            endTime:"",
            leader:"",
            guardian:"",
            worker:"",
            firstSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          secondSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          thirdSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          fourthSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          fifthSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          sixthSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          seventhSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          eighthSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          ninethSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          tenthSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          elevenSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          twelfthSpaceAnalyse:{
            date:"",
              name:"",
              analyseData:"",
              person:""
          },
          poisonous:false,
            poisonousDetail:"",
            combustible:false,
            combustibleDetail:"",
            oxygen:"",
            oxygenDetail:"",
            hit:false,
            hitDetail:"",
            elestic:false,
            elesticDetail:"",
            drop:false,
            dropDetail:"",
            foreignMatter:false,
            foreignMatterDetail:"",
            danger:false,
            dangerDetail:"",
            other:false,
            otherDetail:"",
            dangerousAnalyse:{
            isChecked:false,
              comfir:""
          },
          blindPlate:{
            isChecked:false,
              comfir:""
          },
          deviceDeal:{
            isChecked:false,
              comfir:""
          },
          air:{
            isChecked:false,
              comfir:""
          },
          cutPower:{
            isChecked:false,
              comfir:""
          },
          proof:{
            isChecked:false,
              comfir:""
          },
          obstacle:{
            isChecked:false,
              comfir:""
          },
          contents:{
            isChecked:false,
              comfir:""
          },
          otherDangerous:{
            isChecked:false,
              comfir:""
          },
          guardianMeasure:{
            fire:"",
              gas:"",
              oxygen:"",
              isChecked:false,
              comfir:""
          },
          otherSafetyMeasures:"",
            educator:"",
            professionalMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          safeDept:{
            opinion:"",
              sign:"",
              date:""
          },
          factoryMajor:{
            opinion:"",
              sign:"",
              date:""
          },
          produce:{
            opinion:"",
              sign:"",
              date:""
          },
          complete:{
            opinion:"",
              sign:"",
              date:""
          }
        };
        //射线
        this.ray = {
          workRange:"",
            workLocation:"",
            licenceNum:"",
            rayX:false,
            rayY:false,
            otherRay:false,
            range:"",
            otherLicenceNum:"",
            applyPerson:"",
            applyDept:"",
            leader:"",
            guardian:"",
            worker:"",
            startTime:"",
            endTime:"",
            dangerMark:"",
            qualifications:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          protect:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          warn:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          guard:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          light:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          safeLine:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          clean:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          vigilance:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          plane:{
            yes:false,
              no:false,
              noSuit:false,
              remark:""
          },
          otherSafetyMeasures:"",
            otherSafetyMeasuresRemark:"",
            apply:{
            sign:"",
              date:""
          },
          influence:{
            firstSign:"",
              firstDate:"",
              secondSign:"",
              secondDate:"",
              thirdSign:"",
              thirdDate:"",
              fourthSign:"",
              fourthDate:"",
              fifthSign:"",
              fifthDate:""
          },
          jointlySign:{
            firstSign:"",
              firstDate:"",
              secondSign:"",
              secondDate:"",
              thirdSign:"",
              thirdDate:"",
              fourthSign:"",
              fourthDate:"",
              fifthSign:"",
              fifthDate:""
          },
          approved:{
            sign:"",
              date:""
          },
          finish:{
            person:"",
              date:""
          },
          close:{
            person:"",
              date:""
          }
        };
      },
      //作业单意见
      suggestion(type,obj){
        this.specialWorkList.forEach(specialWork =>{
          if(type === specialWork.specialWorkType){
            updateSpecialWorkStatus({workPermitId:specialWork.workPermitId,specialWorkPermitId:specialWork.specialWorkPermitId,specialWorkType:specialWork.specialWorkType,specialWorkData:JSON.stringify(obj)}).then(res =>{
                if(res.code = 200){
                  this.msgSuccess("作业单审核成功！");
                  this.certificateApprovalApplyOpen = false;
                  this.getList();
                }
            })
          }
        })
      },
      //获取所有承包商
      getAllContractorInfo(){
        listAll().then(res =>{
          this.allContractorInfo = res.data;
        })
      },
      //获取审核人
      getApproval(){
        getAllUserName().then(res =>{
          this.approvalList = res.data;
        })
      },
      //风险评价
      dangerousAppraise(row){
        this.dangerousAppraiseOpen = true;
        this.dangerousAppraiseForm.workPermitId = row.workPermitId;
        this.dangerousAppraiseForm.applyStatus = "8";
      },
      cancleDangerousAppraise(){
        this.dangerousAppraiseOpen = false;
        this.dangerousAppraiseForm = {};
      },
      submitDangerousAppraise(){
        updatePermit(this.dangerousAppraiseForm).then(response => {
          this.msgSuccess("风险评价完成！");
          this.dangerousAppraiseOpen = false;
          this.getList();
        });
      },
      applyNameFormate(row){
        var user = this.approvalList.find(item => item.userId == row.linkMan);
        if(user && user.userName){
          return user.userName;
        }
        return "";
      },
      applyStatusFormate(row){
         var value = this.certificateStatus.find(item => item.dictValue == row.applyStatus);
         if(value && value.dictLabel){
           return value.dictLabel;
         }
         return "";
      }
    }
  };
</script>

<style scoped lang="scss">
  .num{
    border: none;
    text-align: center;
  }
  .num:focus{
    outline: none;
  }
  .tags_box {
    height: 10%;
    display: flex;
    .tags {
      div {
        padding: 10px 20px;
        cursor: pointer;
        border: #cccccc 1px solid;
        #margin-right: 20px;
        #border-radius: 5px;
      }
      .isActive {
        background-color: #409EFF;
        color: white;
      }
    }
  }

  .con_box {
    height: 500px;;
    border: #cccccc 1px solid;
    padding: 10px;
    overflow-y: scroll;
    overflow-x: hidden;
    &::-webkit-scrollbar {
      width:5px;
    }
    &::-webkit-scrollbar-track {
      -webkit-box-shadow:inset006pxrgba(0,0,0,0.3);
      border-radius:10px;
    }
    &::-webkit-scrollbar-thumb {
      border-radius:5px;
      background:rgba(0,0,0,0.1);
      -webkit-box-shadow:inset006pxrgba(0,0,0,0.5);
    }
  }
</style>
