<template>
  <div>
    <el-card>
      <span>班组</span>
      <el-select v-model="maintenanceTeam" class="select12" clearable placeholder="请选择班组">
        <el-option
          v-for="item in maintenanceTeams"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <span>班次</span>
      <el-select v-model="Frequency" class="select12" clearable placeholder="请选择班次">
        <el-option
          v-for="item in FrequencyNames"
          :key="item.value"
          :label="item.label"
          :value="item.value"/>
      </el-select>
      <span>日期</span>
      <el-date-picker
        v-model="handoverDate"
        :clearable="false"
        :picker-options="pickerOptions"
        type="daterange"
        align="center"
        unlink-panels
        placeholder="选择日期"
        value-format="yyyy-MM-dd"
        style="height: 51px"
      />
      <el-button style="font-size: 16px;height: 50px;margin-left: 10px" plain type="success" icon="el-icon-search" size="small" @click="searchTable()">查询</el-button>
      <el-tooltip placement="top">
        <div slot="content" v-html="toolTips"/>
        <el-button style="font-size: 16px;height: 50px;margin-left: 10px" plain type="success" icon="el-icon-circle-plus-outline" size="small" @click="editItem()">发起交班</el-button>
      </el-tooltip>
      <!--设备正常交班-->
      <el-table
        v-loading="loading"
        ref="multipleTable"
        :data="tableData"
        :header-cell-style="{background:'#F5F5F5'}"
        element-loading-text="数据加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(0, 0, 0, 0.2)"
        stripe
        tooltip-effect="dark"
        style="width: 100%;margin-top: 10px"
        height="600"
        border
        size="mini"
        highlight-current-row>
        <el-table-column align="center" label="班组" min-width="60" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.班组 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="班次" min-width="60" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.交接班名称 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="交班人员" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.交班人员 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="交班时间" min-width="120" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.交班时间 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="安全情况" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.安全方面代码 === 1" color="rgb(0,142,207)" type="info" size="mini" >{{ scope.row.安全情况 }}</el-tag>
            <el-tag v-else="" color="red" type="info" size="mini" >{{ scope.row.安全情况 }}</el-tag>
          </template>
        </el-table-column>
        <!--        <el-table-column align="center" label="异常情况" min-width="90" show-overflow-tooltip>-->
        <!--          <template slot-scope="scope">-->
        <!--            {{ scope.row.异常情况 }}-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column align="center" label="运转情况" min-width="60" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.设备运转情况代码 === 1" color="rgb(0,142,207)" type="info" size="mini" >{{ scope.row.运转情况 }}</el-tag>
            <el-tag v-else="" color="red" type="info" size="mini" >{{ scope.row.运转情况 }}</el-tag>
          </template>
        </el-table-column>
        <!--        <el-table-column align="center" label="交班留言" min-width="60" show-overflow-tooltip>-->
        <!--          <template slot-scope="scope">-->
        <!--            {{ scope.row.交班留言 }}-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column align="center" label="是否接班" min-width="60">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.是否接班 === 1" color="rgb(0,142,207)" type="info" size="mini" >已接班</el-tag>
            <el-tag v-else="" color="red" type="info" size="mini" >未接班</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="接班时间" min-width="120" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.接班时间 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="接班人员" min-width="80" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.接班人员 }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" min-width="150">
          <template slot-scope="scope">
            <el-tooltip class="item" effect="dark" content="查看详情" placement="top">
              <el-button style="margin-left: 0px" type="text" size="mini" icon="el-icon-search" @click="searchExceptionTable(scope.row)"/>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="编辑" placement="top">
              <el-button :disabled="!parseInt(scope.row.允许修改)" style="margin-left: 10px" type="text" size="mini" icon="el-icon-edit" @click="editExceptionTable(scope.row)"/>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="删除" placement="top">
              <el-button :disabled="!parseInt(scope.row.允许修改)" style="margin-left: 10px;" type="text" size="mini" icon="el-icon-delete" @click="handleDelete(scope.row)"/>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="接班" placement="top">
              <el-button :disabled="!parseInt(scope.row.允许接班)" style="margin-left: 10px" type="text" size="mini" icon="el-icon-check" @click="Succession(scope.row)"/>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="导出" placement="top">
              <el-button style="margin-left: 10px" type="text" size="mini" icon="el-icon-download" @click="exportExcel(scope.row)"/>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="margin-top: 10px;">
        <el-pagination
          v-if="!loading"
          :current-page="pageCurrent"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"/>
      </div>
    </el-card>
    <!--交班编辑-->
    <el-dialog id="dialog123" :modal-append-to-body="false" :title="title" :visible.sync="dialogFormVisible" top="10vh" center width="800px">
      <el-form ref="form" :model="form" :rules="rules" label-position="top" label-width="700px" label-padding-bottom="0px">
        <el-collapse ref="coll" v-model="activeNames">
          <el-collapse-item name="1" style="padding: 0px">
            <template slot="title">
              <div style="display: flex" @click="$event.stopPropagation()">
                <span style="margin-right: 5px">设备维修交班</span>
                <div v-show="isExistInfo">
                  <span style="margin-right: 5px;color:#ff0000">当前班组已录入交班信息，是否拉取？</span>
                  <el-tooltip class="item" effect="dark" content="拉取信息" placement="top">
                    <el-button type="text" icon="el-icon-refresh" @click="getExistInfos()"/>
                  </el-tooltip>
                </div>
              </div>
            </template>
            <el-row>
              <el-col :span="8">
                <el-form-item label="交班负责人" prop="responsiblePerson">
                  <el-select v-model="form.responsiblePerson" style="width: 200px" placeholder="负责人">
                    <el-option
                      v-for="item in responsiblePersons"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="维修班组" prop="maintenanceTeam">
                  <el-select v-model="form.maintenanceTeam" style="width:200px;" placeholder="请选择班组" @change="isAllowSuccession()">
                    <el-option
                      v-for="item in maintenanceTeams"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="班次" prop="Frequency">
                  <el-select v-model="form.Frequency" style="width: 200px" placeholder="请选择班次" @change="isAllowSuccession()">
                    <el-option
                      v-for="item in FrequencyNames"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="安全方面" prop="Safety">
                  <el-select v-model="form.Safety" style="width:200px " placeholder="请选择安全方面">
                    <el-option
                      v-for="item in Safetys"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item label="设备运转情况" prop="EquipmentOperation">
                  <el-select v-model="form.EquipmentOperation" style="width:200px " placeholder="请选择设备运转情况" @change="getworkOrders()">
                    <el-option
                      v-for="item in EquipmentOperations"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-show="form.Safety === 2">
              <el-form-item label="异常情况" prop="abnormalSituation">
                <el-input :rows="2" v-model="form.abnormalSituation" type="textarea" style="width: 90%" placeholder="请输入异常情况"/>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="交班留言" prop="LeaveMessage">
                <el-input :rows="2" v-model="form.LeaveMessage" type="textarea" style="width: 90%" placeholder="请输入交班留言"/>
              </el-form-item>
            </el-row>
          </el-collapse-item>
          <el-collapse-item v-if="form.EquipmentOperation === 2" name="2">
            <template slot="title">
              <div @click="$event.stopPropagation()">
                <span style="margin-right: 5px;color:#ff0000">设备异常交班和处理情况</span>
                <el-select v-model="form.workOrder" style="width:150px" size="mini" placeholder="请选择未完成工单">
                  <el-option
                    v-for="item in workOrders"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
                <el-tooltip class="item" effect="dark" content="查看详情" placement="top">
                  <el-button :disabled="!form.workOrder" style="margin-left: 5px" type="text" icon="el-icon-search" size="mini" @click="searchLook(form.workOrder)"/>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="记录当前" placement="top">
                  <el-button :disabled="!form.workOrder" style="margin-left: 5px" type="text" icon="el-icon-plus" size="mini" @click="addOrderInfo()"/>
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="删除当前" placement="top">
                  <el-button :disabled="!form.workOrder" style="margin-left: 5px" type="text" icon="el-icon-delete" size="mini" @click="deleteOrderInfo()"/>
                </el-tooltip>
              </div>
            </template>
            <el-carousel ref="workerOrderCarousel" :autoplay="false" indicator-position="none" arrow="always">
              <el-carousel-item v-for="(item, index) in form.abnormalCondition" :key="index" name="index">
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="维修工单" prop="maintenancePeople">
                      <el-input v-model="item.workOrder" style="width: 200px" readonly placeholder="维修工单"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="维修人员" prop="maintenancePeople">
                      <el-input v-model="item.maintenancePeople" style="width: 200px" readonly placeholder="维修人员"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="生产线" prop="productionLine">
                      <el-input v-model="item.productionLine" style="width: 200px" readonly placeholder="生产线"/>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="设备名称" prop="equipmentName">
                      <el-input v-model="item.equipmentName" style="width: 200px" readonly placeholder="设备名称"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="工序号" prop="processNumber">
                      <el-input v-model="item.processNumber" style="width: 200px" readonly placeholder="工序号"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="故障接报时间" prop="receivingTime">
                      <el-input v-model="item.receivingTime" style="width: 200px" readonly placeholder="故障接报时间"/>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="故障维修时间" prop="maintenanceTime">
                      <el-input v-model="item.maintenanceTime" style="width: 200px" readonly placeholder="故障维修时间"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="故障现象" prop="faultPhenomenon">
                      <el-input v-model="item.faultPhenomenon" style="width: 200px" placeholder="故障现象"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="完成情况" prop="completionSituation">
                      <el-select v-model="item.completionSituation" style="width:200px" placeholder="请选择完成情况">
                        <el-option
                          v-for="item in completionSituations"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"/>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="维修处理情况" prop="treatmentSituation">
                  <el-input :rows="2" v-model="item.treatmentSituation" type="textarea" style="width: 90%" placeholder="请输入维修处理情况"/>
                </el-form-item>
              </el-carousel-item>
            </el-carousel>
            <el-form-item label="其他" prop="otherThings">
              <el-input :rows="2" v-model="form.otherThings" type="textarea" style="width: 90%" placeholder="请输入其他情况"/>
            </el-form-item>
          </el-collapse-item>
        </el-collapse>
        <el-row style="text-align: center">
          <el-form-item>
            <!--<div v-if="currentFrequency" style="position: absolute;display: block;font-size: 20px">当前属于<span style="color: red">{{ currentFrequencyInfo }}</span>时间</div>-->
            <!--<div v-else="" style="position: absolute;display: block;font-size: 20px"><span style="color: red">当前时间无法交班</span></div>-->
            <div v-if="isAllowSubmit" style="position: absolute;display: block;font-size: 20px"><span style="color: red">当前班尚未接班</span></div>
            <el-button size="small" @click="callOff('form')">取 消</el-button>
            <el-button :disabled="isAllowSubmit" size="small" type="primary" @click="submit('form')">提 交</el-button>
          </el-form-item>
        </el-row>
      </el-form>
    </el-dialog>
    <!--交班查看-->
    <el-dialog id="dialog124" :modal-append-to-body="false" :title="title1" :visible.sync="dialogFormVisible1" top="10vh" center width="800px">
      <el-form ref="form1" :model="form1" label-position="top" label-width="700px" label-padding-bottom="0px">
        <el-collapse ref="coll" v-model="activeNames1">
          <el-collapse-item title="设备维修交班" name="1" style="padding: 0px">
            <el-row>
              <el-col :span="8">
                <el-form-item label="交班负责人" prop="responsiblePerson">
                  <el-select v-model="form1.responsiblePerson" style="width: 200px" disabled placeholder="负责人">
                    <el-option
                      v-for="item in responsiblePersons"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="维修班组" prop="maintenanceTeam">
                  <el-select v-model="form1.maintenanceTeam" style="width:200px;" disabled placeholder="请选择班组">
                    <el-option
                      v-for="item in maintenanceTeams"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="班次" prop="Frequency">
                  <el-select v-model="form1.Frequency" style="width: 200px" disabled placeholder="请选择班次">
                    <el-option
                      v-for="item in FrequencyNames"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="安全方面" prop="Safety">
                  <el-select v-model="form1.Safety" style="width:200px " placeholder="请选择安全方面" disabled @change="getSafetys">
                    <el-option
                      v-for="item in Safetys"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item label="设备运转情况" prop="EquipmentOperation">
                  <el-select v-model="form1.EquipmentOperation" style="width:200px " placeholder="请选择设备运转情况" disabled @change="getEquipmentOperations">
                    <el-option
                      v-for="item in EquipmentOperations"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-show="form1.Safety === 2">
              <el-form-item label="异常情况" prop="abnormalSituation">
                <el-input :rows="2" v-model="form1.abnormalSituation" type="textarea" readonly style="width: 90%" placeholder="请输入异常情况"/>
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="交班留言" prop="LeaveMessage">
                <el-input :rows="2" v-model="form1.LeaveMessage" type="textarea" readonly style="width: 90%" placeholder="请输入交班留言"/>
              </el-form-item>
            </el-row>
          </el-collapse-item>
          <el-collapse-item v-if="form1.EquipmentOperation === 2" name="2">
            <template slot="title">
              <div @click="$event.stopPropagation()">
                <span style="margin-right: 5px;color:#ff0000">设备异常交班和处理情况</span>
                <el-select v-model="form1.workOrder" style="width:150px" size="mini" placeholder="请选择未完成工单">
                  <el-option
                    v-for="item in workOrders"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"/>
                </el-select>
                <el-tooltip class="item" effect="dark" content="查看详情" placement="top">
                  <el-button :disabled="!form1.workOrder" style="margin-left: 5px" type="text" icon="el-icon-search" size="mini" @click="searchLook(form1.workOrder)"/>
                </el-tooltip>
              </div>
            </template>
            <el-carousel ref="workerOrderCarousel" :autoplay="false" indicator-position="none" arrow="always">
              <el-carousel-item v-for="(item, index) in form1.abnormalCondition" :key="index" name="index">
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="维修工单" prop="maintenancePeople">
                      <el-input v-model="item.workOrder" style="width: 200px" readonly placeholder="维修工单"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="维修人员" prop="maintenancePeople">
                      <el-input v-model="item.maintenancePeople" style="width: 200px" readonly placeholder="维修人员"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="生产线" prop="productionLine">
                      <el-input v-model="item.productionLine" style="width: 200px" readonly placeholder="生产线"/>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="设备名称" prop="equipmentName">
                      <el-input v-model="item.equipmentName" style="width: 200px" readonly placeholder="设备名称"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="工序号" prop="processNumber">
                      <el-input v-model="item.processNumber" style="width: 200px" readonly placeholder="工序号"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="故障接报时间" prop="receivingTime">
                      <el-input v-model="item.receivingTime" style="width: 200px" readonly placeholder="故障接报时间"/>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="故障维修时间" prop="maintenanceTime">
                      <el-input v-model="item.maintenanceTime" style="width: 200px" readonly placeholder="故障维修时间"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="故障现象" prop="faultPhenomenon">
                      <el-input v-model="item.faultPhenomenon" style="width: 200px" readonly placeholder="故障现象"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="完成情况" prop="completionSituation">
                      <el-select v-model="item.completionSituation" style="width:200px" disabled placeholder="请选择完成情况">
                        <el-option
                          v-for="item in completionSituations"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"/>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="维修处理情况" prop="treatmentSituation">
                  <el-input :rows="2" v-model="item.treatmentSituation" type="textarea" readonly style="width: 90%" placeholder="请输入维修处理情况"/>
                </el-form-item>
              </el-carousel-item>
            </el-carousel>
            <el-form-item label="其他" prop="otherThings">
              <el-input :rows="2" v-model="form1.otherThings" type="textarea" readonly style="width: 90%" placeholder="请输入其他情况"/>
            </el-form-item>
          </el-collapse-item>
        </el-collapse>
        <!--        <el-row>-->
        <!--          <el-form-item v-if="!buttonChange">-->
        <!--            <el-button size="small" @click="callOff('form')">取消</el-button>-->
        <!--            <el-button size="small" type="primary" @click="submit('form')">确 定</el-button>-->
        <!--          </el-form-item>-->
        <!--          <el-form-item v-if="buttonChange">-->
        <!--            <el-button size="small" @click="cancelEdit('form')">取消</el-button>-->
        <!--            <el-button size="small" type="primary" @click="confirmEdit('form')">确 定</el-button>-->
        <!--          </el-form-item>-->
        <!--        </el-row>-->
      </el-form>
    </el-dialog>
    <!--接班-->
    <el-dialog id="dialog125" :modal-append-to-body="false" :title="title2" :visible.sync="dialogFormVisible2" top="10vh" center width="500px">
      <el-form ref="form2" :model="form2" :rules="rules2" label-position="right" label-width="120px" style="width: 90%;margin: auto">
        <el-row>
          <el-form-item label="接班人员" prop="responsiblePerson">
            <el-select v-model="form2.responsiblePerson" style="width: 150px" placeholder="接班负责人">
              <el-option
                v-for="item in responsiblePersons"
                :key="item.value"
                :label="item.label"
                :value="item.value"/>
            </el-select>
            <el-button plain type="success" icon="el-icon-check" @click="submitSuccession('form2')">确认接班</el-button>
          </el-form-item>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import { ExecDatabase } from '@/main'
import { mapGetters } from 'vuex'
import { getNowDate } from '@/utils/tool'
import $ from 'jquery'
export default {
  data() {
    return {
      pickerOptions: { // 对象
        disabledDate: (time) => {
          let nowData = new Date()
          nowData = new Date(nowData.setDate(nowData.getDate()))
          return time >= nowData
        }
      },
      toolTips: '',
      currentFrequency: false,
      currentFrequencyInfo: '',
      activeNames: ['1'],
      activeNames1: ['1'],
      isAllowSubmit: false,
      isExistInfo: false,
      im: 0,
      时间: '',
      maintenanceTeam: '', // 维修班组
      maintenanceTeams: [], // 维修班组
      title: '',
      title1: '',
      title2: '',
      title3: '',
      handoverDate: [getNowDate(), getNowDate()], // 交班日期
      dialogFormVisible: false, // 正常交班信息
      dialogFormVisible1: false, // 接班信息
      dialogFormVisible2: false, // 异常信息查看
      dialogFormVisible3: false, // 异常信息编辑
      abnormalNumber: [], // 交接班记录流水号
      buttonChange: false, // 确认取消按钮变换
      // 正常交班信息
      form: {
        Frequency: '', // 班次
        maintenanceTeam: '', // 班组
        responsiblePerson: '', // 交班负责人
        EquipmentOperation: '', // 设备运转情况
        Safety: '', // 安全方面
        LeaveMessage: '', // 交班留言
        abnormalSituation: '', // 异常情况
        workOrder: '', // 工单
        abnormalCondition: [], // 工单详情信息
        otherThings: '' // 其他情况
      },
      // 正常交班信息编辑
      form1: {
        Frequency: '', // 班次
        maintenanceTeam: '', // 班组
        responsiblePerson: '', // 交班负责人
        EquipmentOperation: '', // 设备运转情况
        Safety: '', // 安全方面
        LeaveMessage: '', // 交班留言
        abnormalSituation: '', // 异常情况
        workOrder: '', // 工单
        abnormalCondition: [], // 工单详情信息
        otherThings: '' // 其他情况
      },
      // 接班
      form2: {
        responsiblePerson: '', // 接班负责人
        abnormalNumber: '' // 交接班流水号
      },
      form3: {
        abnormalSituation: '',
        workOrder: '',
        maintenancePeople: '',
        productionLine: '',
        equipmentName: '',
        processNumber: '',
        receivingTime: '',
        maintenanceTime: '',
        completionSituation: '',
        faultPhenomenon: '',
        treatmentSituation: ''
      },
      Frequency: '',
      FrequencyNames: [],
      handoverlnumber: '', // 交接班流水号
      responsiblePersons: [],
      EquipmentOperations: [],
      productionLines: [],
      processNumbers: [],
      equipmentNames: [],
      Safetys: [],
      workOrders: [],
      workOrdersGroup: [],
      completionSituations: [],
      faultPhenomenons: [],
      shiftHandlers: [],
      successionTimes: [],
      rules: {
        responsiblePerson: [{ required: true, message: '请选择交班负责人', trigger: 'blur' }],
        maintenanceTeam: [{ required: true, message: '请选择维修班组', trigger: 'blur' }],
        Frequency: [{ required: true, message: '请选择班次', trigger: 'blur' }],
        Safety: [{ required: true, message: '请选择安全情况', trigger: 'blur' }],
        EquipmentOperation: [{ required: true, message: '请选择设备运转情况', trigger: 'blur' }]
      },
      rules1: {},
      rules2: {
        responsiblePerson: [{ required: true, message: '请选择接班负责人', trigger: 'blur' }]
      },
      tableData: [],
      abnormalData: [],
      loading: false,
      pageCurrent: 1,
      total: 0, // 总条数
      pageSize: 40 // 每页显示条数
    }
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar',
      'name',
      'id',
      'token',
      'name',
      'cname'
    ])
  },
  created() {
    this.getResponsiblePersons()
    this.getmaintenanceTeam()
    this.getmaintenanceTeamFirst()
    this.getFrequency()
    this.getfaultPhenomenons()
    this.getcompletionSituations()
    this.getEquipmentOperations()
    this.getSafetys()
    this.getToolTips()
    this.$route.meta.keepAlive = true
  },
  methods: {
    exportExcel(row) {
      var param = []
      // param[0] = ['维修工单代码', '209']
      // var Data = this.CreateData('2001', '维修工单_工单_导出', param)
      // this.exportExcel_NPOI(Data)
      param[0] = ['交接班记录流水号', row.交接班记录流水号]
      var Data = this.CreateData('2001', '交接班记录_导出', param)
      this.exportExcel_NPOI(Data)
    },
    // 获取信息
    getToolTips() {
      this.toolTips = ''
      var param = []
      this.FrequencyNames = []
      var Data = this.CreateData('11', '基础数据_交接班次提示信息查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.toolTips += response.data[i].交接班名称 + '：' + response.data[i].开始时间.Hours + ':' + response.data[i].开始时间.Minutes +
            '-' + response.data[i].结束时间.Hours + ':' + response.data[i].结束时间.Minutes + '<br/>'
          }
          console.log(this.toolTips)
        }
      })
    },
    // 初始化班组负责人
    getResponsiblePersons() {
      this.responsiblePersons = []
      var param = []
      var Data = this.CreateData('11', '设备管理_人员_查询', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.responsiblePersons.push({
              label: response.data[i].姓名,
              value: response.data[i].人员代码
            })
          }
        }
      })
    },
    // 初始化维修班组
    getmaintenanceTeam() {
      this.maintenanceTeams = []
      var param = []
      param[0] = ['人员代码', this.id]
      var Data = this.CreateData('11', '基础数据_班组_查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.maintenanceTeams.push({
              label: response.data[i].班组名称,
              value: response.data[i].班组代码
            })
          }
        }
      })
    },
    // 初始化维修班组
    getmaintenanceTeamFirst() {
      var param = []
      param[0] = ['人员代码', this.id]
      var Data = this.CreateData('11', '基础数据_班组_查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          // this.maintenanceTeam = response.data[0].班组代码
          this.searchTable()
        }
      })
    },
    // 班次查询
    getFrequency() {
      var param = []
      this.FrequencyNames = []
      var Data = this.CreateData('11', '基础数据_交接班次查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.FrequencyNames.push({
              label: response.data[i].交接班名称,
              value: response.data[i].ID
            })
          }
        }
      })
    },
    // 当前班次查询
    getCurrentFrequency() {
      var param = []
      var Data = this.CreateData('11', '维修工单_当前交接班次查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          this.form.Frequency = response.data[0].班次代码
          this.currentFrequency = true
          this.currentFrequencyInfo = response.data[0].交接班名称
        } else {
          this.form.Frequency = ''
          this.currentFrequency = false
          this.currentFrequencyInfo = ''
        }
      })
    },
    // 安全情况查询
    getSafetys() {
      var param = []
      this.Safetys = []
      var Data = this.CreateData('11', '基础数据_安全情况查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.Safetys.push({
              label: response.data[i].安全情况,
              value: response.data[i].ID
            })
          }
        }
      })
    },
    // 设备运转情况查询
    getEquipmentOperations() {
      var param = []
      this.EquipmentOperations = []
      var Data = this.CreateData('11', '基础数据_交接班设备运转情况查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.EquipmentOperations.push({
              label: response.data[i].运转情况,
              value: response.data[i].ID
            })
          }
        }
      })
    },
    // 完成情况
    getcompletionSituations() {
      var param = []
      this.completionSituations = []
      var Data = this.CreateData('11', '基础数据_完成情况查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.completionSituations.push({
              label: response.data[i].完成情况,
              value: response.data[i].ID
            })
          }
        }
      })
    },
    // 故障现象
    getfaultPhenomenons() {
      var param = []
      var Data = this.CreateData('11', '设备维修班组交接班记录_故障现象_查询数据', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          this.faultPhenomenons.splice(0, this.faultPhenomenons.length)
          for (let i = 0; i < response.data.length; i++) {
            this.faultPhenomenons.push({
              label: response.data[i].故障现象,
              value: response.data[i].故障现象流水号
            })
          }
        }
      })
    },
    // 查看未完成工单详情
    searchLook(jobNumber) {
      var row = {}
      var param = []
      param[0] = ['维修工单代码', jobNumber]
      var Data = this.CreateData('11', '维修工单_当前工单详情_查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          for (let i = 0; i < response.data.length; i++) {
            const v = response.data[0]
            row = {
              维修工单代码: v.维修工单代码,
              工单号: v.工单号,
              设备名称: v.设备名称,
              资产号: v.资产号,
              故障名称: v.故障名称,
              维修人员姓名: v.维修人员姓名,
              状态: v.状态,
              状态代码: v.状态代码,
              申请人姓名: v.申请人姓名,
              申请人代码: v.申请人代码,
              开始时间: v.开始时间,
              持续时长: v.持续时长,
              设备代码: v.设备代码,
              是否停机: v.是否停机,
              设备编号: v.设备编号,
              工序名称: v.工序名称,
              车间: v.车间
            }
          }
          this.$router.push({
            name: 'Test',
            query: {
              jobNumber: row
            }
          })
        }
      })
    },
    // 查询交接班表
    searchTable() {
      this.loading = true
      this.tableData = []
      var param = []
      let maintenanceTeam_check = 0
      let Frequency_check = 0
      if (this.maintenanceTeam) maintenanceTeam_check = 1
      if (this.Frequency) Frequency_check = 1
      param[0] = ['班组代码', this.maintenanceTeam]
      param[1] = ['班组代码_check', maintenanceTeam_check]
      param[2] = ['班次代码', this.Frequency]
      param[3] = ['班次代码_check', Frequency_check]
      param[4] = ['开始时间', this.handoverDate[0]]
      param[5] = ['结束时间', this.handoverDate[1]]
      param[6] = ['PageSize', this.pageSize]
      param[7] = ['PageCurrent', this.pageCurrent]
      param[8] = ['PageCount', '1111', 'int', '1']
      param[9] = ['ItemCount', '1111', 'int', '1']
      param[10] = ['人员代码', this.id]
      param[11] = ['角色代码', this.token]
      var Data = this.CreateData('11', '设备维修_班组交接班记录_查询数据', param)
      ExecDatabase(Data).then(response => {
        if (response.data.result.length !== 0) {
          for (let i = 0; i < response.data.result.length; i++) {
            this.tableData.push({
              交接班记录流水号: response.data.result[i].交接班记录流水号,
              交班负责人员代码: response.data.result[i].交班负责人员代码,
              维修班组代码: response.data.result[i].维修班组代码,
              班次代码: response.data.result[i].班次代码,
              安全方面代码: response.data.result[i].安全方面代码,
              设备运转情况代码: response.data.result[i].设备运转情况代码,
              异常情况: response.data.result[i].异常情况,
              交班留言: response.data.result[i].交班留言,
              交班时间: response.data.result[i].交班时间,
              是否接班: response.data.result[i].是否接班,
              接班负责人员代码: response.data.result[i].接班负责人员代码,
              接班时间: response.data.result[i].接班时间,
              运转情况: response.data.result[i].运转情况,
              交接班名称: response.data.result[i].交接班名称,
              安全情况: response.data.result[i].安全情况,
              班组: response.data.result[i].班组,
              交班人员: response.data.result[i].交班人员,
              接班人员: response.data.result[i].接班人员,
              允许修改: parseInt(this.token) === 1 ? 1 : parseInt(this.id) === response.data.result[i].交班负责人员代码 ? response.data.result[i].允许修改 : 0,
              允许接班: parseInt(this.token) === 1 ? 1 : parseInt(this.id) === response.data.result[i].交班负责人员代码 ? 0 : response.data.result[i].允许接班
            })
          }
        }
        console.log(this.tableData)
        this.total = parseInt(response.data.output[0].ItemCount)
        this.loading = false
      })
    },
    // 增加（发起交班）
    editItem() {
      if (this.$refs['form'] !== undefined) {
        this.$refs['form'].resetFields()
      }
      this.title = '设备维修交班录入'
      this.form = {
        maintenanceTeam: this.maintenanceTeam, // 班组
        responsiblePerson: this.responsiblePersons[0].value, // 人员
        Frequency: '', // 班次
        EquipmentOperation: '', // 设备运转情况
        Safety: '', // 安全方面
        LeaveMessage: '', // 交班留言
        abnormalSituation: '', // 异常情况
        workOrder: '', // 工单
        abnormalCondition: [], // 工单详情信息
        otherThings: '' // 其他情况
      }
      // this.getCurrentFrequency()
      setTimeout(() => {
        $('#dialog123').find('.el-dialog__header').css({ 'padding': '20px 0px 0px 0px' })
        $('#dialog123').find('.el-collapse-item__content').css({ 'padding-bottom': '10px' })
      }, 100)
      this.dialogFormVisible = true
      this.isAllowSuccession()
    },
    isAllow() {
      this.isAllowSuccession()
    },
    // 工单查询
    getworkOrders() {
      var param = []
      this.workOrders = []
      param[0] = ['排序方式', '']
      param[1] = ['关键字', '']
      param[2] = ['关键字_check', 0]
      param[3] = ['车间', '']
      param[4] = ['车间_check', 0]
      param[5] = ['产线', '']
      param[6] = ['产线_check', 0]
      param[7] = ['工序', '']
      param[8] = ['工序_check', 0]
      param[9] = ['人员代码', this.id]
      param[10] = ['角色代码', this.token]
      param[11] = ['班组代码', this.form.maintenanceTeam]
      var Data = this.CreateData('11', '维修工单_当前工单_查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.workOrders.push({
              label: response.data[i].工单号,
              value: response.data[i].维修工单代码
            })
          }
        }
      })
    },
    // 往交接班表中增加工单信息
    addOrderInfo() {
      var param = []
      param[0] = ['维修工单代码', this.form.workOrder]
      var Data = this.CreateData('11', '维修工单_当前工单详情_查询_交接班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          var newOrder = response.data.filter(obj => {
            return this.workOrdersGroup.indexOf(obj.维修工单代码) === -1
          })
          for (let i = 0; i < newOrder.length; i++) {
            this.form.abnormalCondition.push({
              workOrderCode: newOrder[0].维修工单代码, // 维修人员
              workOrder: newOrder[0].工单号, // 维修人员
              maintenancePeople: newOrder[0].维修人员姓名, // 维修人员
              productionLine: newOrder[0].产线名称, // 生产线
              equipmentName: newOrder[0].设备名称, // 设备名称
              equipmentCode: newOrder[0].设备编号, // 设备名称
              processNumber: newOrder[0].工序名称, // 工序号
              receivingTime: newOrder[0].开始时间, // 故障接报时间
              maintenanceTime: newOrder[0].持续时长, // 故障维修时间
              faultPhenomenon: newOrder[0].故障现象, // 故障现象
              completionSituation: '', // 完成情况
              treatmentSituation: '' // 维修或处理情况
            })
            this.workOrdersGroup.push(newOrder[0].维修工单代码)
          }
          setTimeout(() => {
            this.jumpOrderPosition(this.form.workOrder)
          }, 100)
        }
      })
    },
    // 删除接班表中工单信息
    deleteOrderInfo() {
      this.form.abnormalCondition = this.form.abnormalCondition.filter(res => {
        return this.form.workOrder !== res.workOrderCode
      })
      this.workOrdersGroup = this.workOrdersGroup.filter(res => {
        return this.form.workOrder !== res
      })
    },
    // 跳转组件对应的工单信息，
    jumpOrderPosition(workOrder) {
      this.$refs.workerOrderCarousel.setActiveItem(this.workOrdersGroup.findIndex(value => { return value === workOrder }))
    },
    // 增加确定交班信息
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let workOrderGroup = ''
          let faultPhenomenonGroup = ''
          let finishTypeGroup = ''
          let handlingInformationGroup = ''
          let state = 0
          if (this.form.EquipmentOperation === 2) {
            if (!this.form.abnormalCondition.length) state = 1
            this.form.abnormalCondition.forEach(value => {
              if (!value.completionSituation) state = 1
              workOrderGroup += (value.workOrderCode + '^')
              faultPhenomenonGroup += (value.faultPhenomenon + '^')
              finishTypeGroup += (value.completionSituation + '^')
              handlingInformationGroup += (value.treatmentSituation + '^')
            })
            workOrderGroup = workOrderGroup.substring(0, workOrderGroup.lastIndexOf('^'))
            faultPhenomenonGroup = faultPhenomenonGroup.substring(0, faultPhenomenonGroup.lastIndexOf('^'))
            finishTypeGroup = finishTypeGroup.substring(0, finishTypeGroup.lastIndexOf('^'))
            handlingInformationGroup = handlingInformationGroup.substring(0, handlingInformationGroup.lastIndexOf('^'))
          }
          if (state) {
            this.$message.error('当前交接单中工单信息不完整！')
            return
          }
          var param = []
          param[0] = ['交班负责人员代码', this.form.responsiblePerson]
          param[1] = ['维修班组代码', this.form.maintenanceTeam]
          param[2] = ['班次代码', this.form.Frequency]
          param[3] = ['安全方面代码', this.form.Safety]
          param[4] = ['设备运转情况代码', this.form.EquipmentOperation]
          param[5] = ['异常情况', this.form.abnormalSituation]
          param[6] = ['交班留言', this.form.LeaveMessage]
          param[7] = ['维修工单代码组', workOrderGroup]
          param[8] = ['故障现象组', faultPhenomenonGroup]
          param[9] = ['完成情况代码组', finishTypeGroup]
          param[10] = ['维修或处理情况组', handlingInformationGroup]
          param[11] = ['其他情况', this.form.otherThings]
          var Data = this.CreateData('11', '维修工单_交接班增加_循环增加', param)
          ExecDatabase(Data).then(response => {
            if (response.data[0].result === 1) {
              this.$message({
                message: '交接班信息提交成功！',
                type: 'success'
              })
              this.dialogFormVisible = false
              this.searchTable()
            } else {
              this.$message.error('交接班信息提交失败！')
            }
          })
        } else {
          return false
        }
      })
    },
    // 查询单条交接班信息
    searchExceptionTable(row) {
      var param = []
      this.workOrders = []
      this.completionSituations = []
      this.form1 = {}
      param[0] = ['交接班记录流水号', row.交接班记录流水号]
      var Data = this.CreateData('11', '设备维修_班组交接班记录工单详情_查询数据', param)
      ExecDatabase(Data).then(response => {
        var abnormalCondition = []
        if (response.data.length !== 0) {
          for (let i = 0; i < response.data.length; i++) {
            this.workOrders.push({
              label: response.data[i].维修工单号,
              value: response.data[i].维修工单代码
            })
            this.completionSituations.push({
              label: response.data[i].完成情况,
              value: response.data[i].完成情况代码
            })

            var obj = {}
            this.completionSituations = this.completionSituations.reduce((item, next) => {
              obj[next.value] ? '' : obj[next.value] = item.push(next)
              return item
            }, [])
            abnormalCondition.push({
              workOrder: response.data[i].维修工单号,
              maintenancePeople: response.data[i].维修人员,
              productionLine: response.data[i].生产线,
              equipmentName: response.data[i].设备名称,
              processNumber: response.data[i].工序号,
              faultPhenomenon: response.data[i].故障现象,
              receivingTime: response.data[i].故障接报时间,
              maintenanceTime: response.data[i].故障维修时间,
              completionSituation: response.data[i].完成情况代码,
              treatmentSituation: response.data[i].维修或处理情况,
              otherThings: response.data[i].其他情况
            })
          }
        }
        this.form1 = {
          Frequency: row.班次代码, // 班次
          maintenanceTeam: row.维修班组代码, // 班组
          responsiblePerson: row.交班负责人员代码, // 交班负责人
          EquipmentOperation: row.设备运转情况代码, // 设备运转情况
          Safety: row.安全方面代码, // 安全方面
          LeaveMessage: row.交班留言, // 交班留言
          abnormalSituation: row.异常情况, // 异常情况
          workOrder: this.workOrders.length ? this.workOrders[0].value : '', // 工单
          abnormalCondition: abnormalCondition, // 工单详情信息
          otherThings: abnormalCondition.length ? abnormalCondition[0].otherThings : '' // 其他情况
        }
        this.title1 = '设备维修交班查看'
        setTimeout(() => {
          $('#dialog124').find('.el-dialog__header').css({ 'padding': '20px 0px 0px 0px' })
          $('#dialog124').find('.el-collapse-item__content').css({ 'padding-bottom': '10px' })
        }, 100)
        this.dialogFormVisible1 = true
      })
    },
    // 编辑条交接班信息
    editExceptionTable(row) {
      var param = []
      this.getFrequency()
      this.getEquipmentOperations()
      this.getSafetys()
      this.getcompletionSituations()
      this.getworkOrders()
      this.completionSituations = []
      this.workOrdersGroup = []
      param[0] = ['交接班记录流水号', row.交接班记录流水号]
      var Data = this.CreateData('11', '设备维修_班组交接班记录工单详情_查询数据', param)
      ExecDatabase(Data).then(response => {
        var abnormalCondition = []
        if (response.data.length !== 0) {
          for (let i = 0; i < response.data.length; i++) {
            abnormalCondition.push({
              workOrderCode: response.data[i].维修工单代码,
              workOrder: response.data[i].维修工单号,
              maintenancePeople: response.data[i].维修人员,
              productionLine: response.data[i].生产线,
              equipmentName: response.data[i].设备名称,
              processNumber: response.data[i].工序号,
              faultPhenomenon: response.data[i].故障现象,
              receivingTime: response.data[i].故障接报时间,
              maintenanceTime: response.data[i].故障维修时间,
              completionSituation: response.data[i].完成情况代码,
              treatmentSituation: response.data[i].维修或处理情况,
              otherThings: response.data[i].其他情况
            })
            this.workOrdersGroup.push(response.data[i].维修工单代码)
          }
        }
        this.form = {
          Frequency: row.班次代码, // 班次
          maintenanceTeam: row.维修班组代码, // 班组
          responsiblePerson: row.交班负责人员代码, // 交班负责人
          EquipmentOperation: row.设备运转情况代码, // 设备运转情况
          Safety: row.安全方面代码, // 安全方面
          LeaveMessage: row.交班留言, // 交班留言
          abnormalSituation: row.异常情况, // 异常情况
          abnormalCondition: abnormalCondition, // 工单详情信息
          otherThings: abnormalCondition.length ? abnormalCondition[0].otherThings : '' // 其他情况
        }
        this.title = '设备维修交班录入'
        setTimeout(() => {
          $('#dialog123').find('.el-dialog__header').css({ 'padding': '20px 0px 0px 0px' })
          $('#dialog123').find('.el-collapse-item__content').css({ 'padding-bottom': '10px' })
        }, 100)
        this.dialogFormVisible = true
      })
    },
    // 判断是否允许进行交班填写
    isAllowSuccession() {
      var param = []
      param[0] = ['维修班组代码', this.form.maintenanceTeam]
      var Data = this.CreateData('11', '维修工单_交接班_是否允许交班', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length > 0) {
          if (response.data[0].result === 0) {
            this.isAllowSubmit = false
            this.isExistInfo = false
            this.form.EquipmentOperation = ''
            this.form.Safety = ''
            this.form.LeaveMessage = ''
            this.form.abnormalSituation = ''
            this.form.workOrder = ''
            this.form.abnormalCondition = []
            this.form.otherThings = ''
          } else {
            this.isAllowSubmit = true
            this.isExistInfo = true
          }
        }
      })
    },
    // 拉取已经存在的信息
    getExistInfos() {
      var param = []
      param[0] = ['维修班组代码', this.form.maintenanceTeam]
      var Data = this.CreateData('11', '维修工单_交接班_当前班组交接信息', param)
      ExecDatabase(Data).then(response => {
        if (response.data.length !== 0) {
          const row = {
            交接班记录流水号: response.data[0].交接班记录流水号,
            班次代码: response.data[0].班次代码, // 班次
            维修班组代码: response.data[0].维修班组代码, // 班组
            交班负责人员代码: parseInt(this.id), // 交班负责人
            设备运转情况代码: response.data[0].设备运转情况代码, // 设备运转情况
            安全方面代码: response.data[0].安全方面代码, // 安全方面
            交班留言: response.data[0].交班留言, // 交班留言
            异常情况: response.data[0].异常情况 // 异常情况
          }
          this.isAllowSubmit = false
          this.isExistInfo = false
          this.editExceptionTable(row)
        }
      })
    },
    // 删除交班信息
    handleDelete(row) {
      this.$confirm('此操作将删除本次交班记录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['交接班记录流水号', row.交接班记录流水号]
        var Data = this.CreateData('12', '维修工单_交接班删除', param)
        ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message.success('删除成功')
            this.searchTable()
          } else {
            this.$message.error('删除失败')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消删除'
        })
      })
    },
    // 增加取消
    callOff(formName) {
      this.dialogFormVisible = false
      this.$refs[formName].resetFields()
    },
    // 发起接班
    Succession(row) {
      if (this.$refs['form2'] !== undefined) {
        this.$refs['form2'].resetFields()
      }
      $('#dialog125').find('.el-dialog__header').css({ 'padding': '20px 0px 0px 0px' })
      this.form2.abnormalNumber = row.交接班记录流水号
      this.title2 = '接 班'
      this.dialogFormVisible2 = true
      setTimeout(() => {
        $('#dialog125').find('.el-form-item__label').css({ 'line-height': '40px' })
      }, 100)
    },
    // 确定接班
    submitSuccession(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var param = []
          param[0] = ['接班负责人员代码', this.form2.responsiblePerson]
          param[1] = ['交接班记录流水号', this.form2.abnormalNumber]
          var Data = this.CreateData('12', '维修工单_交接班_确认接班', param)
          ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '接班成功!',
                type: 'success'
              })
              this.searchTable()
            } else {
              this.$message.error('接班失败!')
            }
          })
          this.dialogFormVisible2 = false
        } else {
          return false
        }
      })
    },
    // 页码变化
    handleSizeChange(val) {
      this.pageList = 1
      this.pageSize = val
      this.searchTable()
    },
    handleCurrentChange(val) {
      this.pageList = val
      this.searchTable()
    }
  }
}
</script>
<style scoped lang="scss">
  .el-form-item{
    margin-bottom: 5px;
  }
</style>

