<template>
  <div>
    <table>
      <tr>
        <td colspan="13" style="background-color: #fff70036">
          <font style="color: red">注意:安全措施没有落实之前,不得执行任何工作! 当现场出现报警,气体泄漏,撤离或其它紧急情况时,此作业证立即中止/取消!</font>
        </td>
      </tr>
      <tr>
        <td colspan="2">申请单位</td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.applyUnit" class="editInput"/></td>
        <td>申请人</td>
        <td colspan="4"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.proposer" class="editInput"/></td>
        <td>作业编号</td>
        <td colspan="3"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.licenceNum" class="editInput"/></td>
      </tr>
      <tr>
        <td rowspan="2" colspan="2">设备情况</td>
        <td colspan="2">设备管道名称</td>
        <td>介质</td>
        <td>温度</td>
        <td>压力</td>
        <td rowspan="2" colspan="2">盲板情况</td>
        <td>材质</td>
        <td>规格</td>
        <td>数量</td>
        <td>编号</td>
      </tr>
      <tr>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.pipeName"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.medium" class="editInput"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.temperature" class="editInput"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.pressure" class="editInput"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.material" class="editInput"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.specifications" class="editInput"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.quantity" class="editInput"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.num" class="editInput"/></td>
      </tr>
      <tr>
        <td colspan="2">抽堵盲板作业内容描述</td>
        <td colspan="11"><div><span style="float: left">盲板位置示意图(在P&ID上标识)及编号标注:</span><textarea :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" rows="3" v-model="blindPlate.workContent"/></div></td>
      </tr>
      <tr>
        <td colspan="4">涉及的其它特殊作业/作业证编号</td>
        <td colspan="9"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.otherLicenceNum" class="editInput"/></td>
      </tr>
      <tr>
        <td colspan="2">作业日期/时间</td>
        <td colspan="11">自<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="startYear" style="width: 45px;"/>年<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="startMonth" style="width: 45px;"/>月<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="startDay" style="width: 45px;"/>日<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="startTime" style="width: 45px;"/>时<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="startMinute" class="editLine" style="width: 45px;"/>分 始 至<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="endYear" style="width: 45px;"/>年<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="endMonth" style="width: 45px;"/>月<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="endDay" style="width: 45px;"/>日<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="endTime" style="width: 45px;"/>时<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="endMinute" style="width: 45px;"/>分止</td>
      </tr>
      <tr>
        <td colspan="2" style="background-color: #67f60e70">作业负责人</td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.workLeader" class="editInput"/></td>
        <td colspan="2" style="background-color: #67f60e70">监护人</td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.guarder" class="editInput"/></td>
        <td style="background-color: #67f60e70">作业人</td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.worker" class="editInput"/></td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox" v-model="blindPlate.block" value="堵"/>堵<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox" v-model="blindPlate.draw" value="抽"/>抽</td>
      </tr>
      <tr>
        <td colspan="13" style="background-color: #fff70036">危害辨识与安全措施</td>
      </tr>
      <tr>
        <td>序号</td>
        <td colspan="2">危害辨识</td>
        <td colspan="8">安全措施</td>
        <td>选项</td>
        <td>确认人</td>
      </tr>
      <tr>
        <td>1</td>
        <td rowspan="7" colspan="2">
          <div style="margin-top: 2px">
            <input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox" v-model="blindPlate.blindDefect"/>盲板有缺陷<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="blindPlate.blindDefectDetail" class="editLine" style="width: 100px;"/>
          </div>
          <div style="margin-top: 5px">
            <input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox" v-model="blindPlate.harmful"/>危险有害物质(能量)突出<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="blindPlate.harmfulDetail" style="width: 100px;"/>
          </div>
          <div style="margin-top: 5px">
            <input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox" v-model="blindPlate.fireSoruce"/>点火源<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="blindPlate.fireSourceDetail" style="width: 100px;"/>
          </div>
          <div style="margin-top: 5px">
            <input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox" v-model="blindPlate.other"/>其它<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editLine" v-model="blindPlate.otherDetail" style="width: 100px;"/>
          </div>
        </td>
        <td colspan="8">在有毒介质的管道、设备上作业时,尽可能降低系统压力,作业点应为常压</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox" v-model="blindPlate.atmosphericPressure.isChecked" /></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.atmosphericPressure.comfire" /></td>
      </tr>
      <tr>
        <td>2</td>
        <td colspan="8">在有毒介质的管道、设备上作业时,作业人员穿戴适合的防护用具</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox"  v-model="blindPlate.protectiveTools.isChecked" /></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.protectiveTools.comfire" /></td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="8">易燃易爆场所,作业人员穿防静电工作服、工作鞋;作业时使用防爆灯具和防爆工具</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox"  v-model="blindPlate.nonSparkingTools.isChecked" /></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.nonSparkingTools.comfire" /></td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="8">易燃易爆场所,距作业地点30m内无其他动火作业</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox"  v-model="blindPlate.thirtyMeter.isChecked"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.thirtyMeter.comfire"/></td>
      </tr>
      <tr>
        <td>5</td>
        <td colspan="8">在强腐蚀性介质的管道、设备上作业时,作业人员已采取防止酸碱灼伤的措施</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox"  v-model="blindPlate.corrosionProtection.isChecked"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.corrosionProtection.comfire"/></td>
      </tr>
      <tr>
        <td>6</td>
        <td colspan="8">介质温度较高、可能造成烫伤的情况下,作业人员已采取防烫措施</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox"  v-model="blindPlate.antiScalding.isChecked"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.antiScalding.comfire"/></td>
      </tr>
      <tr>
        <td>7</td>
        <td colspan="8">同一管道上不同时进行两处以上的盲板抽堵作业</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" type="checkbox"  v-model="blindPlate.thanTwo.isChecked"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.thanTwo.comfire"/></td>
      </tr>
      <tr>
        <td>8</td>
        <td colspan="2">其他安全措施:</td>
        <td colspan="6"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.otherSafetyMeasures"/></td>
        <td colspan="2">实施安全教育人</td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" class="editInput" v-model="blindPlate.educator"/></td>
      </tr>
      <tr v-if="!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))">
        <td colspan="3" style="text-align: left">作业部门负责人意见:<textarea :disabled="-1 == post.findIndex(item => item === 5) || blindPlate.auditing.deptLeader.status != '0'" style="height: 70%" v-model="blindPlate.auditing.deptLeader.opinion"></textarea></td>
        <td colspan="2" style="text-align: left">专业主管批准人意见:<textarea :disabled="-1 == post.findIndex(item => item === 6) || blindPlate.auditing.professionalMajor.status != '0'" style="height: 48%" v-model="blindPlate.auditing.professionalMajor.opinion"></textarea></td>
        <td colspan="2" style="text-align: left">安全部批准人审批意见:<textarea :disabled="-1 == post.findIndex(item => item === 7) || blindPlate.auditing.safeDept.status != '0'" style="height: 48%" v-model="blindPlate.auditing.safeDept.opinion"></textarea></td>
        <td colspan="2" style="text-align: left">工厂经理审批意见:<textarea :disabled="-1 == post.findIndex(item => item === 8) || blindPlate.auditing.factory.status != '0'" style="height: 70%" v-model="blindPlate.auditing.factory.opinion"></textarea></td>
        <td colspan="2" style="text-align: left">生产班组长验票确认<textarea :disabled="-1 == post.findIndex(item => item === 9) || blindPlate.auditing.produce.status != '0'" style="height: 70%" v-model="blindPlate.auditing.produce.opinion"></textarea></td>
        <td colspan="2" style="text-align: left">完工验收:<textarea :disabled="-1 == post.findIndex(item => item === -2) || blindPlate.auditing.complete.status != '0'" style="height: 70%" v-model="blindPlate.auditing.complete.opinion"></textarea></td>
      </tr>
      <tr v-if="!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))">
        <td colspan="3" style="text-align: left">
          <div>签名:</div>
          <Esign :resultImg.sync="blindPlate.auditing.deptLeader.sign" v-if="-1 != post.findIndex(item => item === 5) || blindPlate.auditing.deptLeader.status != '0'" :height="100" :width="200"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 5) && blindPlate.auditing.deptLeader.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间:<input  :disabled ="-1 == post.findIndex(item => item === 5) || blindPlate.auditing.deptLeader.status !='0'" v-model="blindPlate.auditing.deptLeader.date" class="editInput" style="height: 16px;width: 120px"/>
        </td>
        <td colspan="2" style="text-align: left">
          <div>签名:</div>
          <Esign :resultImg.sync="blindPlate.auditing.professionalMajor.sign" v-if ="-1 != post.findIndex(item => item === 6) || blindPlate.auditing.professionalMajor.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 6) && blindPlate.auditing.professionalMajor.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间:<input :disabled ="-1 == post.findIndex(item => item === 6) || blindPlate.auditing.professionalMajor.status != '0'" v-model="blindPlate.auditing.professionalMajor.date" class="editInput" style="height: 16px;width: 58px"/>
        </td>
        <td colspan="2" style="text-align: left">
          <div>签名:</div>
          <Esign :resultImg.sync="blindPlate.auditing.safeDept.sign"  v-if ="-1 != post.findIndex(item => item === 7) || blindPlate.auditing.safeDept.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 7) && blindPlate.auditing.safeDept.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间:<input :disabled ="-1 == post.findIndex(item => item === 7) || blindPlate.auditing.safeDept.status != '0'" v-model="blindPlate.auditing.safeDept.date" class="editInput" style="height: 16px;width: 58px"/>
        </td>
        <td colspan="2" style="text-align: left">
          <div>签名:</div>
          <Esign :resultImg.sync="blindPlate.auditing.factory.sign" v-if ="-1 != post.findIndex(item => item === 8) || blindPlate.auditing.factory.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 1) && blindPlate.auditing.factory.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间:<input :disabled ="-1 == post.findIndex(item => item === 1) || blindPlate.auditing.factory.status != '0'" v-model="blindPlate.auditing.factory.date" class="editInput" style="height: 16px;width: 58px"/>
        </td>
        <td colspan="2" style="text-align: left">
          <div>签名:</div>
          <Esign :resultImg.sync="blindPlate.auditing.produce.sign" v-if ="-1 != post.findIndex(item => item === 9) || blindPlate.auditing.produce.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 9) && blindPlate.auditing.produce.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间:<input :disabled ="-1 == post.findIndex(item => item === 9) || blindPlate.auditing.produce.status != '0'" v-model="blindPlate.auditing.produce.date" class="editInput" style="height: 16px;width: 58px"/>
        </td>
        <td colspan="2" style="text-align: left">
          <div>签名:</div>
          <Esign :resultImg.sync="blindPlate.auditing.complete.sign" v-if ="-1 != post.findIndex(item => item === -2) || blindPlate.auditing.complete.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === -2) && blindPlate.auditing.complete.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间:<input :disabled ="-1 == post.findIndex(item => item === -2) || blindPlate.auditing.complete.status != '0'" v-model="blindPlate.auditing.complete.date" class="editInput" style="height: 16px;width: 58px"/>
        </td>
      </tr>
    </table>
    <div style="text-align: right;margin-top: 10px"
         v-if="(applyStatus == '0' && -1 != post.findIndex(item => item === 5) && blindPlate.auditing.deptLeader.status == '0')||
         (applyStatus == '0' && -1 != post.findIndex(item => item === 6) && blindPlate.auditing.professionalMajor.status == '0') ||
         (applyStatus == '0' && -1 != post.findIndex(item => item === 7) && blindPlate.auditing.safeDept.status == '0') ||
         (applyStatus == '0' && -1 != post.findIndex(item => item === 8) && blindPlate.auditing.factory.status == '0') ||
         (applyStatus == '0' && -1 != post.findIndex(item => item === 9) && blindPlate.auditing.produce.status == '0') ||
         (applyStatus == '0' && -1 != post.findIndex(item => item === -2) && blindPlate.auditing.complete.status == '0')">
      <el-button type="primary" @click="suggestion('1')">同意</el-button>
      <el-button @click="suggestion('2')">驳回</el-button>
    </div>
  </div>

</template>

<script>
import Esign from "./Esign";
export default {
  name: "Bind-plat",
  props:{
    blindPlate:{
      type:Object
    },
    //作业单申请状态
    applyStatus:{
      type:String,
      default: ""
    },
    //岗位
    post:{
      type:Array
    }
  },
  components:{
    Esign
  },
  data(){
    return{
      startYear:"",
      startMonth:"",
      startDay:"",
      startTime:"",
      startMinute:"",
      endYear:"",
      endMonth:"",
      endDay:"",
      endTime:"",
      endMinute:""
    }
  },
  watch:{
    startMinute(newValue){
      if(this.startYear && this.startMonth && this.startDay &&  this.startTime && this.startMinute){
        this.blindPlate.workStartTime = this.getStartTime();
      }
    },
    endMinute(newValue){
      if(this.endYear && this.endMonth && this.endDay &&  this.endTime && this.endMinute){
        this.blindPlate.workEndTime = this.getEndTime();
      }
    }
  },
  methods:{
    //获取开始时间
    getStartTime(){
      return this.startYear + "-" +this.startMonth + "-" + this.startDay + " " + this.startTime + ":" + this.startMinute;
    },
    //获取结束时间
    getEndTime(){
      return this.endYear + "-" +this.endMonth + "-" + this.endDay + " " + this.endTime + ":" + this.endMinute;
    },
    //同意
    suggestion(type){
      if(-1 != this.post.findIndex(item => item === 5) && this.blindPlate.auditing.deptLeader.sign != "" && this.blindPlate.auditing.deptLeader.status =="0"){
        this.blindPlate.auditing.deptLeader.status = type;
      }
      if(-1 != this.post.findIndex(item => item === 6) && this.blindPlate.auditing.professionalMajor.sign != "" && this.blindPlate.auditing.professionalMajor.status =="0"){
        this.blindPlate.auditing.professionalMajor.status = type;
      }
      if(-1 != this.post.findIndex(item => item === 7) && this.blindPlate.auditing.safeDept.sign != "" && this.blindPlate.auditing.safeDept.status =="0"){
        this.blindPlate.auditing.safeDept.status = type;
      }
      if(-1 != this.post.findIndex(item => item === 8) && this.blindPlate.auditing.factory.sign != "" && this.blindPlate.auditing.factory.status =="0"){
        this.blindPlate.auditing.factory.status = type;
      }
      if(-1 != this.post.findIndex(item => item === 9) && this.blindPlate.auditing.produce.sign != "" && this.blindPlate.auditing.produce.status =="0"){
        this.blindPlate.auditing.produce.status = type;
      }
      if(-1 != this.post.findIndex(item => item === -2) && this.blindPlate.auditing.complete.sign != "" && this.blindPlate.auditing.complete.status =="0"){
        this.blindPlate.auditing.complete.status = type;
      }
      this.$emit("suggestion","blindPlate",this.blindPlate);
    },
  }

}
</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>