<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" :model="searchData">
      <el-form-item :label="'BU'">
        <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 80px">
          <el-option
            v-for = "i in userBuList"
            :key = "i.buNo"
            :label = "i.buDesc"
            :value = "i.buDesc">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'报修方式'">
        <el-select v-model="searchData.repairReportingType" placeholder="请选择" clearable style="width: 100px">
          <el-option label="设备故障" value="设备故障"></el-option>
          <el-option label="TPM红牌" value="TPM红牌"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'紧急程度'">
        <el-select v-model="searchData.urgency" placeholder="请选择" clearable style="width: 80px">
          <el-option label="特急" value="特急"></el-option>
          <el-option label="紧急" value="紧急"></el-option>
          <el-option label="一般" value="一般"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'是否退回'">
        <el-select v-model="searchData.isReturn" placeholder="请选择" clearable style="width: 100px">
          <el-option label="Y" value="Y"></el-option>
          <el-option label="N" value="N"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'反馈单号'">
        <el-input v-model="searchData.planID" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'工单编码'">
        <el-input v-model="searchData.orderNo" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'设备编码'">
        <el-input ref="objectID" @focus="cancelKeyboard" v-model="searchData.objectID" placeholder="请扫描设备" @keyup.native.enter="objectIdEnter" clearable style="width: 100px"></el-input>
      </el-form-item>
<!--      <el-form-item style="margin-left: 0px" >-->
<!--        <span slot="label" style="" @click="getBaseList(201)"><a herf="#">计划执行人员编码</a></span>-->
<!--        <el-input v-model="searchData.planOperator" clearable style="width: 120px"></el-input>-->
<!--      </el-form-item>-->
    </el-form>
    <el-form :inline="true" label-position="top" :model="searchData">
      <el-form-item :label="'状态'">
        <el-select v-model="searchData.status" clearable style="width: 100px">
          <el-option label="未开工" value="未开工"></el-option>
          <el-option label="已到达" value="已到达"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'单据来源'">
        <el-select v-model="searchData.documentSource" clearable style="width: 100px">
          <el-option label="设备点检" value="设备点检"></el-option>
          <el-option label="设备维修" value="设备维修"></el-option>
          <el-option label="维修失败" value="维修失败"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'计划执行日期：'">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.startDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item style="margin-top: 23px;">
        <laber style="margin-left: -9px;font-size: 19px">&#10142</laber>
      </el-form-item>
      <el-form-item :label="' '">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.endDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label=" ">
        <el-button v-if="!authSearch" @click="getDataList()">查询</el-button>
        <el-button @click="exportExcel()" type="primary" style="margin-left: 2px">{{'导出'}}</el-button>
<!--      <download-excel-->
<!--        :fields="fields()"-->
<!--        :data="exportData"-->
<!--        type="xls"-->
<!--        :name="exportName"-->
<!--        :header="exportHeader"-->
<!--        :footer="exportFooter"-->
<!--        :fetch="createExportData"-->
<!--        :before-generate="startDownload"-->
<!--        :before-finish="finishDownload"-->
<!--        worksheet="导出信息"-->
<!--        class="el-button el-button&#45;&#45;primary el-button&#45;&#45;medium">-->
<!--        {{ "导出" }}-->
<!--      </download-excel>-->
        <el-button type="primary" v-if="!authSearch" @click="transferOrderHandle()">转单</el-button>
      </el-form-item>
    </el-form>

    <el-table
      :height="height"
      :data="dataList"
      @selection-change="selectionChangeHandle"
      border
      style="width: 100%;"
      :row-style="rowStyle">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        prop="buDesc"
        header-align="center"
        align="center"
        label="BU"
        width="60">
      </el-table-column>
      <el-table-column
        prop="urgency"
        header-align="center"
        align="center"
        label="紧急程度"
        width="70">
        <template slot-scope="scope">
          <div :style="{fontWeight:'bold', color: scope.row.urgency === '特急' ? 'red' : scope.row.urgency === '紧急' ? '#ffa500e0' : scope.row.urgency === '一般' ? '#47B0FF' : ''}">
            {{ scope.row.urgency }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
      <el-table-column
        prop=""
        header-align="center"
        align="center"
        min-width="100"
        fixed="right"
        label="操作">
        <template slot-scope="scope">
          <el-link style="cursor: pointer" v-if="scope.row.status=='未开工' && !authReach" @click="chooseReachOperator(scope.row)">到达</el-link>
          <el-link style="cursor: pointer" v-if="scope.row.status=='已到达' && !authReport" @click="reportModal(scope.row)">执行</el-link>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[20, 50, 100, 200, 500]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <el-dialog top="18vh" :close-on-click-modal="false" v-drag :visible.sync="detailModelFlag" width="940px">
      <template v-slot:title>
        <div style="padding-top: 5px;padding-left: 15px">
          <span :style="{ fontSize: '15px', fontWeight: 'bold' }">维修工单</span>
          <span :style="{
          marginTop: '-5px',
          marginLeft: '5px',
          fontSize: '15px',
          verticalAlign: 'middle',
          display: 'inline-block',
          width: '17px',
          height: '17px',
          borderRadius: '50%',
          background: saveData.urgency === '特急' ? 'red' : saveData.urgency === '紧急' ? '#ffa500e0' : saveData.urgency === '一般' ? '#47B0FF' : ''}">
        </span>
        </div>
      </template>
      <div style="margin-left: 10px">
        <el-form :inline="true" label-position="top" style="margin-top: 10px">
          <el-form-item label="工单号">
            <el-input v-model="saveData.orderNo" disabled style="width: 100px"></el-input>
          </el-form-item>
          <el-form-item label="计划执行人员" style="margin-left: 30px">
            <el-input v-model="saveData.planOperatorName" disabled style="width: 100px"></el-input>
          </el-form-item>
          <el-form-item label="设备编码" style="margin-left: 30px">
            <el-input v-model="saveData.objectID" disabled style="width: 100px"></el-input>
          </el-form-item>
          <el-form-item label="设备名称" style="margin-left: 30px">
            <el-input v-model="saveData.objectDesc" disabled style="width: 150px"></el-input>
          </el-form-item>
          <el-form-item label="报修人" style="margin-left: 30px">
            <el-input v-model="saveData.createBy" disabled style="width: 100px"></el-input>
          </el-form-item>
          <el-form-item label="报修时间" style="margin-left: 30px">
            <el-input v-model="saveData.createdDate" disabled style="width: 130px"></el-input>
          </el-form-item>
        </el-form>
        <el-form :inline="true" label-position="top">
          <el-form-item label="响应人">
            <el-input v-model="saveData.reachOperatorName" disabled style="width: 100px"></el-input>
          </el-form-item>
          <el-form-item label="响应时间" style="margin-left: 30px">
            <el-input v-model="saveData.reachDate" disabled style="width: 130px"></el-input>
          </el-form-item>
          <el-form-item label="响应时长(m)">
            <el-input v-model="saveData.responseTime" disabled style="width: 100px"></el-input>
          </el-form-item>
          <el-form-item label="停机维修" style="margin-left: 30px">
            <el-input v-model="saveData.shutdownWarranty" disabled style="width: 68px"></el-input>
          </el-form-item>
          <el-form-item label="审核退回" style="margin-left: 0px">
            <el-input v-model="saveData.isReturn" disabled style="width: 68px"></el-input>
          </el-form-item>
          <el-form-item label="维修结果" prop="result" style="margin-left: 30px">
            <el-select v-model="saveData.result" style="width: 100px">
              <el-option label="维修完成" value="维修完成"></el-option>
              <el-option label="维修失败" value="维修失败"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item v-if="this.saveData.result === '维修失败'" label="处置措施" style="margin-left: 30px">
            <el-select v-model="saveData.disposalMeasures" style="width: 130px">
              <el-option label="缺少备件" value="缺少备件"></el-option>
              <el-option label="等待售后" value="等待售后"></el-option>
              <el-option label="远程协助" value="远程协助"></el-option>
              <el-option label="换班换人" value="换班换人"></el-option>
              <el-option label="设备维修组" value="设备维修组"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-form :inline="true" :model="saveData" label-position="top">
          <el-form-item label="报修反馈描述">
            <el-input type="textarea" v-model="saveData.feedBackDesc" :rows="3" resize='none' show-word-limit style="width: 900px"></el-input>
          </el-form-item>
        </el-form>
        <el-tabs v-model="activeTable" style="margin-top: 55px; width: 99%; height: 100%;" @tab-click="tabClick" class="customer-tab">
          <el-tab-pane label="维修单" name="inspection_form" style="height: 275px">
            <el-form :inline="true" :model="saveData" label-position="top" :rules="rules" style="margin-top: 5px">
              <el-form-item prop="defectID" :rules="rules.defectID">
                <span style="cursor: pointer" slot="label" @click="getBaseList(1033)"><a>故障编码</a></span>
                <el-input v-model="saveData.defectID" style="width: 120px"></el-input>
              </el-form-item>
              <el-form-item label="故障名称" style="margin-left: -10px">
                <el-input v-model="saveData.defectDesc" disabled style="width: 200px"></el-input>
              </el-form-item>
              <el-form-item prop="operatorName">
                <span style="cursor: pointer" slot="label" @click="getOperatorList"><a>实际维修人员</a></span>
                <el-input v-model="saveData.operatorName" style="width: 285px"></el-input>
              </el-form-item>
              <el-form-item :label="' '">
                <el-button type="primary" @click="uploadFaultImageModal">故障图片</el-button>
              </el-form-item>
              <el-form-item :label="' '">
                <el-button type="primary" @click="uploadSparPartImageModal">备件图片</el-button>
              </el-form-item>
              <el-form-item :label="' '">
                <el-button type="primary" @click="coreComponentModal">核心备件</el-button>
              </el-form-item>
            </el-form>
            <el-form :inline="true" :model="saveData" label-position="top" :rules="rules" style="margin-top: 15px">
              <el-form-item :label="'故障原因'">
                <el-input type="textarea" v-model="saveData.faultReason" :rows="3" resize='none' show-word-limit style="width: 431px"></el-input>
              </el-form-item>
              <el-form-item :label="'处理方式'" prop="handlingMethod" :rules="rules.handlingMethod">
                <el-input type="textarea" v-model="saveData.handlingMethod" :rows="3" resize='none' show-word-limit style="width: 431px"></el-input>
              </el-form-item>
            </el-form>
            <el-form :inline="true" label-position="top" style="margin-top: 65px">
              <el-form-item :label="'预防措施'">
                <el-input type="textarea" v-model="saveData.preventiveMeasure" :rows="3" resize='none' show-word-limit style="width: 431px"></el-input>
              </el-form-item>
              <el-form-item :label="'备注说明'">
                <el-input type="textarea" v-model="saveData.remark" :rows="3" resize='none' show-word-limit style="width: 431px"></el-input>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="故障图片" name="feed_back_img">
            <div class="rq ">
              <el-table
                :height="280"
                :data="feedBackImages"
                border
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnFeedBackImages" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :min-width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
                <el-table-column
                  fixed="right"
                  header-align="center"
                  align="center"
                  width="120"
                  label="操作">
                  <template slot-scope="scope">
                    <el-link style="cursor:pointer" @click="previewFile(scope.row)">预览</el-link>
                    <el-link style="cursor:pointer" @click="downloadFile(scope.row)">下载</el-link>
                    <el-link style="cursor:pointer" @click="deleteFile(scope.row)">删除</el-link>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="备件图片" name="spar_part_img">
            <div class="rq ">
              <el-table
                :height="280"
                :data="sparPartImages"
                border
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnSparPartImages" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :min-width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
                <el-table-column
                  fixed="right"
                  header-align="center"
                  align="center"
                  width="120"
                  label="操作">
                  <template slot-scope="scope">
                    <el-link style="cursor:pointer" @click="previewFile(scope.row)">预览</el-link>
                    <el-link style="cursor:pointer" @click="downloadFile(scope.row)">下载</el-link>
                    <el-link style="cursor:pointer" @click="deleteFile(scope.row)">删除</el-link>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="备品备件清单" name="part_spare_list">
            <div class="rq ">
              <el-table
                :height="280"
                :data="partSpareList"
                border
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnPartSpareList" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :min-width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
                <el-table-column
                  fixed="right"
                  header-align="center"
                  align="center"
                  width="100"
                  label="操作">
                  <template slot-scope="scope">
                    <el-link style="cursor:pointer" @click="defectExWarehouseModal()">维修出库</el-link>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="维修记录" name="history_record">
            <div class="rq ">
              <el-table
                :height="250"
                :data="historyRecordList"
                border
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnHistoryList" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :min-width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
                <el-table-column
                  fixed="right"
                  header-align="center"
                  align="center"
                  width="120"
                  label="图片">
                  <template slot-scope="scope">
                    <el-button v-if="scope.row.reportFaultFlag === 'Y'"
                               @click="checkFaultImageModal(scope.row)" style="background-color: #16df9e;color: white">故障
                    </el-button>
                    <el-button type="primary" v-else @click="checkFaultImageModal(scope.row)">故障</el-button>
                    <el-button v-if="scope.row.reportSparPartFlag === 'Y'" style="background-color: #16df9e;color: white"
                               @click="checkSparPartImageModal(scope.row)">备件</el-button>
                    <el-button type="primary" v-else @click="checkSparPartImageModal(scope.row)">备件</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <!-- 分页插件 -->
              <el-pagination
                style="margin-top: 0px"
                @size-change="sizeChangeHandle2"
                @current-change="currentChangeHandle2"
                :current-page="pageIndex2"
                :page-sizes="[20, 50, 100, 200, 500]"
                :page-size="pageSize2"
                :total="totalPage2"
                layout="total, sizes, prev, pager, next, jumper">
              </el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="核心备品备件更换记录" name="core_component">
            <el-button @click="insertCoreComponents()" type="primary" style="margin-left: 2px">{{'新增'}}</el-button>
            <div class="rq ">
              <el-table
                :height="280"
                :data="corePartSpareList"
                border
                style="width: 100%;">
                <el-table-column
                  v-for="(item,index) in columnCoreComponent" :key="index"
                  :sortable="item.columnSortable"
                  :prop="item.columnProp"
                  :header-align="item.headerAlign"
                  :show-overflow-tooltip="item.showOverflowTooltip"
                  :align="item.align"
                  :fixed="item.fixed==''?false:item.fixed"
                  :min-width="item.columnWidth"
                  :label="item.columnLabel">
                  <template slot-scope="scope">
                    <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
                  </template>
                </el-table-column>
                <el-table-column label="操作">
                  <template slot-scope="scope">
                    <a @click="updateCoreComponents(scope.row)">编辑</a>
                    <a @click="deleteCoreComponents(scope.row)">删除</a>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
<!--          <el-tab-pane label="设备知识库" name="eam_knowledge">-->
<!--            <div class="rq ">-->
<!--              <el-table-->
<!--                :height="250"-->
<!--                :data="knowledgeRecordList"-->
<!--                border-->
<!--                style="width: 100%;">-->
<!--                <el-table-column-->
<!--                  v-for="(item,index) in columnKnowledgeList" :key="index"-->
<!--                  :sortable="item.columnSortable"-->
<!--                  :prop="item.columnProp"-->
<!--                  :header-align="item.headerAlign"-->
<!--                  :show-overflow-tooltip="item.showOverflowTooltip"-->
<!--                  :align="item.align"-->
<!--                  :fixed="item.fixed==''?false:item.fixed"-->
<!--                  :min-width="item.columnWidth"-->
<!--                  :label="item.columnLabel">-->
<!--                  <template slot-scope="scope">-->
<!--                    <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>-->
<!--                    <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>-->
<!--                  </template>-->
<!--                </el-table-column>-->
<!--                <el-table-column-->
<!--                  fixed="right"-->
<!--                  header-align="center"-->
<!--                  align="center"-->
<!--                  min-width="80"-->
<!--                  label="操作">-->
<!--                  <template slot-scope="scope">-->
<!--                    <el-link style="cursor:pointer" @click="getFileContentData(scope.row)">文档</el-link>-->
<!--                  </template>-->
<!--                </el-table-column>-->
<!--              </el-table>-->
<!--              &lt;!&ndash; 分页插件 &ndash;&gt;-->
<!--              <el-pagination-->
<!--                style="margin-top: 0px"-->
<!--                @size-change="sizeChangeHandle3"-->
<!--                @current-change="currentChangeHandle3"-->
<!--                :current-page="pageIndex3"-->
<!--                :page-sizes="[20, 50, 100, 200, 500]"-->
<!--                :page-size="pageSize3"-->
<!--                :total="totalPage3"-->
<!--                layout="total, sizes, prev, pager, next, jumper">-->
<!--              </el-pagination>-->
<!--            </div>-->
<!--          </el-tab-pane>-->
        </el-tabs>
      </div>
      <el-footer style="height:35px;margin-top: 5px;text-align:center">
        <el-button type="primary" @click="saveCheckReport">保存</el-button>
        <el-button type="primary" @click="detailModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 执行人员清单 -->
    <el-dialog title="执行人员清单" :close-on-click-modal="false" v-drag :visible.sync="operatorModelFlag" width="820px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="operatorData">
            <el-form-item :label="'所属角色'">
              <el-select v-model="operatorData.roleId" placeholder="请选择" style="width: 120px">
                <el-option
                  v-for = "i in roleList"
                  :key = "i.roleId"
                  :label = "i.roleName"
                  :value = "i.roleId">
                </el-option>
              </el-select>
            </el-form-item>
          <el-form-item :label="'人员编码'">
            <el-input v-model="operatorData.adminID" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'人员姓名'">
            <el-input v-model="operatorData.adminName" clearable style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getOperatorList2">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="operatorList"
          ref="operatorTable"
          @row-click="operatorClickRow"
          @selection-change="selectionChangeHandle2"
          border
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            width="50">
          </el-table-column>
          <el-table-column
            v-for="(item,index) in operatorDetailList" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="confirmOperator()">确认</el-button>
        <el-button type="primary" @click="operatorModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="到达" :close-on-click-modal="false" v-drag :visible.sync="chooseReachModelFlag" width="410px">
      <el-form :inline="true" label-position="top">
        <el-form-item >
          <span style="cursor: pointer" slot="label" @click="getOperatorList()"><a>选择到达人员</a></span>
          <el-input v-model="saveData.operatorName" style="width: 389px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="reach()">保存</el-button>
        <el-button type="primary" @click="chooseReachModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="核心备件" :close-on-click-modal="false" v-drag :visible.sync="coreComponentFlag" width="450px">
      <el-form :inline="true" label-position="top">
        <el-form-item label="备件编码">
          <span slot="label" @click="getBaseList(1059)" v-if="updateCoreComponentsFlag"><a href="#">备件编码</a></span>
          <el-input v-model="coreComponentData.partNo" @blur="partNoBlur(1059)" :disabled="!updateCoreComponentsFlag" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="备件名称">
          <el-input v-model="coreComponentData.partDescription" disabled style="width: 280px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top">
        <el-form-item label="老序列号">
          <el-input v-model="coreComponentData.oldSerialNo" style="width: 200px"></el-input>
        </el-form-item>
        <el-form-item label="新序列号">
          <el-input v-model="coreComponentData.newSerialNo" style="width: 200px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="saveCoreComponent()">保存</el-button>
        <el-button type="primary" @click="coreComponentFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="图片查看" :close-on-click-modal="false" v-drag :visible.sync="imageModalFlag" width="390px" style="height: 550px;">
      <div v-viewer>
        <img v-for="(item, index) in descImages" :src="item" :key="index" style="width: 100px;height: 100px"/>
      </div>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="imageModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="维修出库" top="25vh" :close-on-click-modal="false" v-drag :visible.sync="exWarehouseModalFlag" width="600px">
      <el-form :inline="true" label-position="top" style="margin-top: -5px">
        <el-form-item label=" " style="width: 100px">
          请扫描条码
        </el-form-item>
        <el-form-item label=" ">
          <el-input ref="serialNoRef" v-model="exWarehouseData.serialNo" @keyup.native.enter="serialNoEnter" style="width: 450px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-top: -5px">
        <el-form-item label=" " style="width: 100px">
          备品备件编码
        </el-form-item>
        <el-form-item label=" ">
          <el-input v-model="exWarehouseData.partNo" disabled style="width: 450px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-top: -5px">
        <el-form-item label=" " style="width: 100px">
          名称/规格
        </el-form-item>
        <el-form-item label=" ">
          <el-input v-model="exWarehouseData.partDescription" disabled style="width: 450px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-top: -5px">
        <el-form-item label=" " style="width: 100px">
          序列号
        </el-form-item>
        <el-form-item label=" ">
          <el-input v-model="exWarehouseData.batchNo" disabled style="width: 450px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-top: -5px">
        <el-form-item label=" " style="width: 100px">
          出库数量
        </el-form-item>
        <el-form-item label=" ">
          <el-input v-model="exWarehouseData.qtyRequired" type="number" style="width: 450px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-top: -5px">
        <el-form-item label=" " style="width: 100px">
          供应商
        </el-form-item>
        <el-form-item label=" ">
          <el-input v-model="exWarehouseData.supplierDesc" disabled style="width: 450px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-top: -5px">
        <el-form-item label=" " style="width: 100px">
          备注
        </el-form-item>
        <el-form-item label=" ">
          <el-input v-model="exWarehouseData.remark" style="width: 450px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: 15px;text-align:center">
        <el-button type="primary" @click="saveSfdcTh">保存</el-button>
        <el-button type="primary" @click="exWarehouseModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>

    <!-- 上传文件的modal -->
    <reportImageUpload ref="reportImageUpload" @refreshPageTables="getDataList()" v-drag></reportImageUpload>

    <upload-file-list ref="defectRef" :folder="uploadData.folder" :title="uploadData.title" :upload-status="true" :label="'工单编码:'" :file-list.sync="fileData.file" :no="uploadData.orderNo" :upload-dialog.sync="uploadDialog" path="/base/uploadFileList"></upload-file-list>
  </div>
</template>

<script>
  import {
    eamWorkOrderSearch2,
    eamWorkOrderItemSearch,
    saveOrderReportForDefect,
    checkSparPartImage,
    getOperatorList, // 获取机修人员列表
    queryHistoryRecord, // 查看维修历史
    searchFileUrl, // 查询文件路径
    reach, // 到达
    getSiteAndBuByUserName, // 获取用户的site和bu
    getUserRoleList, // 获取用户角色列表
    getFeedBackImages, // 获取故障图片
    deleteObjectFile,
    getInventoryStockList, // 获取领用出库信息
    saveTrans, // 维修出库
    saveCoreComponent,
    getSparPartImages, // 获取备件图片
    deleteCoreComponents,//删除核心备件
  } from "@/api/eam/eam.js"
  import {
    downLoadObjectFile,
    getDeviceCorePartListAll,
    getDeviceCorePartList,
    getDevicePartList,
    getKnowledgeBaseList,
    getFileContentList
  } from '@/api/eam/eam_object_list.js';
  import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
  import Chooselist from '@/views/modules/common/Chooselist_eam'
  import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  import reportImageUpload from "./report_image_upload.vue"
  import UploadFileList from "../common/uploadFileList.vue";
  import {updateRepairTypes} from "../../../api/eam/eam";
  import {verifyData} from "../../../api/part/partInformation";
  import excel from "@/utils/excel-util.js";
  export default {
    components: {
      Chooselist,
      reportImageUpload,
      UploadFileList
    },
    watch: {
      saveData: {
        deep: true,
        handler: function (newV, oldV) {
          this.saveData.workTime = Math.ceil(Math.floor(this.dayjs(this.saveData.endDate).diff(this.saveData.startDate, 'seconds') / 30) / 2)
        }
      },
      exWarehouseData: {
        deep: true,
        handler: function (newV, oldV) {
          this.exWarehouseData.serialNo = this.exWarehouseData.serialNo.toUpperCase()
        }
      },
    },
    data () {
      return {
        coreComponentFlag: false,
        uploadDialog: false,
        planPeople:'',
        uploadData: {
          folder: '',
          title: '',
          orderNo: ''
        },
        corePartSpareList: [],
        corePartSpareListAll: [],
        updateCoreComponentsFlag: false,
        coreComponentData: {
          site: '',
          orderNo: '',
          buNo: '',
          objectID: '',
          partNo: '',
          partDescription: '',
          createdBy: '',
          oldSerialNo: '',
          newSerialNo: '',
        },
        fileData: {
          file: [],
          orderRef1: '',
          orderRef2: '',
          orderRef3: '',
          orderRef4: '',
          folder: ''
        },
        // 是否收藏
        favorite: false,
        tagNo:'',
        // 导出 start
        userBuList: [],
        exportData: [],
        exportName: "维修执行" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["维修执行"],
        exportFooter: [],
        exportList: [],
        // 导出 end
        searchData: {
          site: '',
          userName: this.$store.state.user.name,
          orderNo: '',
          planID: '',
          objectID: '',
          buNo: '',
          planOperator: '',
          buDesc: '',
          functionType: 'C',
          status: '',
          startDate: '',
          endDate: '',
          page: 1,
          limit: 10,
          searchType: 'reportDefect',
          documentSource: '',
          urgency: '',
          repairReportingType: '',
          repairType: '换线专家组'
        },
        height: 200,
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        pageIndex2: 1,
        pageSize2: 20,
        totalPage2: 0,
        pageIndex3: 1,
        pageSize3: 20,
        totalPage3: 0,
        dataList: [],
        dataListLoading: false,
        dataListSelections: [],
        modalFlag: false,
        modalDisableFlag: false,
        departmentList: [],
        // 展示列集
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1OrderNo',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'orderNo',
            headerAlign: "center",
            align: "left",
            columnLabel: '工单编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1PlanID',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'planID',
            headerAlign: "center",
            align: "left",
            columnLabel: '反馈单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1FeedBackDesc',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'feedBackDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '反馈描述',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1DefectID',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'defectID',
            headerAlign: "center",
            align: "left",
            columnLabel: '故障编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1DefectDesc',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'defectDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '故障名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1ObjectID',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'objectID',
            headerAlign: "center",
            align: "left",
            columnLabel: '设备编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1ObjectDesc',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'objectDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '设备名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1CreateBy',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'createBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '报修人员名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1Status',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'status',
            headerAlign: "center",
            align: "center",
            columnLabel: '状态',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1PlanOperatorName',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'planOperatorName',
            headerAlign: "center",
            align: "center",
            columnLabel: '计划执行人员',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1PlanDate',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'planDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '计划执行日期',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1DifficultyRemark',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'difficultyRemark',
            headerAlign: "center",
            align: "left",
            columnLabel: '审核备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1Remark',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'remark',
            headerAlign: "center",
            align: "left",
            columnLabel: '备注说明',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004003,
            serialNumber: '101004003Table1DocumentSource',
            tableId: "101004003Table1",
            tableName: "维修执行表",
            columnProp: 'documentSource',
            headerAlign: "center",
            align: "center",
            columnLabel: '单据来源',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
        ],
        detailModelFlag: false,
        detailList: [],
        saveData: {
          site: '',
          buNo: '',
          functionType: 'C',
          orderNo: '',
          planOperator: '',
          planOperatorName: '',
          startDate: '',
          endDate: '',
          workTime: '',
          remark: '',
          mesUser: '',
          planID: '',
          itemList: [],
          result: '',
          defectID: '',
          defectDesc: '',
          operator: '',
          operatorName: '',
          disposalMeasures: '',
          objectID: '',
          objectDesc: '',
          checkWorkPlanId: '',
          checkItemNo: '',
          reachDate: '',
          finishDate: '',
          handlingMethod: '',
          feedBackDesc: '',
          faultReason: '',
          preventiveMeasure: '',
          repairReportingType: '',
          repairType: '',
          createBy: '',
          createdDate: '',
          reachOperator: '',
          reachOperatorName: '',
          urgency: '',
          responseTime: '',
          shutdownWarranty: ''
        },
        operatorData: {
          site: '',
          bu: '',
          adminID: '',
          adminName: '',
          roleId: '',
          roleName: '',
        },
        operatorModelFlag: false,
        operatorList: [],
        roleList: [],
        dataListSelections2: [],
        operatorDetailList: [
          {
            columnProp: 'adminID',
            headerAlign: "center",
            align: "center",
            columnLabel: '用户账号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'adminName',
            headerAlign: "center",
            align: "center",
            columnLabel: '用户名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'email',
            headerAlign: "center",
            align: "center",
            columnLabel: '邮箱',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'phone',
            headerAlign: "center",
            align: "center",
            columnLabel: '手机号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
        ],
        columnFeedBackImages: [
          {
            columnProp: 'fileName',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '文件名称',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false
          },
          {
            columnProp: 'typeFlag',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '图片来源',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false
          },
          {
            columnProp: 'createdBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传人',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false
          },
          {
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传时间',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false
          }
        ],
        columnSparPartImages: [
          {
            columnProp: 'fileName',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '文件名称',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false
          },
          {
            columnProp: 'createdBy',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传人',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false
          },
          {
            columnProp: 'createDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '上传时间',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false
          }
        ],
        columnPartSpareList: [
          {
            columnProp: 'partNo',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '备品备件编码',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 120,
          },
          {
            columnProp: 'partDescription',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '备品备件名称',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 150,
          },
          {
            columnProp: 'spec',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '规格型号',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 120,
          },
          {
            columnProp: 'umid',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '单位',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 100,
          },
        ],
        columnCoreComponent: [
          {
            columnProp: 'partNo',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '备件编码',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 120,
          },
          {
            columnProp: 'partDescription',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '备件名称',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 200,
          },
          {
            columnProp: 'oldSerialNo',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '老序列号',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 120,
          },
          {
            columnProp: 'newSerialNo',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '新序列号',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: false,
            columnWidth: 120,
          },
        ],
        // 日期限制
        pickerOptions: {
          disabledDate(time) {
            return time.getTime() > Date.now();
          },
        },
        activeTable: 'inspection_form',
        historyRecordList: [],
        feedBackImages: [],
        sparPartImages: [],
        partSpareList: [],
        coreComponentList: [],
        columnHistoryList: [
          {
            columnWidth: 100,
            columnProp: 'orderNo',
            headerAlign: "center",
            align: "left",
            columnLabel: '工单编号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 200,
            columnProp: 'planDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '故障描述',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 120,
            columnProp: 'defectDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '故障名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 100,
            columnProp: 'result',
            headerAlign: "center",
            align: "center",
            columnLabel: '维修结论',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 100,
            columnProp: 'disposalMeasures',
            headerAlign: "center",
            align: "left",
            columnLabel: '处置措施',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 100,
            columnProp: 'actualOperatorName',
            headerAlign: "center",
            align: "center",
            columnLabel: '维修人员',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 80,
            columnProp: 'workTime',
            headerAlign: "center",
            align: "right",
            columnLabel: '工作时长(m)',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 130,
            columnProp: 'actualDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '维修时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnWidth: 200,
            columnProp: 'remark',
            headerAlign: "center",
            align: "left",
            columnLabel: '备注说明',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
        ],
        descImages: [],
        imageModalFlag: false,
        chooseReachModelFlag: false,
        reachData: {},
        authSearch: false,
        authReach: false,
        authReport: false,
        menuId: this.$route.meta.menuId,
        exWarehouseData: {
          site: '',
          serialNo: '',
          partNo: '',
          partDescription: '',
          batchNo: '',
          qtyRequired: '',
          supplierId: '',
          supplierDesc: '',
          remark: '',
          locationId: '',
          warehouseId: '',
          sCodeControlFlag: ''
        },
        exWarehouseModalFlag: false,
        currentPartSpareData: {},
        rules: {
          defectID: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          operatorName: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          result: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          handlingMethod: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ]
        },
        columnKnowledgeList: [
          {
            columnProp: 'defectId',
            headerAlign: "center",
            align: "center",
            columnLabel: '故障编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            columnProp: 'defectDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '故障原因',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            columnProp: 'defectDescribe',
            headerAlign: "center",
            align: "left",
            columnLabel: '故障描述',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
          {
            columnProp: 'disposalMeasures',
            headerAlign: "center",
            align: "left",
            columnLabel: '处置措施',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            columnProp: 'orderNo',
            align: 'left',
            columnLabel: '单据号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            columnProp: 'remark',
            headerAlign: "center",
            align: "left",
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200,
          },
          {
            columnProp: 'createDate',
            align: 'center',
            columnLabel: '上传时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 130,
          },
          {
            columnProp: 'createBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '上传人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
          {
            columnProp: 'updateDate',
            align: 'center',
            columnLabel: '更新时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150,
          },
          {
            columnProp: 'updateBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '更新人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
        ],
        knowledgeRecordList: []
      }
    },

    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 212
      })
      this.$refs.objectID.focus()
    },

    created() {
      // 按钮控制
      this.getButtonAuthData()
      this.getSiteAndBuByUserName()
      this.favoriteIsOk()
      // 动态列
      this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
      this.getTableUserColumn(this.$route.meta.menuId+'table2',2)
      if (!this.authSearch) {
        // 获取数据列表
        this.getDataList()
      }
      // 获取用户角色
      this.getUserRoleList()
    },

    methods: {
      // 取消小键盘
      cancelKeyboard (e) {
        // this.$refs.objectID
        e.target.setAttribute('readonly', true);
        setTimeout(() => {
          e.target.removeAttribute('readonly');
        }, 100);
      },

      // 设备编码回车事件
      objectIdEnter () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        eamWorkOrderSearch2(this.searchData).then(({data}) => {
          if (data.code === 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
            if (this.searchData.objectID != null && this.searchData.objectID !== '' && this.dataList.length > 0) {
              if (this.dataList[0].status == '未开工') {
                this.saveData.site = this.dataList[0].site
                this.saveData.buNo = this.dataList[0].buNo
                this.saveData.operator = ''
                this.saveData.operatorName = ''
                this.operatorData.bu = this.dataList[0].site + '_' + this.dataList[0].buNo
                this.reachData = this.dataList[0]
                this.chooseReachModelFlag = true
              } else if (this.dataList[0].status == '已到达') {
                this.reportModal(this.dataList[0])
              }
            }
          }
        })
      },

      // 请扫描条码回车事件
      serialNoEnter () {
        if (this.exWarehouseData.serialNo === '' || this.exWarehouseData.serialNo == null) {
          this.$message.warning('请输入序列号！')
          this.exWarehouseData.batchNo = ''
          this.exWarehouseData.serialNo = ''
          this.exWarehouseData.partNo = ''
          this.exWarehouseData.partDescription = ''
          this.exWarehouseData.qtyRequired = ''
          this.exWarehouseData.supplierId = ''
          this.exWarehouseData.supplierDesc = ''
          this.exWarehouseData.remark = ''
          this.exWarehouseData.locationId = ''
          this.exWarehouseData.warehouseId = ''
          this.exWarehouseData.sCodeControlFlag = ''
          this.$nextTick(() => {
            this.$refs.serialNoRef.focus()
          })
          return
        }
        let serialNoSplit = this.exWarehouseData.serialNo.split(";")
        let jsonData
        if (serialNoSplit.length > 1) {
          jsonData = {
            site: this.exWarehouseData.site,
            partNo: serialNoSplit[0],
            batchNo: serialNoSplit[1],
            active: 'Y',
          }
        } else {
          jsonData = {
            site: this.exWarehouseData.site,
            serialNo: this.exWarehouseData.serialNo,
            active: 'Y',
          }
        }
        this.getPartSpareData(jsonData)
      },

      // 获取领用出库信息
      getPartSpareData (jsonData) {
        getInventoryStockList(jsonData).then(({data}) => {
          if (data.code === 0) {
            if (data.rows.length === 0) {
              this.$message.error('无此记录！')
              this.$nextTick(() => {
                this.$refs.serialNoRef.focus()
              })
            } else {
              if (!this.partSpareList.some(item => item.partNo === data.rows[0].partNo)) {
                this.$message.warning('设备中不包含该备品备件！')
                this.exWarehouseData.serialNo = ''
                return false;
              }
              this.exWarehouseData.partNo = data.rows[0].partNo
              this.exWarehouseData.batchNo = data.rows[0].batchNo
              this.exWarehouseData.qtyRequired = data.rows[0].qtyOnHand
              this.exWarehouseData.partDescription = data.rows[0].partDescription
              this.exWarehouseData.supplierId = data.rows[0].supplierId
              this.exWarehouseData.supplierDesc = data.rows[0].supplierDesc
              this.exWarehouseData.locationId = data.rows[0].locationId
              this.exWarehouseData.warehouseId = data.rows[0].warehouseId
              this.exWarehouseData.sCodeControlFlag = data.rows[0].sCodeControlFlag
            }
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 维修出库
      saveSfdcTh () {
        if (this.exWarehouseData.partNo === '' || this.exWarehouseData.partNo == null) {
          this.$message.warning('请输入备品备件编码！')
          return;
        }
        if (this.exWarehouseData.qtyRequired === '' || this.exWarehouseData.qtyRequired == null || this.exWarehouseData.qtyRequired < 1) {
          this.$message.warning('供应商不能为空值，或者小于1！')
          return;
        }
        if (this.exWarehouseData.supplierId === '' || this.exWarehouseData.supplierId == null) {
          this.$message.warning('供应商不能为空值！')
          return;
        }
        let jsonData = {
          site: this.exWarehouseData.site,
          userName: this.$store.state.user.name,
          transTypeDB: 'WXCK',
          partNo: this.exWarehouseData.partNo,
          transType: '维修出库',
          erpFlag: 'N',
          locationId: this.exWarehouseData.locationId,
          direction: '-',
          inQty: 0,
          outQty: this.exWarehouseData.qtyRequired,
          useLocation: 'N',
          status: '已录入',
          remark: this.exWarehouseData.remark,
          warehouseId: this.exWarehouseData.warehouseId,
          supplierId: this.exWarehouseData.supplierId,
          sCodeControlFlag: this.exWarehouseData.sCodeControlFlag,
          resourceId: '',
          batchNo: this.exWarehouseData.batchNo,
          buNo: this.saveData.buNo,
          orderNo: this.saveData.orderNo,
          outType: '维修出库'
        }
        saveTrans(jsonData).then(({data}) => {
          if (data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
            this.exWarehouseData = {
              site: this.saveData.site,
              serialNo: '',
              partNo: '',
              partDescription: '',
              batchNo: '',
              qtyRequired: '',
              supplierId: '',
              supplierDesc: '',
              remark: '',
              locationId: '',
              warehouseId: '',
              sCodeControlFlag: ''
            }
            this.$nextTick(() => {
              this.$refs.serialNoRef.focus()
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 获取用户的bu
      getSiteAndBuByUserName () {
        let tempData = {
          username: this.$store.state.user.name,
        }
        getSiteAndBuByUserName(tempData).then(({data}) => {
          if (data.code === 0) {
            this.userBuList = data.rows
          }
        })
      },

      // 时间处理函数
      getStandTime (data) {
        let value =
          data.getFullYear() +
          "-" +
          this.checkTime(data.getMonth() + 1) +
          "-" +
          this.checkTime(data.getDate()) +
          " " +
          this.checkTime(data.getHours()) +
          ":" +
          this.checkTime(data.getMinutes()) +
          ":" +
          this.checkTime(data.getSeconds());
        return value;
      },

      // 时间处理,如果时间小于10 则再前面加一个'0'
      checkTime (i) {
        if (i < 10) {
          i = "0" + i
        }
        return i
      },

      // 日期时间选择器改变
      handleChangeTime () {
        // 当选择的时间大于当前时间，自动填充为当前时间
        // 设备开始时间
        let start = (new Date(this.saveData.startDate) * 1000) / 1000
        if (start > Date.now()) {
          this.saveData.startDate = this.getStandTime(new Date())
          this.$message({
            message: "时间超出范围！",
            type: "warning",
          })
        }
        // 设备结束时间
        let end = (new Date(this.saveData.endDate) * 1000) / 1000
        if (end > Date.now()) {
          this.saveData.endDate = this.getStandTime(new Date())
          this.$message({
            message: "时间超出范围！",
            type: "warning",
          })
        }
        // 结束时间小于开始时间
        if (start > end) {
          this.saveData.endDate = this.saveData.startDate
          this.$message({
            message: "结束时间小于开始时间！",
            type: "warning",
          })
        }
      },

      // 点击行选中复选框
      operatorClickRow (row) {
        this.$refs.operatorTable.toggleRowSelection(row)
      },

      // 获取用户角色
      getUserRoleList () {
        getUserRoleList().then(({data}) => {
          if (data.code === 0) {
            this.roleList = data.rows
          } else {
            this.roleList = []
          }
        })
      },

      // 获取机修人员列表
      getOperatorList () {
        this.operatorData.bu = this.saveData.site + '_' + this.saveData.buNo
        if (this.roleList.length > 0) {
          let filterList = this.roleList.filter(item => item.roleName === '机修人员')
          if (filterList.length > 0) {
            this.operatorData.roleId = filterList[0].roleId
          } else {
            this.operatorData.roleId = this.roleList[0].roleId
          }
        } else {
          this.operatorData.roleId = ''
        }
        // 先清空缓存选中
        this.$nextTick(() => this.$refs.operatorTable.clearSelection())
        // 拿到选中的人员编号
        let tempDataList = (this.saveData.operator == null ? '' : this.saveData.operator).split(';')
        // 查询人员
        getOperatorList(this.operatorData).then(({data}) => {
          if (data && data.code === 0) {
            this.operatorList = data.rows
            this.operatorList.forEach(val => {
              // 回显选中的人员
              if (tempDataList.includes(val.adminID)) {
                this.$nextTick(() => this.$refs.operatorTable.toggleRowSelection(val, true))
              }
            })
            this.operatorModelFlag = true
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
        if (this.saveData.operator == null) {
          this.saveData.operator = ''
          this.saveData.operatorName = ''
        }
      },

      // 查询机修人员列表
      getOperatorList2 () {
        // // 先清空缓存选中
        // this.$nextTick(() => this.$refs.operatorTable.clearSelection())
        // 查询人员
        getOperatorList(this.operatorData).then(({data}) => {
          if (data && data.code === 0) {
            this.operatorList = data.rows
          } else {
            this.operatorList = []
          }
        })
      },

      // // 获取数据列表
      // getRoleNameList () {
      //   this.$http({
      //     url: this.$http.adornUrl('/sys/role/list2'),
      //     method: 'get',
      //     params: this.$http.adornParams({
      //       'page': this.pageIndex,
      //       'limit': this.pageSize,
      //     })
      //   }).then(({data}) => {
      //     let temp = []
      //     if (data && data.code === 0) {
      //       this.roleList = data.page.list
      //       temp = this.roleList[0]
      //       this.roleList[0] = this.roleList[1]
      //       this.roleList[1] = temp
      //     } else {
      //       this.roleList = []
      //     }
      //   })
      // },

      // 多选
      selectionChangeHandle2 (val) {
        this.dataListSelections2 = val
      },

      // 确认多选机修人员
      confirmOperator () {
        this.saveData.operatorName = ''
        this.saveData.operator = ''
        for (let i = 0; i < this.dataListSelections2.length; i++) {
          this.saveData.operatorName = this.saveData.operatorName + ";" + this.dataListSelections2[i].adminName
          this.saveData.operator = this.saveData.operator + ";" + this.dataListSelections2[i].adminID
        }
        this.saveData.operator = this.saveData.operator.substring(1)
        this.saveData.operatorName = this.saveData.operatorName.substring(1)
        this.operatorModelFlag = false
      },

      // 校验用户是否收藏
      favoriteIsOk () {
        let userFavorite = {
          userId: this.$store.state.user.id,
          languageCode: this.$i18n.locale
        }
        userFavoriteList(userFavorite).then(({data}) => {
          for (let i = 0; i < data.list.length; i++) {
            if(this.$route.meta.menuId === data.list[i].menuId){
              this.favorite = true
            }
          }
        })
      },

      // 收藏 OR 取消收藏
      favoriteFunction () {
        let userFavorite = {
          userId: this.$store.state.user.id,
          functionId: this.$route.meta.menuId,
        }
        if (this.favorite) {
          removeUserFavorite(userFavorite).then(({data}) => {
            this.$message.success(data.msg)
            this.favorite = false
          })
        } else {
          // 收藏
          saveUserFavorite(userFavorite).then(({data}) => {
            this.$message.success(data.msg)
            this.favorite = true
          })
        }
      },

      // 获取基础数据列表S
      getBaseList (val,type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          let conSql = ''
          if (val === 201) {
            strVal = this.searchData.planOperator
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 1033) {
            strVal = this.saveData.defectID
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 1059) {
            strVal = this.coreComponentData.partNo
            let tempData = {
              site: this.saveData.site,
              buNo: this.saveData.buNo,
              objectID: this.saveData.objectID,
              orderNo: this.saveData.orderNo,
            }
            conSql = " and rs.bu_no = '" + tempData.buNo + "' and rs.site = '" + tempData.site +
              "' and rs.resource_id = '" +
              tempData.objectID +"'"
            this.$refs.baseList.init(val, strVal, conSql)
          }
        })
      },

      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 201) {
          this.searchData.planOperator = val.username
        }
        if (this.tagNo === 1033) {
          this.saveData.defectID = val.DefectID
          this.saveData.defectDesc = val.DefectDesc
        }
        if (this.tagNo === 1059) {
          this.coreComponentData.partNo = val.part_no
          this.coreComponentData.partDescription = val.part_description
        }
      },

      partNoBlur (tagNo) {
        if (this.coreComponentData.partNo != null && this.coreComponentData.partNo !== '') {
          let tempData = {
            tagno: tagNo,
            conditionSql: " and rs.part_no = '" + this.coreComponentData.partNo + "' and rs.bu_no = '" +
              this.saveData.buNo +
              "' and rs.site = '" + this.saveData.site +
              "' and rs.resource_id = '" +
              this.saveData.objectID + "'",
          }
          verifyData(tempData).then(({data}) => {
            if (data && data.code === 0) {
              if (data.baseListData.length > 0) {
                this.coreComponentData.partNo = data.baseListData[0].part_no
                this.coreComponentData.partDescription = data.baseListData[0].part_description
                return
              }
            }
          })
        }
        this.coreComponentData.partDescription = ''
      },

      async exportExcel() {
        this.searchData.limit = -1
        this.searchData.page = 1
        excel.exportTable({
          url: "/pms/eam/eamWorkOrderSearch2",
          columnMapping:  this.columnList,//可以直接用table，不需要的列就剔除
          mergeSetting: [],//需要合并的列
          params: this.searchData,
          fileName: this.exportName+".xlsx",
          rowFetcher: res => res.data,
          columnFormatter: [],
          dropColumns: [],//需要剔除的列，例如dropColumns: ["netWeight"]，即剔除净重列
        });
      },

      //导出excel
      // async createExportData () {
      //   this.searchData.limit = -1
      //   this.searchData.page = 1
      //   await eamWorkOrderSearch2(this.searchData).then(({data}) => {
      //     this.exportList= data.page.list
      //   })
      //   return this.exportList
      // },
      //
      // startDownload () {},
      //
      // finishDownload () {},
      //
      // fields () {
      //   let json = "{"
      //   this.columnList.forEach((item, index) => {
      //     if (index == this.columnList.length - 1) {
      //       json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
      //     } else {
      //       json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
      //     }
      //   })
      //   json += "}"
      //   let s = eval("(" + json + ")")
      //   return s
      // },

      // 获取数据列表
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        eamWorkOrderSearch2(this.searchData).then(({data}) => {
          if (data.code === 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
          }
        })
      },

      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },

      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },

      // 每页数
      sizeChangeHandle2 (val) {
        this.pageSize2 = val
        this.pageIndex2 = 1
        this.queryHistoryRecord()
      },

      // 当前页
      currentChangeHandle2 (val) {
        this.pageIndex2 = val
        this.queryHistoryRecord()
      },

      // 每页数
      sizeChangeHandle3 (val) {
        this.pageSize3 = val
        this.pageIndex3 = 1
        this.queryKnowledgeRecord()
      },

      // 当前页
      currentChangeHandle3 (val) {
        this.pageIndex3 = val
        this.queryKnowledgeRecord()
      },

      // 多选
      selectionChangeHandle (val) {
          this.dataListSelections = val
      },
      rowStyle({row}){
        let isReturn = row.isReturn
        // 区分不同的样式对应不同的颜色
        if (isReturn=='Y') {
          return { 'background-color': '#FFD3D3', cursor: 'pointer' }
        }
      },

      // 选择到达人员
      chooseReachOperator (row) {
        this.saveData.site = row.site
        this.saveData.buNo = row.buNo
        this.saveData.operator = ''
        this.saveData.operatorName = ''
        this.operatorData.bu = row.site + '_' + row.buNo
        this.reachData = row
        this.chooseReachModelFlag = true
        this.planPeople = row.planOperatorName
        this.buNo = row.buNo
      },

      // 到达
      reach () {
        if (this.saveData.operator === '' || this.saveData.operator == null) { // 2025-02-13 海波要求
          this.$message.warning('请选择到达人员！')
          return
        }
        if (this.buNo != '01-Label' && this.planPeople){
          if (!this.saveData.operatorName.includes(this.planPeople)){
            this.$message.warning('到达人员中不包含计划人员！')
            return
          }
        }
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          functionType: 'C',
          orderNo: this.reachData.orderNo,
          feedBackId: this.reachData.feedBackId,
          objectID: this.reachData.objectID,
          status: '已到达',
          reachOperator: this.saveData.operator,
          reachOperatorName: this.saveData.operatorName
        }
        reach(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.chooseReachModelFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      insertCoreComponents(){
        this.coreComponentData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          orderNo: this.saveData.orderNo,
          objectID: this.saveData.objectID,
          createdBy: this.$store.state.user.name,
          partNo: '',
          partDescription: '',
          oldSerialNo: '',
          newSerialNo: '',
        }
        this.updateCoreComponentsFlag = true
        this.coreComponentFlag = true
      },
      updateCoreComponents(row){
        this.coreComponentData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          orderNo: this.saveData.orderNo,
          objectID: this.saveData.objectID,
          createdBy: this.$store.state.user.name,
          partNo: row.partNo,
          partDescription: row.partDescription,
          oldSerialNo: row.oldSerialNo,
          newSerialNo: row.newSerialNo,
        }
        this.updateCoreComponentsFlag = false
        this.coreComponentFlag = true
      },
      deleteCoreComponents(row){
        this.$confirm('确定删除该核心备件吗？',{
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(()=>{
          this.coreComponentData = {
            site: this.saveData.site,
            buNo: this.saveData.buNo,
            orderNo: this.saveData.orderNo,
            objectID: this.saveData.objectID,
            createdBy: this.$store.state.user.name,
            partNo: row.partNo,
            partDescription: row.partDescription,
            oldSerialNo: row.oldSerialNo,
            newSerialNo: row.newSerialNo,
          }
          deleteCoreComponents(this.coreComponentData).then(({data})=>{
            if (data && data.code === 0) {
              this.getCorePartSpareList()
              this.$message.success(data.msg)
            } else {
              this.$message.warning(data.msg)
            }
          }).catch((error)=>{
            this.$message.error(error)
          })
        })

      },

      // 执行
      reportModal (row) {
        this.saveData = {
          site: row.site,
          buNo: row.buNo,
          functionType: 'C',
          orderNo: row.orderNo,
          planID: row.planID,
          planOperator: row.planOperator,
          planOperatorName: row.planOperatorName,
          workTime: '',
          remark: row.remark,
          disposalMeasures: row.disposalMeasures,
          mesUser: this.$store.state.user.name,
          itemList: [],
          defectID: row.defectID,
          defectDesc: row.defectDesc,
          objectID: row.objectID,
          objectDesc: row.objectDesc,
          checkWorkPlanId: row.checkWorkPlanId,
          checkItemNo: row.checkItemNo,
          reachDate: row.reachDate,
          operator: row.result == null ? row.reachOperator : row.adminID,
          operatorName: row.result == null ? row.reachOperatorName : row.operator,
          handlingMethod: row.handlingMethod,
          feedBackDesc: row.feedBackDesc,
          faultReason: row.faultReason,
          preventiveMeasure: row.preventiveMeasure,
          result: row.result,
          repairReportingType: row.repairReportingType,
          repairType: row.repairType,
          createBy: row.createBy,
          createdDate: row.createdDate,
          reachOperator: row.reachOperator,
          reachOperatorName: row.reachOperatorName,
          urgency: row.urgency,
          responseTime: row.responseTime,
          shutdownWarranty: row.repairReportingType === '设备故障' ? '是' : '否',
          isReturn: row.isReturn
        }
        this.buNo = row.buNo
        this.activeTable = 'inspection_form'
        this.detailModelFlag = true
      },

      saveCheckReport () {
        if (this.saveData.defectID === '' || this.saveData.defectID == null) {
          this.$message.warning('请选择故障编码！')
          return
        }
        if (this.saveData.result === '' || this.saveData.result == null) {
          this.$message.warning('请选择维修结果！')
          return
        }
        if (this.saveData.result === '维修失败' && (this.saveData.disposalMeasures == null || this.saveData.disposalMeasures === '')) {
          this.$message.warning('请选择处置措施！')
          return
        }
        if (this.saveData.operator == null || this.saveData.operator === '') {
          this.$message.warning('请选择维修人员！')
          return
        }
        if (this.saveData.faultReason === '' || this.saveData.faultReason == null || this.saveData.faultReason.length < 11) {
          this.$message.warning('请填写故障原因，且大于十个字数！')
          return
        }
        if (this.saveData.handlingMethod === '' || this.saveData.handlingMethod == null || this.saveData.handlingMethod.length < 11) {
          this.$message.warning('请填写处理方式，且大于十个字数！')
          return
        }
        if (this.buNo != '01-Label' && this.saveData.planOperatorName){
          if (!this.saveData.operatorName.includes(this.saveData.planOperatorName)){
            this.$message.warning('实际执行人员中不包含计划人员，请检查！')
            return
          }
        }
        saveOrderReportForDefect(this.saveData).then(({data}) => {
          if (data && data.code === 0) {
            this.getDataList()
            this.detailModelFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 上传维修故障图片
      uploadFaultImageModal () {
        let currentData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          createBy: this.$store.state.user.name,
          orderNo: this.saveData.orderNo,
          folder: 'reportFault',
        }
        // 打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.reportImageUpload.init(currentData)
        })
      },

      // 上传备件图片
      uploadSparPartImageModal () {
        let currentData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          createBy: this.$store.state.user.name,
          orderNo: this.saveData.orderNo,
          folder: 'reportSparPart',
        }
        // 打开组件 去做新增业务
        this.$nextTick(() => {
          this.$refs.reportImageUpload.init(currentData)
        })
      },

      // 列表表格选择替换
      tabClick (tab, event) {
        // 刷新列表数据
        this.refreshCurrentTabTable()
      },

      // 刷新页签的table数据
      refreshCurrentTabTable () {
        // 区分不同的页签刷新不同的列表数据
        if (this.activeTable === 'inspection_form') {
          //this.getInspectionFormData()
        } else if (this.activeTable === 'history_record') {
          this.queryHistoryRecord()
        } else if (this.activeTable === 'feed_back_img') {
          this.getFeedBackImages()
        } else if (this.activeTable === 'part_spare_list') {
          this.getPartSpareList()
        } else if (this.activeTable === 'eam_knowledge') {
          this.queryKnowledgeRecord()
        } else if (this.activeTable === 'spar_part_img') {
          this.getSparPartImages()
        } else if (this.activeTable === 'core_component') {
          this.getCorePartSpareList()
        }
      },

      // 维修记录
      queryHistoryRecord () {
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          objectID: this.saveData.objectID,
          functionType: 'C',
          limit: this.pageSize2,
          page: this.pageIndex2
        }
        queryHistoryRecord(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.historyRecordList = data.page.list
            this.pageIndex2 = data.page.currPage
            this.pageSize2 = data.page.pageSize
            this.totalPage2 = data.page.totalCount
          } else {
            this.historyRecordList = []
          }
        })
      },

      // 知识库记录
      queryKnowledgeRecord () {
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          objectId: this.saveData.objectID,
          fileType: '维修',
          limit: this.pageSize3,
          page: this.pageIndex3
        }
        getKnowledgeBaseList(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.knowledgeRecordList = data.page.list
            this.pageIndex3 = data.page.currPage
            this.pageSize3 = data.page.pageSize
            this.totalPage3 = data.page.totalCount
          } else {
            this.knowledgeRecordList = []
          }
        })
      },

      // 刷新派设备文档的列表
      getFileContentData (row) {
        let currentData = {
          orderRef1: row.site,
          orderRef2: row.num,
        }
        getFileContentList(currentData).then(({data}) => {
          //区分请求成功和失败的状况
          if (data && data.code == 200) {
            this.fileContentList = data.rows
          } else {
            this.fileContentList = []
          }
        })
      },

      // 获取故障图片
      getFeedBackImages () {
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          orderNo: this.saveData.orderNo,
          planID: this.saveData.planID
        }
        getFeedBackImages(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.feedBackImages = data.rows
          } else {
            this.feedBackImages = []
          }
        })
      },

      // 获取备件图片
      getSparPartImages () {
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          orderNo: this.saveData.orderNo,
          folder: 'reportSparPart'
        }
        getSparPartImages(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.sparPartImages = data.rows
          } else {
            this.sparPartImages = []
          }
        })
      },

      // 获取备品备件信息
      getPartSpareList () {
        let tempData = {
          site: this.saveData.site,
          objectID: this.saveData.objectID
        }
        getDevicePartList(tempData).then(({data}) => {
          // 区分请求成功和失败的状况
          if (data && data.code === 200) {
            this.partSpareList = data.rows
          } else {
            this.partSpareList = []
          }
        })
      },

      // 预览
      previewFile (row) {
        // 预览文件
        let image = ['jpg', 'jpeg', 'png', 'gif', 'bmp']
        let type = ''
        if (image.includes(row.fileType.toLowerCase())) {
          type = 'image/' + row.fileType
        }
        let video = ['mp4', 'avi', 'mov', 'wmv', 'flv']
        if (video.includes(row.fileType.toLowerCase())) {
          type = 'video/' + row.fileType
        }
        let txt = ['txt']
        if (txt.includes(row.fileType.toLowerCase())) {
          type = 'text/plain;charset=utf-8'
        }
        let office = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']
        if (office.includes(row.fileType.toLowerCase())) {
          if (row.fileType.toLowerCase() === 'doc' || row.fileType.toLowerCase() === 'docx') {
            type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
          } else if (row.fileType.toLowerCase() === 'ppt' || row.fileType.toLowerCase() === 'pptx') {
            type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
          } else {
            type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
          }
        }
        let pdf = ['pdf']
        if (pdf.includes(row.fileType.toLowerCase())) {
          type = 'application/pdf'
        }
        downLoadObjectFile(row).then(({data}) => {
          const blob = new Blob([data], { type: type });
          // 创建URL来生成预览
          const fileURL = URL.createObjectURL(blob);
          // 在新标签页中打开文件预览
          const newTab = window.open(fileURL, '_blank')
        })
      },

      // 下载
      downloadFile (row) {
        downLoadObjectFile(row)
          .then(({data}) => {
            // 不限制文件下载类型
            const blob = new Blob([data], {type:'application/octet-stream;charset=utf-8'})
            // 下载文件名称
            const fileName = row.fileName
            // a标签下载
            const linkNode = document.createElement('a')
            linkNode.download = fileName // a标签的download属性规定下载文件的名称
            linkNode.style.display = 'none'
            linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
            document.body.appendChild(linkNode)
            linkNode.click() // 模拟在按钮上的一次鼠标单击
            URL.revokeObjectURL(linkNode.href) // 释放URL 对象
            document.body.removeChild(linkNode)
          })
      },

      // 删除文件
      deleteFile (row) {
        this.$confirm('确定要删除此文件?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteObjectFile(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getFeedBackImages()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                }
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },

      // 查看故障图片
      checkFaultImageModal (row) {
        this.descImages = []
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          orderNo: row.orderNo,
          folder: 'reportFault',
        }
        searchFileUrl(tempData).then(({data}) => {
          if (data.code === 0) {
            for (let i = 0; i < data.rows.length; i++) {
              this.descImages.push(data.rows[i].url)
            }
          } else {
            this.$message.warning(data.msg)
          }
        })
        this.imageModalFlag = true
      },

      // 查看备件图片
      checkSparPartImageModal (row) {
        this.descImages = []
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          orderNo: row.orderNo,
          folder: 'reportSparPart',
        }
        searchFileUrl(tempData).then(({data}) => {
          if (data.code === 0) {
            for (let i = 0; i < data.rows.length; i++) {
              this.descImages.push(data.rows[i].url)
            }
          } else {
            this.$message.warning(data.msg)
          }
        })
        this.imageModalFlag = true
      },

      // 维修出库
      defectExWarehouseModal () {
        this.exWarehouseData = {
          site: this.saveData.site,
          serialNo: '',
          partNo: '',
          partDescription: '',
          batchNo: '',
          qtyRequired: '',
          supplierId: '',
          supplierDesc: '',
          remark: '',
          locationId: '',
          warehouseId: '',
          sCodeControlFlag: ''
        }
        this.exWarehouseModalFlag = true
        this.$nextTick(() => {
          this.$refs.serialNoRef.focus()
        })
      },

      //去掉input框获得的焦点
      elDatePickerOnFocus () {
        document.activeElement.blur()
      },

      // closeDialog () {
      //   this.operatorData = {
      //     site: '',
      //     adminName: '',
      //     adminID: '',
      //     roleName: '机修人员',
      //   }
      // },

      // 动态列开始 获取 用户保存的 格式列
      async getTableUserColumn (tableId, columnId) {
        let queryTableUser = {
          userId: this.$store.state.user.name,
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          status: true,
          languageCode: this.$i18n.locale
        }
        await getTableUserListLanguage(queryTableUser).then(({data}) => {
          if (data.rows.length > 0) {
            switch (columnId) {
              case 1:
                this.columnList = data.rows
                break;
              case 2:
                this.columnHistoryList = data.rows
                break;
            }
          } else {
            this.getColumnList(tableId, columnId)
          }
        })
      },

      // 获取 tableDefault 列
      async getColumnList (tableId, columnId) {
        let queryTable = {
          functionId: this.$route.meta.menuId,
          tableId: tableId,
          languageCode: this.$i18n.locale
        }
        await getTableDefaultListLanguage(queryTable).then(({data}) => {
          if (!data.rows.length === 0) {
            switch (columnId) {
              case 1:
                this.columnList = data.rows
                break;
              case 2:
                this.columnHistoryList = data.rows
                break;
            }
          }
        })
      },

      //获取按钮的权限数据
      getButtonAuthData () {
        let searchFlag = this.isAuth(this.menuId+":search")
        let reachFlag = this.isAuth(this.menuId+":reach")
        let reportFlag = this.isAuth(this.menuId+":report")
        //处理页面的权限数据
        this.authSearch = !searchFlag
        this.authReach = !reachFlag
        this.authReport = !reportFlag
      },

      // 获取核心备件列表
      getCorePartSpareListAll () {
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          objectID: this.saveData.objectID,
          orderNo: this.saveData.orderNo,
        }
        getDeviceCorePartList(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.corePartSpareListAll = data.rows
          } else {
            this.corePartSpareListAll = []
          }
        })
      },

      async getCorePartSpareList () {
        let tempData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          objectID: this.saveData.objectID,
          orderNo: this.saveData.orderNo,
        }
        await getDeviceCorePartList(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.corePartSpareList = data.rows
          } else {
            this.corePartSpareList = []
          }
        })
      },

      async coreComponentModal () {
        await this.getCorePartSpareList()
        this.coreComponentData = {
          site: this.saveData.site,
          buNo: this.saveData.buNo,
          orderNo: this.saveData.orderNo,
          objectID: this.saveData.objectID,
          createdBy: this.$store.state.user.name,
          partNo: '',
          partDescription: '',
          oldSerialNo: '',
          newSerialNo: '',
        }
        this.updateCoreComponentsFlag = true
        this.coreComponentFlag = true
      },

      async saveCoreComponent () {
        await this.partNoBlur(1059)
        if (this.coreComponentData.orderNo === '' || this.coreComponentData.orderNo == null) {
          this.$message.warning('未绑定维修工单号！')
          return
        }
        if (this.coreComponentData.partNo === '' || this.coreComponentData.partNo == null) {
          this.$message.warning('请选择备件！')
          return
        }
        saveCoreComponent(this.coreComponentData).then(({data}) => {
          if (data && data.code === 0) {
            this.getCorePartSpareList()
            this.coreComponentFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      componentChange (value) {
        if (value && value !== '') {
          let tempData = this.corePartSpareList.filter(item => item.partNo === value)[0]
          this.coreComponentData.partDescription = tempData.partDescription
        } else {
          this.coreComponentData.partDescription = ''
        }
      },

      // 转单方法
      transferOrderHandle () {
        if (this.dataListSelections.length === 0) {
          this.$message.warning('请选择要转单的工单！')
          return
        }
          this.dataListSelections[0].repairType = '设备维修组'
          updateRepairTypes(this.dataListSelections).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '转单成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
              this.getDataList()
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
      },
    }
  }
</script>

<style scoped lang="scss">
/deep/ .customer-tab .el-tabs__content {
  padding: 5px !important;
}
/deep/ .el-table .cell {
  line-height: 14px;
  font-size: 12px;
  height: auto;
}
</style>
