<template>
  <div>
    <div style="float: right">
      作业票证编号：{{licenceNum}}
    </div>
    <table id="breakGroundPrint">
      <tr>
        <td>申请单位</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.applyUnit" class="editInput"/></td>
        <td colspan="2">作业申请时间</td>
        <td colspan="2" v-if="(applyStatus-0) == 0">
          <el-date-picker clearable size="small"
                          v-model="breakGround.applyTime"
                          type="datetime"
                          value-format="yyyy-MM-dd HH:mm:ss"
                          placeholder="选择作业申请时间"
                          style="width: 100%">
          </el-date-picker>
        </td>
        <td colspan="2" v-if="(applyStatus-0) > 0">
          {{ (breakGround.applyTime == null || breakGround.applyTime =='') ? "-" :breakGround.applyTime.split(" ")[0].split("-")[0]}}年{{ (breakGround.applyTime == null || breakGround.applyTime =='') ? "-" :breakGround.applyTime.split(" ")[0].split("-")[1]}}月{{(breakGround.applyTime == null || breakGround.applyTime =='') ? "-" :breakGround.applyTime.split(" ")[0].split("-")[2]}}日{{(breakGround.applyTime == null || breakGround.applyTime =='') ? "-" :breakGround.applyTime.split(" ")[1].split(":")[0]}}时{{(breakGround.applyTime == null || breakGround.applyTime =='') ? "-" :breakGround.applyTime.split(" ")[1].split(":")[1]}}分
        </td>
      </tr>
      <tr>
        <td>作业单位</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.workUnit" class="editInput"/></td>
        <td>作业地点</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.heightLocation" class="editInput"/></td>
        <td>作业内容</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.heightContent" class="editInput"/></td>
      </tr>
      <tr>
        <td>监护人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="breakGround.guarder" class="editInput"/></td>
        <td>作业负责人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="breakGround.workLeader" class="editInput"/></td>
      </tr>
      <tr>
        <td>关联的其他特殊作业及安全作业票编号</td>
        <td colspan="5"><input :disabled="(applyStatus-0) > 0" v-model="breakGround.otherLicenceNum" class="editInput"/></td>
      </tr>
      <tr>
        <td colspan="6">
          <div style="text-align: left">
            <span>作业范围、内容、方式（包括深度、面积、并附简图）：</span>
            <textarea :disabled="(applyStatus-0) > 0" v-model="breakGround.workContent" rows="3"></textarea>
            <div style="float: right">
              签字：<input :disabled="(applyStatus-0) > 0" v-model="breakGround.sign" class="editInput" style="width: 47%"/>
              <el-date-picker clearable size="small"
                              v-model="breakGround.signdate"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择签字日期"
                              style="width: 40%"
                              v-if="(applyStatus-0) == 0">
              </el-date-picker>
              <span v-if="(applyStatus-0) > 0">
              {{ (breakGround.signdate == null || breakGround.signdate =='') ? "-" :breakGround.signdate.split(" ")[0].split("-")[0]}}年{{ (breakGround.signdate == null || breakGround.signdate =='') ? "-" :breakGround.signdate.split(" ")[0].split("-")[1]}}月{{(breakGround.signdate == null || breakGround.signdate =='') ? "-" :breakGround.signdate.split(" ")[0].split("-")[2]}}日
            </span>
            </div>
          </div>
        </td>
      </tr>
      <tr>
        <td>风险辨识结果在下列画“√”</td>
        <td colspan="5" style="text-align: left">
          <el-row>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numOne" type="checkbox"/>1.物体打击
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numTwo" type="checkbox"/>2.车辆伤害
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numThree" type="checkbox"/>3.机械伤害
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numFour" type="checkbox"/>4.起重伤害
            </el-col>
            <el-col :span="4">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numFive" type="checkbox"/> 5.触电
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numSix" type="checkbox"/> 6.淹溺
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numSeven" type="checkbox"/> 7.灼烫
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numEight" type="checkbox"/> 8.火灾
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numNine" type="checkbox"/> 9.高处坠落
            </el-col>
            <el-col :span="4">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numTen" type="checkbox"/> 10.坍塌
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numEleven" type="checkbox"/> 11.锅炉爆炸
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numTwelve" type="checkbox"/> 12.容器爆炸
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numThirteen" type="checkbox"/> 13.中毒和窒息
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="breakGround.risk.numFourteen" type="checkbox"/> 14.其它伤害
            </el-col>
          </el-row>
        </td>
      </tr>
      <tr>
        <td>作业实施时间</td>
        <td colspan="5" v-if="(applyStatus-0) == 0">
          <el-row>
            <el-col :span="11">
              <el-date-picker clearable size="small"
                              v-model="breakGround.workStartTime"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择作业实施开始时间"
                              style="width: 100%">
              </el-date-picker>
            </el-col>
            <el-col :span="2" style="margin-top: 5px">
              至
            </el-col>
            <el-col :span="11">
              <el-date-picker clearable size="small"
                              v-model="breakGround.workEndTime"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择作业实施结束时间"
                              style="width: 100%">
              </el-date-picker>
            </el-col>
          </el-row>
        </td>
        <td colspan="5" v-if="(applyStatus-0) > 0">
          自{{ (breakGround.workStartTime == null || breakGround.workStartTime =='') ? "-" :breakGround.workStartTime.split(" ")[0].split("-")[0]}}年{{ (breakGround.workStartTime == null || breakGround.workStartTime =='') ? "-" :breakGround.workStartTime.split(" ")[0].split("-")[1]}}月{{(breakGround.workStartTime == null || breakGround.workStartTime =='') ? "-" :breakGround.workStartTime.split(" ")[0].split("-")[2]}}日{{(breakGround.workStartTime == null || breakGround.workStartTime =='') ? "-" :breakGround.workStartTime.split(" ")[1].split(":")[0]}}时{{(breakGround.workStartTime == null || breakGround.workStartTime =='') ? "-" :breakGround.workStartTime.split(" ")[1].split(":")[1]}}分至{{ (breakGround.workEndTime == null || breakGround.workEndTime =='') ? "-" :breakGround.workEndTime.split(" ")[0].split("-")[0]}}年{{(breakGround.workEndTime == null || breakGround.workEndTime =='') ? "-" :breakGround.workEndTime.split(" ")[0].split("-")[1]}}月{{(breakGround.workEndTime == null || breakGround.workEndTime =='') ? "-" :breakGround.workEndTime.split(" ")[0].split("-")[2]}}日{{(breakGround.workEndTime == null || breakGround.workEndTime =='') ? "-" :breakGround.workEndTime.split(" ")[1].split(":")[0]}}时{{(breakGround.workEndTime == null || breakGround.workEndTime =='') ? "-" :breakGround.workEndTime.split(" ")[1].split(":")[1]}}分
        </td>
      </tr>
      <tr>
        <td>序号</td>
        <td colspan="3">安全措施</td>
        <td>是否涉及</td>
        <td>确认人</td>
      </tr>
      <tr>
        <td>1</td>
        <td colspan="3">地下电力电缆、通信电(光)缆、局域网络电(光)缆已确认,保护措施已落实；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresOne" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresOnePeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>2</td>
        <td colspan="3">地下供排水、消防管线、工艺管线已确认，保护措施已落实；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresTwo" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresTwoPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="3">已按作业方案图划线和立桩；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresThree" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresThreePeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="3">作业现场围栏、警戒线、警告牌、夜间警示灯已按要求设置；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresFour" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresFourPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>5</td>
        <td colspan="3">已进行放坡处理和固壁支撑；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresFive" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresFivePeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>6</td>
        <td colspan="3">道路施工作业已报:交通、消防、安全监督部门、应急中心；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresSix" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresSixPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>7</td>
        <td colspan="3">现场夜间有充足照明:A.36 V.24 V.12 V防水型灯;B.36 V.24 V.12 V防爆型灯；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresSeven" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresSevenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>8</td>
        <td colspan="3">作业人员配备有必要的个人防护装备；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresEight" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresEightPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>9</td>
        <td colspan="3">易燃易爆、有毒气体存在的场所动土深度超过1.2 m,已按照受限空间作业要求采取了措施；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresNine" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresNineoPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>10</td>
        <td colspan="3">其他相关特殊作业已办理相应安全作业票；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresTen" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresTenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>11</td>
        <td colspan="3">
          <div>
            其他安全措施：<input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresElevenDetail" class="editInput" style="width: 77%"/>
          </div>
          <div style="float: right">
            编制人：
            <input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresElevenEdit" class="editInput" style="width: 40%"/>
          </div>
        </td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresEleven" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="breakGround.safetyMeasures.measuresElevenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>安全交底人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="breakGround.discloser" class="editInput"/></td>
        <td>接受交底人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="breakGround.recipient" class="editInput"/></td>
      </tr>
      <tr v-for="item in specialWorkPermitSigns" v-if="(applyStatus-0) > 0">
        <td v-if="item.staffType=='leader'">作业负责人意见</td>
        <td v-if="item.staffType=='workDept'">所在单位意见</td>
        <td v-if="item.staffType=='auditDept'">有关水、电、汽、工艺、设备、消防、安全等部门会签意见</td>
        <td v-if="item.staffType=='approval'">审批部门意见</td>
        <td v-if="item.staffType=='complete'">完工验收</td>
        <td colspan="2" v-if="(applyStatus-0) ==1"><input :disabled="item.staffId != $store.state.user.userId" v-model="item.opinion" class="editInput"/></td>
        <td colspan="2" v-if="(applyStatus-0) !=1"><input disabled v-model="item.opinion" class="editInput"/></td>
        <td>签字:</td>
        <td><NewEsign :resultImg.sync ="item.signName" :isDisabled="item.staffId != $store.state.user.userId" :isReWrite="(applyStatus-0) ==1" :width="918" :height="100"/></td>
        <td v-if="(applyStatus-0) ==1">
          <el-date-picker clearable size="small"
                          v-model="item.signDate"
                          type="datetime"
                          :disabled="item.staffId != $store.state.user.userId"
                          value-format="yyyy-MM-dd HH:mm:ss"
                          placeholder="选择时间"
                          style="width: 100%">
          </el-date-picker>
        </td>
        <td v-if="(applyStatus-0) !=1">
          {{ item.signDate == null ? "-" :item.signDate.split(" ")[0].split("-")[0]}}年{{ item.signDate == null ? "-" :item.signDate.split(" ")[0].split("-")[1]}}月{{item.signDate == null ? "-" :item.signDate.split(" ")[0].split("-")[2]}}日{{item.signDate == null ? "-" :item.signDate.split(" ")[1].split(":")[0]}}时{{item.signDate == null ? "-" :item.signDate.split(" ")[1].split(":")[1]}}分
        </td>
      </tr>
    </table>

    <div v-if="(applyStatus-0) == 0">
      <el-row style="margin-top: 10px">
        <el-col :span="4">
          <div style="font-size: 18px;margin-top: 5px">作业负责人：</div>
        </el-col>
        <el-col :span="8">
          <el-select v-model="leaderDeptId" filterable placeholder="请选择作业负责人部门" @change="switchDept(leaderDeptId,1)">
            <el-option
              v-for="item in deptList"
              :key="item.deptId"
              :label="item.deptName"
              :value="item.deptId"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="12">
          <el-select v-model="leaderAuditor" filterable placeholder="请选择审核人">
            <el-option
              v-for="item in leaderUserList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-col>
      </el-row>

      <el-row style="margin-top: 10px">
        <el-col :span="4">
          <div style="font-size: 18px;margin-top: 5px">所在单位：</div>
        </el-col>
        <el-col :span="8">
          <el-select v-model="workDeptId" filterable placeholder="请选择作业单位" @change="switchDept(workDeptId,2)">
            <el-option
              v-for="item in deptList"
              :key="item.deptId"
              :label="item.deptName"
              :value="item.deptId"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="12">
          <el-select v-model="workAuditor" filterable placeholder="请选择审核人">
            <el-option
              v-for="item in workUserList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-col>
      </el-row>

      <el-row style="margin-top: 10px">
        <el-col :span="4">
          <div style="font-size: 18px;margin-top: 5px">有关部门：</div>
        </el-col>
        <el-col :span="8">
          <el-select v-model="auditDeptDeptId" filterable placeholder="请选择审核部门" @change="switchDept(auditDeptDeptId,3)">
            <el-option
              v-for="item in deptList"
              :key="item.deptId"
              :label="item.deptName"
              :value="item.deptId"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="12">
          <el-select v-model="auditDeptAuditor" filterable placeholder="请选择审核人">
            <el-option
              v-for="item in auditUserList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-col>
      </el-row>

      <el-row style="margin-top: 10px">
        <el-col :span="4">
          <div style="font-size: 18px;margin-top: 5px">审批部门：</div>
        </el-col>
        <el-col :span="8">
          <el-select v-model="approvalDeptId" filterable placeholder="请选择审批部门" @change="switchDept(approvalDeptId,4)">
            <el-option
              v-for="item in deptList"
              :key="item.deptId"
              :label="item.deptName"
              :value="item.deptId"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="12">
          <el-select v-model="approvalAuditor" filterable placeholder="请选择审核人">
            <el-option
              v-for="item in approvalUserList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-col>
      </el-row>

      <el-row style="margin-top: 10px">
        <el-col :span="4">
          <div style="font-size: 18px;margin-top: 5px">完工验收 ：</div>
        </el-col>
        <el-col :span="8">
          <el-select v-model="completeDeptId" filterable placeholder="请选择验收部门" @change="switchDept(completeDeptId,5)">
            <el-option
              v-for="item in deptList"
              :key="item.deptId"
              :label="item.deptName"
              :value="item.deptId"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="12">
          <el-select v-model="completeAuditor" filterable placeholder="请选择审核人">
            <el-option
              v-for="item in completeUserList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-col>
      </el-row>
    </div>

    <!-- 审核按钮 -->
    <div style="text-align: right;margin-top: 10px" v-if="applyStatus == '1'">
      <el-button type="primary" @click="submitApproval">确定</el-button>
      <el-button @click="cancelApproval">取消</el-button>
    </div>

    <div style="margin-top:10px;float: right" v-if="(applyStatus-0) > '1'"><el-button type="primary" v-print="'#breakGroundPrint'">打印</el-button></div>

  </div>

</template>

<script>
  import { listDept } from "@/api/system/dept";
  import { listUser } from "@/api/system/user";
  import { addSpecialPermit, getSpecialWorkPermitByWorkPermitId } from "@/api/workPermit/specialPermit";
  import { addSign, listSign, batchUpdateSignWorkPermit } from "@/api/workPermit/workPermitSign";
  import { judgeSignUpdateTWorkPermit } from "@/api/workPermit/permit";
  import NewEsign from "@/components/SaftyWork/NewEsign";
  export default {
    name: "break-ground",
    props:{
      workPermitId:{
        type:Number
      },
      licenceNum:{
        type:String
      },
      applyStatus:{
        type:String
      }
    },
    components:{
      NewEsign
    },
    data(){
      return{
        breakGround:{
          applyUnit:"",//申请单位
          applyTime:"",//申请时间
          licenceNum:"",//作业证编号
          workUnit:"",//作业单位
          heightLocation:"",//作业地点
          heightContent:"",//作业内容
          guarder:"",//监护人
          workLeader:"",//作业负责人
          otherLicenceNum:"",//涉及的其它特殊作业/作业证编号
          workContent:"",//作业范围、内容、方式（包括深度、面积、并附简图）
          picture:"",//图片
          sign:"",//签字
          signdate:"",//签字日期
          risk:{		//风险辨识结果在下列画√
            numOne:false,
            numTwo:false,
            numThree:false,
            numFour:false,
            numFive:false,
            numSix:false,
            numSeven:false,
            numEight:false,
            numNine:false,
            numTen:false,
            numEleven:false,
            numTwelve:false,
            numThirteen:false,
            numFourteen:false,
          },

          workStartTime:"",//开始时间
          workEndTime:"",//结束时间
          safetyMeasures:{//安全措施
            measuresOne: "",
            measuresOnePeople: "",
            measuresTwo: "",
            measuresTwoPeople: "",
            measuresThree: "",
            measuresThreePeople: "",
            measuresFour: "",
            measuresFourPeople: "",
            measuresFive: "",
            measuresFivePeople: "",
            measuresSix: "",
            measuresSixPeople: "",
            measuresSeven: "",
            measuresSevenPeople: "",
            measuresEight: "",
            measuresEightPeople: "",
            measuresNine: "",
            measuresNineoPeople: "",
            measuresTen: "",
            measuresTenPeople: "",
            measuresEleven: "",
            measuresElevenPeople: "",

            measuresElevenDetail:"",//内容
            measuresElevenEdit:"",//编辑人
            measuresEleven: "",
            measuresElevenPeople: ""
          },
          discloser: "",//交底人
          recipient: "",//接收人
        },
        deptList:[],
        leaderUserList:[],
        workUserList:[],
        auditUserList:[],
        approvalUserList:[],
        completeUserList:[],
        leaderDeptId:"",
        workDeptId:"",
        auditDeptDeptId:"",
        approvalDeptId:"",
        completeDeptId:"",
        leaderAuditor:"",
        workAuditor:"",
        auditDeptAuditor:"",
        approvalAuditor:"",
        completeAuditor:"",
        specialWorkPermitSigns:[],
        specialWorkPermitId:"",
        sign:"",
        signOpen:false
      }
    },
    created(){
      this.getList();
      this.breakGround.licenceNum = this.licenceNum;
    },
    methods:{
      /** 查询部门列表 */
      getList() {
        listDept().then(response => {
            this.deptList = response.data;
        });
      },
      //部门切换
      switchDept(deptId,type){
        listUser({ pageNum: 1,pageSize: 99999,deptId:deptId}).then(response => {
            if(type == 1){
                this.leaderUserList = response.rows;
            }
            if(type == 2){
                this.workUserList = response.rows;
            }
            if(type == 3){
              this.auditUserList = response.rows;
            }
            if(type == 4){
              this.approvalUserList = response.rows;
            }
            if(type == 5){
              this.completeUserList = response.rows;
            }
        });
      },
      //数据校验
      validateData(){
        if(typeof this.breakGround.applyUnit== "undefined" || this.breakGround.applyUnit== null || this.breakGround.applyUnit== ""){
          console.log("fdsafdsafdasfd:"+this.breakGround.applyUnit)
          this.msgError("动土作业申请单位为空！");
          return true;
        }
        if(typeof this.breakGround.applyTime== "undefined" || this.breakGround.applyTime== null || this.breakGround.applyTime== ""){
          this.msgError("动土作业申请时间为空！");
          return true;
        }
        if(typeof this.breakGround.workUnit== "undefined" || this.breakGround.workUnit== null || this.breakGround.workUnit== ""){
          this.msgError("动土作业单位为空！");
          return true;
        }
        if(typeof this.breakGround.heightLocation== "undefined" || this.breakGround.heightLocation== null || this.breakGround.heightLocation== ""){
          this.msgError("动土作业内容为空！");
          return true;
        }
        if(typeof this.leaderAuditor== "undefined" || this.leaderAuditor== null || this.leaderAuditor== ""){
          this.msgError("动土作业负责人未选择！");
          return true;
        }
        if(typeof this.workAuditor== "undefined" || this.workAuditor== null || this.workAuditor== ""){
          this.msgError("动土所属单位审核人未选择！");
          return true;
        }
        if(typeof this.auditDeptAuditor== "undefined" || this.auditDeptAuditor== null || this.auditDeptAuditor== ""){
          this.msgError("动土相关部门审核人未选择！");
          return true;
        }
        if(typeof this.approvalAuditor== "undefined" || this.approvalAuditor== null || this.approvalAuditor== ""){
          this.msgError("动土审批部门审批人未选择！");
          return true;
        }
        if(typeof this.completeAuditor== "undefined" || this.completeAuditor== null || this.completeAuditor== ""){
          this.msgError("动土完工验收人未选择！");
          return true;
        }
      },
      //新增特殊作业单
      addSpecialWorkPermit(){
        let param = {};
        param.workPermitId = this.workPermitId;
        param.licenceNum = this.licenceNum;
        param.specialWorkType = "breakGround"
        param.specialWorkData = JSON.stringify(this.breakGround);
        param.signs = this.combinSign();
        return param;
      },
      //新增审核人
      combinSign(){
        let signs = [];
        signs.push({staffId:this.leaderAuditor,staffType:"leader"});
        signs.push({staffId:this.workAuditor,staffType:"workDept"});
        signs.push({staffId:this.auditDeptAuditor,staffType:"auditDept"});
        signs.push({staffId:this.approvalAuditor,staffType:"approval"});
        signs.push({staffId:this.completeAuditor,staffType:"complete"});
        return signs;
      },
      submitApproval(){
        let data =[];
        for(let key in this.specialWorkPermitSigns){
          if(this.specialWorkPermitSigns[key].staffId == this.$store.state.user.userId
            && '' != this.specialWorkPermitSigns[key].signName
            && null != this.specialWorkPermitSigns[key].signName){
            data.push(this.specialWorkPermitSigns[key]);
          }
        }
        if(data.length >0){
          batchUpdateSignWorkPermit(data).then(res =>{
            if(res.code == 200){
            this.updateWorkPermitStatus();
            this.msgSuccess("审核成功");
          }
        })
        }
      },
      //更新作业单状态
      async updateWorkPermitStatus(){
    await  judgeSignUpdateTWorkPermit({workPermitId:this.workPermitId,applyStatus:"2"});
    getSpecialWorkPermitByWorkPermitId({workPermitId:this.workPermitId}).then(res =>{
      let specialWorkPermits = res.data.specialWorkPermits;
    let flag = true;
    for(let key in specialWorkPermits){
      let signs = specialWorkPermits[key].signs;
      for(let signKey in signs){
        if(signs[signKey].staffId == this.$store.state.user.userId){
          if("" == signs[signKey].signName || null == signs[signKey].signName){
            flag = false;
          }
        }
      }
    }
    if(flag){
      this.cancelApproval();
      this.$parent.$parent.getList();
    }
  })
  },
      cancelApproval(){
        this.$parent.$parent.cancelCertificateApproval();
      },
      signName(imageSrc){
        this.sign = imageSrc;
        this.signOpen = true;
      },
    }
  }
</script>

<style scoped lang="scss">
  table{
    border-collapse: collapse;
    table-layout: fixed;
    text-align: center;
    width: 100%;
  }
  table td, table th{
    border: 1px solid;
    height: 30px;
  }

  .editInput{
    border: none;
    width: 100%;
    height: 100%;
    text-align: center;
  }

  .editInput:focus{
    outline: none;
  }

  .editLine{
    border-bottom: 1px solid;
    border-top: none;
    border-left: none;
    border-right: none;
    text-align: center;
  }

  .editLine:focus{
    outline: none;
  }

  textarea{
    height: 100%;
    width: 100%;
    border: none;
    resize:none;
  }

  textarea:focus{
    outline: none;
  }

</style>
