<template>
  <div>
    <table id="heightWorkPrint">
      <tr>
        <td>申请单位</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.applyUnit" class="editInput"/></td>
        <td>作业申请时间</td>
        <td v-if="(applyStatus-0) == 0">
          <el-date-picker clearable size="small"
                          v-model="heightWork.applyTime"
                          type="datetime"
                          value-format="yyyy-MM-dd HH:mm:ss"
                          placeholder="选择作业申请时间"
                          style="width: 100%">
          </el-date-picker>
        </td>
        <td v-if="(applyStatus-0) > 0">
          {{ (heightWork.applyTime == null || heightWork.applyTime =='') ? "-" :heightWork.applyTime.split(" ")[0].split("-")[0]}}年{{ (heightWork.applyTime == null || heightWork.applyTime =='') ? "-" :heightWork.applyTime.split(" ")[0].split("-")[1]}}月{{(heightWork.applyTime == null || heightWork.applyTime =='') ? "-" :heightWork.applyTime.split(" ")[0].split("-")[2]}}日{{(heightWork.applyTime == null || heightWork.applyTime =='') ? "-" :heightWork.applyTime.split(" ")[1].split(":")[0]}}时{{(heightWork.applyTime == null || heightWork.applyTime =='') ? "-" :heightWork.applyTime.split(" ")[1].split(":")[1]}}分
        </td>
        <td>作业证编号</td>
        <td><input disabled v-model="heightWork.licenceNum" class="editInput"/></td>
      </tr>
      <tr>
        <td>作业地点</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.heightLocation" class="editInput"/></td>
        <td>作业内容</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.heightContent" class="editInput"/></td>
      </tr>
      <tr>
        <td>作业高度</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.height" class="editInput"/></td>
        <td>高处作业级别</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.heightLevel" class="editInput"/></td>
      </tr>
      <tr>
        <td>作业单位</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.workUnit" class="editInput"/></td>
        <td>监护人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.guarder" class="editInput"/></td>
      </tr>
      <tr>
        <td>作业人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.worker" class="editInput"/></td>
        <td>作业负责人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.workLeader" class="editInput"/></td>
      </tr>
      <tr>
        <td>关联的其他特殊作业及安全作业票编号</td>
        <td colspan="5"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.otherLicenceNum" class="editInput"/></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="heightWork.risk.numOne" type="checkbox"/>1.物体打击
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numTwo" type="checkbox"/>2.车辆伤害
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numThree" type="checkbox"/>3.机械伤害
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numFour" type="checkbox"/>4.起重伤害
            </el-col>
            <el-col :span="4">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numFive" type="checkbox"/> 5.触电
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numSix" type="checkbox"/> 6.淹溺
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numSeven" type="checkbox"/> 7.灼烫
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numEight" type="checkbox"/> 8.火灾
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numNine" type="checkbox"/> 9.高处坠落
            </el-col>
            <el-col :span="4">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numTen" type="checkbox"/> 10.坍塌
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numEleven" type="checkbox"/> 11.锅炉爆炸
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numTwelve" type="checkbox"/> 12.容器爆炸
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numThirteen" type="checkbox"/> 13.其它爆炸
            </el-col>
            <el-col :span="5">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numFourteen" type="checkbox"/> 14.中毒和窒息
            </el-col>
            <el-col :span="4">
              <input :disabled="(applyStatus-0) > 0" v-model="heightWork.risk.numFifteen" type="checkbox"/>15.其它伤害
            </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="heightWork.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="heightWork.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">
          自{{ (heightWork.workStartTime == null || heightWork.workStartTime =='') ? "-" :heightWork.workStartTime.split(" ")[0].split("-")[0]}}年{{ (heightWork.workStartTime == null || heightWork.workStartTime =='') ? "-" :heightWork.workStartTime.split(" ")[0].split("-")[1]}}月{{(heightWork.workStartTime == null || heightWork.workStartTime =='') ? "-" :heightWork.workStartTime.split(" ")[0].split("-")[2]}}日{{(heightWork.workStartTime == null || heightWork.workStartTime =='') ? "-" :heightWork.workStartTime.split(" ")[1].split(":")[0]}}时{{(heightWork.workStartTime == null || heightWork.workStartTime =='') ? "-" :heightWork.workStartTime.split(" ")[1].split(":")[1]}}分至{{ (heightWork.workEndTime == null || heightWork.workEndTime =='') ? "-" :heightWork.workEndTime.split(" ")[0].split("-")[0]}}年{{(heightWork.workEndTime == null || heightWork.workEndTime =='') ? "-" :heightWork.workEndTime.split(" ")[0].split("-")[1]}}月{{(heightWork.workEndTime == null || heightWork.workEndTime =='') ? "-" :heightWork.workEndTime.split(" ")[0].split("-")[2]}}日{{(heightWork.workEndTime == null || heightWork.workEndTime =='') ? "-" :heightWork.workEndTime.split(" ")[1].split(":")[0]}}时{{(heightWork.workEndTime == null || heightWork.workEndTime =='') ? "-" :heightWork.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="heightWork.safetyMeasures.measuresOne" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresOnePeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>2</td>
        <td colspan="3">作业人员着装符合工作要求；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresTwo" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresTwoPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="3">作业人员佩戴符合标准要求的安全帽、安全带，有可能散发有毒气体的场所携带正压式空气呼吸器或面罩备用；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresThree" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresThreePeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="3">作业人员携带有工具袋和安全绳；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFour" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFourPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>5</td>
        <td colspan="3">现场搭设的脚手架、防护网、围栏符合安全规定；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFive" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFivePeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>6</td>
        <td colspan="3">垂直分层作业中间有隔离设施；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresSix" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresSixPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>7</td>
        <td colspan="3">梯子、绳子符合安全规定；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresSeven" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresSevenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>8</td>
        <td colspan="3">轻型棚的承重梁、柱能承重作业过程最大负荷的要求；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresEight" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresEightPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>9</td>
        <td colspan="3">作业人员在不承重处物作业所搭设的承重板稳定牢固；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresNine" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresNineoPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>10</td>
        <td colspan="3">采光，夜间作业照明符合作业要求；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresTen" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresTenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>11</td>
        <td colspan="3">30m以上高处作业时，作业人员已配备通讯、联络工具；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresEleven" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresElevenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>12</td>
        <td colspan="3">作业现场四周已设警戒区；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresTwelve" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresTwelvePeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>13</td>
        <td colspan="3">露天作业,风力满足作业安全要求；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresThirteen" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresThirteenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>14</td>
        <td colspan="3">其他相关特殊作业已办理相应安全作业票；</td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFourteen" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFourteenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>15</td>
        <td colspan="3" style="text-align: left">
          <div>
            其他安全措施：<input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFifteenDetail" class="editInput" style="width: 77%"/>
          </div>
          <div style="float: right">
            编制人：
            <input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFifteenEdit" class="editInput" style="width: 60%"/>
          </div>
        </td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFifteen" class="editInput"/></td>
        <td><input :disabled="(applyStatus-0) > 0" v-model="heightWork.safetyMeasures.measuresFifteenPeople" class="editInput"/></td>
      </tr>
      <tr>
        <td>安全交底人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.discloser" class="editInput"/></td>
        <td>接受交底人</td>
        <td colspan="2"><input :disabled="(applyStatus-0) > 0" v-model="heightWork.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="'#heightWorkPrint'">打印</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: "height-work",
    props:{
      workPermitId:{
        type:Number
      },
      licenceNum:{
        type:String
      },
      applyStatus:{
        type:String
      }
    },
    components:{
      NewEsign
    },
    data(){
      return{
        heightWork:{
          applyUnit:"",//申请单位
          applyTime:"",//申请时间
          licenceNum:"",//作业证编号
          heightLocation:"",//作业地点
          heightContent:"",//作业内容
          height:"",//作业高度
          heightLevel:"",//作业级别
          workUnit:"",//作业单位
          guarder:"",//监护人
          worker:"",//作业人
          workLeader:"",//作业负责人
          otherLicenceNum:"",//涉及的其它特殊作业/作业证编号
          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,
            numFifteen: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: "",
            measuresTwelve: "",
            measuresTwelvePeople: "",
            measuresThirteen: "",
            measuresThirteenPeople: "",
            measuresFourteen: "",
            measuresFourteenPeople: "",

            measuresFifteenDetail:"",//内容
            measuresFifteenEdit:"",//编辑人
            measuresFifteen: "",
            measuresFifteenPeople: ""
          },
          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.heightWork.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.heightWork.applyUnit== "undefined" || this.heightWork.applyUnit== null || this.heightWork.applyUnit== ""){
          this.msgError("高空作业申请单位为空！");
          return true;
        }
        if(typeof this.heightWork.heightLocation== "undefined" || this.heightWork.heightLocation== null || this.heightWork.heightLocation== ""){
          this.msgError("高空作业地点为空！");
          return true;
        }
        if(typeof this.heightWork.heightContent== "undefined" || this.heightWork.heightContent== null || this.heightWork.heightContent== ""){
          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 = "heightWork"
        param.specialWorkData = JSON.stringify(this.heightWork);
        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>
