<template>
  <div class="app-container">

    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item :label="$t('装置名称')" prop="plantCode">
        <el-select v-model="queryParams.plantCode" @change="handleLoop" :placeholder="$t('请选择') + $t('装置')" filterable clearable size="small">
          <el-option
            v-for="dict in plantOptions"
            :key="dict.name"
            :label="dict.name"
            :value="dict.name"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('腐蚀回路图')" prop="loopNo">
        <el-select v-model="queryParams.loopNo" @change="handleQuery" placeholder="请选择腐蚀回路图号" filterable clearable size="small">
          <el-option
            v-for="dict in loopOptions"
            :key="dict.loopNo"
            :label="dict.loopNo"
            :value="dict.loopNo"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('单元名称')" prop="unitCode">
        <el-input
          v-model="queryParams.unitCode"
          :placeholder="$t('请输入') + $t('单元名称')"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item :label="$t('单位内编号')" prop="tagno">
        <el-input
          v-model="queryParams.tagno"
          :placeholder="$t('请输入') + $t('单位内编号')"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备类型" prop="devType">
        <el-select v-model="queryParams.devType" placeholder="请选择设备类型" clearable size="small">
          <el-option label="管道" value="管道" />
          <el-option label="设备" value="设备" />
        </el-select>
      </el-form-item>

      <el-form-item :label="$t('测厚部位CML')" prop="position">
        <el-input
          v-model="queryParams.position"
          :placeholder="$t('请输入') + $t('测厚部位CML')"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item :label="$t('关键字')" prop="searchValue" label-width="50">
        <el-input
          v-model="queryParams.searchValue"
          :placeholder="$t('请输入') + $t('关键字')"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item label="预估剩余寿命" prop="estRemainWarn">
        <el-select v-model="queryParams.estRemainWarn"  :placeholder="$t('请选择') + $t('寿命预警')" filterable clearable size="small">
          <el-option
            key="1"
            label="小于1年"
            value="1"
          />
          <el-option
            key="3"
            label="小于3年"
            value="3"
          />
          <el-option
            key="5"
            label="小于5年"
            value="5"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="下次测厚预警" prop="measureDateWarn">
        <el-select v-model="queryParams.measureDateWarn"  :placeholder="$t('请选择') + $t('下次测厚预警')" filterable clearable size="small">
          <el-option
            key="1"
            label="小于1个月"
            value="1"
          />
          <el-option
            key="3"
            label="小于3个月"
            value="3"
          />
        </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="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sems:thickness:add']"
        >{{ $t('新增') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['sems:thickness:edit']"
        >{{ $t('修改') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['sems:thickness:remove']"
        >{{ $t('删除') }}</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImportData"
          v-hasPermi="['sems:thickness:add']"
        >{{$t('导入')}}
        </el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['sems:thickness:export']"
        >{{ $t('导出') }}</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['sems:thickness:edit']"
        >{{$t('更新数据')}}
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>


    <el-table v-loading="loading" :data="thicknessList" @selection-change="handleSelectionChange" :cell-style="tableCellStyle" :height="clientHeight" border>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column :label="$t('装置名称')" align="center" prop="plantCode" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('单元名称')" align="center" prop="unitCode" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('腐蚀回路图号')" align="center" prop="loopNo" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <a style="text-decoration: underline;" class="link-type" @click="handleSeeLoop(scope.row)" > {{ scope.row.loopNo }} </a>
        </template>
      </el-table-column>

      <el-table-column :label="$t('单位内编号')" align="center" prop="tagno" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('状态')" align="center" prop="status" :formatter="statusFormat" />
      <el-table-column :label="$t('测厚部位CML')" align="center" :render-header="remarksHeader" prop="position" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('检测编号')" align="center" prop="measureNo" :show-overflow-tooltip="true"/>

      <!--      <el-table-column label="记录人" align="center" prop="recorder" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="记录时间" align="center" prop="recorderDate" width="100">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.recorderDate, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column :label="$t('设备/管线名称')" align="center" prop="equipmentName" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('材质')" align="center" prop="material" :show-overflow-tooltip="true"/>
<!--      <el-table-column label="腐蚀裕度" align="center" prop="corAllowance" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="原始壁厚" align="center" prop="originalThickness" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="介质" align="center" prop="medium" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="压力" align="center" prop="pressure" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="规格" align="center" prop="specification" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="流速" align="center" prop="flowRate" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="温度" align="center" prop="temperature" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="腐蚀类型" align="center" prop="corrosionType" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="腐蚀照片" align="center" prop="photo" :show-overflow-tooltip="true"/>-->
<!--      <el-table-column label="原因分析" align="center" prop="analysis" :show-overflow-tooltip="true"/>-->
      <el-table-column :label="$t('公称壁厚(mm)')" align="center" prop="nominalTickness" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('最小允许壁厚(mm)')" align="center" prop="thicknessMin" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('短期腐蚀速率(mm/year)')" align="center" prop="stCorrosion" :show-overflow-tooltip="true"/>
      <el-table-column :label="$t('长期腐蚀速率(mm/year)')" align="center" prop="ltCorrosion" :show-overflow-tooltip="true"/>
      <el-table-column
        prop="measureCycle"
        header-align="center"
        align="center"
        :label="$t('测厚周期(月)')">
      </el-table-column>
      <el-table-column
        prop="installDate"
        header-align="center"
        align="center"
        label="安装日期"/>
      <el-table-column
        prop="firstMeasureDate"
        header-align="center"
        align="center"
        :label="$t('首次测厚日期')"/>
      <el-table-column
        prop="newMeasureDate"
        header-align="center"
        align="center"
        :label="$t('最近测厚日期')"/>

      <el-table-column :label="$t('预估剩余寿命(year)')" align="center" prop="estRemain" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span  v-if="scope.row.estRemain"> {{ scope.row.estRemain }}</span>
          <span v-else-if="!scope.row.thicknessMin">缺少最小允许壁厚</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="nextWarnDate"
        header-align="center"
        align="center"
        :label="$t('下次测厚日期')">
      </el-table-column>
      <el-table-column :label="$t('检测方法')" align="center" prop="inspectionMethod" :formatter="inspectionMethodFormat" />
      <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="handleView(scope.row)">{{ $t('查看') }}</el-button>
          <el-button type="text" size="small" @click="recordHandle(scope.row)">{{ $t('测厚记录') }}</el-button>
          <el-button type="text" size="small" @click="wordView(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>
    <pagination
      v-show="total>0"
      :total="total"
             :page.sync="queryParams.pageNum"
      :page-sizes="[20,100,300,500]"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改定点测厚对话框 -->
    <el-dialog  :close-on-click-modal="false" v-dialogDrag :title="title" :visible.sync="open" width="70%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-row>
          <el-col :span="6">
          <el-form-item :label="$t('装置名称')" prop="plantCode">
            <el-select v-model="form.plantCode" :placeholder="$t('请选择') + $t('装置')" filterable clearable size="small">
              <el-option
                v-for="dict in plantOptions"
                :key="dict.name"
                :label="dict.name"
                :value="dict.name"
              />
            </el-select>
          </el-form-item>
          </el-col>
          <el-col :span="6">
          <el-form-item :label="$t('单元名称')" prop="unitCode">
            <el-input v-model="form.unitCode" :placeholder="$t('请输入') + $t('单元名称')" />
          </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="腐蚀回路图号" prop="loopNo">
              <el-input v-model="form.loopNo" placeholder="请输入腐蚀回路图号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
          <el-form-item :label="$t('单位内编号')" prop="tagno">
            <el-input v-model="form.tagno" :placeholder="$t('请输入') + $t('单位内编号')" />
          </el-form-item>
          </el-col>
      </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item :label="$t('测厚部位CML')" prop="position">
              <el-input v-model="form.position" :placeholder="$t('请输入') + $t('测厚部位CML')" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('安装日期')" prop="installDate" >
              <el-date-picker clearable size="mini"
                              style="width: 100%;"
                              v-model="form.installDate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              :placeholder="$t('请选择') + $t('安装日期')">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('记录人')" prop="recorder">
              <el-input v-model="form.recorder" :placeholder="$t('请输入') + $t('记录人')" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item :label="$t('记录时间')" prop="recorderDate" >
              <el-date-picker clearable size="mini"
                              v-model="form.recorderDate"
                              type="date"
                              style="width: 100%;"
                              value-format="yyyy-MM-dd"
                              :placeholder="$t('请选择') + $t('记录时间')">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item :label="$t('设备/管线名称')" prop="equipmentName">
          <el-input v-model="form.equipmentName" :placeholder="$t('请输入') + $t('设备/管线名称')" />
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item :label="$t('材质')" prop="material">
          <el-input v-model="form.material" :placeholder="$t('请输入') + $t('材质')" />
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item :label="$t('腐蚀裕度(mm)')" prop="corAllowance">
          <el-input v-model="form.corAllowance" :placeholder="$t('请输入') + $t('腐蚀裕度(mm)')" />
        </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="设备类型" prop="devType">
              <el-select v-model="form.devType" placeholder="请选择设备类型">
                <el-option label="管道" value="管道" />
                <el-option label="设备" value="设备" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设计压力" prop="desPressure">
              <el-input v-model="form.desPressure" placeholder="请输入设计压力" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设计温度" prop="desTemp">
              <el-input v-model="form.desTemp" placeholder="请输入设计温度" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
        <el-form-item :label="$t('原始壁厚(mm)')" prop="originalThickness">
          <el-input v-model="form.originalThickness" :placeholder="$t('请输入') + $t('原始壁厚(mm)')" />
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item :label="$t('介质')" prop="medium">
          <el-input v-model="form.medium" :placeholder="$t('请输入') + $t('介质')" />
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item :label="$t('工作压力(MPag)')" prop="pressure">
          <el-input v-model="form.pressure" :placeholder="$t('请输入') + $t('工作压力(MPag)')" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
        <el-form-item :label="$t('规格')" prop="specification">
          <el-input v-model="form.specification" :placeholder="$t('请输入') + $t('规格')" />
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item :label="$t('流速(m/s)')" prop="flowRate">
          <el-input v-model="form.flowRate" :placeholder="$t('请输入') + $t('流速(m/s)')" />
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item :label="$t('工作温度(℃)')" prop="temperature">
          <el-input v-model="form.temperature" :placeholder="$t('请输入') + $t('工作温度(℃)')" />
        </el-form-item>
          </el-col>
        </el-row>

        <el-form-item :label="$t('状态')">
          <el-radio-group v-model="form.status">
            <el-radio
              v-for="dict in statusOptions"
              :key="dict.dictValue"
              :label="parseInt(dict.dictValue)"
            >{{dict.dictLabel}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item :label="$t('测厚位置')"  prop="checkUrl">
            <el-upload
              ref="analysis"
              :limit="1"
              :headers="check.headers"
              :action="check.url"
              :disabled="check.isUploading"
              :on-progress="handleFileDocProgressCheck"
              :on-success="handleFileDocSuccessCheck"
              :auto-upload="true"
              drag
            >
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">
                {{ $t('将文件拖到此处，或') }}
                <em>{{ $t('点击上传') }}</em>
              </div>
            </el-upload>
        </el-form-item>
        <el-form-item :label="$t('腐蚀位置')"  prop="locationUrl">
          <el-upload
            :action="locationpic.url"
            :headers="locationpic.headers"
            :file-list="locationList"
            :limit="3"
            :on-success="handleAvatarSuccess"
            :on-exceed="handleExceed"
            :before-upload="beforeAvatarUpload"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove">
            <i class="el-icon-plus"></i>
          </el-upload>
          <el-dialog  :close-on-click-modal="false" v-dialogDrag :visible.sync="dialogVisible" append-to-body>
            <img width="100%" :src="dialogImageUrl" alt="">
          </el-dialog>
        </el-form-item>
        <el-form-item :label="$t('检测方法')">
          <el-checkbox-group v-model="form.inspectionMethod">
            <el-checkbox
              v-for="dict in inspectionMethodOptions"
              :key="dict.dictValue"
              :label="dict.dictValue">
              {{dict.dictLabel}}
            </el-checkbox>
          </el-checkbox-group>
          <el-input :placeholder="$t('请输入') + $t('其他')+ $t('空格')+ $t('检测方法')" class="otherMethod" v-if="form.inspectionMethod == 5" v-model="form.otherContent"></el-input>
        </el-form-item>
        <el-form-item :label="$t('腐蚀照片')"  prop="photo">
          <el-upload
            :action="photo.url"
            :headers="photo.headers"
            :file-list="photoList"
            :limit="3"
            :on-success="handleAvatarSuccess2"
            :on-exceed="handleExceed"
            :before-upload="beforeAvatarUpload"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove2">
            <i class="el-icon-plus"></i>
          </el-upload>
          <el-dialog  :close-on-click-modal="false" v-dialogDrag :visible.sync="dialogVisible" append-to-body>
            <img width="100%" :src="dialogImageUrl" alt="">
          </el-dialog>
        </el-form-item>
        <el-form-item :label="$t('原因分析')" prop="analysis">
          <el-input v-model="form.analysis" :placeholder="$t('请输入') + $t('原因分析')" />
        </el-form-item>
        <el-row>
          <el-col :span="8">
        <el-form-item :label="$t('公称壁厚(mm)')" prop="nominalTickness">
          <el-input v-model="form.nominalTickness" :placeholder="$t('请输入') + $t('名义壁厚(mm)')" />
        </el-form-item>
            <el-form-item :label="$t('原因分析附件')" prop="analysisUrl">
              <el-upload
                ref="analysis"
                :limit="1"
                :headers="analysis.headers"
                :action="analysis.url"
                :disabled="analysis.isUploading"
                :on-progress="handleFileDocProgress"
                :on-success="handleFileDocSuccess"
                :auto-upload="true"
                drag
              >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  {{ $t('将文件拖到此处，或') }}
                  <em>{{ $t('点击上传') }}</em>
                </div>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="16">
        <el-form-item :label="$t('最小允许壁厚(mm)')" label-width="150px" prop="thicknessMin">
          <el-input v-model="form.thicknessMin" :placeholder="$t('请输入') + $t('最小允许壁厚(mm)')" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-form-item :label="$t('检测编号')" prop="measureNo">
          <el-input v-model="form.measureNo" :placeholder="$t('请输入') + $t('检测编号')" />
        </el-form-item>

      <el-row>
        <el-col :span="8">
        <el-form-item :label="$t('短期腐蚀速率(mm/year)')" label-width="180px" prop="stCorrosion">
          <el-input v-model="form.stCorrosion" :placeholder="$t('请输入') + $t('短期腐蚀速率(mm/year)')" />
        </el-form-item>
        </el-col>
        <el-col :span="8">
        <el-form-item :label="$t('长期腐蚀速率(mm/year)')" label-width="180px" prop="ltCorrosion">
          <el-input v-model="form.ltCorrosion" :placeholder="$t('请输入') + $t('长期腐蚀速率(mm/year)')" />
        </el-form-item>
        </el-col>
        <el-col :span="8">
        <el-form-item :label="$t('预估剩余寿命(year)')" label-width="180px" prop="estRemain">
          <el-input v-model="form.estRemain" :placeholder="$t('请输入') + $t('预估剩余寿命(year)')" />
        </el-form-item>
        </el-col>
      </el-row>
        <el-row>
        <el-form-item :label="$t('治理方法及依据')" prop="methodCause">
          <el-input v-model="form.methodCause" :placeholder="$t('请输入') + $t('治理方法及依据')" />
        </el-form-item>
        </el-row>
        <el-form-item :label="$t('效果跟踪')" prop="effectTracing">
          <el-input v-model="form.effectTracing" :placeholder="$t('请输入') + $t('效果跟踪')" />
        </el-form-item>
        <el-row>
          <el-col :span="8">
        <el-form-item :label="$t('提出人')" prop="raiser">
          <el-input v-model="form.raiser" :placeholder="$t('请输入') + $t('提出人')" />
        </el-form-item>
          </el-col>
          <el-col :span="16">
        <el-form-item :label="$t('提出时间')" prop="raiserDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.raiserDate"
            type="date"
            value-format="yyyy-MM-dd"
            :placeholder="$t('请选择') + $t('提出时间')">
          </el-date-picker>
        </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('测厚周期(月)')" prop="remarks">
              <el-input v-model="form.measureCycle" :placeholder="$t('请输入') + $t('测厚周期(月)')" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item :label="$t('下次测厚日期')" prop="raiserDate">
          <el-date-picker clearable size="small" style="width: 200px"
                          v-model="form.nextWarnDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          :placeholder="$t('请选择') + $t('下次测厚日期')">
          </el-date-picker>
        </el-form-item>
          </el-col>
        </el-row>
        <el-form-item :label="$t('备注')" prop="remarks">
          <el-input v-model="form.remarks" type="textarea" :placeholder="$t('请输入') + $t('内容')" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
        <el-button @click="cancel">{{ $t('取 消') }}</el-button>
      </div>
    </el-dialog>
    <el-dialog  :close-on-click-modal="false"
      :title="$t('查看')"

      width="1200px"
      :visible.sync="visible">
      <el-descriptions class="margin-top" :column="3" size="medium" border>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('装置名称') }}
          </template>
          {{ dataForm.plantCode }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('单元名称') }}
          </template>
          {{ dataForm.unitCode }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('单位内编号') }}
          </template>
          {{ dataForm.tagno }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('测厚部位CML') }}
          </template>
          {{ dataForm.position }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('记录人') }}
          </template>
          {{ dataForm.recorder }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('记录时间') }}
          </template>
          {{ dataForm.recorderDate }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('设备/管线名称') }}
          </template>
          {{ dataForm.equipmentName }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('材质') }}
          </template>
          {{ dataForm.material }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('腐蚀裕度(mm)') }}
          </template>
          {{ dataForm.corAllowance }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('原始壁厚(mm)') }}
          </template>
          {{ dataForm.originalThickness }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('介质') }}
          </template>
          {{ dataForm.medium }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('工作压力(MPag)') }}
          </template>
          {{ dataForm.pressure }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('规格') }}
          </template>
          {{ dataForm.specification }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('流速(m/s)') }}
          </template>
          {{ dataForm.flowRate }}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            {{ $t('工作温度(℃)') }}
          </template>
          {{ dataForm.temperature }}
        </el-descriptions-item>

        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('腐蚀位置') }}
          </template>
          <el-upload
            :action="locationpic.url"
            :headers="locationpic.headers"
            :file-list="locationList"
            :limit="3"
            :on-success="handleAvatarSuccess"
            :on-exceed="handleExceed"
            :before-upload="beforeAvatarUpload"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove">
            <i class="el-icon-plus"></i>
          </el-upload>
        </el-descriptions-item>
        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('检测方法') }}
          </template>
          <el-checkbox-group v-model="dataForm.inspectionMethod">
            <el-checkbox
              v-for="dict in inspectionMethodOptions"
              :key="dict.dictValue"
              :label="dict.dictValue">
              {{dict.dictLabel}}
            </el-checkbox>
          </el-checkbox-group>
          {{ dataForm.otherContent }}
        </el-descriptions-item>
        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('腐蚀照片') }}
          </template>
          <el-upload
            :action="photo.url"
            :headers="photo.headers"
            :file-list="photoList"
            :limit="3"
            :on-success="handleAvatarSuccess2"
            :on-exceed="handleExceed"
            :before-upload="beforeAvatarUpload"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove2">
            <i class="el-icon-plus"></i>
          </el-upload>
        </el-descriptions-item>
        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('原因分析') }}
          </template>
          {{ dataForm.analysis }}
        </el-descriptions-item>
        <el-descriptions-item span="1">
          <template slot="label">
            {{ $t('公称壁厚(mm)') }}
          </template>
          {{ dataForm.nominalTickness }}
        </el-descriptions-item>
        <el-descriptions-item span="2">
          <template slot="label">
            {{ $t('最小允许壁厚(mm)') }}
          </template>
          {{ dataForm.thicknessMin }}
        </el-descriptions-item>
        <el-descriptions-item span="1">
          <template slot="label">
            {{ $t('短期腐蚀速率(mm/year)') }}
          </template>
          {{ dataForm.stCorrosion }}
        </el-descriptions-item>
        <el-descriptions-item span="1">
          <template slot="label">
            {{ $t('长期腐蚀速率(mm/year)') }}
          </template>
          {{ dataForm.ltCorrosion }}
        </el-descriptions-item>
        <el-descriptions-item span="1">
          <template slot="label">
            {{ $t('预估剩余寿命(year)') }}
          </template>
          {{ dataForm.estRemain }}
        </el-descriptions-item>
        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('原因分析附件') }}
          </template>
          <span style="text-decoration: underline;" class="link-type" @click="handleDownload(dataForm.analysisUrl)">{{ dataForm.analysisUrl }}</span>

        </el-descriptions-item>
        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('治理方法及依据') }}
          </template>
          {{ dataForm.methodCause }}
        </el-descriptions-item>
        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('效果跟踪') }}
          </template>
          {{ dataForm.effectTracing }}
        </el-descriptions-item>
        <el-descriptions-item span="1">
          <template slot="label">
            {{ $t('提出人') }}
          </template>
          {{ dataForm.raiser }}
        </el-descriptions-item>
        <el-descriptions-item span="2">
          <template slot="label">
            {{ $t('提出时间') }}
          </template>
          {{ dataForm.raiserDate }}
        </el-descriptions-item>
        <el-descriptions-item span="1">
          <template slot="label">
            {{ $t('测厚周期(月)') }}
          </template>
          {{ dataForm.measureCycle }}
        </el-descriptions-item>
        <el-descriptions-item span="2">
          <template slot="label">
            {{ $t('下次测厚日期') }}
          </template>
          {{ dataForm.nextWarnDate }}
        </el-descriptions-item>
        <el-descriptions-item span="3">
          <template slot="label">
            {{ $t('趋势图') }}
          </template>
          <img :src="dataForm.recordUrl" width="900px" />
        </el-descriptions-item>
      </el-descriptions>
          <template slot="label">
            {{ $t('测厚数据') }}
          </template>
         <template>
           <el-table
             :data="dataList"
             border
             style="width: 100%;">
             <el-table-column
               prop="measureValue"
               header-align="center"
               align="center"
               :label="$t('实测记录')">
               <template slot-scope="scope">
                 <el-input v-if="scope.row.isEdit" v-model="scope.row.measureValue"></el-input>
                 <span v-else>{{scope.row.measureValue}}</span>
               </template>
             </el-table-column>
             <el-table-column
               prop="measureDate"
               header-align="center"
               align="center"
               :label="$t('日期')">
               <template slot-scope="scope">
                 <el-date-picker
                   v-if="scope.row.isEdit"
                   v-model="scope.row.measureDate"
                   type="date"
                   value-format="yyyy-MM-dd"
                   :placeholder="$t('日期')">
                 </el-date-picker>
                 <span v-else>{{scope.row.measureDate}}</span>
               </template>
             </el-table-column>
             <el-table-column
               prop="recorder"
               header-align="center"
               align="center"
               :label="$t('记录人')">
               <template slot-scope="scope">
                 <el-input v-if="scope.row.isEdit" v-model="scope.row.recorder"></el-input>
                 <span v-else>{{scope.row.recorder}}</span>
               </template>
             </el-table-column>
           </el-table>
         </template>

      <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">{{ $t('取消') }}</el-button>
    </span>
    </el-dialog>
    <!-- 侧厚导入对话框 -->
    <el-dialog  :close-on-click-modal="false" :title="uploadThickness.title" :visible.sync="uploadThickness.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="uploadThickness.headers"
        :action="uploadThickness.url + '?updateSupport=' + uploadThickness.updateSupport"
        :disabled="uploadThickness.isUploading"
        :on-progress="handleFileUploadProgress2"
        :on-success="handleFileSuccess2"
        :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="importTemplateData">下载模板</el-link>
        </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="submitFileForm"
                   v-loading.fullscreen.lock="fullscreenLoading">确 定</el-button>
        <el-button @click="uploadThickness.open = false">取 消</el-button>
      </div>
      <form ref="downloadFileDataForm" :action="uploadThickness.downloadAction" target="FORMSUBMIT">
        <input name="type" :value="uploadThickness.type" hidden/>
      </form>
    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog  :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <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>
      <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>
      <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
        <input name="type" :value="upload.type" hidden/>
      </form>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px"
               append-to-body>
      <div style="margin-top: -60px;float: right;margin-right: 40px;">
        <el-button size="mini" type="text" @click="openPdf">{{ $t('新页面打开PDF') }}</el-button>
      </div>
      <div style="margin-top: -30px">
        <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
      </div>
    </el-dialog>
    <record v-if="recordVisible" ref="record" @refreshDataList="getList" :showFlag="showFlag" @closeChildDialog="closeChildDialog"></record>
  </div>
</template>

<script>
import {wordView, listThickness, getThickness, delThickness, addThickness, updateThickness, exportThickness, importTemplate} from "@/api/sems/thickness";
import { treeselect } from "@/api/system/dept";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Editor from '@/components/Editor';
import request from "@/utils/request";
import record from './record'
import {listMeasurerecord} from "@/api/sems/measure-record";
import {listPlant, mylistPlant} from "@/api/system/plant";
import {queryUrl ,getLoopByPlant} from "@/api/sems/measure-loop";

export default {
  name: "Thickness",
  components: { Treeselect ,record },
  // components: { Editor },
  data() {
    return {
      fullscreenLoading: false,
      recordVisible: false,
      showFlag: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 定点测厚表格数据
      thicknessList: [],
      dataList: [],
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      clientHeight:300,
      // 是否显示弹出层
      open: false,
      visible: false,
      // 检测方法字典
      inspectionMethodOptions: [],
      statusOptions:[],
      plantOptions: [],
      loopOptions: [],
      // 用户导入参数
      upload: {
          //模板下载路由
          downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
          //模板下载区分
          type: "thickness",
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: { Authorization: "Bearer " + getToken() },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/sems/measure-record/importForUpdate"
      },
      // 用户导入参数
      uploadThickness: {
        //模板下载路由
        downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
        //模板下载区分
        type: "thicknessData",
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sems/thickness/importData"
      },
      downloadForm: {
        id: '',
        key: ''
      },
      downloadAction: process.env.VUE_APP_BASE_API +'/sems/thickness/measure/exportPDF',
      check: {
        imageUrl: '',
        fileList: [],
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sems/thickness/uploadFile",
      },
      locationpic: {
        imageUrl: '',
        fileList: [],
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sems/thickness/uploadFile",
      },
      photo: {
        imageUrl: '',
        fileList: [],
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sems/thickness/uploadFile",
      },
      analysis: {
        file: "",
        // 是否显示弹出层（报告附件）
        open: false,
        // 弹出层标题（报告附件）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 报告附件上传位置编号
        ids: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sems/thickness/uploadFile",
        commonfileList: null,
        pType: 'traning',
        pId: null
      },
      pdf: {
        title: '',
        pdfUrl: '',
        numPages: null,
        open: false,
        pageNum: 1,
        pageTotalNum: 1,
        loadedRatio: 0,
      },
      locationList: [],
      photoList: [],
      dialogImageUrl: '',
      dialogVisible: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        plantCode: null,
        unitCode: null,
        tagno: null,
        status: null,
        remarks: null,
        position: null,
        recorder: null,
        recorderDate: null,
        equipmentName: null,
        material: null,
        corAllowance: null,
        originalThickness: null,
        medium: null,
        pressure: null,
        specification: null,
        flowRate: null,
        temperature: null,
        corrosionType: null,
        inspectionMethod: null,
        photo: null,
        analysis: null,
        nominalTickness: null,
        thicknessMin: null,
        stCorrosion: null,
        ltCorrosion: null,
        estRemain: null,
        methodCause: null,
        effectTracing: null,
        raiser: null,
        raiserDate: null,
        locationUrl: null,
        analysisUrl: null,
        measureCycle: null,
        recordUrl: null,
        otherContent: null,
        estRemainWarn: null,
        measureDateWarn: null,
      }, // 查询参数
      recordParams: {
        pageNum: 1,
        pageSize: 99,

      },
      // 表单参数
      form: {},
      dataForm: {},
      // 表单校验
      rules: {
        plantCode: [
          { required: true, message: this.$t('装置名称')+this.$t('不能为空'), trigger: "blur" }
        ],
        unitCode: [
          { required: true, message: this.$t('单元名称')+this.$t('不能为空'), trigger: "blur" }
        ],
        position: [
          { required: true, message: this.$t('测厚部位CML')+this.$t('不能为空'), trigger: "blur" }
        ],
        equipmentName: [
          { required: true, message: this.$t('设备/管线名称')+this.$t('不能为空'), trigger: "blur" }
        ],
        material: [
          { required: true, message: this.$t('材质')+this.$t('不能为空'), trigger: "blur" }
        ],
        corAllowance: [
          { required: true, message: this.$t('腐蚀裕度(mm)')+this.$t('不能为空'), trigger: "blur" }
        ],
        originalThickness: [
          { required: true, message: this.$t('原始壁厚(mm)')+this.$t('不能为空'), trigger: "blur" }
        ],
        medium: [
          { required: true, message: this.$t('介质')+this.$t('不能为空'), trigger: "blur" }
        ],
        pressure: [
          { required: true, message: this.$t('工作压力')+this.$t('不能为空'), trigger: "blur" }
        ],
        specification: [
          { required: true, message: this.$t('规格')+this.$t('不能为空'), trigger: "blur" }
        ],
/*        flowRate: [
          { required: true, message: this.$t('流速(m/s)')+this.$t('不能为空'), trigger: "blur" }
        ],*/
        temperature: [
          { required: true, message: this.$t('工作温度(℃)')+this.$t('不能为空'), trigger: "blur" }
        ],
        corrosionType: [
          { required: true, message: this.$t('腐蚀类型')+this.$t('不能为空'), trigger: "change" }
        ],
        /*analysis: [
          { required: true, message: "原因分析不能为空", trigger: "blur" }
        ],*/
        nominalTickness: [
          { required: true, message: this.$t('公称壁厚(mm)')+this.$t('不能为空'), trigger: "blur" }
        ],
        // thicknessMin: [
        //   { required: true, message: this.$t('最小允许壁厚(mm)')+this.$t('不能为空'), trigger: "blur" }
        // ],
        /*stCorrosion: [
          { required: true, message: "短期腐蚀速率不能为空", trigger: "blur" }
        ],
        ltCorrosion: [
          { required: true, message: "长期腐蚀速率不能为空", trigger: "blur" }
        ],
        estRemain: [
          { required: true, message: "预估剩余寿命不能为空", trigger: "blur" }
        ],*/
        /*methodCause: [
          { required: true, message: "治理方法及依据不能为空", trigger: "blur" }
        ],
        effectTracing: [
          { required: true, message: "效果跟踪不能为空", trigger: "blur" }
        ],*/
        /*raiser: [
          { required: true, message: "提出人不能为空", trigger: "blur" }
        ],
        raiserDate: [
          { required: true, message: "提出时间不能为空", trigger: "blur" }
        ],
        locationUrl: [
          { required: true, message: "腐蚀位置不能为空", trigger: "blur" }
        ],
        measureCycle: [
          { required: true, message: "测厚周期不能为空", trigger: "blur" }
        ],
        otherContent: [
          { required: true, message: "其他检测方法内容不能为空", trigger: "blur" }
        ]*/
      }
    };
  },
  watch: {
        // 根据名称筛选部门树
        deptName(val) {
            this.$refs.tree.filter(val);
        }
   },
  created() {
      //设置表格高度对应屏幕高度
      this.$nextTick(() => {
          this.clientHeight = document.body.clientHeight -250
      })
    this.getList();
    this.getTreeselect();
    this.getDicts("spec_measure_status").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("spec_measure_method").then(response => {
      this.inspectionMethodOptions = response.data;
    });
    let plantParams = {
      pType: 1
    }
    mylistPlant(plantParams).then(response => {
      this.plantOptions = response.data;
    });
  },
  methods: {
    /** 查询定点测厚列表 */
    getList() {
      this.loading = true;
      listThickness(this.queryParams).then(response => {
        this.thicknessList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
     /** 查询部门下拉树结构 */
     getTreeselect() {
          treeselect().then(response => {
              this.deptOptions = response.data;
          });
     },
    // 状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    // 检测方法字典翻译
    inspectionMethodFormat(row, column) {
      return this.selectDictLabels(this.inspectionMethodOptions, row.inspectionMethod);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        plantCode: null,
        unitCode: null,
        tagno: null,
        status: 0,
        createdate: null,
        updaterCode: null,
        updatedate: null,
        deptId: null,
        remarks: null,
        position: null,
        recorder: null,
        recorderDate: null,
        equipmentName: null,
        material: null,
        corAllowance: null,
        originalThickness: null,
        medium: null,
        pressure: null,
        specification: null,
        flowRate: null,
        temperature: null,
        corrosionType: null,
        inspectionMethod: [],
        photo: null,
        analysis: null,
        nominalTickness: null,
        thicknessMin: null,
        stCorrosion: null,
        ltCorrosion: null,
        estRemain: null,
        methodCause: null,
        effectTracing: null,
        raiser: null,
        raiserDate: null,
        delFlag: null,
        locationUrl: null,
        analysisUrl: null,
        measureCycle: null,
        recordUrl: null,
        otherContent: null,
        measureNo: null,
        nextWarnDate: 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
    },
    handleLoop(val){
      let paramLoop = {
        plantCode: val,
      }
      getLoopByPlant(paramLoop).then(response => {
        this.loopOptions = response.data;
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = this.$t('添加') + this.$t('定点测厚');
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getThickness(id).then(response => {
        this.form = response.data;
        if (this.form.inspectionMethod) {
          this.form.inspectionMethod = this.form.inspectionMethod.split(",");
        }else {
          this.form.inspectionMethod = []
        }
        this.open = true;
        this.title = this.$t('修改') + this.$t('定点测厚');
        if (this.form.photo!= null){
          this.photoList =[]
          let fileList = this.form.photo.split(",")
          for (let i = 0; i < fileList.length; i++) {
            let item = {url: process.env.VUE_APP_BASE_API +fileList[i],response: {msg: fileList[i]} }
            this.photoList.push(item)
          }
        }
        if (this.form.locationUrl!= null){
          this.locationList =[]
          let fileList = this.form.locationUrl.split(",")
          for (let i = 0; i < fileList.length; i++) {
            let item = {url: process.env.VUE_APP_BASE_API +fileList[i],response: {msg: fileList[i]} }
            this.locationList.push(item)
          }
        }
      });
    },
    handleView (row){
      const id = row.id
      getThickness(id).then(response => {
        this.dataForm = response.data;
        if (this.dataForm.inspectionMethod) {
          this.dataForm.inspectionMethod = this.dataForm.inspectionMethod.split(",");
        }else {
          this.dataForm.inspectionMethod = []
        }
        this.visible = true;
        this.title = this.$t('查看') + this.$t('定点测厚');
        if (this.dataForm.photo!= null){
          this.photoList =[]
          let fileList = this.dataForm.photo.split(",")
          for (let i = 0; i < fileList.length; i++) {
            let item = {url: process.env.VUE_APP_BASE_API +fileList[i],response: {msg: fileList[i]} }
            this.photoList.push(item)
          }
        }
        if (this.dataForm.locationUrl!= null){
          this.locationList =[]
          let fileList = this.dataForm.locationUrl.split(",")
          for (let i = 0; i < fileList.length; i++) {
            let item = {url: process.env.VUE_APP_BASE_API +fileList[i],response: {msg: fileList[i]} }
            this.locationList.push(item)
          }
        }
        this.dataForm.recordUrl = process.env.VUE_APP_BASE_API + this.dataForm.recordUrl
      });
      this.recordParams.measureId = row.id
      listMeasurerecord(this.recordParams).then(response => {
        this.dataList = response.rows;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.inspectionMethod) {
            this.form.inspectionMethod = this.form.inspectionMethod.join(",");
          }else {
            this.form.inspectionMethod = ''
          }
          if (this.form.id != null) {
            updateThickness(this.form).then(response => {
              this.msgSuccess(this.$t('修改成功'));
              this.open = false;
              this.getList();
            });
          } else {
            addThickness(this.form).then(response => {
              this.msgSuccess(this.$t('新增成功'));
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    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 delThickness(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess(this.$t('删除成功'));
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm(this.$t('是否确认导出所有定点测厚数据项?'), this.$t('警告'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
          type: "warning"
        }).then(function() {
          return exportThickness(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    },
      /** 导入按钮操作 */
      handleImportData() {
        this.uploadThickness.title = this.$t('导入数据');
        this.uploadThickness.open = true;
      },
      /** 下载侧厚模板操作 */
      importTemplateData() {
        this.$refs['downloadFileDataForm'].submit()
      },
      /** 导入按钮操作 */
      handleImport() {
          this.upload.title = this.$t('导入更新数据');
          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.failRow.length > 0) {
          let failrow = ''
          for (let i = 0; i < response.data.failRow.length; i++) {
            failrow += response.data.failRow[i] + ','
          }
          this.$alert(this.$t('导入成功条数:') + response.msg + '<br>' + this.$t('失败行数:') + failrow, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
        } else {
          console.log(response.data.abnormalRow.length)
          if (response.data.abnormalRow.length > 0) {
            let abnormalRow = ''
            for (let i = 0; i < response.data.abnormalRow.length; i++) {
              abnormalRow += response.data.abnormalRow[i] + ','
            }
            this.$alert(this.$t('导入成功条数:') + response.msg + '<br>' + this.$t('数据异常行:') + abnormalRow, 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;
      },
    // 文件上传中处理
    handleFileUploadProgress2(event, file, fileList) {
      this.uploadThickness.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess2(response, file, fileList) {
      this.uploadThickness.open = false;
      this.uploadThickness.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();
    },
    // 提交上传文件
    submitFileForm2() {
      this.$refs.uploadThickness.submit();
      this.fullscreenLoading = true;
    },
      //下载报告
      downloadHandle (row) {
        this.downloadForm.id = row.id;
        this.$nextTick(() => {
          this.$refs['downloadForm'].submit()
        })
      },
    //查询测厚记录
    recordHandle (row) {
      this.recordVisible = true
      this.$nextTick(() => {
        this.$refs.record.init(row)
      })
    },
    closeChildDialog () {
      this.showFlag = false
      this.getList();
    },

    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件`);
    },
    handleRemove(file, fileList) {
      this.form.locationUrl = fileList.map((obj)=>{return obj.response.msg}).join(",");
      console.log(this.form.locationUrl)
    },
    handleAvatarSuccess(res, file, fileList) {
      console.log(fileList)
      this.locationList = fileList
      this.form.locationUrl = fileList.map((obj)=>{return obj.response.msg}).join(",");
      console.log(this.form.locationUrl)
    },
    handleRemove2(file, fileList) {
      this.form.photo = fileList.map((obj)=>{return obj.response.msg}).join(",");
    },
    handleAvatarSuccess2(res, file, fileList) {
      console.log(fileList)
      this.photoList = fileList
      this.form.photo = fileList.map((obj)=>{return obj.response.msg}).join(",");
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
      const isLt2M = file.size / 1024 / 1024 < 2

      if (!isJPG) {
        this.$message.error(this.$t('上传图片只能是 JPG/PNG 格式!'));
      }
      if (!isLt2M) {
        this.$message.error(this.$t('上传图片大小不能超过 2MB!'));
      }
      return isJPG && isLt2M;
    },
    //附件上传中处理
    handleFileDocProgress(event, file, fileList) {
      this.analysis.file = file;
    },
    //附件上传中处理
    handleFileDocProgressCheck(event, file, fileList) {
      this.check.file = file;
    },
    //附件上传成功处理
    handleFileDocSuccess(response, file, fileList) {
      this.form.analysisUrl = response.msg
      this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
    },
    //附件上传成功处理
    handleFileDocSuccessCheck(response, file, fileList) {
      this.form.checkUrl = response.msg
      this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
    },
    // 寿命颜色预警
    tableCellStyle({ row, column, rowIndex, columnIndex }) {
        if (row.estRemain) {
          if (row.estRemain < 1) {
            return {'background-color': 'rgba(255, 68,68, 0.5)'}
          }
          if (row.estRemain < 2) {
            return {'background-color': 'rgba(255, 255,153, 0.5)'}
          }

        }

    },
    handleSeeLoop(row) {
        let paramLoop = {
          plantCode: row.plantCode,
          loopNo: row.loopNo
      }
      queryUrl(paramLoop).then(response => {
        this.pdf.open = true
        this.pdf.title = response.data.loopNo
        this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + response.data.loopUrl
      });
    },
    openPdf() {
      window.open(this.pdf.pdfUrl);//path是文件的全路径地址
    },
    wordView(row) {
      wordView(row.id).then(response => {
        console.log(response.msg)
        this.handleSee("每周检查记录", response.msg)
      });
    },
    handleSee(fileName, url) {
      //office预览
      this.loadingFlash = true
      this.pdf.open = true
      this.pdf.title = fileName
      this.pdf.pdfUrl = ""
      this.pptView = false
      this.ppt = true
      //如果是PDF等直接可以打开的就不调接口，否则调用接口
      if (fileName.endsWith('pdf')) {
        this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + url
        this.loadingFlash = false
      } else {
        const formatDate = new FormData();
        formatDate.append("filepath", url)
        //调用文件预览api
        let res = this.officeConvert.bookConvertCommon(formatDate)
        //查看接受全局方法的返回结果 console.log(res)
        //利用.then方法接受Promise对象
        res.then((result) => {
          //关闭加载中
          this.loadingFlash = false
          if (result.msg.includes("csv")) {
            this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + result.data
            this.$alert(result.msg, this.$t('检查乱码'), {dangerouslyUseHTMLString: true});
            //    this.$message({message: result.msg, center: true,type:'warning',  offset:400, });
          } else if (result.msg.includes("不存在")) {
            //文件不存在时提示
            this.pdf.pdfUrl = ""
            this.$alert(result.msg, this.$t('预览失败'), {dangerouslyUseHTMLString: true});
            //    this.$message({message: result.msg, center: true,type:'warning',  offset:400, });
            this.pdf.open = false
          } else if (result.msg.includes("不支持此格式")) {
            this.pdf.pdfUrl = ""
            this.$alert(result.msg, this.$t('预览失败'), {dangerouslyUseHTMLString: true});
            //    this.$message({message: result.msg, center: true,type:'warning',  offset:400, });
            this.pdf.open = false
          } else {
            //成功时直接给地址
            this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + result.data
          }
        }).catch(result => {
          //请求失败，关闭loading，pdf地址直接为为空，不显示
          this.pdf.pdfUrl = ""
          this.loadingFlash = false;
        })
      }
    },
// 文件下载处理
    handleDownload(row) {
      var name = '附件';
      var url = row;
      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()
    },
    //备注
    remarksHeader(h, {column, $index}) {
      return [
        column.label,
        h(
          "el-tooltip",
          {
            props: {
              content: (function () {
                return '管道:弯头-W,直管-Z,大小头-Y,三通-S; 设备:管箱,筒体,封头,换热管,罐壁,罐顶,罐底\n' +
                  '\n'
              })(),
              placement: "top"
            }
          },
          [
            h("span", {
              class: {
                "el-icon-question": true,
                "report-headerTips": true
              }
            })
          ]
        )
      ]
    },
  }
};
</script>
<style>
.otherMethod {
  width: 40%;
}
</style>
