<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item :label="$t('装置名称')" prop="plantCode">
        <el-input
          v-model="queryParams.plantCode"
          :placeholder="$t('请输入') + $t('装置名称')"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item :label="$t('单元')" prop="unit">
        <el-input
          v-model="queryParams.unit"
          :placeholder="$t('请输入') + $t('单元')"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item :label="$t('位号')" prop="devno">
        <el-input
          v-model="queryParams.devno"
          :placeholder="$t('请输入') + $t('位号')"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item :label="$t('申请状态')" prop="approveStatus">
        <el-select v-model="queryParams.approveStatus" :placeholder="$t('请选择') + $t('申请状态')" clearable size="small">
          <el-option
            v-for="dict in approveStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          size="mini"
          @click="thirdPartyList"
        >{{ $t('第三方数据列表') }}
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <u-table v-loading="loading" ref="reportTable" :data="reportYlrqList"
              :row-key="row => { return row.id }"
              @selection-change="handleSelectionChange"
              use-virtual
              showBodyOverflow="title"
              :height="clientHeight" border>
      <u-table-column type="selection" width="55" :reserve-selection="true" align="center"/>
      <u-table-column :label="$t('装置')" align="center" fixed="left" prop="plantCode" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('单元')" align="center" fixed="left" prop="unit" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('位号')" align="center" fixed="left" prop="devno" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('申请状态')" align="center" fixed="left" prop="approveStatus"
                       :formatter="approveStatusFormat"/>
      <u-table-column :label="$t('设备名称')" align="center" prop="devname" width="200" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('使用证号码')" align="center" prop="useno" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('设备代码')" align="center" prop="regno" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('介质')" align="center" prop="medium" :show-overflow-tooltip="true" :render-header="renderHeader">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.medium" :placeholder="$t('请输入')+$t('介质')"/>
          <span v-else>{{ scope.row.medium }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('设计压力')+'(MPa)'" align="center" prop="desPressure" :show-overflow-tooltip="true" :render-header="renderHeader">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.desPressure" :placeholder="$t('请输入')+$t('设计压力')+'(MPa)'"/>
          <span v-else>{{ scope.row.desPressure }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('设计温度')+'(℃)'" align="center" prop="desTemp" :show-overflow-tooltip="true" :render-header="renderHeader">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.desTemp" :placeholder="$t('请输入')+$t('设计温度')+'(℃)'"/>
          <span v-else>{{ scope.row.desTemp }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('操作压力')+'(MPa)'" align="center" prop="optPressure" :show-overflow-tooltip="true" :render-header="renderHeader">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.optPressure" :placeholder="$t('请输入')+$t('操作压力')+'(MPa)'"/>
          <span v-else>{{ scope.row.optPressure }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('操作温度')+'(℃)'" align="center" prop="optTemp" :show-overflow-tooltip="true" :render-header="renderHeader">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.optTemp" :placeholder="$t('请输入')+$t('操作温度')+'(℃)'"/>
          <span v-else>{{ scope.row.optTemp }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('安全状况等级')" align="center" prop="safeClass" :show-overflow-tooltip="true"/>
      <u-table-column :label="$t('下次定期检验日期')" align="center" prop="nextWarnDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.nextWarnDate, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('容器管理')" header-align="center">
        <u-table-column label="1" align="center" prop="pj1" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj1" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj1Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj1 != null">{{ pj1Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="2" align="center" prop="pj2" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj2" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj2Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj2 != null">{{ pj2Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="3" align="center" prop="pj3" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj3" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj3Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj3 != null">{{ pj3Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="4" align="center" prop="pj4" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj4" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj4Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj4 != null">{{ pj4Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="5" align="center" prop="pj5" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj5" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj5Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj5 != null">{{ pj5Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="6" align="center" prop="pj6" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj6" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj6Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj6 != null">{{ pj6Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="7" align="center" prop="pj7" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj7" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj7Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj7 != null">{{ pj7Format(scope.row) }}</span>
          </template>
        </u-table-column>
      </u-table-column>
      <u-table-column :label="$t('本体及运行情况')" header-align="center">
        <u-table-column label="8" align="center" prop="pj8" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj8" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj8Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj8 != null">{{ pj8Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="9" align="center" prop="pj9" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj9" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj9Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj9 != null">{{ pj9Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="10" align="center" prop="pj10" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj10" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj10Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj10 != null">{{ pj10Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="11" align="center" prop="pj11" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj11" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj11Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj11 != null">{{ pj11Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="12" align="center" prop="pj12" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj12" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj12Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj12 != null">{{ pj12Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="13" align="center" prop="pj13" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj13" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj13Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj13 != null">{{ pj13Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="14" align="center" prop="pj14" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj14" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj14Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj14 != null">{{ pj14Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="15" align="center" prop="pj15" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj15" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj15Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj15 != null">{{ pj15Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="16" align="center" prop="pj16" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj16" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj16Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj16 != null">{{ pj16Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="17" align="center" prop="pj17" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj17" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj17Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj17 != null">{{ pj17Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="18" align="center" prop="pj18" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj18" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj18Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj18 != null">{{ pj18Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="19" align="center" prop="pj19" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj19" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj19Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj19 != null">{{ pj19Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="20" align="center" prop="pj20" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj20" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj20Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj20 != null">{{ pj20Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="21" align="center" prop="pj21" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj21" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj21Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj21 != null">{{ pj21Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="22" align="center" prop="pj22" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj22" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj22Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj22 != null">{{ pj22Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="23" align="center" prop="pj23" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj23" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj23Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj23 != null">{{ pj23Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="24" align="center" prop="pj24" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj24" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj24Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj24 != null">{{ pj24Format(scope.row) }}</span>
          </template>
        </u-table-column>
      </u-table-column>
      <u-table-column :label="$t('安全附件及设施')" header-align="center">
        <u-table-column label="25" align="center" prop="pj25" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj25" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj25Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj25 != null">{{ pj25Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="26" align="center" prop="pj26" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj26" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj26Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj26 != null">{{ pj26Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="27" align="center" prop="pj27" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj27" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj27Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj27 != null">{{ pj27Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="28" align="center" prop="pj28" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj28" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj28Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj28 != null">{{ pj28Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="29" align="center" prop="pj29" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj29" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj29Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj29 != null">{{ pj29Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="30" align="center" prop="pj30" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj30" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj30Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj30 != null">{{ pj30Format(scope.row) }}</span>
          </template>
        </u-table-column>
        <u-table-column label="31" align="center" prop="pj31" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj31" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj31Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj31 != null">{{ pj31Format(scope.row) }}</span>
          </template>
        </u-table-column>
      </u-table-column>
      <u-table-column :label="$t('其他')" header-align="center">
        <u-table-column label="32" align="center" prop="pj32" :render-header="renderHeader">
          <template slot-scope="scope">
            <el-select v-if="scope.row.isEdit" v-model="scope.row.pj32" :placeholder="$t('请选择')">
              <el-option
                v-for="dict in pj32Options"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              ></el-option>
            </el-select>
            <span v-if="scope.row.isEdit === false && scope.row.pj32 != null">{{ pj32Format(scope.row) }}</span>
          </template>
        </u-table-column>
      </u-table-column>
      <u-table-column :label="$t('备注')" align="center" prop="remarks" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.remarks" :placeholder="$t('请输入')+$t('备注')"/>
          <span v-else>{{ scope.row.remarks }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('检查日期')" align="center" prop="checkDate" width="100">
        <template slot-scope="scope">
          <el-date-picker clearable size="small" style="width: 200px"
                          v-model="scope.row.checkDate"
                          type="date"
                          v-if="scope.row.isEdit"
                          value-format="yyyy-MM-dd"
                          :placeholder="$t('请选择')+$t('检查日期')">
          </el-date-picker>
          <span v-else>{{ parseTime(scope.row.checkDate, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('下次年度检查日期')" align="center" prop="nextCheckDate" width="100">
        <template slot-scope="scope">
          <el-date-picker clearable size="small" style="width: 200px"
                          v-model="scope.row.nextCheckDate"
                          type="date"
                          v-if="scope.row.isEdit"
                          value-format="yyyy-MM-dd"
                          :placeholder="$t('请选择')+$t('下次年度检查日期')">
          </el-date-picker>
          <span v-else>{{ parseTime(scope.row.nextCheckDate, '{y}-{m}-{d}') }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('问题及处理')" align="center" prop="problem" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.problem" :placeholder="$t('请输入')+$t('问题及处理')"/>
          <span v-else>{{ scope.row.problem }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('检查结论')" align="center" prop="con" :formatter="conFormat">
        <template slot-scope="scope">
          <el-select v-if="scope.row.isEdit" v-model="scope.row.con" :placeholder="$t('请选择')+$t('检查结论')">
            <el-option
              v-for="dict in conOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
          <span v-if="scope.row.isEdit === false && scope.row.con != null">{{ conFormat(scope.row) }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('年检报告编号')" align="center" prop="yearReportNo" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <el-input v-if="scope.row.isEdit" v-model="scope.row.yearReportNo" :placeholder="$t('请输入')+$t('年检报告编号')"/>
          <span v-else>{{ scope.row.yearReportNo }}</span>
        </template>
      </u-table-column>
      <u-table-column :label="$t('操作')" align="center" fixed="right" width="200"
                       class-name="small-padding">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-tickets"
            @click="handleHistory(scope.row)"
            v-if="!scope.row.isEdit"
          >{{ $t('历史报告') }}
          </el-button>
          <el-button
            type="text"
            size="mini"
            v-if="scope.row.isEdit"
            @click="handleSave(scope.row)"
          >{{ $t('保存') }}
          </el-button>
          <el-button
            type="text"
            size="small"
            v-if="scope.row.isEdit"
            @click="handleCancel(scope.row, scope.$index)"
          >{{ $t('取消') }}
          </el-button>
        </template>
      </u-table-column>
    </u-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page-sizes="[20,100,300,500]"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 历史报告对话框 -->
    <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="title" :visible.sync="open" width="90%" append-to-body>
      <el-table :data="historyYlrqList" border>
        <el-table-column :label="$t('生成时间')" align="center" prop="buildDate" fixed="left" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.buildDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('装置名称')" align="center" prop="plantCode" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('单元')" align="center" prop="unit" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('位号')" align="center" prop="devno" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('名称')" align="center" prop="devname" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('使用证号码')" align="center" prop="useno" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('注册代码')" align="center" prop="regno" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('介质')" align="center" prop="medium" :show-overflow-tooltip="true" :render-header="renderHeader"/>
        <el-table-column :label="$t('设计压力')+'(MPa)'" align="center" prop="desPressure" :show-overflow-tooltip="true" :render-header="renderHeader"/>
        <el-table-column :label="$t('设计温度')+'(℃)'" align="center" prop="desTemp" :show-overflow-tooltip="true" :render-header="renderHeader"/>
        <el-table-column :label="$t('操作压力')+'(MPa)'" align="center" prop="optPressure" :show-overflow-tooltip="true" :render-header="renderHeader"/>
        <el-table-column :label="$t('操作温度')+'(℃)'" align="center" prop="optTemp" :show-overflow-tooltip="true" :render-header="renderHeader"/>
        <el-table-column :label="$t('安全状况等级')" align="center" prop="safeClass" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('下次定期检验日期')" align="center" prop="nextWarnDate" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.nextWarnDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('年检报告编号')" align="center" prop="yearReportNo" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('容器管理')" header-align="center">
        <el-table-column label="1" align="center" prop="pj1" :formatter="pj1Format" :render-header="renderHeader"/>
        <el-table-column label="2" align="center" prop="pj2" :formatter="pj2Format" :render-header="renderHeader"/>
        <el-table-column label="3" align="center" prop="pj3" :formatter="pj3Format" :render-header="renderHeader"/>
        <el-table-column label="4" align="center" prop="pj4" :formatter="pj4Format" :render-header="renderHeader"/>
        <el-table-column label="5" align="center" prop="pj5" :formatter="pj5Format" :render-header="renderHeader"/>
        <el-table-column label="6" align="center" prop="pj6" :formatter="pj6Format" :render-header="renderHeader"/>
        <el-table-column label="7" align="center" prop="pj7" :formatter="pj7Format" :render-header="renderHeader"/>
        </el-table-column>
        <el-table-column  :label="$t('容器本体及运行情况')" header-align="center">
        <el-table-column label="8" align="center" prop="pj8" :formatter="pj8Format" :render-header="renderHeader"/>
        <el-table-column label="9" align="center" prop="pj9" :formatter="pj9Format" :render-header="renderHeader"/>
        <el-table-column label="10" align="center" prop="pj10" :formatter="pj10Format" :render-header="renderHeader"/>
        <el-table-column label="11" align="center" prop="pj11" :formatter="pj11Format" :render-header="renderHeader"/>
        <el-table-column label="12" align="center" prop="pj12" :formatter="pj12Format" :render-header="renderHeader"/>
        <el-table-column label="13" align="center" prop="pj13" :formatter="pj13Format" :render-header="renderHeader"/>
        <el-table-column label="14" align="center" prop="pj14" :formatter="pj14Format" :render-header="renderHeader"/>
        <el-table-column label="15" align="center" prop="pj15" :formatter="pj15Format" :render-header="renderHeader"/>
        <el-table-column label="16" align="center" prop="pj16" :formatter="pj16Format" :render-header="renderHeader"/>
        <el-table-column label="17" align="center" prop="pj17" :formatter="pj17Format" :render-header="renderHeader"/>
        <el-table-column label="18" align="center" prop="pj18" :formatter="pj18Format" :render-header="renderHeader"/>
        <el-table-column label="19" align="center" prop="pj19" :formatter="pj19Format" :render-header="renderHeader"/>
        <el-table-column label="20" align="center" prop="pj20" :formatter="pj20Format" :render-header="renderHeader"/>
        <el-table-column label="21" align="center" prop="pj21" :formatter="pj21Format" :render-header="renderHeader"/>
        <el-table-column label="22" align="center" prop="pj22" :formatter="pj22Format" :render-header="renderHeader"/>
        <el-table-column label="23" align="center" prop="pj23" :formatter="pj23Format" :render-header="renderHeader"/>
        <el-table-column label="24" align="center" prop="pj24" :formatter="pj24Format" :render-header="renderHeader"/>
        </el-table-column>
        <el-table-column :label="$t('安全附件或设施')" header-align="center">
        <el-table-column label="25" align="center" prop="pj25" :formatter="pj25Format" :render-header="renderHeader"/>
        <el-table-column label="26" align="center" prop="pj26" :formatter="pj26Format" :render-header="renderHeader"/>
        <el-table-column label="27" align="center" prop="pj27" :formatter="pj27Format" :render-header="renderHeader"/>
        <el-table-column label="28" align="center" prop="pj28" :formatter="pj28Format" :render-header="renderHeader"/>
        <el-table-column label="29" align="center" prop="pj29" :formatter="pj29Format" :render-header="renderHeader"/>
        <el-table-column label="30" align="center" prop="pj30" :formatter="pj30Format" :render-header="renderHeader"/>
        <el-table-column label="31" align="center" prop="pj31" :formatter="pj31Format" :render-header="renderHeader"/>
        </el-table-column>
        <el-table-column :label="$t('其他')" header-align="center">
        <el-table-column label="32" align="center" prop="pj32" :formatter="pj32Format" :render-header="renderHeader"/>
        </el-table-column>
        <el-table-column :label="$t('备注')" align="center" prop="remarks" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('检查日期')" align="center" prop="checkDate" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.checkDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('下次年度检查日期')" align="center" prop="nextCheckDate" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.nextCheckDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column :label="$t('问题及处理')" align="center" prop="problem" :show-overflow-tooltip="true"/>
        <el-table-column :label="$t('检查结论')" align="center" prop="con" :formatter="conFormat"/>
        <el-table-column :label="$t('操作')" align="center" fixed="right" width="120"
                         class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button  type="text" size="small"
                       @click="handleDownloadReport(scope.row)">{{ $t('下载报告') }}
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <form ref="downloadForm" :action="downloadAction" target="FORMSUBMIT">
        <input name="id" v-model="downloadForm.id" hidden/>
      </form>
    </el-dialog>
    <year-approve v-if="approveVisible" ref="yearApprove" @refreshDataList="getList"></year-approve>
    <form ref="downloadForm2" :action="downloadAction2" target="FORMSUBMIT">
      <input name="year" v-model="downloadForm2.year" hidden/>
    </form>
    <!--  批量导出年检报告的历史报告  -->
    <el-dialog  :close-on-click-modal="false"
      title="选择需要导出的历史报告年份"
      :visible.sync="dialogVisible"
      width="20%">
      <el-date-picker
        v-model="exportCheckYear"
        type="year"
        placeholder="选择需要导出的历史报告年份">
      </el-date-picker>
      <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="exportDataForYear">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog  :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-form  ref="dateform" label-width="120px">
        <el-form-item>
          <span>{{$t('已选择')}} {{dataListSelections.length}}</span>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" :disabled="dataListSelections.length <= 0" @click="downloadDev(2)">{{$t('downloadSelect')}}</el-button>
        </el-form-item>
        <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
        >
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">
            将文件拖到此处，或
            <em>点击上传</em>
          </div>
          <!--<div class="el-upload__tip" slot="tip">-->
            <!--<el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>-->
          <!--</div>-->
          <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
        </el-upload>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm"
                   v-loading.fullscreen.lock="fullscreenLoading">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 第三方导入对话框 -->
    <el-dialog  :close-on-click-modal="false" :title="thirdUpload.title" :visible.sync="thirdUpload.open" width="400px" append-to-body>
      <div>{{ $t('装置') }}：
        <el-select v-model="plantCodeThird" :placeholder="$t('请选择') + $t('导入装置')" clearable size="small">
          <el-option
            v-for="dict in plantOptions"
            :key="dict.name"
            :label="dict.name"
            :value="dict.name"
          />
        </el-select>
      </div>
      <div>{{ $t('年份') }}：
        <el-date-picker
          v-model="importThirdYear"
          type="year"
          placeholder="选择导入的第三方数据年份">
        </el-date-picker>
      </div>
      <el-upload
        ref="thirdUpload"
        :limit="1"
        accept=".xlsx, .xls"
        :data="submitData"
        :headers="thirdUpload.headers"
        :action="thirdUpload.url + '?updateSupport=' + thirdUpload.updateSupport"
        :disabled="thirdUpload.isUploading"
        :on-progress="handleFileUploadProgressThird"
        :on-success="handleFileSuccessThird"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <!--        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>-->
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="thirdSubmitFileForm"
                   v-loading.fullscreen.lock="fullscreenLoading">确 定</el-button>
        <el-button @click="thirdUpload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 第三方数据列表对话框 -->
    <el-dialog  :close-on-click-modal="false" :title="thirdList.title" :visible.sync="thirdList.open" width="650px" append-to-body>
      <el-table
        :data="reportYlrqThirdList"
        style="width: 100%">
        <el-table-column
          prop="plantCode"
          :label="$t('装置名称')"
          width="100"
          :show-overflow-tooltip="true"
          align="center"/>
        <el-table-column
          prop="year"
          :label="$t('年份')"
          width="100"
          :show-overflow-tooltip="true"
          align="center"/>
        <el-table-column
          prop="fileName"
          :label="$t('文件名称')"
          width="300"
          :show-overflow-tooltip="true"
          align="center">
          <template slot-scope="scope">
            <a class="link-type" @click="handleDownload(scope.row)">
              <span>{{ scope.row.fileName }}</span>
            </a>
          </template>
        </el-table-column>
        <el-table-column :label="$t('操作')" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDeleteThird(scope.row)"
            >{{ $t('删除') }}
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
      <input name="type" :value="upload.type" hidden/>
    </form>
  </div>
</template>

<script>
import {
  listReportYlrq,
  delReportYlrq,
  updateReportYlrq,
  exportReportYlrq,
  syncReportYlrq,
  exportReportYlrqSelected,exportPDF
} from "@/api/sems/reportYlrq";
import {listHistoryYlrq} from "@/api/sems/historyYlrq";
import {treeselect} from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import YearApprove from './yearapprove'
import {getToken} from "@/utils/auth";
import {mylistPlant} from "@/api/system/plant";
import {listTReportThird,delReportThird} from "@/api/sems/tReportThird";

export default {
  name: "ReportYlrq",
  components: {Treeselect, YearApprove},
  data() {
    return {
      submitData: {
        plantCode: null,
        year: null,
      },
      thirdListQuery: {
        type: 1,
      },
      reportYlrqThirdList: [],
      plantOptions: [],
      plantCodeThird: null,
      importThirdYear: null,
      exportCheckYear: null,
      dialogVisible: false,
      // 遮罩层
      loading: true,
      approveVisible: false,
      // 选中数组
      ids: [],
      dataListSelections: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 压力容器年检报告表格数据
      reportYlrqList: [],
      // 压力容器报告历史表格数据
      historyYlrqList: [],
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      clientHeight: 300,
      // 是否显示弹出层
      open: false,
      approveStatusOptions: [],
      // 1字典
      pj1Options: [],
      // 2字典
      pj2Options: [],
      // 3字典
      pj3Options: [],
      // 4字典
      pj4Options: [],
      // 5字典
      pj5Options: [],
      // 6字典
      pj6Options: [],
      // 7字典
      pj7Options: [],
      // 8字典
      pj8Options: [],
      // 9字典
      pj9Options: [],
      // 10字典
      pj10Options: [],
      // 11字典
      pj11Options: [],
      // 12字典
      pj12Options: [],
      // 13字典
      pj13Options: [],
      // 14字典
      pj14Options: [],
      // 15字典
      pj15Options: [],
      // 16字典
      pj16Options: [],
      // 17字典
      pj17Options: [],
      // 18字典
      pj18Options: [],
      // 19字典
      pj19Options: [],
      // 20字典
      pj20Options: [],
      // 21字典
      pj21Options: [],
      // 22字典
      pj22Options: [],
      // 23字典
      pj23Options: [],
      // 24字典
      pj24Options: [],
      // 25字典
      pj25Options: [],
      // 26字典
      pj26Options: [],
      // 27字典
      pj27Options: [],
      // 28字典
      pj28Options: [],
      // 29字典
      pj29Options: [],
      // 30字典
      pj30Options: [],
      // 31字典
      pj31Options: [],
      // 32字典
      pj32Options: [],
      // 检查结论字典
      conOptions: [],
      // 查询参数
      queryParams: {
        plantCode: 'BCC',
        unit: null,
        approveStatus: null,
        devno: null,
        pageNum: 1,
        pageSize: 20,
        orderByColumn: null,
        isAsc: null,
      },
      // 查询参数
      queryHistoryParams: {
        pageNum: 1,
        pageSize: 50,
        reportId: null,
      },
      // 表单参数
      form: {},
      //下载参数
      downloadForm: {
        id: '',
      },
      downloadForm2: {
        year: '',
      },
      downloadAction: process.env.VUE_APP_BASE_API + '/sems/historyYlrq/exportPDF',
      downloadAction2: process.env.VUE_APP_BASE_API + '/sems/historyYlrq/exportPDFForYear',
      // 表单校验
      rules: {
        devId: [
          {required: true, message: this.$t('设备id') + this.$t('不能为空'), trigger: "blur"}
        ],
      },
      // 用户导入参数
      upload: {
        downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
        type: "reportYlrq",
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sems/reportYlrq/importForUpdate"
      },
      fullscreenLoading: false,
      // 第三方导入参数
      thirdUpload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sems/reportYlrq/importForThird"
      },
      // 第三方数据列表
      thirdList: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
      },
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    }
  },
  created() {
    //设置表格高度对应屏幕高度
    this.$nextTick(() => {
      this.clientHeight = (document.body.clientHeight - 80) * 0.8
    })
    this.getList();
    this.getTreeselect();
    this.getDicts("spec_approve_status").then(response => {
      for (let i = 0; i < response.data.length; i++) {
        if ( ["0","7","8"].includes(response.data[i].dictValue)){
          this.approveStatusOptions.push(response.data[i])
        }
      }
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj1Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj2Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj3Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj4Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj5Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj6Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj7Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj8Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj9Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj10Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj11Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj12Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj13Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj14Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj15Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj16Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj17Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj18Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj19Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj20Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj21Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj22Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj23Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj24Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj25Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj26Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj27Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj28Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj29Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj30Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj31Options = response.data;
    });
    this.getDicts("TEST_RESULT").then(response => {
      this.pj32Options = response.data;
    });
    this.getDicts("REPORT_CON").then(response => {
      this.conOptions = response.data;
    });
    this.getDicts("PLANT_DIVIDE").then(response => {
      this.plantCodeOptions = response.data;
    });
    let plantParams = {
      pType: 1
    }
    mylistPlant(plantParams).then(response => {
      this.plantOptions = response.data;
    });
  },
  methods: {
    //导出excel
    downloadDev(type){
      var rows = this.dataListSelections.map(item => {
        return item.id
      })
      const queryParams = {ids: null};
      queryParams.ids = rows.join()
      exportReportYlrqSelected(queryParams).then(response => {
        this.download(response.msg);
      })
    },
    /** 查询压力容器年检报告列表 */
    getList() {
      this.loading = true;
      console.log(this.queryParams.approveStatus);
      listReportYlrq(this.queryParams).then(response => {
        response.rows.forEach(element => {
          element["isEdit"] = false
        });
        this.reportYlrqList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.$nextTick(() => {
          this.$refs.reportTable.doLayout(); // 解决表格错位
        });
      });
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 申请状态字典翻译
    approveStatusFormat(row, column) {
      return this.selectDictLabel(this.approveStatusOptions, row.approveStatus);
    },
    // 1字典翻译
    pj1Format(row, column) {
      return this.selectDictLabel(this.pj1Options, row.pj1);
    },
    // 2字典翻译
    pj2Format(row, column) {
      return this.selectDictLabel(this.pj2Options, row.pj2);
    },
    // 3字典翻译
    pj3Format(row, column) {
      return this.selectDictLabel(this.pj3Options, row.pj3);
    },
    // 4字典翻译
    pj4Format(row, column) {
      return this.selectDictLabel(this.pj4Options, row.pj4);
    },
    // 5字典翻译
    pj5Format(row, column) {
      return this.selectDictLabel(this.pj5Options, row.pj5);
    },
    // 6字典翻译
    pj6Format(row, column) {
      return this.selectDictLabel(this.pj6Options, row.pj6);
    },
    // 7字典翻译
    pj7Format(row, column) {
      return this.selectDictLabel(this.pj7Options, row.pj7);
    },
    // 8字典翻译
    pj8Format(row, column) {
      return this.selectDictLabel(this.pj8Options, row.pj8);
    },
    // 9字典翻译
    pj9Format(row, column) {
      return this.selectDictLabel(this.pj9Options, row.pj9);
    },
    // 10字典翻译
    pj10Format(row, column) {
      return this.selectDictLabel(this.pj10Options, row.pj10);
    },
    // 11字典翻译
    pj11Format(row, column) {
      return this.selectDictLabel(this.pj11Options, row.pj11);
    },
    // 12字典翻译
    pj12Format(row, column) {
      return this.selectDictLabel(this.pj12Options, row.pj12);
    },
    // 13字典翻译
    pj13Format(row, column) {
      return this.selectDictLabel(this.pj13Options, row.pj13);
    },
    // 14字典翻译
    pj14Format(row, column) {
      return this.selectDictLabel(this.pj14Options, row.pj14);
    },
    // 15字典翻译
    pj15Format(row, column) {
      return this.selectDictLabel(this.pj15Options, row.pj15);
    },
    // 16字典翻译
    pj16Format(row, column) {
      return this.selectDictLabel(this.pj16Options, row.pj16);
    },
    // 17字典翻译
    pj17Format(row, column) {
      return this.selectDictLabel(this.pj17Options, row.pj17);
    },
    // 18字典翻译
    pj18Format(row, column) {
      return this.selectDictLabel(this.pj18Options, row.pj18);
    },
    // 19字典翻译
    pj19Format(row, column) {
      return this.selectDictLabel(this.pj19Options, row.pj19);
    },
    // 20字典翻译
    pj20Format(row, column) {
      return this.selectDictLabel(this.pj20Options, row.pj20);
    },
    // 21字典翻译
    pj21Format(row, column) {
      return this.selectDictLabel(this.pj21Options, row.pj21);
    },
    // 22字典翻译
    pj22Format(row, column) {
      return this.selectDictLabel(this.pj22Options, row.pj22);
    },
    // 23字典翻译
    pj23Format(row, column) {
      return this.selectDictLabel(this.pj23Options, row.pj23);
    },
    // 24字典翻译
    pj24Format(row, column) {
      return this.selectDictLabel(this.pj24Options, row.pj24);
    },
    // 25字典翻译
    pj25Format(row, column) {
      return this.selectDictLabel(this.pj25Options, row.pj25);
    },
    // 26字典翻译
    pj26Format(row, column) {
      return this.selectDictLabel(this.pj26Options, row.pj26);
    },
    // 27字典翻译
    pj27Format(row, column) {
      return this.selectDictLabel(this.pj27Options, row.pj27);
    },
    // 28字典翻译
    pj28Format(row, column) {
      return this.selectDictLabel(this.pj28Options, row.pj28);
    },
    // 29字典翻译
    pj29Format(row, column) {
      return this.selectDictLabel(this.pj29Options, row.pj29);
    },
    // 30字典翻译
    pj30Format(row, column) {
      return this.selectDictLabel(this.pj30Options, row.pj30);
    },
    // 31字典翻译
    pj31Format(row, column) {
      return this.selectDictLabel(this.pj31Options, row.pj31);
    },
    // 32字典翻译
    pj32Format(row, column) {
      return this.selectDictLabel(this.pj32Options, row.pj32);
    },
    // 检查结论字典翻译
    conFormat(row, column) {
      return this.selectDictLabel(this.conOptions, row.con);
    },

    // 表单重置
    reset() {
      this.form = {
        id: null,
        devId: null,
        medium: null,
        desPressure: null,
        desTemp: null,
        optPressure: null,
        optTemp: null,
        pj1: null,
        pj2: null,
        pj3: null,
        pj4: null,
        pj5: null,
        pj6: null,
        pj7: null,
        pj8: null,
        pj9: null,
        pj10: null,
        pj11: null,
        pj12: null,
        pj13: null,
        pj14: null,
        pj15: null,
        pj16: null,
        pj17: null,
        pj18: null,
        pj19: null,
        pj20: null,
        pj21: null,
        pj22: null,
        pj23: null,
        pj24: null,
        pj25: null,
        pj26: null,
        pj27: null,
        pj28: null,
        pj29: null,
        pj30: null,
        pj31: null,
        pj32: null,
        remarks: null,
        checkDate: null,
        nextCheckDate: null,
        problem: null,
        con: null,
        approveStatus: 0,
        approveTime: null,
        deptId: null,
        delFlag: null,
        createrCode: null,
        createdate: null,
        updaterCode: null,
        updatedate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      this.dataListSelections = selection
    },
    /** 历史报告按钮操作 */
    handleHistory(row) {
      this.queryHistoryParams.reportId = row.id;
      listHistoryYlrq(this.queryHistoryParams).then(response => {
        this.historyYlrqList = response.rows;
        this.open = true;
        this.title = row.devno + this.$t('空格') + this.$t('历史报告');
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      // 备份原始数据
      row['oldRow'] = JSON.parse(JSON.stringify(row));
      this.$nextTick(() => {
        row.isEdit = true;
      })
    },
    /** 保存按钮操作 */
    handleSave(row) {
      row.isEdit = false;
      this.loading = true;
      this.form = row;
      updateReportYlrq(this.form).then(response => {
        this.msgSuccess(this.$t('修改成功'));
        this.getList();
      });
    },
    /** 取消按钮操作 */
    handleCancel(row, index) {
      // 还原数据
      for (const i in row.oldRow) {
        row[i] = row.oldRow[i]
      }
      row.isEdit = false
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: "warning"
      }).then(function () {
        return delReportYlrq(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess(this.$t('删除成功'));
      })
    },
    /** 第三方文件删除按钮操作 */
    handleDeleteThird(row) {
      const ids = row.id;
      this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: "warning"
      }).then(function () {
        return delReportThird(ids);
      }).then(() => {
        this.thirdPartyList();
        this.msgSuccess(this.$t('删除成功'));
      })
    },
    //提交报告
    approveHandle(row) {
      var rows = this.dataListSelections.map(item => {
        return item
      })
      for (let i = 0; i < rows.length; i++) {
        if (rows[i].approveStatus != 0) {
          this.$alert(this.$t('当前设备正在申请中，无法重复申请'), this.$t('提示'), {
            type: 'warning'
          })
          return
        }
      }
      this.approveVisible = true
      this.$nextTick(() => {
        this.$refs.yearApprove.init(rows)
      })
    },

    // 根据压力容器台账数据进行同步
    syncData() {
      syncReportYlrq().then(response => {
        this.$message({
          message: response.msg,
          type: 'success'
        });
        this.getList();
      })
    },
    //结论备注
    renderHeader(h, {column, $index}) {
      let _this = this
      return [
        column.label,
        h(
          "el-tooltip",
          {
            props: {
              content: (function () {
                if (column.label == 1) {
                  return `管理制度、操作规程、运行记录`
                } else if (column.label == 2) {
                  return `设计文件、竣工图样、产品合格证、质量证明文件、安装使用说明`
                } else if (column.label == 3) {
                  return `监督检验证书以及安装、改造、修理等资料`
                } else if (column.label == 4) {
                  return `使用登记证，使用登记表是否与实际相符`
                } else if (column.label == 5) {
                  return `日常维护保养、定期安全检查记录`
                } else if (column.label == 6) {
                  return `年度检查、定期检验报告齐全，报告中问题解决`
                } else if (column.label == 7) {
                  return `作业人员定期培训情况`
                } else if (column.label == 8) {
                  return `设备铭牌、漆色、标志、使用证号码`
                } else if (column.label == 9) {
                  return `本体裂、过热、变形、泄漏、损伤情况`
                } else if (column.label == 10) {
                  return `接口部位、焊接接头等裂纹、泄漏、损伤情况`
                } else if (column.label == 11) {
                  return `外表面腐蚀、异常结霜、结露情况`
                } else if (column.label == 12) {
                  return `保温层、隔热层、衬里情况`
                } else if (column.label == 13) {
                  return `检漏孔、信号孔`
                } else if (column.label == 14) {
                  return `容器与相邻管道、构件间异常振动、响声、摩擦`
                } else if (column.label == 15) {
                  return `支承、支座、基础、紧固螺栓`
                } else if (column.label == 16) {
                  return `遮阳罩、操作台紧固`
                } else if (column.label == 17) {
                  return `罐体与底盘等连接`
                } else if (column.label == 18) {
                  return `波板、罐内扶梯与罐体连接`
                } else if (column.label == 19) {
                  return `罐车拉紧带、鞍座、中间支座`
                } else if (column.label == 20) {
                  return `气液相管及其它管路`
                } else if (column.label == 21) {
                  return `疏水、排放、排污装置`
                } else if (column.label == 22) {
                  return `设备运行稳定情况`
                } else if (column.label == 23) {
                  return `接地装置`
                } else if (column.label == 24) {
                  return `安全状况等级为4级的压力容器的监控措施`
                } else if (column.label == 25) {
                  return `安全阀`
                } else if (column.label == 26) {
                  return `压力表`
                } else if (column.label == 27) {
                  return `爆破片`
                } else if (column.label == 28) {
                  return `测温仪表`
                } else if (column.label == 29) {
                  return `液位计`
                } else if (column.label == 30) {
                  return `快开门安全联锁装置`
                } else if (column.label == 31) {
                  return `紧急切断装置`
                } else if (column.label == 32) {
                  return `装卸软管、装卸阀门`
                }else {
                  return _this.$t('如果是多腔压力容器')
                }
              })(),
              placement: "top"
            }
          },
          [
            h("span", {
              class: {
                "el-icon-question": true,
                "report-headerTips": true
              }
            })
          ]
        )
      ]
    },
    //下载报告
    downloadReport(row) {
      this.downloadForm.id = row.id;
      this.$nextTick(() => {
        this.$refs['downloadForm'].submit()
      })
    },
    // 文件下载处理
    handleDownloadReport(row) {
      let param = {
        id: row.id
      }
      exportPDF(param).then(response => {
        let url = response;
        var name = response;
        var suffix = url.substring(url.lastIndexOf("."), url.length);
        console.log(url)
        const a = document.createElement('a')
        a.setAttribute('download', name)
        a.setAttribute('target', '_blank')
        a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
        a.click()
      });
    },
    //批量下载某年份的历史报告
    exportDataForYear() {
      //将控件时间转为年,如果未选中年份，默认当前年
      if (this.exportCheckYear == null) {
        this.exportCheckYear = Date.now();
      }
      var date = new Date(this.exportCheckYear)
      this.downloadForm2.year = date.getFullYear();
      this.$nextTick(() => {
        this.$refs['downloadForm2'].submit()
      })
      //下载完成后关闭弹窗
      this.dialogVisible = false;
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.$refs['downloadFileForm'].submit()
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.fullscreenLoading = false;
      if (response.data.length > 0) {
        let failrow = ''
        for (let i = 0; i < response.data.length; i++) {
          failrow += response.data[i] + ','
        }
        this.$alert(this.$t('导入成功条数:') + response.msg + '<br>' + this.$t('失败行数:') + failrow, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
      } else {
        this.$alert(this.$t('导入成功条数:') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
      }
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
      this.fullscreenLoading = true;
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm(this.$t('是否确认导出所有特种设备压力容器年检报告数据项?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: "warning"
      }).then(function () {
        return exportReportYlrq(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    },
    //导入第三方数据
    importThirdParty() {
      this.thirdUpload.title = "第三方数据导入";
      this.thirdUpload.open = true;
    },
    thirdSubmitFileForm() {
      this.submitData.plantCode = this.plantCodeThird;
      this.submitData.year = new Date(this.importThirdYear).getFullYear();
      this.$refs.thirdUpload.submit();
      this.fullscreenLoading = true;
    },
    //第三方数据列表
    thirdPartyList() {
      listTReportThird(this.thirdListQuery).then(response => {
        this.reportYlrqThirdList = response.data;
      });
      this.thirdList.title = "第三方数据列表";
      this.thirdList.open = true;
    },
    // 第三方文件上传中处理
    handleFileUploadProgressThird(event, file, fileList) {
      this.thirdUpload.isUploading = true;
    },
    // 第三方文件上传成功处理
    handleFileSuccessThird(response, file, fileList) {
      this.thirdUpload.open = false;
      this.thirdUpload.isUploading = false;
      this.$refs.thirdUpload.clearFiles();
      this.fullscreenLoading = false;
      if (response.data.length > 0) {
        this.$alert(this.$t('导入成功'));
      } else {
        this.$alert(this.$t('导入成功'));
      }
      this.getList();
    },
    // 文件下载处理
    handleDownload(row) {
      var name = row.fileName;
      var url = row.filePath;
      var suffix = url.substring(url.lastIndexOf("."), url.length);
      const a = document.createElement('a')
      a.setAttribute('download', name)
      a.setAttribute('target', '_blank')
      a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
      a.click()
    },
  }
};
</script>
