<template>
  <div class="mod-config">

    <div>
        <span @click="favoriteFunction()">
         <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
        </span>
    </div>

    <el-form :inline="true" label-position="top" :model="searchData">
      <el-form-item :label="'BU'">
        <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 130px">
          <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-input v-model="searchData.planID" clearable style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'计划描述'">
        <el-input v-model="searchData.planDesc" clearable style="width: 120px"></el-input>
      </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-select filterable v-model="searchData.status" style="width: 120px">
          <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-button @click="getDataList()">查询</el-button>
        <el-button type="primary" @click="addModal()">新增计划</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"
      style="width: 100%;">
      <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="200"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" v-if="scope.row.status === '已计划'" @click="createOrder(scope.row)">下达</a>
          <a type="text" size="small" v-if="scope.row.status === '进行中'" @click="planOrder(scope.row)">计划</a>
          <a type="text" size="small" v-if="scope.row.status !== '已结束' && scope.row.status !== '已取消'" @click="cancelPlan(scope.row)">取消</a>
          <a type="text" size="small" v-if="scope.row.status === '已计划'" @click="updateModal(scope.row)">编辑</a>
          <a type="text" size="small" v-if="scope.row.status !== '进行中'" @click="deletePlan(scope.row)">删除</a>
          <a type="text" size="small" @click="itemModal(scope.row)">点检项目</a>
        </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="580px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
<!--        <el-form-item label="计划编码">-->
<!--          <el-input v-model="modalData.planID" disabled style="width: 260px"></el-input>-->
<!--        </el-form-item>-->
        <el-form-item label="BU" prop="bu" :rules="rules.bu">
          <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 260px">
            <el-option
              v-for = "i in userBuList"
              :key = "i.buNo"
              :label = "i.buNo"
              :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="计划描述" prop="planDesc" :rules="rules.planDescType">
          <el-input v-model="modalData.planDesc" style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item prop="propertiesCode" :rules="rules.propertiesCodeType">
          <span slot="label" @click="getBaseList(31)"><a href="#">点检模板</a></span>
          <el-input v-model="modalData.propertiesCode" @blur="modalCodeBlur" style="width: 260px"></el-input>
        </el-form-item>
        <el-form-item label="模板名称" prop="propertiesDesc" :rules="rules.propertiesDescType">
          <el-input v-model="modalData.propertiesDesc" disabled style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="计划开始日期" prop="planStartDate" :rules="rules.planStartDateType">
          <el-date-picker
            style="width: 260px"
            v-model="modalData.planStartDate"
            type="date"
            value-format="yyyy-MM-dd"
            format='yyyy-MM-dd'
            placeholder="请选择"
            :editable=false
            :picker-options="pickerOptions2">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划结束日期" prop="planEndDate" :rules="rules.planEndDateType">
          <el-date-picker
            style="width: 260px"
            v-model="modalData.planEndDate"
            type="date"
            value-format="yyyy-MM-dd"
            format='yyyy-MM-dd'
            placeholder="请选择"
            :editable=false
            :picker-options="pickerOptions2">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="任务开始时间" prop="taskStartDate" :rules="rules.taskStartDateType">
          <el-time-picker
            format="HH:mm"
            arrow-control
            style="width: 260px"
            v-model="modalData.taskStartDate"
            placeholder="请选择"
            value-format="HH:mm">
          </el-time-picker>
        </el-form-item>
        <el-form-item label="点检频率" prop="planPeriod" :rules="rules.planPeriodType">
          <el-input v-model="modalData.planPeriod" type="number" onkeyup="value=value.replace(/^[^\d]+/g,'')" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item label="点检周期">
          <el-select v-model="modalData.planCycle" style="width: 60px">
            <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="周末">-->
<!--          <input type="checkbox" value="A" name="addWorkOrderRule" v-model="modalData.workOrderRule"/>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="自动生成">-->
<!--          <input type="checkbox" value="Y" name="addAutoRenewalRule" v-model="modalData.autoRenewal"/>-->
<!--        </el-form-item>-->
        <el-form-item style="margin-top: 8px;margin-left: 19px">
          <el-checkbox v-model="modalData.workOrderRule" true-label="A">周末点检</el-checkbox><br>
          <el-checkbox v-model="modalData.autoRenewal" true-label="Y">自动生成</el-checkbox>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item prop="operatorName" :rules="rules.operatorNameType">
          <span slot="label" @click="getOperatorList()"><a>计划执行人员</a></span>
          <el-input v-model="modalData.operatorName" style="width: 260px"></el-input>
        </el-form-item>
        <el-form-item prop="checkerName" :rules="rules.checkerNameType">
          <span slot="label" @click="getCheckerList()"><a>选择审核人员</a></span>
          <el-input v-model="modalData.checkerName" style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="备注">
          <el-input v-model="modalData.remark" style="width: 534px"></el-input>
        </el-form-item>
      </el-form>
        <div style="text-align: center ;font-size: 11px">
          <span> ----------------------------------------------------选择设备----------------------------------------------------</span>
        </div>
        <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -8px;">
          <el-form-item label="设备编码">
            <el-input v-model="objectData.objectID" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label="设备名称">
            <el-input v-model="objectData.objectDesc" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label=" ">
            <el-button @click="getObjectList()">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="200"
          :data="objectList"
          border
          ref="objectTable"
          @row-click="objectClickRow"
          @selection-change="selectionChangeHandle"
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            width="50">
          </el-table-column>
          <el-table-column
            prop="objectID"
            header-align="center"
            align="center"
            min-width="30"
            label="设备编码">
          </el-table-column>
          <el-table-column
            prop="objectDesc"
            header-align="center"
            align="center"
            min-width="30"
            label="设备名称">
          </el-table-column>
          <el-table-column
            prop="familyDesc"
            header-align="center"
            align="center"
            min-width="30"
            label="设备分类">
          </el-table-column>
          <el-table-column
            prop="locationName"
            header-align="center"
            align="center"
            min-width="30"
            label="设备区域">
          </el-table-column>
        </el-table>
      <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="modalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 编辑 -->
    <el-dialog title="点检计划" :close-on-click-modal="false" v-drag :visible.sync="updateModalFlag" width="580px">
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="计划编码">
          <el-input v-model="modalData.planID" disabled style="width: 260px"></el-input>
        </el-form-item>
        <el-form-item label="计划描述" prop="planDesc" :rules="rules.planDescType">
          <el-input v-model="modalData.planDesc" style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item prop="propertiesCode" :rules="rules.propertiesCodeType">
          <span slot="label" style="" @click="getBaseList(31)"><a herf="#">点检模板</a></span>
          <el-input v-model="modalData.propertiesCode" @blur="modalCodeBlur" style="width: 260px"></el-input>
        </el-form-item>
        <el-form-item label="模板名称" prop="propertiesDesc" :rules="rules.propertiesDescType">
          <el-input v-model="modalData.propertiesDesc" disabled style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="计划开始日期" prop="planStartDate" :rules="rules.planStartDateType">
          <el-date-picker
            style="width: 260px"
            v-model="modalData.planStartDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择"
            :editable=false
            :picker-options="pickerOptions2">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划结束日期" prop="planEndDate" :rules="rules.planEndDateType">
          <el-date-picker
            style="width: 260px"
            v-model="modalData.planEndDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择"
            :editable=false
            :picker-options="pickerOptions2">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="任务开始时间" prop="taskStartDate" :rules="rules.taskStartDateType">
          <el-time-picker
            format="HH:mm"
            arrow-control
            style="width: 260px"
            v-model="modalData.taskStartDate"
            placeholder="请选择"
            value-format="HH:mm">
          </el-time-picker>
        </el-form-item>
        <el-form-item label="点检频率" prop="planPeriod" :rules="rules.planPeriodType">
          <el-input v-model="modalData.planPeriod" type="number" onkeyup="value=value.replace(/^[^\d]+/g,'')" style="width: 80px"></el-input>
        </el-form-item>
        <el-form-item label="点检周期">
          <el-select filterable v-model="modalData.planCycle" style="width: 60px">
            <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="周末">-->
<!--          <input type="checkbox" value="A" name="updateWorkOrderRule" v-model="modalData.workOrderRule"/>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="自动生成">-->
<!--          <input type="checkbox" value="Y" name="updateAutoRenewalRule" v-model="modalData.autoRenewal"/>-->
<!--        </el-form-item>-->
        <el-form-item style="margin-top: 8px;margin-left: 19px">
          <el-checkbox v-model="modalData.workOrderRule" true-label="A">周末点检</el-checkbox><br>
          <el-checkbox v-model="modalData.autoRenewal" true-label="Y">自动生成</el-checkbox>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item prop="operatorName" :rules="rules.operatorNameType">
          <span slot="label" @click="getOperatorList()"><a>计划执行人员</a></span>
          <el-input v-model="modalData.operatorName" style="width: 260px"></el-input>
        </el-form-item>
        <el-form-item prop="checkerName" :rules="rules.checkerNameType">
          <span slot="label" @click="getCheckerList()"><a>选择审核人员</a></span>
          <el-input v-model="modalData.checkerName" style="width: 260px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="备注">
          <el-input v-model="modalData.remark" style="width: 534px"></el-input>
        </el-form-item>
      </el-form>
        <div style="text-align: center ;font-size: 11px">
          <span> ----------------------------------------------------选择设备----------------------------------------------------</span>
        </div>
      <el-button type="primary" @click="addPlanDetail()">设备编辑</el-button>
        <el-table
          :height="200"
          :data="updateObjectList"
          border
          style="width: 100%;">
          <el-table-column
            prop="objectID"
            header-align="center"
            align="center"
            min-width="30"
            label="设备编码">
          </el-table-column>
          <el-table-column
            prop="objectDesc"
            header-align="center"
            align="center"
            min-width="30"
            label="设备名称">
          </el-table-column>
          <el-table-column
            prop="familyDesc"
            header-align="center"
            align="center"
            min-width="30"
            label="设备分类">
          </el-table-column>
          <el-table-column
            prop="locationName"
            header-align="center"
            align="center"
            min-width="30"
            label="设备区域">
          </el-table-column>
        </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button :loading="updateLoading" type="primary" @click="saveData()">保存</el-button>
        <el-button type="primary" @click="updateModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 点检项目 -->
    <el-dialog title="点检项目清单" :close-on-click-modal="false" v-drag :visible.sync="detailModelFlag" width="830px">
      <el-form :inline="true" label-position="top">
        <el-form-item :label="'点检模板编码'">
          <el-input v-model="detailData.codeNo" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'点检模板名称'">
          <el-input v-model="detailData.codeDesc" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="计划设备">
          <el-select v-model="detailData.objectID" @change="objectChange()" placeholder="请选择">
            <el-option label="全部" value=""></el-option>
            <el-option
              v-for = "i in options"
              :key = "i.objectID"
              :label = "i.objectDesc"
              :value = "i.objectID">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-table
        :height="300"
        :data="detailList"
        border
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in columnDetailList" :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">
            <a type="text" size="small" v-if="scope.row.valueChooseFlag=='Y'" @click="chooseModal(scope.row)">可选值</a>
            <a type="text" size="small" @click="updateItemModal(scope.row)">编辑</a>
          </template>
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <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="itemModalFlag" width="430px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="点检项目编码:">
          <el-input v-model="itemModalData.itemNo" :disabled="itemModalDisableFlag" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="点检项目名称:">
          <el-input v-model="itemModalData.itemDesc" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'检测值类型'">
          <el-select filterable v-model="itemModalData.valueTypeDb" style="width: 120px">
            <el-option label="文本" value="T"></el-option>
            <el-option label="数字" value="N"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="点检方法说明:">
          <el-input v-model="itemModalData.itemRemark" style="width: 254px"></el-input>
        </el-form-item>
        <el-form-item :label="'是否值可选'">
          <el-select filterable v-model="itemModalData.valueChooseFlag" style="width: 120px">
            <el-option label="是" value="Y"></el-option>
            <el-option label="否" value="N"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="参照值:">
          <el-input v-model="itemModalData.defaultValue" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="最大值:">
          <el-input v-model="itemModalData.maxValue" type="number" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="最小值:">
          <el-input v-model="itemModalData.minValue" type="number" style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="itemSaveData()">保存</el-button>
        <el-button type="primary" @click="itemModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="可选值" :close-on-click-modal="false" v-drag :visible.sync="chooseModalFlag" width="430px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="点检项目名称:">
          <el-input v-model="chooseModalData.itemDesc" disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'检测值类型'">
          <el-select filterable v-model="chooseModalData.valueTypeDb" disabled style="width: 120px">
            <el-option label="文本" value="T"></el-option>
            <el-option label="数字" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="addChooseModal()">新增</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="300"
        :data="chooseTableData"
        border
        style="width: 100%">
        <el-table-column
          prop="availableValue"
          header-align="center"
          align="center"
          min-width="200"
          label="属性值">
        </el-table-column>
        <el-table-column
          prop=""
          header-align="center"
          align="center"
          min-width="100"
          label="操作">
          <template slot-scope="scope">
            <a type="text" size="small" @click="updateChooseModal(scope.row)">修改</a>
            <a type="text" size="small" @click="deleteItemAvailable(scope.row)">删除</a>
          </template>
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="chooseModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="可选值维护" :close-on-click-modal="false" v-drag :visible.sync="itemAddModalFlag" width="215px" >
      <el-form :inline="true" label-position="top" style="margin-left: 22px;margin-top: -5px;" @submit.native.prevent>
        <el-form-item :label="'可选值：'">
          <el-input v-model="itemData.availableValue" :type="itemFlag" style="width: 130px;"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="saveItemAvailable()">保存</el-button>
        <el-button type="primary" @click="itemAddModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

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

    <!-- 机修人员清单 -->
    <el-dialog title="执行人员清单" @close="closeDialog" :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 value="roleName" v-model="operatorData.roleName" clearable placeholder="请选择" style="width: 120px">
              <el-option
                v-for = "i in roleList"
                :key = "i.roleID"
                :label = "i.roleName"
                :value = "i.roleName">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="'用户账号'">
            <el-input v-model="operatorData.adminID" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'用户名称'">
            <el-input v-model="operatorData.adminName" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getOperatorList()">查询</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"
            :selectable="selectFlag"
            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="checkerModelFlag" width="820px">
      <div class="rq">
        <el-form :inline="true" label-position="top" :model="checkerData">
          <el-form-item :label="'所属角色'">
            <el-select value="roleName" v-model="checkerData.roleName" clearable placeholder="请选择" style="width: 120px">
              <el-option
                v-for = "i in roleList"
                :key = "i.roleID"
                :label = "i.roleName"
                :value = "i.roleName">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="'人员编码'">
            <el-input v-model="checkerData.adminID" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="'人员姓名'">
            <el-input v-model="checkerData.adminName" style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item :label="' '">
            <el-button type="primary" @click="getCheckerList()">查询</el-button>
          </el-form-item>
        </el-form>
        <el-table
          :height="300"
          :data="checkerList"
          ref="checkerTable"
          @row-click="checkerClickRow"
          @selection-change="selectionChangeHandle3"
          border
          style="width: 100%;">
          <el-table-column
            type="selection"
            header-align="center"
            align="center"
            :selectable="selectFlag"
            width="50">
          </el-table-column>
          <el-table-column
            v-for="(item,index) in checkerDetailList" :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="confirmOperator2()">确认</el-button>
        <el-button type="primary" @click="checkerModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <!-- 编辑->设备->新增 -->
    <el-dialog title="设备编辑" @close="getNewPlanDetailList" :close-on-click-modal="false" v-drag :visible.sync="fastAddFlag" width="900px">
      <el-container style="margin-top: -12px;">
        <el-main style="width: 400px">
          <span style="font-size: 12px" >可选设备：</span>
          <el-table
            height="400px"
            :data="objectList1"
            border
            @selection-change="selectionObject1"
            ref="objectTable1"
            @row-click="objectClickRow1"
            highlight-current-row
            style="width: 100%">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              :selectable="selectFlag"
              width="50">
            </el-table-column>
            <el-table-column
              prop="objectID"
              header-align="center"
              align="center"
              min-width="110"
              label="设备编码">
            </el-table-column>
            <el-table-column
              prop="objectDesc"
              header-align="center"
              align="center"
              min-width="170"
              label="设备名称">
            </el-table-column>
          </el-table>
        </el-main>
        <el-main style="width: 100px">
          <div style="margin-top: 100px">
            <el-button type="primary" @click="addObject()">添加>></el-button>
          </div>
          <div style="margin-top: 20px">
            <el-button type="primary" @click="delObject()">删除<<</el-button>
          </div>
        </el-main>
        <el-main style="width: 400px">
          <span style="font-size: 12px">已有设备：</span>
          <el-table
            height="400px"
            :data="objectList2"
            border
            @selection-change="selectionObject2"
            ref="objectTable2"
            @row-click="objectClickRow2"
            highlight-current-row
            style="width: 100%">
            <el-table-column
              type="selection"
              header-align="center"
              align="center"
              :selectable="selectFlag"
              width="50">
            </el-table-column>
            <el-table-column
              prop="objectID"
              header-align="center"
              align="center"
              min-width="110"
              label="设备编码">
            </el-table-column>
            <el-table-column
              prop="objectDesc"
              header-align="center"
              align="center"
              min-width="170"
              label="设备名称">
            </el-table-column>
          </el-table>
        </el-main>
      </el-container>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="fastAddFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

  </div>
</template>

<script>
  import {
    eamWorkPlanSave,
    eamWorkPlanEdit,
    eamWorkPlanDelete,
    searchPlanItems,
    updatePlanItems,
    searchPlanItemAvailable,
    savePlanItemAvailable,
    deletePlanItemAvailable,
    createEamWorkOrder,
    objectIDBlur,
    modalCodeBlur,
    getObjectList,
    planOrder,
    cancelPlan,
    getOperatorList, // 获取机修人员列表
    getCheckerList, // 获取审核人员列表
    eamWorkPlanOverviewSearch, // 点检计划总览
    getPlanDetailList, // 查询计划详情
    delPlanDetail, // 删除计划中的设备
    getObjList, // 获取设备的差异列表(快速新增)
    addObject, // 添加设备
    delObject, // 移除设备
    planObjectSearch, // 查询该计划的设备
    getSiteAndBuByUserName
  } 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'

  export default {
    components: {
      Chooselist
    },
    data () {
      return {
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "点检计划" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["点检计划"],
        exportFooter: [],
        exportList: [],
        // 导出 end
        tagNo:'',
        searchData: {
          site: this.$store.state.user.site,
          userName: this.$store.state.user.name,
          planID: '',
          planDesc: '',
          objectID: '',
          buDesc: '',
          status: '',
          startDate: new Date(),
          endDate:'',
          functionType:'A',
          page: 1,
          limit: 10,
        },
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        height: 200,
        dataList: [],
        dataListLoading: false,
        dataListSelections: [],
        modalFlag: false,
        modalDisableFlag: false,
        modalData: {
          objectList: [],
          flag: '',
          bu: '',
          functionType: 'A',
          site: '',
          planID: '',
          planDesc: '',
          objectID: '',
          propertiesCode: '',
          propertiesDesc: '',
          operator: '',
          operatorName: '',
          checker: '',
          checkerName: '',
          planPeriod: '',
          status: '',
          planStartDate: '',
          planEndDate: '',
          createdBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
          userId: '',
          remark: '',
          workOrderRule: '',
          planCycle: '',
          taskStartDate: '',
          autoRenewal: ''
        },
        objectData: {
          site: '',
          bu: '',
          objectID: '',
          objectDesc: '',
          familyID: '',
        },
        objectList: [],
        // 展示列集
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1BuDesc',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'buDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: 'BU',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1PlanID',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'planID',
            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: 101002003,
            serialNumber: '101002003Table1PlanDesc',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'planDesc',
            headerAlign: "center",
            align: "left",
            columnLabel: '计划描述',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 119,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1PropertiesCode',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'propertiesCode',
            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: 101002003,
            serialNumber: '101002003Table1Status',
            tableId: "101002003Table1",
            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: 101002003,
            serialNumber: '101002003Table1PlanStartDate',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'planStartDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '计划开始日期',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 82,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1PlanEndDate',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'planEndDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '计划结束日期',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 82,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1TaskStartDate',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'taskStartDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '任务开始时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 82,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1NextWorkDate',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'nextWorkDate',
            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: 101002003,
            serialNumber: '101002003Table1OperatorName',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'operatorName',
            headerAlign: "center",
            align: "center",
            columnLabel: '计划执行人员',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 82,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1CheckerName',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'checkerName',
            headerAlign: "center",
            align: "center",
            columnLabel: '审核人员',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 82,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1PlanPeriod',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'planPeriod',
            headerAlign: "center",
            align: "right",
            columnLabel: '点检频率',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1PlanCycle',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'planCycle',
            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: 101002003,
            serialNumber: '101002003Table1CreatedDate',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'createdDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '创建时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 122,
          },

          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1CreatedBy',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'createdBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '创建人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1UpdateDate',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'updateDate',
            headerAlign: "center",
            align: "center",
            columnLabel: '更新时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 122,
          },

          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1UpdateBy',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'updateBy',
            headerAlign: "center",
            align: "center",
            columnLabel: '更新人',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table1Remark',
            tableId: "101002003Table1",
            tableName: "点检计划表",
            columnProp: 'remark',
            headerAlign: "center",
            align: "center",
            columnLabel: '备注',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },
        ],
        //项目清单
        addDetailModalFlag: false,
        detailData: {
          site: '',
          buNo: '',
          planID: '',
          codeNo: '',
          codeDesc: '',
          functionType: 'A',
          itemNo: '',
          itemDesc: '',
          itemType: 'A',
          objectID: '',
          objectDesc: '',
          userId: this.$store.state.user.name
        },
        detailModelFlag: false,
        detailList: [],
        columnDetailList: [
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table2ItemNo',
            tableId: "101002003Table2",
            tableName: "点检项目表",
            columnProp: 'itemNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '点检项目编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 90,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table2ItemDesc',
            tableId: "101002003Table2",
            tableName: "点检项目表",
            columnProp: 'itemDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '点检项目名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 90,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table2ItemRemark',
            tableId: "101002003Table2",
            tableName: "点检项目表",
            columnProp: 'itemRemark',
            headerAlign: "center",
            align: "center",
            columnLabel: '点检方法说明',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table2ValueType',
            tableId: "101002003Table2",
            tableName: "点检项目表",
            columnProp: 'valueType',
            headerAlign: "center",
            align: "center",
            columnLabel: '检测值类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table2DefaultValue',
            tableId: "101002003Table2",
            tableName: "点检项目表",
            columnProp: 'defaultValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '参照值',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table2MaxValue',
            tableId: "101002003Table2",
            tableName: "点检项目表",
            columnProp: 'maxValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '最大值',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003Table2MinValue',
            tableId: "101002003Table2",
            tableName: "点检项目表",
            columnProp: 'minValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '最小值',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
          {
            userId: this.$store.state.user.name,
            functionId: 101002003,
            serialNumber: '101002003TableValueChooseFlag',
            tableId: "101002003Table",
            tableName: "common",
            columnProp: 'valueChooseFlag',
            headerAlign: "center",
            align: "center",
            columnLabel: '是否值可选',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70,
          },
        ],
        itemModalData: {
          site: '',
          planID: '',
          flag: '',
          itemNo: '',
          itemDesc: '',
          valueTypeDb: '',
          defaultValue: '',
          valueChooseFlag: '',
          createdBy: this.$store.state.user.name,
          maxValue: '',
          minValue: '',
          itemRemark: '',
          itemType: 'A',
        },
        itemModalFlag: false,
        itemModalDisableFlag: false,
        itemFlag: 'text',
        chooseModalFlag: false,
        chooseModalData: {
          site: '',
          buNo: '',
          planID: '',
          itemNo: '',
          itemDesc: '',
          itemType: 'A',
          valueTypeDb: '',
        },
        chooseTableData: [],
        itemData: {
          site: '',
          buNo: '',
          planID: '',
          itemNo: '',
          valueNo: '',
          availableValue: '',
          itemType: 'A',
          createdBy: this.$store.state.user.name
        },
        itemAddModalFlag: false,
        operatorList: [],
        checkerList: [],
        operatorModelFlag: false,
        checkerModelFlag: false,
        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: '',
          },
        ],
        checkerDetailList: [
          {
            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: '',
          }
        ],
        dataListSelections2: [],
        dataListSelections3: [],
        objectSelections1: [],
        objectSelections2: [],
        roleList: [],
        operatorData: {
          site: this.$store.state.user.site,
          bu: '',
          adminID: '',
          adminName: '',
          roleID: '',
          roleName: '机修人员',
        },
        checkerData: {
          site: this.$store.state.user.site,
          bu: '',
          adminID: '',
          adminName: '',
          roleID: '',
          roleName: '机修人员',
        },
        updateDetailData: {
          site: '',
          buNo: '',
          planID: '',
          objectID: '',
          objectDesc: '',
        },
        // 快速添加
        fastAddFlag: false,
        objectList1: [],
        objectList2: [],
        objectListRow1: {},
        objectListRow2: {},
        updateObjectList: [],
        updateModalFlag: false,
        options: [],
        rules: {
          planDescType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          propertiesCodeType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          propertiesDescType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          planStartDateType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          planEndDateType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          planPeriodType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          operatorNameType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          checkerNameType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          taskStartDateType: [
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ]
        },
        message: {
          name: "周末",
          id: 'A'
        },
        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
          },
        },
        pickerOptions2: {
          disabledDate (time) {
            return time.getTime() < Date.now() - 8.64e7
          },
        },
        saveLoading: false,
        updateLoading: false,
        userBuList: []
      }
    },

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

    created () {
      // 获取用户的 site 和 bu
      this.getSiteAndBuByUserName()
      // 校验用户是否收藏
      this.favoriteIsOk()
      // 获取数据列表
      this.getDataList()
      // 动态列
      this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
      this.getTableUserColumn(this.$route.meta.menuId+'table2',2)
    },

    methods: {
      // 获取用户的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.modalData.planStartDate) * 1000) / 1000;
        if (start < Date.now()) {
          this.modalData.planStartDate = this.getStandTime(new Date())
          this.$message({
            message: "时间超出范围！",
            type: "warning",
          })
        }
        // 设备结束时间
        let end = (new Date(this.modalData.planEndDate) * 1000) / 1000;
        if (end < Date.now()) {
          this.modalData.planEndDate = this.getStandTime(new Date())
          this.$message({
            message: "时间超出范围！",
            type: "warning",
          })
        }
        // 结束时间小于开始时间
        if (start > end) {
          this.modalData.planEndDate = this.modalData.planStartDate;
          this.$message({
            message: "结束时间小于开始时间！",
            type: "warning",
          })
        }
      },

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

      // 审核人员
      checkerClickRow (row) {
        this.$refs.checkerTable.toggleRowSelection(row)
      },

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

      // 可选设备
      objectClickRow1 (row) {
        this.$refs.objectTable1.toggleRowSelection(row)
      },

      // 已有设备
      objectClickRow2 (row) {
        this.$refs.objectTable2.toggleRowSelection(row)
      },

      // 设备名内容改变事件
      objectChange () {
        searchPlanItems(this.detailData).then(({data}) => {
          this.detailList = data.rows
        })
      },

      // 新增计划中的设备
      addPlanDetail () {
        this.objectListRow2 = null
        this.objectListRow1 = null
        getObjList(this.updateDetailData).then(({data}) => {
          this.objectList1 = data.row1
          this.objectList2 = data.row2
        })
        this.fastAddFlag = true
      },

      // 添加设备
      addObject () {
        if (this.objectSelections1.length === 0) {
          this.$alert('请勾选要添加的设备！', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        let newData = this.objectList1.filter(
          (a) => !this.objectSelections1.some((b) => a.objectID === b.objectID)
        )
        this.objectList1 = newData
        for (let i = 0; i < this.objectSelections1.length; i++) {
          this.objectList2.push(this.objectSelections1[i])
        }
      },

      // 删除设备
      delObject () {
        if (this.objectSelections2.length === 0) {
          this.$alert('请勾选要删除的设备！', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        let newData = this.objectList2.filter(
          (a) => !this.objectSelections2.some((b) => a.objectID === b.objectID)
        )
        this.objectList2 = newData
        for (let i = 0; i < this.objectSelections2.length; i++) {
          this.objectList1.push(this.objectSelections2[i])
        }
      },

      getNewPlanDetailList () {
        this.updateObjectList = this.objectList2
      },

      // 删除计划中的设备
      delPlanDetail (row) {
        let tempData = {
          site: this.$store.state.user.site,
          planID: row.planID,
          objectID: row.objectID,
        }
        delPlanDetail(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.getPlanDetailList()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 获取计划设备明细
      getPlanDetailList () {
        getPlanDetailList(this.updateDetailData).then(({data}) => {
          if (data && data.code === 0) {
            this.updateObjectList = data.rows
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 获取机修人员列表
      getOperatorList () {
        this.operatorData.bu = this.modalData.bu
        this.operatorData.site = this.$store.state.user.site
        this.getRoleNameList()
        getOperatorList(this.operatorData).then(({data}) => {
          if (data && data.code === 0) {
            this.operatorList = data.rows
            this.modalData.operatorName = ''
            this.modalData.operator = ''
            this.operatorModelFlag = true;
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      // 获取数据列表
      getRoleNameList () {
        this.dataListLoading = true
        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
            this.totalPage = data.page.totalCount
          } else {
            this.roleList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },

      // 获取审核人员
      getCheckerList () {
        this.checkerData.bu = this.modalData.bu
        this.getRoleNameList()
        getCheckerList(this.checkerData).then(({data}) => {
          if (data && data.code === 0) {
            this.checkerList = data.rows
            this.modalData.checkerName = ''
            this.modalData.checker = ''
            this.checkerModelFlag = true
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

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

      selectionChangeHandle3 (val) {
        this.dataListSelections3 = val
      },

      selectionObject1(val){
        this.objectSelections1 = val
      },

      selectionObject2(val){
        this.objectSelections2 = val
      },

      selectFlag(){
        return true
      },

      // 确认多选机修人员
      confirmOperator () {
        if(this.dataListSelections2.length === 0){
          this.$message.warning("请勾选人员!")
          return
        }
        for (let i = 0; i < this.dataListSelections2.length; i++) {
          this.modalData.operatorName = this.modalData.operatorName + ";" + this.dataListSelections2[i].adminName
          this.modalData.operator = this.modalData.operator + ";" + this.dataListSelections2[i].adminID
        }
        this.modalData.operator = this.modalData.operator.substring(1)
        this.modalData.operatorName = this.modalData.operatorName.substring(1)
        this.operatorModelFlag = false
      },

      // 确认多选审核人员
      confirmOperator2 () {
        if (this.dataListSelections3.length === 0) {
          this.$message.warning("请勾选人员!")
          return
        }
        for (let i = 0; i < this.dataListSelections3.length; i++) {
          this.modalData.checkerName = this.modalData.checkerName + ";" + this.dataListSelections3[i].adminName
          this.modalData.checker = this.modalData.checker + ";" + this.dataListSelections3[i].adminID
        }
        this.modalData.checker = this.modalData.checker.substring(1)
        this.modalData.checkerName = this.modalData.checkerName.substring(1)
        this.checkerModelFlag = false
      },

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

      // 列表方法的回调
      getBaseData (val) {
        if (this.tagNo === 200) {
          this.modalData.objectID = val.ObjectID
          this.modalData.objectDesc = val.ObjectDesc
        }
        if (this.tagNo === 31) {
          this.modalData.propertiesCode = val.Code_No
          this.modalData.propertiesDesc = val.Code_Desc
        }
        if (this.tagNo === 201) {
          this.modalData.operator = val.AdminID
        }
      },

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

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

      addModal () {
        this.modalData = {
          flag: '1',
          objectList: [],
          functionType: 'A',
          site: '',
          bu: this.userBuList[0].buNo,
          planID: '',
          planDesc: '',
          objectID: '',
          objectDesc: '',
          propertiesCode: '',
          propertiesDesc: '',
          operator: '',
          operatorName: '',
          checker: '',
          checkerName: '',
          planPeriod: '',
          status: '',
          planStartDate: '',
          planEndDate: '',
          userId: this.$store.state.user.name,
          createdBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
          remark: '',
          workOrderRule: '',
          planCycle: '天',
          taskStartDate: '',
          autoRenewal: ''
        }
        this.modalDisableFlag = false
        this.objectList = []
        this.modalFlag = true
      },

      updateModal (row) {
        this.modalData = {
          flag: '2',
          objectList: [],
          functionType: 'A',
          site: row.site,
          bu: row.site + '_' + row.buNo,
          planID: row.planID,
          planDesc: row.planDesc,
          objectID: row.objectID,
          objectDesc: row.objectID,
          propertiesCode: row.propertiesCode,
          propertiesDesc: row.codeDesc,
          operator: row.operator,
          operatorName: row.operatorName,
          checker: row.checker,
          checkerName: row.checkerName,
          planPeriod: row.planPeriod,
          status: row.status,
          planStartDate: row.planStartDate,
          planEndDate: row.planEndDate,
          userId: this.$store.state.user.name,
          createdBy: this.$store.state.user.name,
          updateBy: this.$store.state.user.name,
          remark: row.remark,
          workOrderRule: row.workOrderRule,
          planCycle: row.planCycle,
          taskStartDate: row.taskStartDate,
          autoRenewal: row.autoRenewal
        }
        this.updateObjectList = []
        this.updateDetailData = {}
        this.updateDetailData.site = row.site
        this.updateDetailData.buNo = row.buNo
        this.updateDetailData.planID = row.planID
        if (this.modalData.workOrderRule != null && this.modalData.workOrderRule.split(",").includes('A')) {
          this.modalData.workOrderRule = 'A'
        } else {
          this.modalData.workOrderRule = ''
        }
        if (this.modalData.autoRenewal != null && this.modalData.autoRenewal.split(",").includes('Y')) {
          this.modalData.autoRenewal = 'Y'
        } else {
          this.modalData.autoRenewal = ''
        }
        getPlanDetailList(this.updateDetailData).then(({data}) => {
          if (data && data.code === 0) {
            this.updateObjectList = data.rows
            this.modalDisableFlag = true
            this.updateModalFlag = true
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      deletePlan (row) {
        this.$confirm(`是否删除这个点检计划?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          eamWorkPlanDelete(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(() => {
        })
      },

      saveData () {
        if (this.modalData.bu === '' || this.modalData.bu == null) {
          this.$message.warning('请选择BU！')
          return
        }
        if (this.modalData.planDesc === '' || this.modalData.planDesc == null) {
          this.$message.warning('请输入计划描述！')
          return
        }
        if (this.modalData.operator === '' || this.modalData.operator == null) {
          this.$message.warning('请选择机修人员！')
          return
        }
        if (this.modalData.checker === '' || this.modalData.checker == null) {
          this.$message.warning('请选择审核人员！')
          return
        }
        if (this.modalData.propertiesCode === '' || this.modalData.propertiesCode == null) {
          this.$message.warning('请选择点检模板！')
          return
        }
        if (this.modalData.planPeriod === '' || this.modalData.planPeriod == null) {
          this.$message.warning('选择点检频率！')
          return
        }
        if (this.modalData.planCycle === '' || this.modalData.planCycle == null) {
          this.$message.warning('选择点检周期！')
          return
        }
        if (this.modalData.planStartDate === '' || this.modalData.planStartDate == null) {
          this.$message.warning('请选择开始日期！')
          return
        }
        if (this.modalData.planEndDate === '' || this.modalData.planEndDate == null) {
          this.$message.warning('请选择结束日期！')
          return
        }
        if (this.modalData.planEndDate < this.dayjs().format("YYYY-MM-DD")) {
          this.$message.warning('计划结束日期不能小于今天！')
          return
        }
        if (this.modalData.planStartDate > this.modalData.planEndDate) {
          this.$message.warning('计划开始日期不能小于结束日期！')
          return
        }
        if (this.modalData.taskStartDate === '' || this.modalData.taskStartDate == null) {
          this.$message.warning('请选择任务开始时间！')
          return
        }
        if (this.modalData.flag === '1') {
          if (this.dataListSelections.length === 0) {
            this.$message.warning('请勾选设备！')
            return
          }
          this.saveLoading = true
          this.modalData.objectList = this.dataListSelections
          // 周日
          // let obj = document.getElementsByName('addWorkOrderRule')
          // let s = ''
          // for (let i = 0; i < obj.length; i++) {
          //   if (obj[i].checked) {
          //     s += obj[i].value + ','
          //   }
          // }
          // s = s.substring(0, s.length - 1)
          // this.modalData.workOrderRule = s
          // // 自动生成
          // let obj2 = document.getElementsByName('addAutoRenewalRule')
          // let s2 = ''
          // for (let i = 0; i < obj2.length; i++) {
          //   if (obj2[i].checked) {
          //     s2 += obj2[i].value + ','
          //   }
          // }
          // s2 = s2.substring(0, s2.length - 1)
          // this.modalData.autoRenewal = s2
          eamWorkPlanSave(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.modalFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
            this.saveLoading = false
          })
        } else {
          this.updateLoading = true
          this.modalData.objectList = this.updateObjectList
          // let obj = document.getElementsByName('updateWorkOrderRule')
          // let s = ''
          // for (let i = 0; i < obj.length; i++) {
          //   if (obj[i].checked) {
          //     s += obj[i].value + ','
          //   }
          // }
          // s = s.substring(0,s.length-1)
          // this.modalData.workOrderRule = s
          // // 自动生成
          // let obj2 = document.getElementsByName('updateAutoRenewalRule')
          // let s2 = ''
          // for (let i = 0; i < obj2.length; i++) {
          //   if (obj2[i].checked) {
          //     s2 += obj2[i].value + ','
          //   }
          // }
          // s2 = s2.substring(0, s2.length - 1)
          // this.modalData.autoRenewal = s2
          eamWorkPlanEdit(this.modalData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.updateModalFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                }
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
            this.updateLoading = false
          })
        }
      },

      //----------项目清单----------------start
      //打开项目清单
      itemModal (row) {
        this.options = []
        this.detailData.objectID = ''
        this.detailData.site = row.site
        this.detailData.buNo = row.buNo
        this.detailData.planID = row.planID
        this.detailData.codeNo = row.propertiesCode
        this.detailData.codeDesc = row.codeDesc
        this.planObjectSearch()
        searchPlanItems(this.detailData).then(({data}) => {
          this.detailList = data.rows
        })
        this.detailModelFlag = true
      },

      // 查询该计划的设备
      planObjectSearch () {
        let tempData = {
          site: this.detailData.site,
          buNo: this.detailData.buNo,
          planID: this.detailData.planID,
        }
        planObjectSearch(tempData).then(({data}) => {
          if (data.code === 0) {
            this.options = data.rows
          }
        })
      },

      updateItemModal (row) {
        this.itemModalData = {
          flag: '2',
          site: row.site,
          buNo: row.buNo,
          planID: row.planID,
          itemNo: row.itemNo,
          itemDesc: row.itemDesc,
          valueTypeDb: row.valueTypeDb,
          defaultValue: row.defaultValue,
          valueChooseFlag: row.valueChooseFlag,
          createdBy:this.$store.state.user.name,
          maxValue: row.maxValue,
          minValue: row.minValue,
          itemRemark: row.itemRemark,
          itemType: 'A',
          objectID: row.objectID
        }
        this.itemModalDisableFlag = true
        this.itemModalFlag = true
      },

      itemSaveData () {
        if (this.itemModalData.itemNo === '' || this.itemModalData.itemNo == null) {
          this.$message.warning('请输入点检项目编码！')
          return
        }
        if (this.itemModalData.itemDesc === '' || this.itemModalData.itemDesc == null) {
          this.$message.warning('请输入点检项目名称！')
          return
        }
        if (this.itemModalData.flag === '1') {
          // eamPropertiesItemSave(this.itemModalData).then(({data}) => {
          //   if (data && data.code == '0') {
          //          searchPlanItems(this.detailData).then(({data}) => {
          //   this.detailList = data.rows
          // })
          //     this.itemModalFlag=false
          //     this.$message({
          //       message: '操作成功',
          //       type: 'success',
          //       duration: 1500,
          //       onClose: () => {
          //       }
          //     })
          //   } else {
          //     this.$alert(data.msg, '错误', {
          //       confirmButtonText: '确定'
          //     })
          //   }
          // })
        } else {
          updatePlanItems(this.itemModalData).then(({data}) => {
            if (data && data.code === 0) {
              searchPlanItems(this.detailData).then(({data}) => {
                this.detailList = data.rows
              })
              this.itemModalFlag = false
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }
      },

      //----------项目可选值----------------start
      chooseModal (row) {
        this.chooseModalData.site = row.site
        this.chooseModalData.buNo = row.buNo
        this.chooseModalData.planID = row.planID
        this.chooseModalData.itemNo = row.itemNo
        this.chooseModalData.itemDesc = row.itemDesc
        this.chooseModalData.valueTypeDb = row.valueTypeDb
        this.chooseModalData.objectID = row.objectID
        searchPlanItemAvailable(this.chooseModalData).then(({data}) => {
          this.chooseTableData = data.rows
        })
        this.chooseModalFlag = true
      },

      addChooseModal () {
        this.itemFlag = this.chooseModalData.valueTypeDb === 'T' ? 'text' : 'number';
        this.itemData = {
          site: this.chooseModalData.site,
          buNo: this.chooseModalData.buNo,
          planID: this.chooseModalData.planID,
          itemNo: this.chooseModalData.itemNo,
          objectID: this.chooseModalData.objectID,
          valueNo: 0,
          availableValue: '',
          itemType: 'A',
          createdBy: this.$store.state.user.name
        }
        this.itemAddModalFlag = true
      },

      updateChooseModal (row) {
        this.itemFlag = this.chooseModalData.valueTypeDb === 'T' ? 'text' : 'number'
        this.itemData = {
          site: this.chooseModalData.site,
          buNo: this.chooseModalData.buNo,
          planID: this.chooseModalData.planID,
          itemNo: this.chooseModalData.itemNo,
          objectID: this.chooseModalData.objectID,
          valueNo: row.valueNo,
          availableValue: row.availableValue,
          itemType: 'A',
          createdBy: this.$store.state.user.name
        }
        this.itemAddModalFlag = true
      },

      saveItemAvailable () {
        if (this.itemData.availableValue === '' || this.itemData.availableValue == null) {
          this.$message.warning('请输入可选值！')
          return
        }
        savePlanItemAvailable(this.itemData).then(({data}) => {
          if (data && data.code === 0) {
            searchPlanItemAvailable(this.chooseModalData).then(({data}) => {
              this.chooseTableData = data.rows
            })
            this.itemAddModalFlag = false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },

      deleteItemAvailable (row) {
        this.$confirm(`是否删除这个可选值?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deletePlanItemAvailable(row).then(({data}) => {
            if (data && data.code === 0) {
              searchPlanItemAvailable(this.chooseModalData).then(({data}) => {
                this.chooseTableData = data.rows
              })
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },

      // 下达
      createOrder (row) {
        let tempData = {
          site: row.site,
          buNo: row.buNo,
          planID: row.planID,
          functionType: row.functionType,
          userId: this.$store.state.user.name,
          objectList: []
        }
        getPlanDetailList(row).then(({data}) => {
          if (data && data.code === 0) {
            tempData.objectList = data.rows
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
        if (row.planStartDate < this.dayjs().format("YYYY-MM-DD")) {
          this.$alert('计划开始日期小于今天！请修改开始日期', '错误', {
            confirmButtonText: '确定'
          })
          return false
        }
        this.$confirm(`是否下达点检工单?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.dataListLoading = true
          createEamWorkOrder(tempData).then(({data}) => {
            if (data && data.code === 0) {
              this.getDataList()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
            this.dataListLoading = false
          })
        }).catch(() => {
        })
      },

      objectIDBlur () {
        let inData = {
          site: this.$store.state.user.site,
          objectID: this.modalData.objectID
        }
        objectIDBlur(inData).then(({data}) => {
          if (data.rows.length > 0) {
            this.modalData.objectDesc = data.rows[0].objectDesc
          } else {
            this.modalData.objectDesc = ''
          }
        })
      },

      modalCodeBlur () {
        let inData = {
          functionType: 'A',
          codeNo: this.modalData.propertiesCode
        }
        modalCodeBlur(inData).then(({data}) => {
          if (data.rows.length > 0) {
            this.modalData.propertiesDesc = data.rows[0].codeDesc
          } else {
            this.modalData.propertiesDesc = ''
          }
        })
      },

      getObjectList () {
        this.objectData.bu = this.modalData.bu
        getObjectList(this.objectData).then(({data}) => {
          this.objectList = data.rows
        })
      },

      planOrder (row) {
        row.userId = this.$store.state.user.name
        this.$confirm(`是否把进行中的计划变为已计划并取消未完成的工单?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          planOrder(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(() => {
        })
      },

      cancelPlan (row) {
        row.userId = this.$store.state.user.name
        this.$confirm(`是否取消计划?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          cancelPlan(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(() => {
        })
      },

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

      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) {
            //this.columnList1 = []
            switch (columnId) {
              case 1:
                this.columnList = data.rows
                break;
              case 2:
                this.columnDetailList = data.rows
                break;
              // case 3:
              //   this.columnList2 = data.rows
              //   break;
              // case 4:
              //   this.columnList3 = 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.columnDetailList = data.rows
                break;
              // case 3:
              //   this.columnList2 = data.rows
              //   break;
              // case 4:
              //   this.columnList3 = data.rows
              //   break;
            }
          } else {
            // this.showDefault = true.
          }
        })
      },
    }
  }
</script>

<style scoped>

</style>
