<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.repairType" placeholder="请选择" 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.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-input v-model="searchData.feedBackID" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'设备编码'">
        <el-input v-model="searchData.objectID" clearable style="width: 100px"></el-input>
      </el-form-item>
      <el-form-item :label="'故障原因'">
        <el-input v-model="searchData.defectDesc" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'设备区域'">
        <el-input v-model="searchData.locationName" clearable style="width: 100px"></el-input>
      </el-form-item>
      <el-form-item :label="'部门'">
        <el-input v-model="searchData.department" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'状态'">
        <el-select filterable v-model="searchData.status" clearable style="width: 100px">
          <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-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 v-if="!authSave" @click="saveModal">新增</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--primary el-button--medium">
          {{ "导出" }}
        </download-excel>
      </el-form-item>
    </el-form>

    <el-table
      :height="height"
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <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
        fixed="right"
        header-align="center"
        align="center"
        width="130"
        label="操作">
        <template slot-scope="scope">
          <el-link style="cursor: pointer" v-if="scope.row.status === '已录入' && !authCancel" @click="cancelFeedBack(scope.row)">取消反馈</el-link>
          <el-link style="cursor: pointer" v-if="scope.row.status === '已录入' && !authRelease" @click="createDefectOrderModel(scope.row)">下达</el-link>
          <el-link style="cursor: pointer" v-if="scope.row.repairReportingType === 'TPM红牌'" @click="searchFeedMatterRecord(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 title="下达维修工单" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="570px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="计划编码:">
          <el-input v-model="modalData.feedBackID" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="计划描述:">
          <el-input v-model="modalData.feedBackDesc" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item >
          <span slot="label" style="">设备编码</span>
          <el-input v-model="modalData.objectID" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="设备名称:">
          <el-input v-model="modalData.objectDesc" disabled style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item >
          <span slot="label" style="">故障编码</span>
          <el-input v-model="modalData.defectID" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="故障原因:">
          <el-input v-model="modalData.defectDesc" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="计划维修日期:">
          <el-date-picker
            style="width: 120px"
            v-model="modalData.planDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="必选">
          </el-date-picker>
        </el-form-item>
        <el-form-item >
          <span style="cursor: pointer" slot="label" @click="getBaseList(201)"><a>计划执行人员</a></span>
          <el-input v-model="modalData.planOperator" style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveDefectOrder()">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 新增 -->
    <el-dialog title="设备故障报备" top="25vh" :close-on-click-modal="false" v-drag :visible.sync="saveModalFlag" width="500px">
      <el-form :inline="true" label-position="top" :model="saveModalData" :rules="saveRules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="BU" prop="bu" :rules="saveRules.bu">
          <el-select v-model="saveModalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 221px">
            <el-option
              v-for = "i in userBuList"
              :key = "i.buNo"
              :label = "i.sitename"
              :value = "i.buNo">
              <span style="float: left;width: 100px">{{ i.sitename }}</span>
              <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
                {{ i.buDesc }}
              </span>
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="反馈单号">
          <el-input v-model="saveModalData.feedBackID" disabled style="width: 105px"></el-input>
        </el-form-item>
        <el-form-item label="报修方式" prop="repairReportingType">
          <el-select v-model="saveModalData.repairReportingType" @change="repairReportingTypeChange" style="width: 102px">
            <el-option label="设备故障" value="设备故障"></el-option>
            <el-option label="TPM红牌" value="TPM红牌"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="saveModalData" :rules="saveRules" style="margin-left: 7px">
        <el-form-item prop="objectID">
          <span style="cursor: pointer" slot="label" @click="getBaseList(200)"><a>设备编码</a></span>
          <el-input v-model="saveModalData.objectID" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="设备名称">
          <el-input v-model="saveModalData.objectDesc" disabled style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form v-if="saveModalData.repairReportingType === '设备故障'" :inline="true" label-position="top" :model="saveModalData" :rules="saveRules" style="margin-left: 7px">
        <el-form-item prop="defectID">
          <span style="cursor: pointer" slot="label" @click="getBaseList(1055)"><a>故障编码</a></span>
          <el-input v-model="saveModalData.defectID" style="width: 221px"></el-input>
        </el-form-item>
        <el-form-item label="故障名称">
          <el-input v-model="saveModalData.defectDesc" disabled style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form v-if="saveModalData.repairReportingType === '设备故障'" :inline="true" label-position="top" :model="saveModalData" style="margin-left: 7px">
        <el-form-item label="故障日期">
          <el-date-picker style="width: 221px" v-model="saveModalData.defectDate" type="date" value-format="yyyy-MM-dd" format='yyyy-MM-dd' placeholder="请选择故障日期" :editable=false :picker-options="pickerOptions"></el-date-picker>
        </el-form-item>
        <el-form-item label="故障描述">
          <el-input v-model="saveModalData.feedBackDesc" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form v-else :inline="true" label-position="top" :model="saveModalData" style="margin-left: 7px">
        <el-form-item label="反馈时间">
          <el-date-picker style="width: 221px" v-model="saveModalData.defectDate" type="date" value-format="yyyy-MM-dd" format='yyyy-MM-dd' placeholder="请选择故障日期" :editable=false :picker-options="pickerOptions"></el-date-picker>
        </el-form-item>
        <el-form-item label="反馈描述">
          <el-input v-model="saveModalData.feedBackDesc" style="width: 221px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="saveModalData" :rules="saveRules" style="margin-left: 7px">
        <el-form-item label="紧急程度" prop="urgency" :rules="saveRules.urgency">
          <el-select v-model="saveModalData.urgency" style="width: 104px">
            <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 v-if="saveModalData.repairReportingType === '设备故障'" label="维修类型" prop="repairType">
          <el-select v-model="saveModalData.repairType" style="width: 104px">
            <el-option label="换线专家组" value="换线专家组"></el-option>
            <el-option label="设备维修组" value="设备维修组"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <span style="cursor: pointer" slot="label" @click="getOperatorList"><a>计划维修人员</a></span>
          <el-input v-model="saveModalData.planOperatorName" disabled style="width: 130px"></el-input>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="uploadFaultImageModal()">故障图片</el-button>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="saveModalData" :rules="saveRules" style="margin-left: 7px">
        <el-form-item label="备注">
          <el-input v-model="saveModalData.remark" style="width: 456px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button :loading="saveLoading" type="primary" @click="saveData">保存</el-button>
        <el-button type="primary" @click="saveModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 维修事项 -->
    <el-dialog title="事项列表" top="20vh" :close-on-click-modal="false" v-drag :visible.sync="searchFeedMatterFlag" width="800px">
      <el-form label-position="top" style="margin-top: 2px; margin-left: 2px;">
        <el-button type="primary" @click="createFeedMatterModel">添加</el-button>
      </el-form>
      <el-table
        :data="matterList"
        height="300"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in columnMatterList" :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="updateFeedMatterModel(scope.row)">编辑 |</el-link>
            <el-link style="cursor: pointer" @click="deleteFeedMatter(scope.row)">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
      <el-footer style="height:35px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="searchFeedMatterFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 添加事项 -->
    <el-dialog title="新增事项" top="23vh" :close-on-click-modal="false" v-drag :visible.sync="saveFeedMatterFlag" width="500px">
      <el-form :inline="true" label-position="top" :rules="saveMatterRules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="计划完成日期">
          <el-date-picker
            style="width: 120px"
            v-model="saveMatterData.plannedExecutionDate"
            type="date"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="实际完成日期">
          <el-date-picker
            style="width: 120px"
            v-model="saveMatterData.actualExecutionDate"
            type="date"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-input v-model="saveMatterData.status" style="width: 90px"></el-input>
        </el-form-item>
        <el-form-item>
          <span style="cursor: pointer" slot="label" @click="getBaseList(201)"><a>跟踪人员</a></span>
          <el-input v-model="saveMatterData.trackingPersonnel" disabled style="width: 90px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :rules="saveMatterRules" style="margin-left: 7px;">
        <el-form-item label="事项描述" prop="eventDesc">
          <el-input type="textarea" v-model="saveMatterData.eventDesc" :rows="3" resize='none' show-word-limit style="width: 460px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:35px;margin-top: 55px;text-align:center">
        <el-button type="primary" @click="saveFeedMatter">保存</el-button>
        <el-button type="primary" @click="saveFeedMatterFlag = 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"
          @row-dblclick="operatorClick"
          border
          style="width: 100%;">
          <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="operatorModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- chooseList -->
    <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>

    <upload-file-list ref="feedBackRef" :folder="uploadData.folder" :title="uploadData.title" :upload-status="true" :label="'反馈单号:'" :file-list.sync="fileData.file" :no="uploadData.feedBackID" :upload-dialog.sync="uploadDialog"></upload-file-list>

  </div>
</template>

<script>
  import {
    eamFeedBackSearch,
    cancelFeedBack,
    saveDefectOrder,
    saveEamGzBbData, // 新增方法
    getSiteAndBuByUserName,
    getFeedBackId, // 获得反馈单号
    searchFeedMatterRecord, // 查询维修事项
    saveFeedMatter, // 新增维修事项
    updateFeedMatter, // 编辑维修事项
    deleteFeedMatter, // 删除维修事项
    getUserRoleList, // 获取用户角色列表
    getOperatorListByOrder, // 获取用户列表
  } from "@/api/eam/eam.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 {uploadFileList} from '../../../api/base/baseFunction.js';
  import UploadFileList from "../common/uploadFileList.vue";
  export default {
    components: {
      Chooselist,
      UploadFileList
    },
    watch: {
      "saveModalData.bu"(newV, oldV) {
        if (newV.includes('RFID') && this.saveModalData.repairReportingType !== 'TPM红牌') {
          this.saveModalData.repairType = '换线专家组'
        } else {
          this.saveModalData.repairType = '设备维修组'
        }
      },
    },
    data () {
      return {
        uploadDialog: false,
        uploadData: {
          folder: '',
          title: '',
          feedBackID: ''
        },
        fileData: {
          file: [],
          orderRef1: '',
          orderRef2: '',
          orderRef3: '',
          orderRef4: '',
          folder: ''
        },
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "维修反馈" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["维修反馈"],
        exportFooter: [],
        exportList: [],
        // 导出 end
        tagNo: '',
        searchData: {
          site: '',
          userName: this.$store.state.user.name,
          feedBackID: '',
          objectID: '',
          planOperator: '',
          functionType: 'C',
          status: '',
          startDate: '',
          defectDesc: '',
          endDate: '',
          page: 1,
          limit: 10,
          buDesc: '',
          urgency: '',
          repairReportingType: '',
          repairType: ''
        },
        height: 200,
        pageIndex: 1,
        pageSize: 50,
        totalPage: 0,
        dataList: [],
        dataListLoading: false,
        dataListSelections: [],
        modalFlag: false,
        modalDisableFlag: false,
        saveModalFlag: false,
        saveModalDisableFlag: false,
        modalData: {
          site: '',
          bu: '',
          feedBackID: '',
          feedBackDesc: '',
          objectID: '',
          objectDesc: '',
          defectID: '',
          defectDesc: '',
          planDate: '',
          planOperator: '',
          createdBy: '',
          repairReportingType: '',
          repairType: ''
        },
        saveModalData: {
          site: '',
          bu: '',
          feedBackID: '',
          feedBackDesc: '',
          objectID: '',
          objectDesc: '',
          defectID: '',
          defectDesc: '',
          defectDate: '',
          remark: '',
          urgency: '',
          status: '',
          createdBy: '',
          updateBy: '',
          repairReportingType: '',
          repairType: '',
          planOperator: '',
          planOperatorName: ''
        },
        operatorData: {
          site: '',
          bu: '',
          adminID: '',
          adminName: '',
          roleId: '',
          roleName: '',
          functionType: 'C'
        },
        departmentList: [],
        matterList: [],
        roleList: [],
        operatorList: [],
        // 展示列集
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1FeedBackID',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'feedBackID',
            headerAlign: "center",
            align: "center",
            columnLabel: '反馈单号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1FeedBackDesc',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'feedBackDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '反馈描述',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1DefectID',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'defectID',
            headerAlign: "center",
            align: "center",
            columnLabel: '故障代码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1DefectDesc',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'defectDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '故障原因',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1ObjectID',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'objectID',
            headerAlign: "center",
            align: "center",
            columnLabel: '设备编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1ObjectDesc',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'objectDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '设备名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1LocationName',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'locationName',
            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: 101004001,
            serialNumber: '101004001TableDepartment',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'department',
            headerAlign: "center",
            align: "left",
            columnLabel: '部门',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 113,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1Status',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'status',
            headerAlign: "center",
            align: "center",
            columnLabel: '状态',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1PlanOperatorName',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'planOperatorName',
            headerAlign: "center",
            align: "center",
            columnLabel: '计划执行人员',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1ActualOperatorName',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'actualOperatorName',
            headerAlign: "center",
            align: "center",
            columnLabel: '实际执行人员',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1DefectDate',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'defectDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '故障发现日期',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1CreatedDate',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'createdDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '反馈时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1FinishDate',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'finishDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '维修时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1CreatedBy',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'createdBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '报修人员账号',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1FeedbackBy',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'feedbackBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '报修人员名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101004001,
            serialNumber: '101004001Table1Remark',
            tableId: "101004001Table1",
            tableName: "维修反馈表",
            columnProp: 'remark',
            headerAlign: "center",
            align: "center",
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 95,
          },
        ],
        columnMatterList:  [
          {
            columnProp: 'eventDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '事项描述',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 250,
          },
          {
            columnProp: 'status',
            headerAlign: "center",
            align: "left",
            columnLabel: '状态',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            columnProp: 'plannedExecutionDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '计划完成日期',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            columnProp: 'actualExecutionDate',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '实际完成日期',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            columnProp: 'trackingPersonnel',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '跟踪人员',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 100,
          },
        ],
        pickerOptions: {
          disabledDate(time) {
            let curDate = new Date().getTime()
            let curD = new Date()
            /* 获取当前月份 */
            let curMonth = curD.getMonth()
            /*  生成实际的月份: 由于curMonth会比实际月份小1, 故需加1 */
            curD.setMonth(curMonth + 1)
            /* 将日期设置为0, 这里为什么要这样设置, 我不知道原因, 这是从网上学来的 */
            curD.setDate(0)
            /* 返回当月的天数 */
            let days = curD.getDate()
            let three = days * 24 * 3600 * 1000
            let threeMonths = curDate - three
            return time.getTime() > Date.now()  || time.getTime() < threeMonths
          },
        },
        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: 'planOrderCount',
            headerAlign: "center",
            align: "right",
            columnLabel: '计划分配工单数',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
          {
            columnProp: 'actualOrderCount',
            headerAlign: "center",
            align: "right",
            columnLabel: '实际维修工单数',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
          },
        ],
        saveRules: {
          objectID: [
            {
              required: true,
              message: ' ',
              trigger: ['blur','change']
            }
          ],
          objectDesc: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
          defectID: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
          defectDesc: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
          urgency: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
          bu: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
          repairReportingType: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
          repairType: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ]
        },
        saveMatterRules: {
          eventDesc: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
          status: [
            {
              required: true,
              message: ' ',
                trigger: ['blur','change']
            }
          ],
        },
        matterData: {
          site: '',
          bu: '',
          feedBackId: ''
        },
        saveMatterData: {
          flag: '',
          id: '',
          site: '',
          bu: '',
          feedBackId: '',
          eventDesc: '',
          status: '',
          plannedExecutionDate: '',
          actualExecutionDate: '',
          trackingPersonnel: '',
          createBy: '',
          updateBy: ''
        },
        saveLoading: false,
        userBuList: [],
        authSearch: false,
        authSave: false,
        authCancel: false,
        authRelease: false,
        menuId: this.$route.meta.menuId,
        saveFeedMatterFlag: false,
        searchFeedMatterFlag: false,
        operatorModelFlag: false,
      }
    },

    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 173
      })
    },

    created () {
      // 按钮控制
      this.getButtonAuthData()
      // 获取用户的 site 和 bu
      this.getSiteAndBuByUserName()
      // 校验用户是否收藏
      this.favoriteIsOk()
      // 动态列
      this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
      if (!this.authSearch) {
        // 获取数据列表
        this.getDataList()
      }
      // 获取用户角色
      this.getUserRoleList()
    },

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

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

      // 报修方式改变事件
      repairReportingTypeChange () {
        this.saveModalData.defectID = ''
        this.saveModalData.defectDesc = ''
        if (this.saveModalData.repairReportingType === 'TPM红牌') {
          this.saveModalData.defectID = '***'
          this.saveModalData.repairType = '设备维修组'
        }
      },

      // 新增模态框
      saveModal () {
        // 获取反馈单号
        getFeedBackId().then(({data}) => {
          if (data.code === 0) {
            this.saveModalData = {
              site: '',
              bu: this.userBuList[0].buNo,
              feedBackID: data.feedBackID,
              feedBackDesc: '',
              objectID: '',
              objectDesc: '',
              defectID: '',
              defectDesc: '',
              defectDate: '',
              remark: '',
              urgency: '',
              status: '已录入',
              createdBy: this.$store.state.user.name,
              repairReportingType: '设备故障',
              repairType: '设备维修组',
              planOperator: '',
              planOperatorName: ''
            }
            this.fileData = {
              file: [],
              orderRef1: '',
              orderRef2: '',
              orderRef3: '',
              orderRef4: '',
              folder: ''
            }
            this.saveModalDisableFlag = false
            this.saveModalFlag = true
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 新增/编辑方法
      saveData () {
        if (this.saveModalData.bu === '' || this.saveModalData.bu == null) {
          this.$message.warning('请选择BU！')
          return
        }
        if (this.saveModalData.objectID === '' || this.saveModalData.objectID == null) {
          this.$message.warning("请选择设备!")
          return;
        }
        if (this.saveModalData.defectID === '' || this.saveModalData.defectID == null) {
          this.$message.warning("请选择故障!")
          return;
        }
        if (this.saveModalData.urgency === '' || this.saveModalData.urgency == null) {
          this.$message.warning("请选择紧急程度!")
          return;
        }
        if (this.saveModalData.repairReportingType === '' || this.saveModalData.repairReportingType == null) {
          this.$message.warning("请选择报修方式!")
          return;
        }
        if (this.saveModalData.repairType === '' || this.saveModalData.repairType == null) {
          this.$message.warning("请选择维修类型!")
          return;
        }
        this.saveLoading = true
        this.fileData.orderRef1 = this.saveModalData.bu.split('_')[0]
        this.fileData.orderRef2 = this.saveModalData.feedBackID
        this.fileData.orderRef3 = this.uploadData.folder
        this.fileData.orderRef4 = this.saveModalData.bu.split('_')[1]
        this.fileData.folder = this.uploadData.folder
        saveEamGzBbData(this.saveModalData).then(({data}) => {
          if (data && data.code === 0) {
            if (this.fileData.file.length > 0) { // 上传文件
              let tempData = new FormData()
              for (let i in this.fileData) {
                if (i === 'file') {
                  for (let j = 0; j < this.fileData.file.length; j++) {
                    tempData.append("file", this.fileData.file[j].raw)
                  }
                  continue
                }
                tempData.append(i, this.fileData[i])
              }
              uploadFileList(tempData).then(({data}) => {
                if (data.code !== 0) {
                  this.$message.warning(data.msg)
                }
              })
            }
            this.getDataList()
            this.saveModalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
          this.saveLoading = false
        })
      },

      // 获取数据列表
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        eamFeedBackSearch(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
          }
          this.dataListLoading = false
        })
      },

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

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

      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },

      cancelFeedBack (row) {
        this.$confirm(`是否取消选定反馈单?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          cancelFeedBack(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },

      // 下达
      createDefectOrderModel (row) {
        this.$confirm(`是否下达反馈单?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          saveDefectOrder(row).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },

      // 查计划事项
      searchFeedMatterRecord (row) {
        this.matterData = {
          site: row.site,
          buNo: row.buNo,
          feedBackId: row.feedBackID
        }
        this.searchFeedMatterRecord2()
      },

      searchFeedMatterRecord2 () {
        searchFeedMatterRecord(this.matterData).then(({data}) => {
          if (data && data.code === 0) {
            this.matterList = data.rows
            this.searchFeedMatterFlag = true
          } else {
            this.matterList = []
          }
        })
      },

      // 新增事项模态框
      createFeedMatterModel () {
        this.saveMatterData = {
          flag: '1',
          id: '',
          site: this.matterData.site,
          buNo: this.matterData.buNo,
          feedBackId: this.matterData.feedBackId,
          eventDesc: '',
          status: '',
          plannedExecutionDate: '',
          actualExecutionDate: '',
          trackingPersonnel: '',
          createBy: this.$store.state.user.name
        }
        this.saveFeedMatterFlag = true
      },

      // 编辑事项模态框
      updateFeedMatterModel (row) {
        this.saveMatterData = {
          flag: '2',
          id: row.id,
          site: row.site,
          buNo: row.buNo,
          feedBackId: row.feedBackId,
          eventDesc: row.eventDesc,
          status: row.status,
          plannedExecutionDate: row.plannedExecutionDate,
          actualExecutionDate: row.actualExecutionDate,
          trackingPersonnel: row.trackingPersonnel,
          updateBy: this.$store.state.user.name
        }
        this.saveFeedMatterFlag = true
      },

      // 新增事项
      saveFeedMatter () {
        if (this.saveMatterData.eventDesc === '' || this.saveMatterData.eventDesc == null) {
          this.$message.warning('请填写事项描述！')
          return
        }
        if (this.saveMatterData.status === '' || this.saveMatterData.status == null) {
          this.$message.warning('请填写状态！')
          return
        }
        if (this.saveMatterData.flag === '1') {
          saveFeedMatter(this.saveMatterData).then(({data}) => {
            if (data && data.code === 0) {
              this.searchFeedMatterRecord2()
              this.saveFeedMatterFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        } else {
          updateFeedMatter(this.saveMatterData).then(({data}) => {
            if (data && data.code === 0) {
              this.searchFeedMatterRecord2()
              this.saveFeedMatterFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },

      // 删除事项
      deleteFeedMatter (row) {
        this.$confirm(`是否删除该事项?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteFeedMatter(row).then(({data}) => {
            if (data && data.code === 0) {
              this.searchFeedMatterRecord2()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },

      // 获取基础数据列表S
      getBaseList (val,type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          let conSql = ''
          if (val === 201) {
            strVal = this.saveMatterData.trackingPersonnel
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 200) {
            strVal = this.saveModalData.objectID
            if (this.saveModalData.bu === null || this.saveModalData.bu === '') {
              this.$message.warning("请选择BU!")
              return
            } else {
              conSql = " and bu_no = '" + this.saveModalData.bu.split('_')[1] + "'"
              this.$refs.baseList.init(val, strVal, conSql)
            }
          }
          if (val === 1055) {
            strVal = this.saveModalData.defectID
            this.$refs.baseList.init(val, strVal)
          }
          if (val === 1058) {
            strVal = this.saveModalData.defectID
            this.$refs.baseList.init(val, strVal)
          }
        })
      },

      // 列表方法的回调
      getBaseData (val) {
        if (this.tagNo === 201) {
          this.saveMatterData.trackingPersonnel = val.username
        }
        if (this.tagNo === 200) {
          this.saveModalData.objectID = val.ObjectID
          this.saveModalData.objectDesc = val.ObjectDesc
        }
        if (this.tagNo === 1055) {
          this.saveModalData.defectID = val.DefectID
          this.saveModalData.defectDesc = val.DefectDesc
        }
        if (this.tagNo === 1058) {
          this.saveModalData.defectID = val.DefectID
          this.saveModalData.defectDesc = val.DefectDesc
        }
      },

      // 校验用户是否收藏
      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
          })
        }
      },

      //导出excel
      async createExportData () {
        this.searchData.limit = -1
        this.searchData.page = 1
        await eamFeedBackSearch(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
      },

      // 动态列开始 获取 用户保存的 格式列
      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;
            }
          } 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;
            }
          }
        })
      },

      //获取按钮的权限数据
      getButtonAuthData () {
        let searchFlag = this.isAuth(this.menuId+":search")
        let saveFlag = this.isAuth(this.menuId+":save")
        let cancelFlag = this.isAuth(this.menuId+":cancel")
        let releaseFlag = this.isAuth(this.menuId+":release")
        //处理页面的权限数据
        this.authSearch = !searchFlag
        this.authSave = !saveFlag
        this.authCancel = !cancelFlag
        this.authRelease = !releaseFlag
      },

      // 上传保修故障图片
      uploadFaultImageModal () {
        this.uploadData = {
          folder: 'feedBack',
          title: '故障保修图片上传',
          feedBackID: this.saveModalData.feedBackID
        }
        this.uploadDialog = true
      },

      // 获取机修人员列表
      getOperatorList () {
        this.operatorData.bu = this.saveModalData.bu
        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 = ''
        }
        // 查询人员
        getOperatorListByOrder(this.operatorData).then(({data}) => {
          if (data && data.code === 0) {
            this.operatorList = data.rows
            this.operatorModelFlag = true
          } else {
            this.operatorList = []
          }
        })
      },

      // 查询机修人员列表
      getOperatorList2 () {
        // 查询人员
        getOperatorListByOrder(this.operatorData).then(({data}) => {
          if (data && data.code === 0) {
            this.operatorList = data.rows
          } else {
            this.operatorList = []
          }
        })
      },

      // 选中人员
      operatorClick (row) {
        this.saveModalData.planOperator = row.adminID
        this.saveModalData.planOperatorName = row.adminName
        this.operatorModelFlag = false
      },

    }
  }
</script>
