<template>
  <div class="app-container">
    <div class="filter-container">
      <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" style="width: 120px;">
        <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
      </el-select>
      <el-input v-model="getdataListParm.parammaps.repairCode" placeholder="报修单号" clearable style="width: 130px;" class="filter-item" />
      <el-input v-model="getdataListParm.parammaps.eqName" placeholder="设备名称" clearable style="width: 130px;" class="filter-item" />
      <el-input v-model="getdataListParm.parammaps.eqCode" placeholder="设备内部编号" clearable style="width: 130px;" class="filter-item" />
      <el-select v-model="getdataListParm.parammaps.orderStatue" clearable placeholder="处理状态" class="filter-item" style="width: 120px;">
        <el-option v-for="item in orderStatues" :key="item.id" :label="item.name" :value="item.id" />
      </el-select>
      <el-select v-model="getdataListParm.parammaps.SHStatue" clearable placeholder="审核状态" class="filter-item" style="width: 120px;">
        <el-option v-for="item in SHStatues" :key="item.id" :label="item.name" :value="item.id" />
      </el-select>
      <el-date-picker
        ref="inputDatetime"
        v-model="getdataListParm.parammaps.inputDatetime"
        class="inputDatetime"
        type="datetimerange"
        style="width: 250px;top:-3px;"
        format="yyyy-MM-dd"
        value-format="yyyy-MM-dd"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
      />
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
      <div>
        <el-button v-if="isRepair" class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">报修</el-button>
        <!-- 临时注释 -->
        <el-button v-if="isRepairExport" class="filter-item" type="success" icon="el-icon-download" style="" @click="handleDownload">导出</el-button>
        <!-- 临时注释 -->
        <el-radio-group v-model="radioAll" style="margin-top:-9px" @change="changeAll()">
          <el-radio-button label="全部" />
          <el-badge :value="pending.total" class="item">
            <el-radio-button label="待处理" />
          </el-badge>
          <el-radio-button label="已处理" />
        </el-radio-group>
      </div>
    </div>
    <el-table
      :key="tableKey"
      v-loading="listLoading"
      element-loading-text="给我一点时间"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%;"
      :row-style="rowStyle"
      :cell-style="cellStyle"
      class="elTable table-fixed"
    >
      <el-table-column label="序号" align="center" type="index" width="50px">
        <template slot-scope="scope">
          <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报修单号" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.repairCode }}</span>
        </template>
      </el-table-column>
      <el-table-column label="牧场" width="140px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.pastureName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="设备内部编号" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.eqCode }}</span>
        </template>
      </el-table-column>
      <el-table-column label="设备名称" min-width="100px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.eqName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="规格型号" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.specification }}</span>
        </template>
      </el-table-column>
      <el-table-column label="部门" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.departmentName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="故障情况" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.details }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报修人" min-width="100px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.requesterName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报修时间" sortable prop="requestTime" min-width="110px" align="center" />
      <el-table-column label="维修日期" sortable prop="stopTime" min-width="110px" align="center" />
      <el-table-column label="维修部门" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.repairDeptName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="处理状态" min-width="100px" align="center" :formatter="orderStatue" />
      <el-table-column label="领用单状态" min-width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.LYStatue }}</span>
        </template>
      </el-table-column>
      <el-table-column label="旧品录入状态" min-width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.LRStatue }}</span>
        </template>
      </el-table-column>
      <el-table-column label="审核状态" min-width="100px" align="center" :formatter="SHStatue" />
      <el-table-column label="操作" align="center" min-width="400" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="{row}">
          <el-button v-if="isMaintenanceSee" type="primary" size="mini" @click="form_see(row)">查看</el-button>
          <!-- 维修审核 -->
          <el-button v-if="(row.SHStatue == 2) && isMaintenanceAudit && row.requesterId == getdataListParm.parammaps.loginId" style="display:inline-block" type="success" size="mini" class="successMaintenanceAudit" @click="handleExamine(row)">维修审核</el-button>
          <el-button v-else style="display:none" type="success" size="mini" class="successMaintenanceAudit" @click="handleExamine(row)">维修审核</el-button>
          <!-- 维修审核2 -->
          <el-button v-if="(row.SHStatue == 3) && isMaintenanceAudit2" style="display:inline-block" type="success" size="mini" class="successMaintenanceAudit" @click="handleExamine2(row)">维修审核2</el-button>
          <el-button v-else style="display:none" type="success" size="mini" class="successMaintenanceAudit" @click="handleExamine2(row)">主管审核</el-button>
          <!-- 派单 -->
          <el-button v-if="(row.orderStatue == 0) && isDistributeLeaflets" style="display:inline-block" type="success" size="mini" @click="handleDistributeLeaflets(row)">派单</el-button>
          <el-button v-else-if="(row.orderStatue == 1 ||row.orderStatue == 2 )" style="display:none" type="success" size="mini" @click="handleDistributeLeaflets(row)">派单</el-button>
          <!-- 接单 -->
          <el-button v-if="(row.orderStatue == 0 && isReceipt && (row.pickId == getdataListParm.parammaps.loginId))" style="display:inline-block" type="success" size="mini" @click="handleReceipt(row)">接单</el-button>
          <el-button v-else-if="(row.orderStatue == 1 ||row.orderStatue == 2 )" style="display:none" type="success" size="mini" @click="handleReceipt(row)">接单</el-button>
          <!-- 维修及领用 -->
          <el-button v-if="(row.orderStatue == 1 && row.SHStatue== 1 || row.SHStatue== 4 || row.SHStatue== 6) && isMaintenanceRequisition && (row.pickId == getdataListParm.parammaps.loginId)" style="display:inline-block" type="success" size="mini" class="successRequisition" @click="handleMaintenanceRequisition(row)">维修及领用</el-button>
          <el-button v-else style="display:none" type="success" size="mini" class="successRequisition" @click="handleMaintenanceRequisition(row)">维修及领用</el-button>
          <!-- 完成维修 -->
          <el-button v-if="(row.orderStatue == 1 && (row.SHStatue == 1 || row.SHStatue== 4 || row.SHStatue== 6)) && isRepairComplete && (row.pickId == getdataListParm.parammaps.loginId)" style="display:inline-block" type="success" size="mini" class="successMaintenanceAudit" @click="handleRepairComplete(row)">完成维修</el-button>
          <el-button v-else style="display:none" type="success" size="mini" class="successMaintenanceAudit" @click="handleRepairComplete(row)">完成维修</el-button>
          <!-- 删除 -->
          <el-button v-if="((row.orderStatue == 0 && row.SHStatue == 1) && isDelete)" style="display:inline-block" type="danger" size="mini" @click="form_delete(row)">删除</el-button>
          <el-button v-else style="display:none" type="success" size="danger" @click="form_delete(row)">删除</el-button>
          <!-- 驳回报修 -->
          <el-button v-if="(row.orderStatue == 0 && isRejectRepair)" style="display:inline-block;" type="success" class="successMaintenanceAudit" size="mini" @click="handleRejectRepair(row)">报修驳回</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination v-show="total>0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="getList" />
  
  
      <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_Create" :close-on-click-modal="false" width="90%">
      <div class="app-create">
        <el-form ref="createTemp" :rules="rules" :model="createTemp" label-position="right" label-width="120px" style="width: 90%;margin:0 auto;">
          <el-row>
            <el-col :span="8">
              <el-form-item label="报修单号：" prop="repairCode">
                <el-input ref="repairCode" v-model="createTemp.repairCode" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="设备名称：" prop="eqName">
                <el-autocomplete
                  v-model="createTemp.eqName"
                  class="inline-input"
                  :fetch-suggestions="querySearchEqName"
                  value-key="eqName"
                  placeholder="设备名称"
                  style="width:100%"
                  @select="handleSelectEqName"
                >
                  <template slot-scope="{ item }">
                    <b>名称：</b><span>{{ item.eqName }}</span>&nbsp;
                    |&nbsp;<b>规格：</b><span>{{ item.specification }}</span>
                  </template>
                </el-autocomplete>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="设备内部编号：" prop="eqCode">
                <el-autocomplete
                  v-model="createTemp.eqCode"
                  class="inline-input"
                  :fetch-suggestions="querySearchCode"
                  style="width:100%"
                  value-key="eqCode"
                  placeholder="设备内部编号"
                  @select="handleSelectEqCode"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="维修人:" prop="pickId">
                <el-select v-model="createTemp.pickId" placeholder="维修人" filterable class="filter-item" style="width:100%" @change="changePickId">
                  <el-option v-for="item in maintainers" :key="item.id" :label="item.empNameAndmt" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="故障情况：" prop="details">
                <el-input ref="details" v-model="createTemp.details" />
              </el-form-item>
               <!-- 这里PC和APP都需要等后端接口出来，是选了设备后带出故障内容。T T -->
              <!-- <el-form-item label="故障情况：" prop="pickId">
                <el-select v-model="createTemp.pickId" placeholder="故障情况" filterable class="filter-item" style="width:100%" @change="changePickId">
                  <el-option v-for="item in maintainers" :key="item.id" :label="item.empNameAndmt" :value="item.id" />
                </el-select>
                
              </el-form-item> -->




            </el-col>
            <el-col :span="8">
              <el-form-item label="牧场：" prop="pastureName">
                <el-select v-model="createTemp.pastureId" style="width: 100%;" placeholder="牧场" class="filter-item">
                  <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="部门：" prop="deptName">
                <el-input ref="deptName" v-model="createTemp.deptName" disabled />
              </el-form-item>
              <!-- <el-form-item label="部门：" prop="departmentId">
                <el-select v-model="createTemp.departmentId" placeholder="部门" class="filter-item" style="width:100%">
                  <el-option
                    v-for="item in findAllDepart"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item> -->
            </el-col>
            <el-col :span="8">
              <el-form-item label="报修人：" prop="requesterId">
                <el-select ref="requesterId" v-model="createTemp.requesterId" placeholder="报修人" class="filter-item" style="width:100%">
                  <el-option
                    v-for="item in findAllEmploye"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="报修日期：" prop="requestTime">
                <el-date-picker
                  v-model="createTemp.requestTime"
                  :picker-options="pickerOptions1"
                  type="datetime"
                  placeholder="报修日期"
                  format="yyyy-MM-dd HH:mm"
                  value-format="yyyy-MM-dd HH:mm"
                  style="width: 100%;"
                  disabled
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
        <el-button @click="dialogFormVisible_Create = false;getList()">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_See" :close-on-click-modal="false" width="90%">
      <div class="app-see">
        <div v-if="orderStatue1" class="see">
          <el-form ref="seeTemp" :rules="rules" :model="seeTemp" label-position="right" label-width="130px" style="width: 90%;margin:0 auto;">
            <el-row>
              <el-col :span="8">
                <el-form-item label="报修单号：" prop="repairCode">
                  <el-input ref="repairCode" v-model="seeTemp.repairCode" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="设备名称：" prop="eqName">
                  <el-input ref="eqName" v-model="seeTemp.eqName" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="设备内部编号：" prop="eqCode">
                  <el-input ref="eqCode" v-model="seeTemp.eqCode" disabled />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <!-- <el-col :span="8">
                <el-form-item label="维修组：" prop="repairDeptName">
                  <el-input ref="repairDeptName" v-model="seeTemp.repairDeptName" disabled />
                </el-form-item>
              </el-col> -->
              <el-col :span="8">
                <el-form-item label="维修人：" prop="pickName">
                  <el-input ref="pickName" v-model="seeTemp.pickName" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="故障情况：" prop="details">
                  <el-input ref="details" v-model="seeTemp.details" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="牧场：" prop="pastureName">
                  <el-input ref="pastureName" v-model="seeTemp.pastureName" disabled />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="8">
                <el-form-item label="部门：" prop="departmentName">
                  <el-input ref="departmentName" v-model="seeTemp.departmentName" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="报修人：" prop="requesterName">
                  <el-input ref="requesterName" v-model="seeTemp.requesterName" disabled />
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="报修日期：" prop="requestTime">
                  <el-input ref="requestTime" v-model="seeTemp.requestTime" disabled />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col v-if="seeTemp.orderStatue == 3" :span="8">
                <el-form-item label="驳回日期：" prop="shutdownDate">
                  <el-input ref="shutdownDate" v-model="seeTemp.shutdownDate" disabled />
                </el-form-item>
              </el-col>
              <el-col v-if="seeTemp.orderStatue == 3" :span="8">
                <el-form-item label="驳回原因：" prop="shutdownReason">
                  <el-input ref="shutdownReason" v-model="seeTemp.shutdownReason" disabled />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <h3>流程进度</h3>
                <el-steps :active="active" align-center finish-status="success">
                  <el-step
                    v-for="(item,index) in activeList"
                    :key="index"
                    :title="item.title"
                    :status="item.status"
                  >
                    <template slot="description">
                      <div class="step-row">
                        <div>{{ item.name }}&nbsp;&nbsp;{{ item.date }}</div>
                        <div>{{ item.reason }}</div>
                        <div>{{ item.scores }}</div>

                      </div>
                    </template>
                  </el-step>
                </el-steps>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <el-form-item label="操作：">
                  <!-- 维修审核 -->
                  <el-button v-if="(seeTemp.SHStatue == 2) && isMaintenanceAudit && seeTemp.requesterId == getdataListParm.parammaps.loginId" style="display:inline-block" type="success" @click="handleExamine()">维修审核</el-button>
                  <el-button v-else style="display:none" type="success" @click="handleExamine()">维修审核</el-button>
                  <!-- 维修审核2 -->
                  <el-button v-if="(seeTemp.SHStatue == 3) && isMaintenanceAudit2" style="display:inline-block" type="success" @click="handleExamine2(row)">维修审核2</el-button>
                  <el-button v-else style="display:none" type="success" @click="handleExamine2()">主管审核</el-button>
                  <!-- 派单 -->
                  <el-button v-if="(seeTemp.orderStatue == 0) && isDistributeLeaflets" style="display:inline-block" type="success" @click="handleDistributeLeaflets()">派单</el-button>
                  <el-button v-else-if="(seeTemp.orderStatue == 1 ||seeTemp.orderStatue == 2 )" style="display:none" type="success" @click="handleDistributeLeaflets()">派单</el-button>
                  <!-- 接单 -->
                  <el-button v-if="(seeTemp.orderStatue == 0 && isReceipt && (seeTemp.pickId == getdataListParm.parammaps.loginId))" style="display:inline-block" type="success" @click="handleReceipt()">接单</el-button>
                  <el-button v-else-if="(seeTemp.orderStatue == 1 ||seeTemp.orderStatue == 2 )" style="display:none" type="success" @click="handleReceipt()">接单</el-button>
                  <!-- 维修及领用 -->
                  <el-button v-if="(seeTemp.orderStatue == 1 && seeTemp.SHStatue== 1 || seeTemp.SHStatue== 4 || seeTemp.SHStatue== 6) && isMaintenanceRequisition && (seeTemp.pickId == getdataListParm.parammaps.loginId)" style="display:inline-block" type="success" @click="handleMaintenanceRequisition()">维修及领用</el-button>
                  <el-button v-else style="display:none" @click="handleMaintenanceRequisition()">维修及领用</el-button>
                  <!-- 完成维修 -->
                  <el-button v-if="(seeTemp.orderStatue == 1 && (seeTemp.SHStatue == 1 || seeTemp.SHStatue== 4 || seeTemp.SHStatue== 6)) && isRepairComplete && (seeTemp.pickId == getdataListParm.parammaps.loginId)" style="display:inline-block" type="success" @click="handleRepairComplete()">完成维修</el-button>
                  <el-button v-else style="display:none" @click="handleRepairComplete()">完成维修</el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <div v-if="orderStatue2" class="see">
          <el-tabs v-model="activeName">
            <el-tab-pane label="基础信息" name="first">
              <el-form ref="seeTemp" :rules="rules" :model="seeTemp" label-position="right" label-width="130px" style="width: 90%;margin:0 auto;">
                <el-row>
                  <el-col :span="8">
                    <h3>报修信息</h3>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="报修单号：" prop="repairCode">
                      <el-input ref="repairCode" v-model="seeTemp.repairCode" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备名称：" prop="eqName">
                      <el-input ref="eqName" v-model="seeTemp.eqName" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备内部编号：" prop="eqCode">
                      <el-input ref="eqCode" v-model="seeTemp.eqCode" disabled />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <!-- <el-col :span="8">
                    <el-form-item label="维修组：" prop="repairDeptName">
                      <el-input ref="repairDeptName" v-model="seeTemp.repairDeptName" disabled />
                    </el-form-item>
                  </el-col> -->
                  <el-col :span="8">
                    <el-form-item label="维修人：" prop="pickName">
                      <el-input ref="pickName" v-model="seeTemp.pickName" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="故障情况：" prop="details">
                      <el-input ref="details" v-model="seeTemp.details" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="牧场：" prop="pastureName">
                      <el-input ref="pastureName" v-model="seeTemp.pastureName" disabled />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="部门：" prop="departmentName">
                      <el-input ref="departmentName" v-model="seeTemp.departmentName" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="报修人：" prop="requesterName">
                      <el-input ref="requesterName" v-model="seeTemp.requesterName" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="报修日期：" prop="requestTime">
                      <el-input ref="requestTime" v-model="seeTemp.requestTime" disabled />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <h3>维修信息</h3>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="维修日期：" prop="stopTime">
                      <el-input ref="stopTime" v-model="seeTemp.stopTime" disabled />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <h3>故障诊断</h3>
                  </el-col>
                </el-row>
              </el-form>
              <el-table
                :key="tableKey"
                v-loading="listLoadingFault"
                element-loading-text="给我一点时间"
                :data="listFault"
                border
                fit
                highlight-current-row
                style="width: 90%;margin:0 auto"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
              >
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="故障部位" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.positionName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="故障详情" prop="appearanceName" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.appearanceName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="故障原因" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.failureCause }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="处理方式" prop="treatmentMethod" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.treatmentMethod }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <el-form
                ref="seeTemp"
                :rules="rules"
                :model="seeTemp"
                label-position="right"
                label-width="120px"
                style="width: 90%;margin:0 auto;"
              >
                <el-row>
                  <el-col>
                    <h3>流程进度</h3>
                    <el-steps :active="active" align-center finish-status="success">
                      <el-step
                        v-for="(item,index) in activeList"
                        :key="index"
                        :title="item.title"
                        :status="item.status"
                      >
                        <template slot="description" style="font-size:18px">
                          <div class="step-row">
                            <div>{{ item.name }}</div>
                            <div>{{ item.date }}</div>
                            <div>{{ item.reason }}</div>
                            <div>{{ item.scores }}</div>
                          </div>
                        </template>
                      </el-step>
                    </el-steps>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col>
                    <h3 style="display:inline">操作</h3>
                    <!-- 维修审核 -->
                    <el-button v-if="(seeTemp.SHStatue == 2) && isMaintenanceAudit && seeTemp.requesterId == getdataListParm.parammaps.loginId" style="display:inline-block" type="success" @click="handleExamine()">维修审核</el-button>
                    <el-button v-else style="display:none" type="success" @click="handleExamine()">维修审核</el-button>
                    <!-- 维修审核2 -->
                    <el-button v-if="(seeTemp.SHStatue == 3) && isMaintenanceAudit2" style="display:inline-block" type="success" @click="handleExamine2(row)">维修审核2</el-button>
                    <el-button v-else style="display:none" type="success" @click="handleExamine2()">主管审核</el-button>
                    <!-- 派单 -->
                    <el-button v-if="(seeTemp.orderStatue == 0) && isDistributeLeaflets" style="display:inline-block" type="success" @click="handleDistributeLeaflets()">派单</el-button>
                    <el-button v-else-if="(seeTemp.orderStatue == 1 ||seeTemp.orderStatue == 2 )" style="display:none" type="success" @click="handleDistributeLeaflets()">派单</el-button>
                    <!-- 接单 -->
                    <el-button v-if="(seeTemp.orderStatue == 0 && isReceipt && (seeTemp.pickId == getdataListParm.parammaps.loginId))" style="display:inline-block" type="success" @click="handleReceipt()">接单</el-button>
                    <el-button v-else-if="(seeTemp.orderStatue == 1 ||seeTemp.orderStatue == 2 )" style="display:none" type="success" @click="handleReceipt()">接单</el-button>
                    <!-- 维修及领用 -->
                    <el-button v-if="(seeTemp.orderStatue == 1 && seeTemp.SHStatue== 1 || seeTemp.SHStatue== 4 || seeTemp.SHStatue== 6) && isMaintenanceRequisition && (seeTemp.pickId == getdataListParm.parammaps.loginId)" style="display:inline-block" type="success" @click="handleMaintenanceRequisition()">维修及领用</el-button>
                    <el-button v-else style="display:none" type="success" @click="handleMaintenanceRequisition()">维修及领用</el-button>
                    <!-- 完成维修 -->
                    <el-button v-if="(seeTemp.orderStatue == 1 && (seeTemp.SHStatue == 1 || seeTemp.SHStatue== 4 || seeTemp.SHStatue== 6)) && isRepairComplete && (seeTemp.pickId == getdataListParm.parammaps.loginId)" style="display:inline-block" type="success" @click="handleRepairComplete()">完成维修</el-button>
                    <el-button v-else style="display:none" type="success" @click="handleRepairComplete()">完成维修</el-button>
                  </el-col>
                </el-row>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="领用记录" name="second">
              <el-table
                :key="tableKey"
                v-loading="listLoadingCollarUse"
                element-loading-text="给我一点时间"
                :data="listCollarUse"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
                @cell-click="openDetails"
              >
                <!-- table表格 -->
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="领用单号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.applyCode }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="领用部门" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.departmentName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="领用日期" sortable prop="createDate" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.createDate }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="领用明细" prop="details" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.details }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="领用状态" min-width="110px" align="center" :formatter="statue" />
                <el-table-column label="操作" min-width="110px" align="center">
                  <template slot-scope="{row}">
                    <el-button type="primary" size="mini" @click="handleCollarUseSee(row,0)">查看</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="旧品录入记录" name="third">
              <el-table
                :key="tableKey"
                v-loading="listLoadingOldProducts"
                element-loading-text="给我一点时间"
                :data="listOldProducts"
                border
                fit
                highlight-current-row
                style="width: 100%;"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable"
                @sort-change="tableSort1"
              >
                <el-table-column label="序号" align="center" type="index" width="50px">
                  <template slot-scope="scope">
                    <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件编号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partCode }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件名称" prop="id" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件规格" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="录入数量" sortable prop="acturalAmount" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.acturalAmount }}</span>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
      <div slot="footer" class="dialog-footer" style="bottom:5px;">
        <el-button @click="dialogFormVisible_See = false">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 派单 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_DistributeLeaflets" :close-on-click-modal="false" width="50%">
      <div class="distributeLeaflets">
        <el-form
          ref="distributeLeafletsTemp"
          :rules="rules"
          :model="distributeLeafletsTemp"
          label-position="right"
          label-width="120px"
          style="width: 90%;margin:0 auto;"
        >
          <el-row>
            <el-col :span="20">
              <el-form-item label="维修人:" prop="pickId">
                <el-select v-model="distributeLeafletsTemp.pickId" filterable placeholder="维修人" class="filter-item" style="width:100%" @change="changePickId">
                  <el-option v-for="item in maintainers" :key="item.id" :label="item.empNameAndmt" :value="item.id" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <el-form-item label="派单人：" prop="chargeId">
                <el-select v-model="distributeLeafletsTemp.chargeId" placeholder="派单人" class="filter-item" style="width:100%">
                  <el-option
                    v-for="item in findAllEmploye"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <el-form-item label="派单日期：" prop="chargeDate">
                <el-date-picker
                  v-model="distributeLeafletsTemp.chargeDate"
                  :picker-options="pickerOptions1"
                  type="date"
                  placeholder="派单日期"
                  style="width:100%;"
                  format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='distributeLeaflets'?createDistributeLeafletsData():createDistributeLeafletsData()">确认</el-button>
        <el-button @click="dialogFormVisible_DistributeLeaflets = false;">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 审核 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_MaintenanceAudit" :close-on-click-modal="false" width="30%">
      <div class="maintenanceAudit">
        <h3 style="width: 100%;margin:0 0 0 5%;line-height:50px;">请确认维修审核结果:</h3>
        <el-form ref="examineTemp" :rules="rules" :model="examineTemp" label-position="right" style="width: 60%;height:150px;margin:0 auto;">
          <el-row style="width:90%;margin:0 auto;">
            <el-col :span="20">
              <el-form-item>
                <el-radio-group v-model="examineTemp.statue" @change="changeStatue">
                  <el-radio :label="3" checked>通过</el-radio>
                  <el-radio :label="4">不通过</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col v-if="statueReason" :span="20">
              <el-input v-model="examineTemp.workflowNote" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入审核不通过原因" />
            </el-col>
          </el-row>
          <el-row v-if="examineTemp.SHStatue == 2 && examineTemp.statue== 3" style="width:90%;margin:0 auto;">
            <el-col :span="24">
              <el-form-item label="评分：" prop="scores">
                <el-rate v-model="examineTemp.scores" show-text :texts="['1分','2分', '3分', '4分', '5分']" style="width:100%;margin-top:10px;" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='maintenanceAudit'?createExamineData():createExamineData2()">确认</el-button>
        <el-button @click="dialogFormVisible_MaintenanceAudit = false;">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_RepairComplete" :close-on-click-modal="false" width="50%">
      <div class="repairComplete">
        <el-form
          ref="repairCompleteTemp"
          :rules="rules"
          :model="repairCompleteTemp"
          label-position="right"
          label-width="120px"
          style="width: 90%;margin:0 auto;"
        >
          <el-row>
            <el-col :span="20">
              <el-form-item label="是否录入旧品：" prop="isOldProducts">
                <el-radio-group v-model="repairCompleteTemp.isOldProducts" @change="changeIsOldProducts">
                  <el-radio :label="0" checked>否</el-radio>
                  <el-radio :label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-if="No2">
            <el-col :span="24">
              <el-form-item label="旧品录入：" prop="partCode">
                <el-autocomplete
                  v-model="repairCompleteTemp.partCode"
                  value-key="name"
                  class="inline-input"
                  :fetch-suggestions="oldProductsSearch"
                  placeholder="请输入备件编号或备件名称或备件规格"
                  style="width:100%"
                  @select="handleSelectOldProducts"
                >
                  <template slot-scope="{ item }">
                    <b>备件编号：</b><span class="name">{{ item.partCode }}</span>
                    |<b>备件名称：</b><span class="addr">{{ item.partName }}</span>
                    |<b style="padding-left:3em;">备件规格：</b><span class="addr">{{ item.specification }}</span>
                  </template>
                </el-autocomplete>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-table
          v-if="No2"
          :key="tableKey"
          v-loading="listLoading"
          element-loading-text="给我一点时间"
          :data="listAdd"
          border
          fit
          highlight-current-row
          style="width: 100%;margin-bottom:30px"
          :cell-style="cellStyle"
          class="elTable"
          :row-style="rowStyle"
        >
          <el-table-column type="index" label="序号" align="center" width="50px" />
          <el-table-column label="备件编号" min-width="90px" prop="partCode" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.partCode }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备件名称" min-width="60px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.partName }}</span><br>
            </template>
          </el-table-column>
          <el-table-column label="备件规格" prop="specification" align="center" min-width="90">
            <template slot-scope="scope">
              <span>{{ scope.row.specification }}</span>
            </template>
          </el-table-column>
          <el-table-column label="录入数量" prop="brand" align="center" min-width="60">
            <template slot-scope="scope">
              <el-form :model="scope.row" :rules="rules">
                <el-form-item prop="acturalAmount">
                  <el-input ref="acturalAmount" v-model="scope.row.acturalAmount" style="margin-top:15px" />
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column label="用途" prop="note" align="center" min-width="60">
            <template slot-scope="scope">
              <el-form :model="scope.row">
                <el-form-item prop="note">
                  <el-input ref="note" v-model="scope.row.note" style="margin-top:15px" />
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="60" class-name="small-padding fixed-width" fixed="right">
            <template slot-scope="{row}">
              <a class="del" @click="partDelete(row)">删除</a>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='repairComplete'?createRepairCompleteData():createRepairCompleteData()">确认</el-button>
        <el-button @click="dialogFormVisible_RepairComplete = false;">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_MaintenanceRequisition" :close-on-click-modal="false" width="90%">
      <div style="position: absolute;top:12px;left:120px;font:18px/40px '' ;color:#303133;">
        <span style="margin:0 10px;">设备名称：{{ maintenanceRequisitionTemp.eqName }}</span>
        <span>内部编号：{{ maintenanceRequisitionTemp.eqCode }}</span>
      </div>
      <div class="maintenanceRequisition" style="width:90%;margin:0 auto;">
        <el-tabs v-model="activeName2" @tab-click="tabMaintenance">
          <el-tab-pane label="维修" name="first">
            <el-form
              ref="maintenanceRequisitionTemp"
              :rules="rules"
              :model="maintenanceRequisitionTemp"
              label-position="right"
              label-width="120px"
              style="width: 90%;margin:0 auto;"
            >
              <el-row>
                <el-col :span="8">
                  <el-form-item label="维修日期" prop="repirsTime">
                    <el-date-picker
                      v-model="maintenanceRequisitionTemp.repirsTime"
                      :picker-options="pickerOptions1"
                      type="date"
                      placeholder="维修日期"
                      style="width:100%;"
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"
                      :clearable="false"
                    />
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
            <div class="newFault">
              <el-form
                ref="newFaultTemp"
                :rules="rules"
                :model="newFaultTemp"
                label-position="right"
                label-width="120px"
                style="width: 90%;margin:0 auto"
              >
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="故障诊断：" prop="positionId">
                      <el-select v-model="newFaultTemp.positionId" style="width:100%;" filterable placeholder="故障部位" @change="changePosition">
                        <el-option
                          v-for="item in positions"
                          :key="item.id"
                          :label="item.positionName"
                          :value="item.id"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item>
                      <el-select v-model="newFaultTemp.appearanceName" style="width:100%;" filterable placeholder="故障详情" @change="changeAppearance">
                        <el-option
                          v-for="item in appearances"
                          :key="item.id"
                          :label="item.appearanceName"
                          :value="item.appearanceName"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <el-table
                :key="tableKey"
                v-loading="listLoading"
                element-loading-text="给我一点时间"
                :data="listNewFault"
                border
                fit
                highlight-current-row
                style="width: 100%;margin-bottom:30px"
                :cell-style="cellStyle"
                class="elTable"
                :row-style="rowStyle"
              >
                <el-table-column type="index" label="序号" align="center" width="50px" />
                <el-table-column label="故障部位" min-width="90px" prop="positionName" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.positionName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="故障详情" min-width="60px" align="center" prop="appearanceName">
                  <template slot-scope="scope">
                    <el-input ref="appearanceName" v-model="scope.row.appearanceName" />
                  </template>
                </el-table-column>
                <el-table-column label="故障原因" min-width="60px" align="center" prop="failureCause">
                  <template slot-scope="scope">
                    <el-input ref="failureCause" v-model="scope.row.failureCause" />
                  </template>
                </el-table-column>
                <el-table-column label="处理方式" min-width="60px" align="center" prop="treatmentMethod">
                  <template slot-scope="scope">
                    <el-input ref="treatmentMethod" v-model="scope.row.treatmentMethod" />
                  </template>
                </el-table-column>
                <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
                  <template slot-scope="{row}">
                    <a class="del" @click="newFaultDelete(row)">删除</a>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="备件领用" name="second">
            <el-button class="filter-item" type="primary" size="mini" style="margin-bottom:10px" @click="handleCollectionSparePartsCreate">添加领用单</el-button>
            <h4>有库存领用</h4>
            <el-table
              :key="tableKey"
              v-loading="listLoading"
              element-loading-text="给我一点时间"
              :data="listCollectionSpareParts"
              border
              fit
              highlight-current-row
              style="width: 100%;"
              :row-style="rowStyle"
              :cell-style="cellStyle"
              class="elTable table-fixed"
            >
              <el-table-column label="序号" align="center" type="index" width="50px">
                <template slot-scope="scope">
                  <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                </template>
              </el-table-column>
              <el-table-column label="领用单号" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.row.applyCode }}</span>
                </template>
              </el-table-column>
              <el-table-column label="领用部门" width="140px" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.row.departmentName }}</span>
                </template>
              </el-table-column>
              <el-table-column label="领用日期" sortable prop="createDate" min-width="80px" align="center" />
              <el-table-column label="领用备件" prop="details" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.row.details }}</span>
                </template>
              </el-table-column>
              <el-table-column label="领用状态" min-width="100px" align="center" :formatter="statue" />
              <el-table-column label="操作" min-width="80px" align="center">
                <template slot-scope="{row}">
                  <el-button type="primary" size="mini" @click="handleCollarUseSee(row,0)">查看</el-button>
                </template>
              </el-table-column>
            </el-table>
            <h4>无库存领用</h4>
            <el-table
              :key="tableKey2"
              v-loading="listLoading"
              element-loading-text="给我一点时间"
              :data="listCollectionSpareParts2"
              border
              fit
              highlight-current-row
              style="width: 100%;"
              :row-style="rowStyle"
              :cell-style="cellStyle"
              class="elTable table-fixed"
            >
              <el-table-column label="序号" align="center" type="index" width="50px">
                <template slot-scope="scope">
                  <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
                </template>
              </el-table-column>
              <el-table-column label="领用部门" width="140px" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.row.departmentName }}</span>
                </template>
              </el-table-column>
              <el-table-column label="最新领用日期" sortable prop="createDate" min-width="80px" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.row.createDate }}</span>
                </template>
              </el-table-column>
              <el-table-column label="领用备件" prop="details" align="center">
                <template slot-scope="scope">
                  <span>{{ scope.row.details }}</span>
                </template>
              </el-table-column>
              <el-table-column label="领用状态" min-width="100px" align="center" :formatter="statue" />
              <el-table-column label="操作" min-width="80px" align="center">
                <template slot-scope="{row}">
                  <el-button type="primary" size="mini" @click="handleCollarUseSee(row,1)">查看</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
      </div>
      <div slot="footer" class="dialog-footer" style="bottom:5px">
        <el-button v-if="rapairBtn" type="primary" :disabled="isokDisable" @click="dialogStatus==='maintenanceRequisition'?createMaintenanceRequisitionteData():createMaintenanceRequisitionteData()">确认</el-button>
        <el-button @click="dialogFormVisible_MaintenanceRequisition = false;getList();">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_CollectionSparePartsSee" :close-on-click-modal="false" width="90%">
      <div class="collectionSparePartsSee">
        <el-form
          ref="collectionSparePartsSeeTemp"
          :rules="rules"
          :model="collectionSparePartsSeeTemp"
          label-position="right"
          label-width="120px"
          style="width: 90%;margin:0 auto;"
        >
          <el-row>
            <el-col v-if="collectionSparePartsSeeTemp.isStock !== 1" :span="8">
              <el-form-item label="领用单号：" prop="applyCode">
                <el-input ref="applyCode" v-model="collectionSparePartsSeeTemp.applyCode" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="领用部门：" prop="departmentName">
                <el-input ref="departmentName" v-model="collectionSparePartsSeeTemp.departmentName" disabled />
              </el-form-item>
            </el-col>
            <el-col v-if="collectionSparePartsSeeTemp.isStock !== 1" :span="8">
              <el-form-item label="领用日期：" prop="createDate">
                <el-input ref="createDate" v-model="collectionSparePartsSeeTemp.createDate" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-if="isPartCode">
            <el-col :span="16">
              <el-form-item label="所需备件：" prop="partCode">
                <el-autocomplete
                  v-model="collectionSparePartsSeeTemp.partCode"
                  value-key="name"
                  class="inline-input"
                  :fetch-suggestions="sparePartSearch"
                  placeholder="请输入备件编号或备件名称或备件规格"
                  style="width:98%"
                  @select="handleSelectSparePart"
                >
                  <template slot-scope="{ item }">
                    <b>备件编号：</b><div class="name" style="display: inline;">{{ item.partCode }}</div>&nbsp;
                    |  &nbsp;<b>备件名称：</b><span class="addr">{{ item.partName }}</span>&nbsp;
                    |  &nbsp;<b>备件规格：</b><span class="addr">{{ item.specification }}</span>
                    |  &nbsp;<b>库存：</b><span class="addr">{{ item.reportery }}</span>
                    |  &nbsp;<b>是否零库存：</b><span class="addr" v-if="item.isZeroStock==1">是</span>
                    <span class="addr" v-else>否</span>
                  </template>
                </el-autocomplete>
              </el-form-item>
            </el-col>
            <el-col :span="2">
              <el-button type="primary" @click="handleAddSparePartsToBeCollected">添加待领用备件</el-button>
            </el-col>
          </el-row>
        </el-form>
        <el-table
          :key="tableKey"
          v-loading="listLoading"
          element-loading-text="给我一点时间"
          :data="listCreateCollectionSpareParts"
          border
          fit
          highlight-current-row
          style="width: 100%;margin-bottom:30px"
          :row-style="rowStyle"
          :cell-style="cellStyle"
          class="elTable table-fixed"
        >
          <!-- table表格 -->
          <el-table-column type="index" label="序号" align="center" width="50px" />
          <el-table-column label="备件编号" min-width="90px" prop="partCode" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.partCode }}</span>
            </template>
          </el-table-column>
          <el-table-column label="备件名称" min-width="80px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.partName }}</span><br>
            </template>
          </el-table-column>
          <el-table-column label="备件规格" prop="specification" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.specification }}</span>
            </template>
          </el-table-column>
          <el-table-column label="库存数" prop="reportery" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.reportery }}</span>
            </template>
          </el-table-column>
          <el-table-column label="领用数量" prop="amount" align="center" min-width="80">
            <template slot-scope="scope">
              <el-form :model="scope.row">
                <el-form-item prop="amount">
                  <el-input ref="amount" v-model="scope.row.amount" :disabled="dialogStatus==='collectionSparePartsSee'" style="margin-top:15px" />
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column v-if="collectionSparePartsSeeTemp.isStock==1" label="领用时间" prop="date" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.date }}</span>
            </template>
          </el-table-column>
          <el-table-column label="用途" prop="note" align="center" min-width="60">
            <template slot-scope="scope">
              <el-form :model="scope.row">
                <el-form-item prop="note">
                  <el-input ref="note" v-model="scope.row.note" :disabled="dialogStatus==='collectionSparePartsSee'" style="margin-top:15px" />
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column v-if="collectionSparePartsSeeTemp.isStock==1" label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
            <template slot-scope="{row}">
              <a class="primary" @click="handleViewProgress(row)">查看进度</a>
            </template>
          </el-table-column>
          <el-table-column v-if="isCreatePartDelete" label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
            <template slot-scope="{row}">
              <a class="del" @click="createPartDelete(row)">删除</a>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer" style="bottom:5px">
        <el-button v-if="isPartCode" type="primary" :disabled="isokDisable" @click="dialogStatus==='collectionSparePartsCreate'?createCollectionSparePartsData():createCollectionSparePartsData()">确认</el-button>
        <el-button @click="dialogFormVisible_CollectionSparePartsSee = false;">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 查看进度 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible_ViewProgress" :close-on-click-modal="false" width="90%">
      <div class="viewProgress">
        <el-form
          ref="viewProgressTemp"
          :rules="rules"
          :model="viewProgressTemp"
          label-position="right"
          label-width="120px"
          style="width: 90%;margin:0 auto;"
        >
          <el-row>
            <el-col :span="8">
              <el-form-item label="本次领用数量：" prop="amountY">
                <span> {{ numbersList.amountY }} </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="其他领用数量：" prop="amountQT">
                <span> {{ numbersList.amountQT }} </span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="未出库数量：" prop="amountLY">
                <span> {{ numbersList.amountLY }} </span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <h4>申购情况：</h4>
        <el-table
          :key="tableKey"
          v-loading="listLoading"
          element-loading-text="给我一点时间"
          :data="purchaseapplicationList"
          border
          fit
          highlight-current-row
          style="width: 100%;margin-bottom:30px"
          :row-style="rowStyle"
          :cell-style="cellStyle"
          class="elTable table-fixed"
          @sort-change="tableSort2"
        >
          <el-table-column type="index" label="序号" align="center" width="50px" />
          <el-table-column label="申购单号" min-width="90px" prop="orderNumber" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.orderNumber }}</span>
            </template>
          </el-table-column>
          <el-table-column sortable prop="amount" label="申购数量" min-width="80px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.amount }}</span><br>
            </template>
          </el-table-column>
          <el-table-column label="申购时间" sortable prop="createTime" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.createTime }}</span>
            </template>
          </el-table-column>
          <el-table-column label="申购部门" prop="deptName" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.deptName }}</span>
            </template>
          </el-table-column>
          <el-table-column label="申购人" prop="amount" align="center" min-width="80">
            <template slot-scope="scope">
              <span>{{ scope.row.empName }}</span>
            </template>
          </el-table-column>
          <el-table-column label="是否配单" prop="buyStatu" align="center" min-width="80">
            <template slot-scope="scope">
              <span>{{ scope.row.buyStatu }}</span>
            </template>
          </el-table-column>
          <el-table-column label="配单号" prop="matchCode" align="center" min-width="80">
            <template slot-scope="scope">
              <span>{{ scope.row.matchCode }}</span>
            </template>
          </el-table-column>
        </el-table>
        <h4>采购情况：</h4>
        <el-table
          :key="tableKey2"
          v-loading="listLoading"
          element-loading-text="给我一点时间"
          :data="procurementList"
          border
          fit
          highlight-current-row
          style="width: 100%;margin-bottom:30px"
          :row-style="rowStyle"
          :cell-style="cellStyle"
          class="elTable table-fixed"
          @sort-change="tableSort3"
        >
          <el-table-column type="index" label="序号" align="center" width="50px" />
          <el-table-column label="采购单号" min-width="90px" prop="buyeCode" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.buyeCode }}</span>
            </template>
          </el-table-column>
          <el-table-column sortable prop="amount" label="采购数量" min-width="80px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.amount }}</span><br>
            </template>
          </el-table-column>
          <el-table-column label="配单号" prop="specification" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.matchCode }}</span>
            </template>
          </el-table-column>
          <el-table-column label="提交时间" prop="buyerDate" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.buyerDate }}</span>
            </template>
          </el-table-column>
          <el-table-column sortable prop="receiveAmount" label="入库数量" align="center" min-width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.receiveAmount }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer" style="bottom:5px">
        <el-button @click="dialogFormVisible_ViewProgress = false;">关闭</el-button>
      </div>
    </el-dialog>
    <!-- 报修驳回 -->
    <el-dialog :title="textMap[dialogStatus]" :visible.sync="rejectRepair.dialogFormVisible" :close-on-click-modal="false" width="30%">
      <div class="maintenanceAudit">
        <h3 style="width: 100%;margin:0 0 0 5%;line-height:50px;">请输入报修驳回原因:</h3>
        <el-form ref="rejectRepair" :rules="rules" :model="rejectRepair.temp" label-position="right" style="width: 60%;height:150px;margin:0 auto;">
          <el-row>
            <el-col :span="20">
              <el-form-item prop="shutdownReason">
                <el-input v-model="rejectRepair.temp.shutdownReason" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入报修驳回原因" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :disabled="isokDisable" @click="rejectRepairData()">确认</el-button>
        <el-button @click="rejectRepair.dialogFormVisible = false;">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// 引入
import { GetDataByName, GetDataByNames,GetAccount, PostDataByName, failproccess, ExecDataByConfig, checkButtons } from '@/api/common'
import { mapGetters } from 'vuex'
import waves from '@/directive/waves' // waves directive
import { parseTime, sortChange,json2excel } from '@/utils/index.js'
// eslint-disable-next-line no-unused-vars
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import { MessageBox } from 'element-ui'
import Cookies from 'js-cookie'
export default {
  name: 'Repair',
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      isokDisable: false,
      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
      cellStyle: { padding: 0 + 'px' },
      findAllPasture: [],
      findAllDepart: [],
      findAllEmploye: [],
      requestParams: [
        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
        { name: 'findAllDepart1', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid'), 'eId': Cookies.get('employeid') }},
        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
      ],
      orderStatues: [{ id: '0', name: '待接单' }, { id: '1', name: '维修中' }, { id: '2', name: '维修完成' }],
      SHStatues: [{ id: '0', name: '审核中' }, { id: '1', name: '已通过' }, { id: '2', name: '未通过' }],
      rules: {
        repairDept: [{ required: true, message: '必填', trigger: 'blur' }],
        pickId: [{ required: true, message: '必填', trigger: 'blur' }],
        chargeDate: [{ required: true, message: '必填', trigger: 'blur' }],
        chargeId: [{ required: true, message: '必填', trigger: 'blur' }],
        repirsTime: [{ required: true, message: '必填', trigger: 'blur' }],
        positionId: [{ required: true, message: '必填', trigger: 'blur' }],
        repairCode: [{ required: true, message: '必填', trigger: 'blur' }],
        eqName: [{ required: true, message: '必填', trigger: 'blur' }],
        eqCode: [{ required: true, message: '必填', trigger: 'blur' }],
        deptName: [{ required: true, message: '必填', trigger: 'blur' }],
        details: [{ required: true, message: '必填', trigger: 'blur' }],
        shutdownReason: [{ required: true, message: '必填', trigger: 'blur' }]
      },
      getdataListParm: {
        name: 'getRepirsList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          pastureName: Cookies.get('pasturename'),
          repairCode: '',
          eqName: '',
          eqCode: '',
          orderStatue: '',
          SHStatue: '',
          inputDatetime: '',

          loginId: Cookies.get('employeid'),
          menu: 'Repair',
          logindeptId: Cookies.get('departmentid'),
          loginpastureId: Cookies.get('pastureid')
        }
      },

      isCanSubmit:false,
      total: 0,
      tableKey: 0,
      listLoading: false,
      list: [],
      dialogFormVisible_Create: false,
      createTemp: {
        pastureId: '',
        departmentId: '',
        eqId: '',
        eqCode: '',
        eqName: '',
        repairDept: '',
        details: '',
        requesterId: '',
        requestTime: parseTime(new Date(), '{y}-{m}-{d} {h}:{i}'),
        pickId: '',
        repairCode: '',
        deptName: ''
      },
      requestEqName: {
        name: 'geteqbyNameCode',
        page: 1,
        offset: 1,
        pagecount: '',
        returntype: 'Map',
        parammaps: {
          pastureId: Cookies.get('pastureid')
        }
      },
      EqNameList: [],
      EqCodeList: [],
      getRepairNumberParm: {
        name: 'autoCreatCode',
        parammaps: {
          pastureId: Cookies.get('pastureid'),
          codeType: 'BX'
        }
      },
      radioAll: '全部',
      dialogFormVisible_See: false,
      dialogStatus: '',
      textMap: {
        create: '报修',
        see: '查看详情',
        distributeLeaflets: '派单',
        maintenanceAudit: '维修审核',
        maintenanceAudit2: '维修审核',
        repairComplete: '完成维修',
        maintenanceRequisition: '维修及领用',
        collectionSparePartsSee: '查看领用',
        collectionSparePartsCreate: '添加领用',
        ViewProgress: '查看进度', rejectRepair: '报修驳回', update: '修改报修'
      },
      activeList: [],
      active: 3,
      seeTemp: {},
      activeName: 'first',
      orderStatue1: false,
      orderStatue2: false,
      // Reason: false,
      // MaintenanceAudit: false,
      listLoadingFault: false,
      listFault: [],
      getFaultListParm: {
        name: 'getmaintainappearance',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      listLoadingCollarUse: false,
      listCollarUse: [],
      getCollarUseListParm: {
        name: 'getPartsapplybyMt',
        page: 1,
        offset: 1,
        returntype: 'Map',
        parammaps: {}
      },
      getCollarUseListParm2: {
        name: 'getPartsapplybyMt_m',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      listLoadingOldProducts: false,
      listOldProducts: [],
      getOldProductsListParm: {
        name: 'getMaintainRefuse',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      dialogFormVisible_DistributeLeaflets: false,
      distributeLeafletsTemp: {
        repairDept: '',
        pickId: '',
        chargeId: this.$store.state.user.employeid,
        chargeDate: parseTime(new Date(), '{y}-{m}-{d}')
      },
      pickerOptions1: {
        disabledDate(time) {
          return time.getTime() > Date.now()// 当天之前的时间可选
        }
      },
      receiptTemp: {},
      requestParam: {},
      maintainers: [],
      getRepirsEmpParm: {
        name: 'getRepirsEmp',
        returntype: 'Map',
        parammaps: {
          pastureId: Cookies.get('pastureid')
        }
      },
      examineTemp: {
        statue: 3
      },
      statueReason: false,
      dialogFormVisible_MaintenanceAudit: false,
      dialogFormVisible_RepairComplete: false,
      repairCompleteTemp: {
        isOldProducts: 0
      },
      requestOldProducts: {
        name: 'getAllPartsListWB',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      No2: false,
      listAdd: [],
      postDataPramas: {},
      maintenanceRequisitionTemp: {
        repirsTime: ''
      },
      dialogFormVisible_MaintenanceRequisition: false,
      activeName2: 'first',
      rowId: 0,
      listNewFault: [],
      newFaultTemp: {},
      appearances: [],
      positions: [],
      getPositionsParm: {
        name: 'geteqPosition',
        parammaps: {}
      },
      getAppearanceParm: {
        name: 'getAppearancebyPid',
        parammaps: {}
      },
      rapairBtn: true,
      listCollectionSpareParts: [],
      tableKey2: 1,
      listCollectionSpareParts2: [],
      collectionSparePartsSeeTemp: {
        isStock: 0
      },
      getParmCreateNumber: {
        name: 'autoCreatCode',
        page: 0,
        offset: 0,
        pagecount: 0,
        returntype: 'Map',
        parammaps: {
          pastureId: Cookies.get('pastureid'),
          codeType: 'LY'
        }
      },
      requestSparePart: {
        name: 'getPartsListLY_m',
        page: 1,
        offset: 1,
        pagecount: 20,
        returntype: 'Map',
        parammaps: {
          pastureId: Cookies.get('pastureid')
        }
      },
      addSparePartsToBeCollectedParam: {
        name: 'getPartapply_mr',
        page: 1,
        offset: 1,
        pagecount: 20,
        returntype: 'Map',
        parammaps: {}
      },
      dialogFormVisible_CollectionSparePartsSee: false,
      listCreateCollectionSpareParts: [],
      isCreatePartDelete: false,
      isPartCode: true,
      getCollarUseSeeParm: {
        name: 'getpartapplyListBybig',
        parammaps: {}
      },
      getCollarUseSeeParm2: {
        name: 'getpartapplyListBybig_m',
        parammaps: {}
      },
      dialogFormVisible_ViewProgress: false,
      viewProgressTemp: {},
      getNumbersParm: {
        name: 'getpartApply_mstatue',
        page: 1,
        offset: 1,
        pagecount: 20,
        returntype: 'Map',
        parammaps: {}
      },
      numbersList: [],
      getPurchaseapplicationParm: {
        name: 'getpartApply_mstatueSG',
        page: 1,
        offset: 1,
        returntype: 'Map',
        parammaps: {}
      },
      purchaseapplicationList: [], // 采购情况
      getProcurementParm: {
        name: 'getpartApply_mstatueCG',
        page: 1,
        offset: 1,
        returntype: 'Map',
        parammaps: {}
      },
      procurementList: [], // 采购情况
      rejectRepair: {
        dialogFormVisible: false,
        temp: {}
      },
      // 权限按钮
      isRepair: [],
      isMaintenanceSee: [],
      isDistributeLeaflets: [],
      isReceipt: [],
      isMaintenanceRequisition: [],
      isRepairComplete: [],
      isDelete: [],
      isMaintenanceAudit: [],
      isMaintenanceAudit2: [], isRejectRepair: [],
      isRepairExport:[],
      buttons: [],
      pending: {
        total: 0,
        getdataListParm: {
          name: 'getRepirsWebListNO', page: 1, offset: 1, getTotal: 'total3', pagecount: 10, returntype: 'Map',
          parammaps: {}
        }
      },
      isPercentage: false,
      percentage: 1,
      downLoadParm:{},
      downLoadList:[],
      resubmit:{}
    }
  },
  // computed: {
  //   ...mapGetters([
  //     'buttons'
  //   ])
  // },
  created() {
    const that = this
    GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
      that.buttons = response.data.list
      that.get_auto_buttons()
    })
  },
  methods: {
    tableSort1(column) {
      sortChange(column, this.listOldProducts)
    },
    tableSort2(column) {
      sortChange(column, this.purchaseapplicationList)
    },
    tableSort3(column) {
      sortChange(column, this.procurementList)
    },
    get_auto_buttons() {
      // 报修
      const Repair = 'maintenance:repair:baoxiu'
      const isRepair = checkButtons(this.buttons, Repair)
      this.isRepair = isRepair
      // 派单
      const DistributeLeaflets = 'maintenance:repair:paidan'
      const isDistributeLeaflets = checkButtons(this.buttons, DistributeLeaflets)
      this.isDistributeLeaflets = isDistributeLeaflets
      // 接单
      const Receipt = 'maintenance:repair:jiedan'
      const isReceipt = checkButtons(this.buttons, Receipt)
      this.isReceipt = isReceipt
      // 维修及领用
      const Repairlingyong = 'maintenance:repair:lingyong'
      const isMaintenanceRequisition = checkButtons(this.buttons, Repairlingyong)
      this.isMaintenanceRequisition = isMaintenanceRequisition
      // 维修完成
      const RepairComplete = 'maintenance:repair:weixiuwancheng'
      const isRepairComplete = checkButtons(this.buttons, RepairComplete)
      this.isRepairComplete = isRepairComplete
      // 删除
      const Delete = 'maintenance:repair:delete'
      const isDelete = checkButtons(this.buttons, Delete)
      this.isDelete = isDelete
      // 维修审核
      const MaintenanceAudit = 'maintenance:repair:seeMaintenanceAudit'
      const isMaintenanceAudit = checkButtons(this.buttons, MaintenanceAudit)
      this.isMaintenanceAudit = isMaintenanceAudit
      // 查看
      const See = 'maintenance:repair:see'
      const isMaintenanceSee = checkButtons(this.buttons, See)
      this.isMaintenanceSee = isMaintenanceSee
      // 主管审核
      const MaintenanceAudit2 = 'maintenance:repair:shenhe2'
      const isMaintenanceAudit2 = checkButtons(this.buttons, MaintenanceAudit2)
      this.isMaintenanceAudit2 = isMaintenanceAudit2
      // 报修驳回
      const RejectRepair = 'maintenance:repair:rejectRepair'
      const isRejectRepair = checkButtons(this.buttons, RejectRepair)
      this.isRejectRepair = isRejectRepair
      // 导出
      const RejectExport = 'maintenance:repair:rejectExport'
      const isRepairExport = checkButtons(this.buttons, RejectExport)
      this.isRepairExport = isRepairExport
      this.get_select_list()
      this.getList()
      this.getPendingList()
    },
    get_select_list() {
      GetDataByNames(this.requestParams).then(response => {
        this.findAllPasture = response.data.findAllPasture.list
        this.findAllDepart = response.data.findAllDepart1.list
        this.findAllEmploye = response.data.findAllEmploye.list
      })
    },
    getPendingList() {
      this.pending.getdataListParm.parammaps.pastureName = this.getdataListParm.parammaps.pastureName
      this.pending.getdataListParm.parammaps.repairCode = this.getdataListParm.parammaps.repairCode
      this.pending.getdataListParm.parammaps.eqName = this.getdataListParm.parammaps.eqName
      this.pending.getdataListParm.parammaps.eqCode = this.getdataListParm.parammaps.eqCode
      this.pending.getdataListParm.parammaps.SHStatue = this.getdataListParm.parammaps.SHStatue
      this.pending.getdataListParm.parammaps.inputDatetime = this.getdataListParm.parammaps.inputDatetime
      this.pending.getdataListParm.parammaps.loginId = this.getdataListParm.parammaps.loginId
      this.pending.getdataListParm.parammaps.menu = this.getdataListParm.parammaps.menu
      this.pending.getdataListParm.parammaps.logindeptId = this.getdataListParm.parammaps.logindeptId
      this.pending.getdataListParm.parammaps.loginpastureId = this.getdataListParm.parammaps.loginpastureId
      this.pending.getdataListParm.parammaps.empId = Cookies.get('employeid')
      this.pending.getdataListParm.parammaps.pastureId = Cookies.get('pastureid')
      this.pending.getdataListParm.parammaps.deptId = Cookies.get('departmentid')
      GetDataByName(this.pending.getdataListParm).then(response => {
        this.pending.total = response.data.total3
      })
    },
    getList() {
      if (this.$refs['inputDatetime'] !== undefined && this.$refs['inputDatetime'].value !== null) {
        this.getdataListParm.parammaps.startTime = this.$refs['inputDatetime'].value[0]
        this.getdataListParm.parammaps.stopTime = this.$refs['inputDatetime'].value[1]
      } else {
        this.getdataListParm.parammaps.startTime = ''
        this.getdataListParm.parammaps.stopTime = ''
      }
      this.listLoading = true
      GetDataByName(this.getdataListParm).then(response => {
        if (response.data.list !== null) {
          console.log('table数据', response.data.list)
          this.list = response.data.list
          this.pageNum = response.data.pageNum
          this.pageSize = response.data.pageSize
        } else {
          this.list = []
        }
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 100)
      })
    },
    changeAll() {
      console.log(this.radioAll)
      if (this.radioAll === '全部') {
        this.getdataListParm.name = 'getRepirsList'
        this.getdataListParm.offset = 1
        this.getdataListParm.parammaps = {
          pastureName: Cookies.get('pasturename'),
          inputDatetime: '',
          loginId: Cookies.get('employeid'),
          menu: 'Repair',
          logindeptId: Cookies.get('departmentid'),
          loginpastureId: Cookies.get('pastureid')
        }
        this.getList()
      } else if (this.radioAll === '待处理') {
        this.getdataListParm.name = 'getRepirsWebListNO'
        this.getdataListParm.offset = 1
        this.getdataListParm.parammaps = {
          pastureName: this.getdataListParm.parammaps.pastureName,
          repairCode: this.getdataListParm.parammaps.repairCode,
          eqName: this.getdataListParm.parammaps.eqName,
          eqCode: this.getdataListParm.parammaps.eqCode,
          orderStatue: this.getdataListParm.parammaps.orderStatue,
          SHStatue: this.getdataListParm.parammaps.SHStatue,
          inputDatetime: this.getdataListParm.parammaps.inputDatetime,

          loginId: Cookies.get('employeid'),
          menu: 'Repair',
          logindeptId: Cookies.get('departmentid'),
          loginpastureId: Cookies.get('pastureid'),
          empId: Cookies.get('employeid'),
          pastureId: Cookies.get('pastureid'),
          deptId: Cookies.get('departmentid')
        }
        this.getList()
      } else if (this.radioAll === '已处理') {
        this.getdataListParm.name = 'getRepirsWebList'
        this.getdataListParm.offset = 1
        this.getdataListParm.parammaps = {
          pastureName: this.getdataListParm.parammaps.pastureName,
          repairCode: this.getdataListParm.parammaps.repairCode,
          eqName: this.getdataListParm.parammaps.eqName,
          eqCode: this.getdataListParm.parammaps.eqCode,
          orderStatue: this.getdataListParm.parammaps.orderStatue,
          SHStatue: this.getdataListParm.parammaps.SHStatue,
          inputDatetime: this.getdataListParm.parammaps.inputDatetime,
          loginId: Cookies.get('employeid'),
          menu: 'Repair',
          logindeptId: Cookies.get('departmentid'),
          loginpastureId: Cookies.get('pastureid'),
          empId: Cookies.get('employeid'),
          pastureId: Cookies.get('pastureid'),
          deptId: Cookies.get('departmentid')
        }
        this.getList()
      }
    },
    orderStatue: function(cellValue) {
      // console.log(cellValue.isZeroStock)
      if (cellValue.orderStatue == 0) {
        return '待接单'
      } else if (cellValue.orderStatue == 1) {
        return '维修中'
      } else if (cellValue.orderStatue == 2) {
        return '维修完成'
      } else if (cellValue.orderStatue == 3) {
        return '已驳回'
      }
    },
    SHStatue: function(cellValue) {
      // console.log(cellValue.isZeroStock)
      if (cellValue.SHStatue == 1) {
        return ''
      } else if (cellValue.SHStatue == 2) {
        return '审核中'
      } else if (cellValue.SHStatue == 3) {
        return '审核中'
      } else if (cellValue.SHStatue == 4) {
        return '未通过'
      } else if (cellValue.SHStatue == 6) {
        return '未通过'
      } else if (cellValue.SHStatue == 5) {
        return '已通过'
      }
    },
    form_search() {
      console.log('点击了table搜索')
      this.listLoading = true
      if (this.getdataListParm.parammaps.inputDatetime === null) {
        this.getdataListParm.parammaps.inputDatetime = ''
      }
      this.getdataListParm.offset = 1
      this.getList()
      this.getPendingList()
    },
    resetCreateTemp() {
      this.createTemp.pastureId = this.$store.state.user.pastureid
      this.createTemp.departmentId = this.$store.state.user.departmentid
      this.createTemp.eqId = ''
      this.createTemp.eqCode = ''
      this.createTemp.eqName = ''
      this.createTemp.repairDept = ''
      this.createTemp.details = ''
      this.createTemp.requesterId = this.$store.state.user.employeid
      this.createTemp.requestTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}')
      this.createTemp.pickId = ''
      this.createTemp.repairCode = ''
      this.createTemp.deptName = ''
      this.createTemp.departmentId = ''
    },
    changePickId(val) {
      if (this.dialogStatus == 'create') {
        this.createTemp.repairDept = this.maintainers.find(obj => obj.id == val).deptid
      } else {
        this.distributeLeafletsTemp.repairDept = this.maintainers.find(obj => obj.id == val).deptid
      }
    },
    form_add() {
      this.dialogStatus = 'create'
      this.dialogFormVisible_Create = true

      this.resetCreateTemp()
      this.getRepairNumber()
      this.getRepirsEmp()
    },
    isToDayrResubmit(){
      //一天同一牧场同一设备同一故障是否重复提交

      this.resubmit.name = 'checkMaintain'
      this.resubmit.parammaps = {
        pastureId : this.createTemp.pastureId,
        eqId : this.createTemp.eqId,
        eqName : this.createTemp.eqName,
        eqCode : this.createTemp.eqCode,
        details : this.createTemp.details,
        requestTime : parseTime(new Date(), '{y}-{m}-{d}')
      }
      
    },
    getRepairNumber() {
      GetDataByName(this.getRepairNumberParm).then(response => {
        this.$nextTick(() => {
          console.log('新增报修单号', response.data.list[0].orderCode)
          this.createTemp.repairCode = response.data.list[0].orderCode
          this.$forceUpdate()
        })
      })
    },
    add_dialog_save() {
      this.isToDayrResubmit()
      GetDataByName(this.resubmit).then(response => {
        console.log('今天已提交,请勿重复提交', this.requestParam,this.resubmit,response)
        if (response.msg !== 'fail') {
          if(response.data.total > 0){
            this.$notify({ title: '提交失败', message: '今天已提交,请勿重复提交', type: 'warning', duration: 2000 })
            this.isCanSubmit = false
            return false
          }
          this.isCanSubmit = true
          // 可以提交
          this.isokDisable = true
          setTimeout(() => {
            this.isokDisable = false
          }, 1000)
          this.$refs['createTemp'].validate(valid => {
            if (valid) {
              if (this.createTemp.repairCode == '' || this.createTemp.repairCode == null || this.createTemp.repairCode == undefined) {
                GetDataByName(this.getRepairNumberParm).then(response => {
                  this.$nextTick(() => {
                    console.log('新增报修单号', response.data.list[0].orderCode)
                    this.createTemp.repairCode = response.data.list[0].orderCode
                    this.$forceUpdate()
                    this.add_dialog_saveSave()
                  })
                })
              } else {
                this.add_dialog_saveSave()
              }
            }
          })
        }else{
          this.$notify({ title: '请检查接口', message: "name: checkMaintain", type: 'warning', duration: 2000 })
        }
      })
    },
    add_dialog_saveSave() {
      this.requestParam.name = 'insertmaintain'
      this.requestParam.parammaps = this.createTemp
      PostDataByName(this.requestParam).then(response => {
        console.log('新增保存发送参数', this.requestParam)
        if (response.msg !== 'fail') {
          this.getList()
          this.getPendingList()
          this.dialogFormVisible_Create = false
          this.$notify({ title: '成功', message: '新增成功', type: 'success', duration: 2000 })
        } else {
          failproccess(response, this.$notify)
        }
      })
    },
    querySearchEqName(queryString, cb) {
      console.log('备件名称/设备内部编号模糊查询输入值', queryString)
      this.requestEqName.parammaps['eqName'] = queryString
      GetDataByName(this.requestEqName).then(response => {
        if (response.data.list !== null) {
          console.log('备件名称模糊查询搜索data', response.data.list)
          this.EqNameList = response.data.list
        } else {
          this.EqNameList = []
        }
        cb(this.EqNameList)
      })
    },
    handleSelectEqName(item) {
      console.log('备件名称/设备内部编号模糊查询选中值', item)
      this.$set(this.createTemp, 'eqCode', item.eqCode)
      this.$set(this.createTemp, 'eqId', item.eqId)
      if (item.deptName !== undefined && item.departmentId !== undefined) {
        this.$set(this.createTemp, 'deptName', item.deptName)
        this.$set(this.createTemp, 'departmentId', item.departmentId)
      } else {
        this.$set(this.createTemp, 'deptName', '')
        this.$set(this.createTemp, 'departmentId', '')
      }
      this.$forceUpdate()
    },
    querySearchCode(queryString, cb) {
      console.log('备件名称/设备内部编号模糊查询输入值', queryString)
      this.requestEqName.parammaps['eqCode'] = queryString
      GetDataByName(this.requestEqName).then(response => {
        if (response.data.list !== null) {
          console.log('备件名称模糊查询搜索data', response.data.list)
          this.EqNameList = response.data.list
        } else {
          this.EqNameList = []
        }
        cb(this.EqNameList)
      })
    },
    handleSelectEqCode(item, row) {
      console.log('备件名称/设备内部编号模糊查询选中值', item)
      console.log('备件名称/设备内部编号模糊查询选中值所在行', row)
      this.$set(this.createTemp, 'eqName', item.eqName)
      this.$set(this.createTemp, 'eqId', item.eqId)
      if (item.deptName !== undefined && item.departmentId !== undefined) {
        this.$set(this.createTemp, 'deptName', item.deptName)
        this.$set(this.createTemp, 'departmentId', item.departmentId)
      } else {
        this.$set(this.createTemp, 'deptName', '')
        this.$set(this.createTemp, 'departmentId', '')
      }
      this.$forceUpdate()
    },
    form_see(row) {
      console.log(row)
      this.seeTemp = Object.assign({}, row)
      // 流程图
      var reason = '未通过原因:' + this.seeTemp.workflowNote
      var scores = '评分:' + this.seeTemp.scores + '分'
      if (this.seeTemp.orderStatue === 0) {
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '维修接单' }, { title: '完成维修' }, { title: '使用人审核' }, { title: '设备主管审核' }]
        this.active = 1
      } else if (this.seeTemp.orderStatue == 3) {
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '报修驳回', date: this.seeTemp.shutdownDate, name: this.seeTemp.shutdownPerson }]
        this.active = 1
      } else if (this.seeTemp.orderStatue === 1 && this.seeTemp.SHStatue === 1) {
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '维修接单', date: this.seeTemp.orderTime, name: this.seeTemp.pickName }, { title: '完成维修' }, { title: '使用人审核' }, { title: '设备主管审核' }]
        this.active = 2
      } else if (this.seeTemp.SHStatue === 2) {
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '维修接单', date: this.seeTemp.orderTime, name: this.seeTemp.pickName }, { title: '完成维修', date: this.seeTemp.stopTime, name: this.seeTemp.pickName }, { title: '使用人审核' }, { title: '设备主管审核' }]
        this.active = 3
      } else if (this.seeTemp.SHStatue === 3) {
        this.active = 4
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '维修接单', date: this.seeTemp.orderTime, name: this.seeTemp.pickName }, { title: '完成维修', date: this.seeTemp.stopTime, name: this.seeTemp.pickName }, { title: '使用人审核', date: this.seeTemp.useChargeDate, name: this.seeTemp.useChargePerson, scores: scores }, { title: '设备主管审核' }]
      } else if (this.seeTemp.SHStatue === 4) {
        this.active = 4
        // var reason = '未通过原因:' + this.seeTemp.workflowNote
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '维修接单', date: this.seeTemp.orderTime, name: this.seeTemp.pickName }, { title: '完成维修', date: this.seeTemp.stopTime, name: this.seeTemp.pickName }, { title: '使用人审核', date: this.seeTemp.useChargeDate, name: this.seeTemp.useChargePerson, status: 'error', reason: reason }, { title: '设备主管审核' }]
      } else if (this.seeTemp.SHStatue === 5) {
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '维修接单', date: this.seeTemp.orderTime, name: this.seeTemp.pickName }, { title: '完成维修', date: this.seeTemp.stopTime, name: this.seeTemp.pickName }, { title: '使用人审核', date: this.seeTemp.useChargeDate, name: this.seeTemp.useChargePerson, scores: scores }, { title: '设备主管审核', date: this.seeTemp.chargeDate, name: this.seeTemp.chargePerson }]
        this.active = 5
      } else if (this.seeTemp.SHStatue === 6) {
        // var reason = '未通过原因:' + this.seeTemp.workflowNote
        this.activeList = [{ title: '报修', date: this.seeTemp.requestTime, name: this.seeTemp.requesterName }, { title: '维修接单', date: this.seeTemp.orderTime, name: this.seeTemp.pickName }, { title: '完成维修', date: this.seeTemp.stopTime, name: this.seeTemp.pickName }, { title: '使用人审核', date: this.seeTemp.useChargeDate, name: this.seeTemp.useChargePerson, scores: scores }, { title: '设备主管审核', date: this.seeTemp.chargeDate, name: this.seeTemp.chargePerson, status: 'error', reason: reason }]
        this.active = 5
      }
      this.seeTemp.requestTime = parseTime(this.seeTemp.requestTime, '{y}-{m}-{d}')
      this.seeTemp.shutdownDate = parseTime(this.seeTemp.shutdownDate, '{y}-{m}-{d}')
      this.seeTemp.orderTime = parseTime(this.seeTemp.orderTime, '{y}-{m}-{d}')
      this.dialogStatus = 'see'
      this.dialogFormVisible_See = true
      if (row.orderStatue == 0) {
        this.orderStatue1 = true
        this.orderStatue2 = false
      } else if (row.orderStatue == 3) {
        this.orderStatue1 = true
        this.orderStatue2 = false
      } else {
        this.orderStatue1 = false
        this.orderStatue2 = true
        this.getFaultList()
        this.getOldProductsList()
        this.getCollarUseList()
      }
    },
    resetDistributeLeafletsTemp() {
      this.distributeLeafletsTemp.repairDept = ''
      this.distributeLeafletsTemp.pickId = ''
      this.distributeLeafletsTemp.chargeDate = parseTime(new Date(), '{y}-{m}-{d}')
      this.distributeLeafletsTemp.chargeId = this.$store.state.user.employeid
    },
    // 派单
    handleDistributeLeaflets(row) {
      if (row == undefined) {
        this.distributeLeafletsTemp = this.seeTemp
      } else {
        this.distributeLeafletsTemp = Object.assign({}, row)
      }
      console.log('点击了派单')
      this.dialogStatus = 'distributeLeaflets'
      this.dialogFormVisible_DistributeLeaflets = true
      this.resetDistributeLeafletsTemp()
      this.getRepirsEmp()
    },
    changeMaintenanceTeam(val) {
      console.log(val)
      this.getRepirsEmpParm.parammaps.deptid = val
      this.createTemp.pickId = ''
      this.distributeLeafletsTemp.pickId = ''
      this.getRepirsEmp()
    },
    getRepirsEmp() {
      GetDataByName(this.getRepirsEmpParm).then(response => {
        console.log('维修人数据', response.data.list)
        this.maintainers = response.data.list
      })
    },
    // 派单-保存
    createDistributeLeafletsData() {
      console.log('点击了派单确认')
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['distributeLeafletsTemp'].validate(valid => {
        if (valid) {
          this.requestParam.name = 'setRepirsEmp'
          this.requestParam.parammaps = this.distributeLeafletsTemp
          this.requestParam.parammaps.id = this.distributeLeafletsTemp.id
          PostDataByName(this.requestParam).then(response => {
            console.log('派单确认发送参数', this.requestParam)
            if (response.msg !== 'fail') {
              this.listLoading = true
              this.getList()
              this.dialogFormVisible_DistributeLeaflets = false
              this.dialogFormVisible_See = false
              this.getPendingList()
              this.$notify({ title: '成功', message: '派单成功', type: 'success', duration: 2000 })
            } else {
              failproccess(response, this.$notify)
            }
          })
        }
      })
    },
    getFaultList() {
      this.listLoadingFault = true
      if (this.dialogStatus == 'repairComplete') {
        this.getFaultListParm.parammaps.maintainId = this.repairCompleteTemp.id
      } else {
        this.getFaultListParm.parammaps.maintainId = this.seeTemp.id
      }
      GetDataByName(this.getFaultListParm).then(response => {
        if (response.data.list !== null) {
          console.log('故障table数据', response.data.list)
          this.listFault = response.data.list
        } else {
          this.listFault = []
        }
        setTimeout(() => {
          this.listLoadingFault = false
        }, 100)
      })
    },
    getCollarUseList() {
      this.listLoadingCollarUse = true
      this.getCollarUseListParm.parammaps.RUCode = this.seeTemp.repairCode
      GetDataByName(this.getCollarUseListParm).then(response => {
        console.log('领用记录table数据', response.data.list)
        this.listCollarUse = response.data.list
        setTimeout(() => {
          this.listLoadingCollarUse = false
        }, 100)
      })
    },
    statue: function(cellValue) {
      // console.log(cellValue.isZeroStock)
      if (cellValue.statue == 0) {
        return '未领用'
      } else if (cellValue.statue == 1) {
        return '已领用'
      }
    },
    getOldProductsList() {
      this.listLoadingOldProducts = true
      this.getOldProductsListParm.parammaps.repairCode = this.seeTemp.repairCode
      GetDataByName(this.getOldProductsListParm).then(response => {
        console.log('旧品录入记录table数据', response.data.list)
        this.listOldProducts = response.data.list
        setTimeout(() => {
          this.listLoadingOldProducts = false
        }, 100)
      })
    },
    // 维修及审核
    handleExamine(row) {
      if (row == undefined) {
        this.examineTemp = this.seeTemp
        this.$set(this.seeTemp, 'statue', 3)
        this.$set(this.seeTemp, 'workflowNote', '')
        this.$set(this.seeTemp, 'scores', '')
      } else {
        this.examineTemp = Object.assign({}, row)
        this.$set(this.examineTemp, 'statue', 3)
        this.$set(this.examineTemp, 'workflowNote', '')
        this.$set(this.examineTemp, 'scores', '')
      }
      console.log('点击了维修审核')
      this.dialogStatus = 'maintenanceAudit'
      this.dialogFormVisible_MaintenanceAudit = true
    },
    changeStatue(val) {
      if (val == 4) {
        this.statueReason = true
      } else {
        this.statueReason = false
      }
    },
    // 维修审核-保存
    createExamineData() {
      console.log('点击了维修审核确认')
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['examineTemp'].validate(valid => {
        if (valid) {
          this.requestParam.name = 'maintainCharge'
          this.requestParam.parammaps = {}
          this.requestParam.parammaps.id = this.examineTemp.id
          this.requestParam.parammaps.statue = this.examineTemp.statue
          this.requestParam.parammaps.empId	 = Cookies.get('employeid')
          this.requestParam.parammaps.workflowNote = this.examineTemp.workflowNote
          if (this.requestParam.parammaps.statue == 4) {
            this.requestParam.parammaps.scores = 5
          } else {
            this.requestParam.parammaps.scores = this.examineTemp.scores
          }
          PostDataByName(this.requestParam).then(response => {
            console.log('维修审核确认发送参数', this.requestParam)
            if (response.msg !== 'fail') {
              if (this.getdataListParm.parammaps.inputDatetime === null) {
                this.getdataListParm.parammaps.inputDatetime = ''
              }
              this.getList()
              this.getPendingList()
              this.dialogFormVisible_MaintenanceAudit = false
              this.dialogFormVisible_See = false
              this.statueReason = false
              this.$notify({ title: '成功', message: '审核成功', type: 'success', duration: 2000 })
            } else {
              failproccess(response, this.$notify)
            }
          })
        }
      })
    },
    // 维修审核2
    handleExamine2(row) {
      if (row == undefined) {
        this.examineTemp = this.seeTemp
        this.$set(this.seeTemp, 'statue', 3)
        this.$set(this.seeTemp, 'workflowNote', '')
      } else {
        this.examineTemp = Object.assign({}, row)
        this.$set(this.examineTemp, 'statue', 3)
        this.$set(this.examineTemp, 'workflowNote', '')
      }
      console.log('点击了维修审核')
      this.dialogStatus = 'maintenanceAudit2'
      this.dialogFormVisible_MaintenanceAudit = true
    },
    // 维修审核2-保养
    createExamineData2() {
      if (this.examineTemp.statue == 3) {
        console.log('点击了维修审核确认-通过')
        this.isokDisable = true
        setTimeout(() => {
          this.isokDisable = false
        }, 1000)
        this.$refs['examineTemp'].validate(valid => {
          if (valid) {
            this.requestParam.name = 'maintainChargDone'
            this.requestParam.parammaps = {}
            this.requestParam.parammaps.id = this.examineTemp.id
            this.requestParam.parammaps.statue = 5
            this.requestParam.parammaps.orderStatue = 2
            this.requestParam.parammaps.empId	 = Cookies.get('employeid')
            this.requestParam.parammaps.workflowNote = this.examineTemp.workflowNote
            PostDataByName(this.requestParam).then(response => {
              console.log('维修审核确认发送参数', this.requestParam)
              if (response.msg !== 'fail') {
                if (this.getdataListParm.parammaps.inputDatetime === null) {
                  this.getdataListParm.parammaps.inputDatetime = ''
                }
                this.getList()
                this.getPendingList()
                this.dialogFormVisible_MaintenanceAudit = false
                this.dialogFormVisible_See = false
                this.statueReason = false
                this.$notify({ title: '成功', message: '审核成功', type: 'success', duration: 2000 })
              } else {
                failproccess(response, this.$notify)
              }
            })
          }
        })
      } else {
        console.log('点击了维修审核确认-未通过')
        this.isokDisable = true
        setTimeout(() => {
          this.isokDisable = false
        }, 1000)
        this.$refs['examineTemp'].validate(valid => {
          if (valid) {
            this.requestParam.name = 'maintainCharge1'
            this.requestParam.parammaps = {}
            this.requestParam.parammaps.id = this.examineTemp.id
            this.requestParam.parammaps.statue = 6
            this.requestParam.parammaps.empId	 = Cookies.get('employeid')
            this.requestParam.parammaps.workflowNote = this.examineTemp.workflowNote
            PostDataByName(this.requestParam).then(response => {
              console.log('维修审核确认发送参数', this.requestParam)
              if (response.msg !== 'fail') {
                if (this.getdataListParm.parammaps.inputDatetime === null) {
                  this.getdataListParm.parammaps.inputDatetime = ''
                }
                this.getList()
                this.getPendingList()
                this.dialogFormVisible_MaintenanceAudit = false
                this.dialogFormVisible_See = false
                this.$notify({ title: '成功', message: '审核成功', type: 'success', duration: 2000 })
              } else {
                failproccess(response, this.$notify)
              }
            })
          }
        })
      }
    },
    // 接单
    handleReceipt(row) {
      if (row == undefined) {
        this.receiptTemp = this.seeTemp
      } else {
        this.receiptTemp = Object.assign({}, row)
      }
      MessageBox.confirm('是否确认接单', {
        title: '接单',
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.requestParam.name = 'takeRepirsEmp'
        this.requestParam.parammaps = {}
        this.requestParam.parammaps.id = this.receiptTemp.id
        PostDataByName(this.requestParam).then((response) => {
          if (response.msg !== 'fail') {
            this.getList()
            this.getPendingList()
            this.dialogFormVisible_See = false
            this.$notify({ title: '成功', message: '接单成功', type: 'success', duration: 2000 })
          } else {
            failproccess(response, this.$notify)
          }
        })
      })
    },
    // 完成维修
    handleRepairComplete(row) {
      console.log('点击了完成维修', row)
      if (row == undefined) {
        this.$set(this.seeTemp, 'isOldProducts', 0)
        this.repairCompleteTemp = this.seeTemp
      } else {
        this.repairCompleteTemp = Object.assign({}, row)
        this.$set(this.repairCompleteTemp, 'isOldProducts', 0)
      }
      this.No2 = false
      this.dialogStatus = 'repairComplete'
      this.dialogFormVisible_RepairComplete = true
      this.getFaultList()
    },
    changeIsOldProducts(val) {
      console.log(val)
      if (val == 1) {
        this.No2 = true
      } else {
        this.No2 = false
      }
    },
    // 完成维修保存
    createRepairCompleteData() {
      console.log('点击了完成维修确认')
      if (this.listFault.length > 0) {
        if (this.repairCompleteTemp.laidcou == 0) {
          if (this.repairCompleteTemp.isOldProducts == 0) {
            console.log('否')
            this.requestParam.name = 'completeRepirs'
            this.requestParam.parammaps = {}
            this.requestParam.parammaps.id = this.repairCompleteTemp.id
            PostDataByName(this.requestParam).then((response) => {
              if (response.msg !== 'fail') {
                this.getList()
                this.getPendingList()
                this.dialogFormVisible_RepairComplete = false
                this.dialogFormVisible_See = false
                this.$notify({ title: '成功', message: '成功', type: 'success', duration: 2000 })
              } else {
                failproccess(response, this.$notify)
              }
            })
          } else {
            console.log('是')
            this.isokDisable = true
            setTimeout(() => {
              this.isokDisable = false
            }, 1000)
            this.$refs['repairCompleteTemp'].validate(valid => {
              if (valid) {
                if (this.listAdd.length !== 0) {
                  for (var i = 0; i < this.listAdd.length; i++) {
                    if (this.listAdd[i].acturalAmount == null || this.listAdd[i].acturalAmount == '') {
                      this.$message({
                        type: 'warning',
                        message: '请录入数量是否未填写',
                        duration: 2000
                      })
                      return false
                    } else {
                      var rulesActuralAmount = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
                      if (!rulesActuralAmount.test(parseFloat(this.listAdd[i].acturalAmount))) {
                        this.$message({ type: 'error', message: '录入数量请输入正数，最多保留两位小数点', duration: 2000 })
                        return false
                      }
                    }
                  }
                  this.postDataPramas.common = { 'returnmap': '0' }
                  this.postDataPramas.data = []
                  this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listAdd }}
                  this.postDataPramas.data[0].children = []
                  this.postDataPramas.data[0].children[0] = { 'name': 'insertRepirsRefuse', 'type': 'e', 'parammaps': {
                    pastureId: this.repairCompleteTemp.pastureId,
                    deptId: this.repairCompleteTemp.departmentId,
                    partCode: '@insertSpotList.partCode',
                    partName: '@insertSpotList.partName',
                    partId: '@insertSpotList.id',
                    specification: '@insertSpotList.specification',
                    unit: '@insertSpotList.unit',
                    acturalAmount: '@insertSpotList.acturalAmount',
                    eqId: this.repairCompleteTemp.eqId,
                    eqCode: this.repairCompleteTemp.eqCode,
                    eqName: this.repairCompleteTemp.eqName,
                    repairCode: this.repairCompleteTemp.repairCode,
                    listType: 0
                  }}
                  this.postDataPramas.data[1] = { 'name': 'completeRepirs', 'type': 'e', 'parammaps': {
                    id: this.repairCompleteTemp.id
                  }}
                  ExecDataByConfig(this.postDataPramas).then(response => {
                    console.log('完成维修-是-保存发送参数', this.postDataPramas)
                    if (response.msg === 'fail') {
                      this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
                    } else {
                      this.listAdd = []
                      this.dialogFormVisible_RepairComplete = false
                      this.dialogFormVisible_See = false
                      this.getList()
                      this.getPendingList()
                      this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
                    }
                  })
                  return true
                } else {
                  this.$notify({ title: '', message: '请完善旧品信息', type: 'warning', duration: 2000 })
                  return false
                }
              }
            })
          }
        } else {
          this.$notify({ message: '备件未领用不可完成维修', type: 'warning', duration: 2000 })
        }
      } else {
        this.$message({ type: 'warning', message: '请完善故障信息！' })
      }
    },
    oldProductsSearch(queryString, cb) {
      console.log('旧品录入模糊查询输入值', queryString)
      this.requestOldProducts.parammaps['partCode'] = queryString
      this.requestOldProducts.parammaps['RUCode'] = this.repairCompleteTemp.repairCode
      GetDataByName(this.requestOldProducts).then(response => {
        console.log('旧品录入模糊查询搜索data', response.data.list)
        cb(response.data.list)
      })
    },
    handleSelectOldProducts(item) {
      this.repairCompleteTemp.partCode = ''
      console.log('旧品录入模糊查询选中值', item)
      if (this.listAdd.length > 0) {
        // eslint-disable-next-line no-redeclare
        if (this.listAdd.find(obj => obj.id === item.id)) {
          this.$message({ type: 'warning', message: '此旧品已存在，请重新选择旧品' })
        } else {
          if (item.checkoutNumber == null) {
            this.$set(item, 'checkoutNumber', item.reportery)
          }
          this.listAdd.unshift(item)
        }
      } else {
        if (item.checkoutNumber == null) {
          this.$set(item, 'checkoutNumber', item.reportery)
        }
        this.listAdd.unshift(item)
      }
    },
    partDelete(row) {
      console.log(this.listAdd)
      MessageBox.confirm('设备名称：' + row.partName, '确认删除？', {
        confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
      }).then(() => {
        // console.log(this.list2)
        for (var i = 0; i < this.listAdd.length; i++) {
          console.log(this.listAdd[i])
          if (this.listAdd[i].id === row.id) {
            var listAddIndex = this.listAdd.indexOf(this.listAdd[i])
          }
          if (listAddIndex > -1) {
            this.listAdd.splice(listAddIndex, 1)
            return
          }
        }
      })
    },
    // 维修及领用
    handleMaintenanceRequisition(row) {
      console.log('点击了维修及领用')
      if (row == undefined) {
        this.maintenanceRequisitionTemp = this.seeTemp
        this.$set(this.maintenanceRequisitionTemp, 'repirsTime', parseTime(new Date(), '{y}-{m}-{d}'))
      } else {
        this.maintenanceRequisitionTemp = Object.assign({}, row)
        this.$set(this.maintenanceRequisitionTemp, 'repirsTime', parseTime(new Date(), '{y}-{m}-{d}'))
      }
      this.dialogStatus = 'maintenanceRequisition'
      this.dialogFormVisible_MaintenanceRequisition = true
      this.getNewFaultList()
      this.getPosition()
      this.getCollectionSpareParts()
      this.getCollectionSpareParts2()
    },
    getNewFaultList() {
      this.listLoadingFault = true
      this.getFaultListParm.parammaps.maintainId = this.maintenanceRequisitionTemp.id
      GetDataByName(this.getFaultListParm).then(response => {
        console.log('故障table数据', response.data.list)
        if (response.data.list !== null) {
          this.listNewFault = response.data.list
        } else {
          this.listNewFault = []
        }
        setTimeout(() => {
          this.listLoadingFault = false
        }, 100)
      })
    },
    getNewCollarUseList() {
      this.listLoadingCollarUse = true
      this.getCollarUseListParm.parammaps.RUCode = this.maintenanceRequisitionTemp.repairCode
      GetDataByName(this.getCollarUseListParm).then(response => {
        console.log('领用记录table数据', response.data.list)
        this.listCollarUse = response.data.list
        setTimeout(() => {
          this.listLoadingCollarUse = false
        }, 100)
      })
    },
    tabMaintenance(tab, event) {
      console.log(tab.name)
      if (tab.name == 'first') {
        this.rapairBtn = true
      } else {
        this.rapairBtn = false
      }
    },
    getPosition() {
      this.getPositionsParm.parammaps.eqId = this.maintenanceRequisitionTemp.eqId
      GetDataByName(this.getPositionsParm).then(response => {
        console.log('故障部位数据', response.data.list)
        this.positions = response.data.list
      })
    },
    changePosition(val) {
      console.log('故障部位输入值', val)
      console.log(this.positions.find(obj => obj.id == val).positionName)
      this.newFaultTemp.positionName = this.positions.find(obj => obj.id == val).positionName
      this.getAppearanceParm.parammaps.id = val
      this.getAppearance()
    },
    getAppearance() {
      GetDataByName(this.getAppearanceParm).then(response => {
        console.log('故障详情数据', response.data.list)
        this.appearances = response.data.list
      })
    },
    changeAppearance(val) {
      console.log('故障详情输入值', val)
      if (this.newFaultTemp.positionId == '') {
        this.$message({
          type: 'warning',
          message: '请选择故障部位'
        })
      }
      if (this.listNewFault == null) {
        this.listNewFault = []
        this.listNewFault.push({ 'rowId': this.rowId++, positionId: this.newFaultTemp.positionId, positionName: this.newFaultTemp.positionName, appearanceName: val, failureCause: this.newFaultTemp.failureCause, treatmentMethod: this.newFaultTemp.treatmentMethod })
        this.newFaultTemp = {}
        this.appearances = []
      } else {
        this.listNewFault.push({ 'rowId': this.rowId++, positionId: this.newFaultTemp.positionId, positionName: this.newFaultTemp.positionName, appearanceName: val, failureCause: this.newFaultTemp.failureCause, treatmentMethod: this.newFaultTemp.treatmentMethod })
        this.newFaultTemp = {}
        this.appearances = []
      }
    },
    newFaultDelete(row) {
      console.log(row)
      MessageBox.confirm('确认删除？', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        for (var i = 0; i < this.listNewFault.length; i++) {
          console.log(this.listNewFault[i])
          if (this.listNewFault[i].rowId === row.rowId) {
            var listNewFaultIndex = this.listNewFault.indexOf(this.listNewFault[i])
          }
          if (listNewFaultIndex > -1) {
            this.listNewFault.splice(listNewFaultIndex, 1)
            return
          }
        }
      })
    },
    // 维修及领用-维修确认
    createMaintenanceRequisitionteData() {
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['maintenanceRequisitionTemp'].validate(valid => {
        if (valid) {
          console.log(this.newFaultTemp.positionId)
          if (this.listNewFault.length == 0) {
            this.$notify({ title: '', message: '请输入故障诊断', type: 'warning', duration: 2000 })
            return false
          } else {
            for (let i = 0; i < this.listNewFault.length; i++) {
              if (this.listNewFault[i].failureCause == '' || this.listNewFault[i].failureCause == undefined) {
                this.$notify({ title: '', message: '请输入故障原因', type: 'warning', duration: 2000 })
                return false
              }
            }
          }
          if (this.listNewFault.length !== 0) {
            this.postDataPramas.common = { 'returnmap': '0' }
            this.postDataPramas.data = []
            this.postDataPramas.data[0] = { 'name': 'deleteMaintainAppearance', 'type': 'e', 'parammaps': {
              maintainId: this.maintenanceRequisitionTemp.id
            }}
            this.postDataPramas.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listNewFault }}
            this.postDataPramas.data[1].children = []
            this.postDataPramas.data[1].children[0] = { 'name': 'insertMaintainAppearance', 'type': 'e', 'parammaps': {
              appearanceName: '@insertSpotList.appearanceName',
              positionId: '@insertSpotList.positionId',
              positionName: '@insertSpotList.positionName',
              repirsTime: this.maintenanceRequisitionTemp.repirsTime,
              maintainId: this.maintenanceRequisitionTemp.id,
              failureCause: '@insertSpotList.failureCause',
              treatmentMethod: '@insertSpotList.treatmentMethod'
            }}
            ExecDataByConfig(this.postDataPramas).then(response => {
              console.log('维修及领用-维修确认保存发送参数', this.postDataPramas)
              if (response.msg === 'fail') {
                this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
              } else {
                this.getList()
                this.getPendingList()
                this.dialogFormVisible_MaintenanceRequisition = false
                this.dialogFormVisible_See = false
                this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
              }
            })
          } else {
            this.$notify({ title: '', message: '请选择故障', type: 'warning', duration: 2000 })
            return false
          }
        }
      })
    },
    getCollectionSpareParts() {
      this.getCollarUseListParm.parammaps.RUCode = this.maintenanceRequisitionTemp.repairCode
      GetDataByName(this.getCollarUseListParm).then(response => {
        console.log('备件领用table数据', response.data.list)
        this.listCollectionSpareParts = response.data.list
      })
    },
    getCollectionSpareParts2() {
      this.getCollarUseListParm2.parammaps.RUCode = this.maintenanceRequisitionTemp.repairCode
      GetDataByName(this.getCollarUseListParm2).then(response => {
        console.log('备件领用无库存table数据', response.data.list)
        this.listCollectionSpareParts2 = response.data.list
      })
    },
    openDetails(row, column, cell, event) {
      if (column.label !== '操作') {
        this.$router.push({ path: '/customs/Receive', query: { applyCode: row.applyCode }})
      }
    },
    handleCollarUseSee(row, isStock) {
      this.collectionSparePartsSeeTemp = Object.assign({}, row)
      this.dialogStatus = 'collectionSparePartsSee'
      this.dialogFormVisible_CollectionSparePartsSee = true
      this.isCreatePartDelete = false
      this.isPartCode = false
      if (isStock == 0) {
        this.collectionSparePartsSeeTemp.isStock = 0
        this.getCollarUseSeeList()
      } else if (isStock == 1) {
        this.collectionSparePartsSeeTemp.isStock = 1
        this.getCollarUseSeeList2()
      }
    },
    getCollarUseSeeList() {
      this.getCollarUseSeeParm.parammaps.id = this.collectionSparePartsSeeTemp.id
      GetDataByName(this.getCollarUseSeeParm).then(response => {
        this.listCreateCollectionSpareParts = response.data.list
      })
    },
    getCollarUseSeeList2() {
      // console.log(this.collectionSparePartsSeeTemp)
      this.getCollarUseSeeParm2.parammaps.bigId = this.maintenanceRequisitionTemp.repairCode
      GetDataByName(this.getCollarUseSeeParm2).then(response => {
        this.listCreateCollectionSpareParts = response.data.list
      })
    },
    handleCollectionSparePartsCreate() {
      this.collectionSparePartsSeeTemp = this.maintenanceRequisitionTemp
      this.collectionSparePartsSeeTemp.createDate = parseTime(new Date(), '{y}-{m}-{d}')
      this.dialogStatus = 'collectionSparePartsCreate'
      this.dialogFormVisible_CollectionSparePartsSee = true
      this.isCreatePartDelete = true
      this.listCreateCollectionSpareParts = []
      this.isPartCode = true
      this.getCreateNumber()
    },
    getCreateNumber() {
      GetDataByName(this.getParmCreateNumber).then(response => {
        this.$nextTick(() => {
          console.log('新增领用单号', response.data.list[0].orderCode)
          this.collectionSparePartsSeeTemp.applyCode = response.data.list[0].orderCode
          this.$forceUpdate()
        })
      })
    },
    sparePartSearch(queryString, cb) {
      console.log('备件模糊查询输入值', queryString)
      this.requestSparePart.parammaps['partCode'] = queryString
      GetDataByName(this.requestSparePart).then(response => {
        console.log('备件模糊查询搜索data', response.data.list)
        if (response.data.list == null) {
          cb([])
        } else {
          cb(response.data.list)
        }
      })
    },
    handleSelectSparePart(item) {
      console.log('备件模糊查询选中值', item)
      if (this.listCreateCollectionSpareParts.length > 0) {
        // eslint-disable-next-line no-redeclare
        if (this.listCreateCollectionSpareParts.find(obj => obj.partId === item.partId)) {
          this.$message({ type: 'warning', message: '此备件已存在，请重新选择备件' })
        } else {
          this.listCreateCollectionSpareParts.unshift(item)
        }
      } else {
        this.listCreateCollectionSpareParts.unshift(item)
      }
    },
    handleAddSparePartsToBeCollected() {
      console.log('添加待领用备件')
      this.addSparePartsToBeCollectedParam.parammaps.RUCode = this.maintenanceRequisitionTemp.repairCode
      GetDataByName(this.addSparePartsToBeCollectedParam).then(response => {
        if (response.data.list == null) {
          this.$message({ type: 'warning', message: '无可添加待领用备件' })
        } else {
          if (this.listCreateCollectionSpareParts.length > 0) {
            console.log(this.filtersArr(this.listCreateCollectionSpareParts, response.data.list))
            this.listCreateCollectionSpareParts = this.filtersArr(this.listCreateCollectionSpareParts, response.data.list)
          } else {
            this.listCreateCollectionSpareParts = response.data.list
          }
        }
      })
    },
    filtersArr(list, list2) {
      for (var i = 0; i < list.length; i++) {
        for (var j = 0; j < list2.length; j++) {
          if (list[i].partId == list2[j].partId) {
            list[i] = list2[j]
            list2.splice(j, 1)
          }
        }
      }
      return list.concat(list2)
    },
    createPartDelete(row) {
      console.log(this.listAdd)
      MessageBox.confirm('设备名称：' + row.partName, '确认删除？', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // console.log(this.list2)
        for (var i = 0; i < this.listCreateCollectionSpareParts.length; i++) {
          console.log(this.listCreateCollectionSpareParts[i])
          if (this.listCreateCollectionSpareParts[i].id === row.id) {
            var listCreateCollectionSparePartsIndex = this.listCreateCollectionSpareParts.indexOf(this.listCreateCollectionSpareParts[i])
          }
          if (listCreateCollectionSparePartsIndex > -1) {
            this.listCreateCollectionSpareParts.splice(listCreateCollectionSparePartsIndex, 1)
            return
          }
        }
      })
    },
    handleViewProgress(row) {
      console.log('查看进度', row)
      console.log(this.maintenanceRequisitionTemp)
      this.viewProgressTemp = Object.assign({}, row)
      this.dialogStatus = 'ViewProgress'
      this.dialogFormVisible_ViewProgress = true
      this.getNumbers()
      this.getPurchaseapplicationList()
      this.getProcurementList()
    },
    getNumbers() {
      this.getNumbersParm.parammaps.contractId = this.viewProgressTemp.contractId
      this.getNumbersParm.parammaps.RUCode = this.maintenanceRequisitionTemp.repairCode
      GetDataByName(this.getNumbersParm).then(response => {
        this.numbersList = response.data.list[0]
      })
    },
    // 申购情况
    getPurchaseapplicationList() {
      this.getPurchaseapplicationParm.parammaps.createDate = this.viewProgressTemp.date
      this.getPurchaseapplicationParm.parammaps.partCode = this.viewProgressTemp.partCode
      this.getPurchaseapplicationParm.parammaps.pastureId = this.viewProgressTemp.pastureId
      GetDataByName(this.getPurchaseapplicationParm).then(response => {
        if (response.data.list !== null) {
          this.purchaseapplicationList = response.data.list
        } else {
          this.purchaseapplicationList = []
        }
      })
    },
    // 采购情况
    getProcurementList() {
      this.getProcurementParm.parammaps.createDate = this.viewProgressTemp.date
      this.getProcurementParm.parammaps.partCode = this.viewProgressTemp.partCode
      this.getProcurementParm.parammaps.pastureId = this.viewProgressTemp.pastureId
      GetDataByName(this.getProcurementParm).then(response => {
        if (response.data.list !== null) {
          this.procurementList = response.data.list
        } else {
          this.procurementList = []
        }
      })
    },
    // 添加领用保存
    createCollectionSparePartsData() {
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['collectionSparePartsSeeTemp'].validate(valid => {
        if (valid) {
          if (this.listCreateCollectionSpareParts.length !== 0) {
            for (var i = 0; i < this.listCreateCollectionSpareParts.length; i++) {
              console.log(this.listCreateCollectionSpareParts[i].amount)
              if (this.listCreateCollectionSpareParts[i].amount !== undefined && this.listCreateCollectionSpareParts[i].amount !== '') {
                var rulesAmount = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
                if (!rulesAmount.test(this.listCreateCollectionSpareParts[i].amount)) {
                  this.$message({
                    type: 'error',
                    message: '领用数量请输入正数，最多保留两位小数',
                    duration: 2000
                  })
                  return false
                } else {
                  var listCreateCollectionSpareParts1 = [] // >库存
                  var listCreateCollectionSpareParts2 = [] // <=库存
                  var amountList = []
                  var amount2List = []
                  for (let i = 0; i < this.listCreateCollectionSpareParts.length; i++) {
                    var obj = {}
                    var obj2 = {}
                    obj.amount = this.listCreateCollectionSpareParts[i].amount
                    obj.bigId = this.listCreateCollectionSpareParts[i].bigId
                    obj.brand = this.listCreateCollectionSpareParts[i].brand
                    obj.brandId = this.listCreateCollectionSpareParts[i].brandId
                    obj.contractId = this.listCreateCollectionSpareParts[i].contractId
                    obj.enable = this.listCreateCollectionSpareParts[i].enable
                    obj.id = this.listCreateCollectionSpareParts[i].id
                    obj.inventoryType = this.listCreateCollectionSpareParts[i].inventoryType
                    obj.isZeroStock = this.listCreateCollectionSpareParts[i].isZeroStock
                    obj.partCode = this.listCreateCollectionSpareParts[i].partCode
                    obj.partId = this.listCreateCollectionSpareParts[i].partId
                    obj.partName = this.listCreateCollectionSpareParts[i].partName
                    obj.partRepId = this.listCreateCollectionSpareParts[i].partRepId
                    obj.pastureId = this.listCreateCollectionSpareParts[i].pastureId
                    obj.pastureName = this.listCreateCollectionSpareParts[i].pastureName
                    obj.planAmount = this.listCreateCollectionSpareParts[i].planAmount
                    obj.price = this.listCreateCollectionSpareParts[i].price
                    obj.providerId = this.listCreateCollectionSpareParts[i].providerId
                    obj.providerName = this.listCreateCollectionSpareParts[i].providerName
                    obj.remark = this.listCreateCollectionSpareParts[i].remark
                    obj.reportery = this.listCreateCollectionSpareParts[i].reportery
                    obj.specification = this.listCreateCollectionSpareParts[i].specification
                    obj.unit = this.listCreateCollectionSpareParts[i].unit
                    obj.prid = this.listCreateCollectionSpareParts[i].prid
                    obj.mr = this.listCreateCollectionSpareParts[i].mr
                    obj.locationId = this.listCreateCollectionSpareParts[i].locationId
                    amountList.push(obj)
                    obj2.amount = this.listCreateCollectionSpareParts[i].amount
                    obj2.bigId = this.listCreateCollectionSpareParts[i].bigId
                    obj2.brand = this.listCreateCollectionSpareParts[i].brand
                    obj2.brandId = this.listCreateCollectionSpareParts[i].brandId
                    obj2.contractId = this.listCreateCollectionSpareParts[i].contractId
                    obj2.enable = this.listCreateCollectionSpareParts[i].enable
                    obj2.id = this.listCreateCollectionSpareParts[i].id
                    obj2.inventoryType = this.listCreateCollectionSpareParts[i].inventoryType
                    obj2.isZeroStock = this.listCreateCollectionSpareParts[i].isZeroStock
                    obj2.partCode = this.listCreateCollectionSpareParts[i].partCode
                    obj2.partId = this.listCreateCollectionSpareParts[i].partId
                    obj2.partName = this.listCreateCollectionSpareParts[i].partName
                    obj2.partRepId = this.listCreateCollectionSpareParts[i].partRepId
                    obj2.pastureId = this.listCreateCollectionSpareParts[i].pastureId
                    obj2.pastureName = this.listCreateCollectionSpareParts[i].pastureName
                    obj2.planAmount = this.listCreateCollectionSpareParts[i].planAmount
                    obj2.price = this.listCreateCollectionSpareParts[i].price
                    obj2.providerId = this.listCreateCollectionSpareParts[i].providerId
                    obj2.providerName = this.listCreateCollectionSpareParts[i].providerName
                    obj2.remark = this.listCreateCollectionSpareParts[i].remark
                    obj2.reportery = this.listCreateCollectionSpareParts[i].reportery
                    obj2.specification = this.listCreateCollectionSpareParts[i].specification
                    obj2.unit = this.listCreateCollectionSpareParts[i].unit
                    obj2.prid = this.listCreateCollectionSpareParts[i].prid
                    obj.mr = this.listCreateCollectionSpareParts[i].mr
                    obj2.locationId = this.listCreateCollectionSpareParts[i].locationId
                    amount2List.push(obj2)
                  }
                  for (let i = 0; i < amountList.length; i++) {
                    if (parseFloat(amountList[i].amount) > parseFloat(amountList[i].reportery)) {
                      var amount = String(parseFloat(amountList[i].amount) - parseFloat(amountList[i].reportery))
                      amountList[i].amount = amount
                      listCreateCollectionSpareParts1.push(amountList[i])
                      if (parseFloat(amountList[i].reportery) > 0) {
                        amount2List[i].amount = String(amount2List[i].reportery)
                        listCreateCollectionSpareParts2.push(amount2List[i])
                      }
                    } else {
                      listCreateCollectionSpareParts2.push(amountList[i])
                    }
                  }
                  console.log(this.listCreateCollectionSpareParts, 'this.listCreateCollectionSpareParts')
                  console.log(listCreateCollectionSpareParts1, '>库存listCreateCollectionSpareParts1')
                  console.log(listCreateCollectionSpareParts2, '<=库存listCreateCollectionSpareParts2')
                  let mySumPrice = 0
                  for (let i = 0; i < listCreateCollectionSpareParts2.length; i++) {
                    mySumPrice += parseFloat(listCreateCollectionSpareParts2[i].price) * parseFloat(listCreateCollectionSpareParts2[i].amount)
                  }
                  if (mySumPrice > 500) {
                    this.collectionSparePartsSeeTemp.SHStatus = 2
                  } else {
                    this.collectionSparePartsSeeTemp.SHStatus = 9
                  }
                  this.postDataPramas.common = { 'returnmap': '0' }
                  this.postDataPramas.data = []
                  this.postDataPramas.data[0] = { 'name': 'insertSpotList3', 'resultmaps': { 'list': this.listCreateCollectionSpareParts }}
                  this.postDataPramas.data[0].children = []
                  this.postDataPramas.data[0].children[0] = { 'name': 'updatePartapplyuseAmount_m', 'type': 'e', 'parammaps': {
                    amount: '@insertSpotList3.amount',
                    paid: '@insertSpotList3.contractId',
                    RUCode: this.collectionSparePartsSeeTemp.repairCode
                  }}
                  this.postDataPramas.data[1] = { 'name': 'insertBigpartapply_m', 'type': 'e', 'parammaps': {
                    pastureId: this.collectionSparePartsSeeTemp.pastureId,
                    applyCode: this.collectionSparePartsSeeTemp.applyCode,
                    applyType: 1,
                    departmentId: this.collectionSparePartsSeeTemp.departmentId,
                    empId: this.collectionSparePartsSeeTemp.pickId,
                    applyDate: this.collectionSparePartsSeeTemp.createDate,
                    RUCode: this.collectionSparePartsSeeTemp.repairCode
                  }}
                  this.postDataPramas.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': listCreateCollectionSpareParts1 }}
                  this.postDataPramas.data[2].children = []
                  this.postDataPramas.data[2].children[0] = { 'name': 'insertpartapply_m', 'type': 'e', 'parammaps': {
                    bigId: this.collectionSparePartsSeeTemp.repairCode,
                    prid: '@insertSpotList2.prid',
                    pastureId: '@insertSpotList2.pastureId',
                    partId: '@insertSpotList2.partId',
                    partCode: '@insertSpotList2.partCode',
                    partName: '@insertSpotList2.partName',
                    specification: '@insertSpotList2.specification',
                    brandId: '@insertSpotList2.brandId',
                    price: '@insertSpotList2.price',
                    amount: '@insertSpotList2.amount',
                    eqName: this.collectionSparePartsSeeTemp.eqName,
                    eqCode: this.collectionSparePartsSeeTemp.eqCode,
                    providerId: '@insertSpotList2.providerId',
                    note: '@insertSpotList2.note',
                    reportery: '@insertSpotList2.reportery',
                    contractId: '@insertSpotList2.contractId'
                  }}
                  if (listCreateCollectionSpareParts2.length > 0) {
                    this.postDataPramas.data[3] = { 'name': 'insertBigpartapply', 'type': 'e', 'parammaps': {
                      pastureId: this.collectionSparePartsSeeTemp.pastureId,
                      applyCode: this.collectionSparePartsSeeTemp.applyCode,
                      applyType: 1,
                      departmentId: this.collectionSparePartsSeeTemp.departmentId,
                      empId: this.collectionSparePartsSeeTemp.pickId,
                      applyDate: this.collectionSparePartsSeeTemp.createDate,
                      RUCode: this.collectionSparePartsSeeTemp.repairCode,
                      SHStatus: this.collectionSparePartsSeeTemp.SHStatus
                    }}
                    this.postDataPramas.data[4] = { 'name': 'insertSpotList', 'resultmaps': { 'list': listCreateCollectionSpareParts2 }}
                    this.postDataPramas.data[4].children = []
                    this.postDataPramas.data[4].children[0] = { 'name': 'insertpartapply', 'type': 'e', 'parammaps': {
                      bigId: '@insertBigpartapply.LastInsertId',
                      pastureId: '@insertSpotList.pastureId',
                      partId: '@insertSpotList.partId',
                      partCode: '@insertSpotList.partCode',
                      partName: '@insertSpotList.partName',
                      specification: '@insertSpotList.specification',
                      brandId: '@insertSpotList.brandId',
                      price: '@insertSpotList.price',
                      amount: '@insertSpotList.amount',
                      eqName: this.collectionSparePartsSeeTemp.eqName,
                      eqCode: this.collectionSparePartsSeeTemp.eqCode,
                      providerId: '@insertSpotList.providerId',
                      note: '@insertSpotList.note',
                      reportery: '@insertSpotList.reportery',
                      contractId: '@insertSpotList.contractId',
                      locationId: '@insertSpotList.locationId'
                    }}
                  }
                  ExecDataByConfig(this.postDataPramas).then(response => {
                    console.log('添加领用保存发送参数', this.postDataPramas)
                    if (response.msg === 'fail') {
                      this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
                    } else {
                      this.dialogFormVisible_CollectionSparePartsSee = false
                      this.getCollectionSpareParts()
                      this.getCollectionSpareParts()
                      this.getCollectionSpareParts2()
                      this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
                    }
                  })
                  return true
                }
              } else {
                this.$message({ type: 'error', message: '请检查领用数量是否未填写', duration: 2000 })
                return false
              }
            }
          } else {
            this.$notify({ title: '', type: 'warning', message: '请选择备件', duration: 2000 })
            return false
          }
        }
      })
    },
    form_delete(row) {
      MessageBox.confirm('确认删除？', {
        confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
      }).then(() => {
        this.requestParam.name = 'deleteMaintain'
        this.requestParam.parammaps = {}
        this.requestParam.parammaps.id = row.id
        PostDataByName(this.requestParam).then((response) => {
          if (response.msg !== 'fail') {
            this.getList()
            this.getPendingList()
            this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
          } else {
            failproccess(response, this.$notify)
          }
        })
      }).catch(() => {
        this.$message({ type: 'info', message: '已取消删除' })
      })
    },
    handleRejectRepair(row) {
      console.log('报修驳回')
      this.rejectRepair.temp = Object.assign({}, row)
      this.dialogStatus = 'rejectRepair'
      this.rejectRepair.dialogFormVisible = true
    },
    rejectRepairData() {
      console.log('报修驳回确认')
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      this.$refs['rejectRepair'].validate(valid => {
        if (valid) {
          this.requestParam.name = 'updateMaintain'
          this.requestParam.parammaps = {}
          this.requestParam.parammaps.shutdownPerson = Cookies.get('employeid')
          this.requestParam.parammaps.id = this.rejectRepair.temp.id
          this.requestParam.parammaps.shutdownReason = this.rejectRepair.temp.shutdownReason
          PostDataByName(this.requestParam).then((response) => {
            if (response.msg !== 'fail') {
              this.getList()
              this.getPendingList()
              this.rejectRepair.dialogFormVisible = false
              this.$notify({ title: '成功', message: '驳回成功', type: 'success', duration: 2000 })
            } else {
              failproccess(response, this.$notify)
            }
          })
        }
      })
    },
    handleDownload() {
      this.$alert('设备维修正在导出中，请勿刷新或离开本页面，若导出时间过长，建议缩小导出数据范围重新导出', {})
      this.isPercentage = true
      this.percentage = 1
      var timer = setInterval(() => {
        this.percentage += 5
        if (this.percentage > 95) {
          this.percentage = 99
          clearInterval(timer)
        }
        this.percentage = this.percentage
      }, 1000)
      this.downLoadParm = {}
      this.downLoadParm.name = 'loadRepirsList'
      this.downLoadParm.offset = 0
      this.downLoadParm.page = 1
      this.downLoadParm.returntype = 'Map'
      if (this.$refs['inputDatetime'] !== undefined && this.$refs['inputDatetime'].value !== null) {
        this.getdataListParm.parammaps.startTime = this.$refs['inputDatetime'].value[0]
        this.getdataListParm.parammaps.stopTime = this.$refs['inputDatetime'].value[1]
      } else {
        this.getdataListParm.parammaps.startTime = ''
        this.getdataListParm.parammaps.stopTime = ''
      }
      this.downLoadParm.parammaps = this.getdataListParm.parammaps
      GetAccount(this.downLoadParm).then(response => {
        if(response.data.list !== null && response.data.list !== ''){
          for(let i=0;i<response.data.list.length;i++){
            if(response.data.list[i].orderStatue == 0){
              this.$set(response.data.list[i],'orderStatue','待接单')
            }else if(response.data.list[i].orderStatue == 1){
              this.$set(response.data.list[i],'orderStatue','维修中')
            }else if(response.data.list[i].orderStatue == 2){
              this.$set(response.data.list[i],'orderStatue','维修完成')
            }else if(response.data.list[i].orderStatue == 3){
              this.$set(response.data.list[i],'orderStatue','已驳回')
            }
            if (response.data.list[i].SHStatue == 1) {
              this.$set(response.data.list[i],'SHStatue','')
            } else if (response.data.list[i].SHStatue == 2 || response.data.list[i].SHStatue == 3) {
              this.$set(response.data.list[i],'SHStatue','审核中')
            } else if (response.data.list[i].SHStatue == 4 || response.data.list[i].SHStatue == 6) {
              this.$set(response.data.list[i],'SHStatue','未通过')
            } else if (response.data.list[i].SHStatue == 5) {
              this.$set(response.data.list[i],'SHStatue','已通过')
            }
          }
        }else{
          response.data.list = []
        }
        this.downLoadList = response.data.list
        console.log(this.downLoadList)
        if (response.data.list !== '') {
          this.percentage = 99
          setTimeout(() => {
            this.isPercentage = false
          }, 2000)
        }
        const elecExcelDatas = [
          {
            tHeader: ['报修单号', '牧场', '设备内部编号', '设备名称', '规格型号', '部门', '故障情况','报修人','报修时间','维修日期','维修部门','处理状态','领用单状态','旧品录入状态','审核状态','故障部位','故障详情','故障原因','处理方式'],
            filterVal: ['repairCode', 'pastureName', 'eqCode', 'eqName', 'specification', 'departmentName', 'details','requesterName','requestTime','stopTime','repairDeptName','orderStatue','LYStatue','LRStatue','SHStatue','positionName','appearanceName','failureCause','treatmentMethod'],
            tableDatas: this.downLoadList,
            sheetName: '设备维修'
          }
        ]
        json2excel(elecExcelDatas, '设备维修', true, 'xlsx')
      })
    },
  }
}
</script>
<style lang="scss" scoped>
.successMaintenanceAudit{
  width: 70px;
  color: #fff;
}
.successRequisition{
  width: 80px;
  color: #fff;
}
/deep/ .el-badge__content.is-fixed{
    z-index: 1;
  }
</style>
<style lang="scss">
.el-step__head.is-success {
    color: #409EFF;
    border-color: #409EFF;
}
.el-step__title.is-success{
  color: #409EFF;
}
.el-step__head.is-process{
  color: #409EFF;
  border-color: #409EFF;
  .el-step__icon.is-text{
    background: #409EFF;
    color: #fff;
  }
}
.step-row{
  color: #000;
}
</style>
