<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="3"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.applyUnit" class="editInput"/></td>
        <td>申请人</td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.proposer"  class="editInput"/></td>
        <td colspan="2">作业编号</td>
        <td colspan="3"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.licenceNum"  class="editInput"/></td>
      </tr>

      <tr>
        <td colspan="5">涉及的其它特殊作业/作业证编号</td>
        <td colspan="8"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.otherLicenceNum" class="editInput"/></td>
      </tr>

      <tr>
        <td colspan="2">用电作业地点</td>
        <td colspan="4"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.electricityUseLocation"  class="editInput"/></td>
        <td colspan="2">电源接入点</td>
        <td colspan="5"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.power"  class="editInput"/></td>
      </tr>

      <tr>
        <td colspan="2">用电设备及功率</td>
        <td colspan="4"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.device"  class="editInput"/></td>
        <td colspan="2">工作电压(V)</td>
        <td colspan="5"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.voltage"  class="editInput"/></td>
      </tr>

      <tr>
        <td colspan="2">用电作业内容描述</td>
        <td colspan="11"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.content"  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))" v-model="startMonth" class="editLine" style="width: 45px;"/>月<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="startDay" class="editLine" style="width: 45px;"/>日<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="startTime" class="editLine" 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))" v-model="endYear" class="editLine" style="width: 45px;"/>年<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="endMonth" class="editLine" style="width: 45px;"/>月<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="endDay" class="editLine" style="width: 45px;"/>日<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="endTime" class="editLine" style="width: 45px;"/>时<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="endMinute" class="editLine" style="width: 45px;"/>分止
          <div style="color: red;font-size: 10px;">临时用电线路使用时间一般不超过15天，特殊情况经过工厂经理/运行经理批准可延长至30天。用电结束后，应及时拆除临时用电线</div>
        </td>
      </tr>

      <tr>
        <td colspan="2" style="background-color: #67f60e70">作业负责人</td>
        <td colspan="4"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.leader" class="editInput"/></td>
        <td colspan="2" style="background-color: #67f60e70">监护人</td>
        <td colspan="5"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.electricityUse" class="editInput"/></td>
      </tr>

      <tr>
        <td colspan="2" style="background-color: #67f60e70">作业人</td>
        <td colspan="4"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.worker" class="editInput"/></td>
        <td colspan="2" style="background-color: #67f60e70">电工证号</td>
        <td colspan="5"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.elesticNum" class="editInput"/></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="9" colspan="2">
          <input type="checkbox" :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.electricalLoad"/>电气负荷<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.electricalLoadDetail" class="editLine" style="width: 126px"/>
          <input type="checkbox" :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.insulation"/>绝缘损坏<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.insulationDetail" class="editLine" style="width: 126px"/>
          <input type="checkbox" :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.shortCircuit"/>配电盘、配电箱短路<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.shortCircuitDetail" class="editLine" style="width: 126px"/>
          <input type="checkbox" :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.damage"/>电缆易被过往设备损坏<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.damageDetail" class="editLine" style="width: 126px"/>
          <input type="checkbox" :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.socket"/>插座接头<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.socketDetail" class="editLine" style="width: 126px"/>
          <input type="checkbox" :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.phaseLine"/>电压等级与相线<input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.phaseLineDetail" class="editLine" style="width: 126px"/>
        </td>
        <td colspan="8">安装临时线路人员持有电工作业操作证</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.operator.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.operator.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>2</td>
        <td colspan="8">在防爆场所使用的临时电源、元器件和线路达到相应的防爆等级要求</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.level.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.level.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>3</td>
        <td colspan="8">临时用电的单相线路应采用三线制；三相线路应采用五线制</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.fivePhase.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.fivePhase.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>4</td>
        <td colspan="8">在装置内不低于2.5m，道路不低于5m</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.low.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.low.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>5</td>
        <td colspan="8">临时用电线路架空进线未采用裸线，未在树或脚手架设</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.overhead.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.overhead.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>6</td>
        <td colspan="8">暗管理设及地下电缆线路设有“走向标志”和“安全标志”，电线埋深大于0.7m</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.deep.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.deep.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>7</td>
        <td colspan="8">现场用的临时用配电盘、箱有防雨措施</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.rain.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.rain.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>8</td>
        <td colspan="8">临时用电设施装有漏电保护器，移动工具、手持工具“一机一闸一保护”</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.protect.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.protect.comfir" class="editInput"/></td>
      </tr>
      <tr>
        <td>9</td>
        <td colspan="8">用电设备、线路容量、负荷符合要求</td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.capacity.isChecked" type="checkbox"/></td>
        <td><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.capacity.comfir" class="editInput"/></td>
      </tr>

      <tr>
        <td>10</td>
        <td colspan="2">其他安全措施：</td>
        <td colspan="6"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.otherSafetyMeasures" class="editInput"/></td>
        <td colspan="2">实施安全教育人</td>
        <td colspan="2"><input :disabled= "!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))" v-model="electricityUse.educator"  class="editInput"/></td>
      </tr>

      <tr v-if="!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))">
        <td colspan="2" style="text-align: left">工厂专业部门意见：<textarea :disabled="-1 == post.findIndex(item => item === 6) || electricityUse.auditing.professionalMajor.status != '0'"  style="height: 80%" v-model="electricityUse.auditing.professionalMajor.opinion"></textarea></td>
        <td colspan="3" style="text-align: left">电气主管批准人意见：<textarea :disabled="-1 == post.findIndex(item => item === 10) || electricityUse.auditing.electicMajor.status != '0'"  style="height: 80%" v-model="electricityUse.auditing.electicMajor.opinion"></textarea></td>
        <td colspan="3" style="text-align: left">生产班组长验票确认：<textarea :disabled="-1 == post.findIndex(item => item === 9) || electricityUse.auditing.produce.status != '0'"  style="height: 80%" v-model="electricityUse.auditing.produce.opinion"></textarea></td>
        <td colspan="3" style="text-align: left">工厂经理/运行经理：<textarea :disabled="-1 == post.findIndex(item => item === 8) || electricityUse.auditing.factory.status != '0'"  style="height: 42%" v-model="electricityUse.auditing.factory.opinion"></textarea>（是否同意延长临时用电线路使用时间至30天）</td>
        <td colspan="2" style="text-align: left">完工验收：<textarea :disabled="-1 == post.findIndex(item => item === -2) || electricityUse.auditing.complete.status != '0'"  style="height: 80%" v-model="electricityUse.auditing.complete.opinion"></textarea></td>
      </tr>

      <tr v-if="!((applyStatus == '' || applyStatus == '2') && -1 != post.findIndex(item => item === -1))">
        <td colspan="2" style="text-align: left">
          <div>签名：</div>
          <Esign :resultImg.sync="electricityUse.auditing.professionalMajor.sign" v-if ="-1 != post.findIndex(item => item === 6) || electricityUse.auditing.professionalMajor.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 6) && electricityUse.auditing.professionalMajor.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间：<input :disabled ="-1 == post.findIndex(item => item === 6) || electricityUse.auditing.professionalMajor.status != '0'" v-model="electricityUse.auditing.professionalMajor.date" class="editInput" style="height: 14px;width: 58px"/>
        </td>
        <td colspan="3" style="text-align: left">
          <div>签名：</div>
          <Esign :resultImg.sync="electricityUse.auditing.electicMajor.sign" v-if ="-1 != post.findIndex(item => item === 10) || electricityUse.auditing.electicMajor.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 10) && electricityUse.auditing.electicMajor.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间：<input :disabled ="-1 == post.findIndex(item => item === 10) || electricityUse.auditing.electicMajor.status != '0'" v-model="electricityUse.auditing.electicMajor.date" class="editInput" style="height: 14px;width: 120px"/>
        </td>
        <td colspan="3" style="text-align: left">
          <div>签名：</div>
          <Esign :resultImg.sync="electricityUse.auditing.produce.sign" v-if ="-1 != post.findIndex(item => item === 9) || electricityUse.auditing.produce.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 9) && electricityUse.auditing.produce.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间：<input :disabled ="-1 == post.findIndex(item => item === 9) || electricityUse.auditing.produce.status != '0'" v-model="electricityUse.auditing.produce.date" class="editInput" style="height: 14px;width: 120px"/>
        </td>
        <td colspan="3" style="text-align: left">
          <div>签名：</div>
          <Esign :resultImg.sync="electricityUse.auditing.factory.sign" v-if ="-1 != post.findIndex(item => item === 8) || electricityUse.auditing.factory.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === 8) && electricityUse.auditing.factory.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间：<input :disabled ="-1 == post.findIndex(item => item === 8) || electricityUse.auditing.factory.status != '0'"  v-model="electricityUse.auditing.factory.date" class="editInput" style="height: 14px;width: 120px"/>
        </td>
        <td colspan="2" style="text-align: left">
          <div>签名：</div>
          <Esign :resultImg.sync="electricityUse.auditing.complete.sign" v-if ="-1 != post.findIndex(item => item === -2) || electricityUse.auditing.complete.status != '0'" :height="100" :width="135"/>
          <textarea v-if ="-1 == post.findIndex(item => item === -2) && electricityUse.auditing.complete.status == '0'" disabled style="height: 72%"></textarea>
          日期/时间：<input :disabled ="-1 == post.findIndex(item => item === -2) || electricityUse.auditing.complete.status != '0'" v-model="electricityUse.auditing.complete.date" class="editInput" style="height: 14px;width: 58px"/>
        </td>
      </tr>
    </table>
    <div style="text-align: right;margin-top: 10px"
         v-if="(applyStatus == '0' && -1 != post.findIndex(item => item === 6) && electricityUse.auditing.professionalMajor.status == '0')||
         (applyStatus == '0' && -1 != post.findIndex(item => item === 10) && electricityUse.auditing.electicMajor.status == '0') ||
         (applyStatus == '0' && -1 != post.findIndex(item => item === 9) && electricityUse.auditing.produce.status == '0')||
         (applyStatus == '0' && -1 != post.findIndex(item => item === 8) && electricityUse.auditing.factory.status == '0')||
         (applyStatus == '0' && -1 != post.findIndex(item => item === -2) && electricityUse.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: "electricity-use",
      props:{
        electricityUse:{
          type:Object
        },
        //作业单申请状态
        applyStatus:{
          type:String,
          default: "0"
        },
        //岗位
        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.electricityUse.workStartTime = this.getStartTime();
          }
        },
        endMinute(newValue){
          if(this.endYear && this.endMonth && this.endDay &&  this.endTime && this.endMinute){
            this.electricityUse.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 === 6) && this.electricityUse.auditing.professionalMajor.sign != ""  && this.electricityUse.auditing.professionalMajor.status == "0"){
            this.electricityUse.auditing.professionalMajor.status = type;
          }
          if(-1 != this.post.findIndex(item => item === 10) && this.electricityUse.auditing.electicMajor.sign != "" && this.electricityUse.auditing.electicMajor.status == "0"){
            this.electricityUse.auditing.electicMajor.status = type;
          }
          if(-1 != this.post.findIndex(item => item === 9) && this.electricityUse.auditing.produce.sign != "" && this.electricityUse.auditing.produce.status == "0"){
            this.electricityUse.auditing.produce.status = type;
          }
          if(-1 != this.post.findIndex(item => item === 8) && this.electricityUse.auditing.factory.sign != "" && this.electricityUse.auditing.factory.status == "0"){
            this.electricityUse.auditing.factory.status = type;
          }
          if(-1 != this.post.findIndex(item => item === -2) && this.electricityUse.auditing.complete.sign != "" && this.electricityUse.auditing.complete.status == "0"){
            this.electricityUse.auditing.complete.status = type;
          }
          this.$emit("suggestion","electricityUse",this.electricityUse);
        },
      }
    }
</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>
