<template>
  <!-- 检查台账 -->
  <div class="fullHeight">
    <el-page-header
      v-if="searchForm.itemId"
      class="backText"
      @back="goBack"
      content="整改单"
    ></el-page-header>
    <div class="statictisBox" v-else>
      <p>
        <!-- 检查总数 -->
        <span class="label">{{
          $t("message.safeMangeCheck.checked") +
            $t("message.safeMangeCheck.total") +
            "："
        }}</span>
        <span class="value">{{ statictisData.totalNum }}</span>
      </p>
      <p>
        <!-- 已闭合数 -->
        <span class="label">{{
          $t("message.safeMangeCheck.alreadyClose") +
            $t("message.safeMangeCheck.num") +
            "："
        }}</span>
        <span class="value">{{ statictisData.closeNum }}</span>
      </p>
      <p>
        <!-- 待整改数 -->
        <span class="label">{{
          $t("message.safeMangeCheck.awaitChange") +
            $t("message.safeMangeCheck.num") +
            "："
        }}</span>
        <span class="value">{{ statictisData.rectificationNum }}</span>
      </p>
      <p>
        <!-- 待复查数 -->
        <span class="label">{{
          $t("message.safeMangeCheck.awaitExamine") +
            $t("message.safeMangeCheck.num") +
            "："
        }}</span>
        <span class="value">{{ statictisData.reviewNum }}</span>
      </p>
      <p>
        <!-- 超期未闭合数 -->
        <span class="label">{{
          $t("message.safeMangeCheck.deleyNotClose") +
            $t("message.safeMangeCheck.num") +
            "："
        }}</span>
        <span class="value">{{ statictisData.overdueNotCloseNum }}</span>
      </p>
      <p>
        <!-- 整改率 -->
        <span class="label">{{
          $t("message.safeMangeCheck.changeRate") + "："
        }}</span>
        <span class="value">{{ statictisData.completeRatio }}%</span>
      </p>
      <p>
        <!-- 闭合率 -->
        <span class="label">{{
          $t("message.safeMangeCheck.closeRate") + "："
        }}</span>
        <span class="value">{{ statictisData.closeRatio }}%</span>
      </p>
    </div>
    <div class="filterBox">
      <!-- 请选择检查结果 -->
      <el-select
        v-model="searchForm.status"
        :placeholder="
          $t('message.safeMangeCheck.pleaseChoose') +
            $t('message.safeMangeCheck.checked') +
            $t('message.safeMangeCheck.result')
        "
        size="medium"
      >
        <!-- 全部 -->
        <el-option :label="$t('message.safeMangeCheck.all')" value="">
        </el-option>
        <el-option
          v-for="(item, index) in statusArr"
          :key="item"
          :label="item"
          :value="index + 1"
        >
        </el-option>
      </el-select>
      <!-- 开始和结束时间 -->
      <el-date-picker
        size="medium"
        style="margin: 0 15px; width: 250px"
        v-model="daterange"
        type="daterange"
        range-separator="-"
        value-format="yyyy-MM-dd"
        :start-placeholder="$t('message.safeManage.safeRocordList.start')"
        :end-placeholder="$t('message.safeManage.safeRocordList.end')"
        @change="changeDate2"
      >
      </el-date-picker>
      <!-- 查询 新增 导出 刷新 -->
      <el-button type="primary" size="medium" @click="loadList(1)">{{
        $t("message.safeMangeCheck.query")
      }}</el-button>
      <el-button type="primary" size="medium" @click="addData">{{
        $t("message.safeMangeCheck.add")
      }}</el-button>
      <el-button type="primary" size="medium" @click="exportData">{{
        $t("message.safeMangeCheck.out")
      }}</el-button>
      <el-button type="warning" plain size="medium" @click="refreshFn">{{
        $t("message.safeMangeCheck.fresh")
      }}</el-button>
    </div>
    <div class="table_wrap whiteBlock">
      <el-table
        class="tables"
        :data="recordList"
        @row-click="showDetailFn"
        height="680px"
      >
        <!-- 检查结果 -->
        <el-table-column
          width="120"
          prop="id"
          :label="
            $t('message.safeMangeCheck.checked') +
              $t('message.safeMangeCheck.result')
          "
        >
          <!-- 超期 -->
          <template slot-scope="scope">
            <div class="tableBtns">
              <span class="mr10">{{
                scope.row.status ? statusArr[scope.row.status - 1] : ""
              }}</span>
              <el-tag
                type="danger"
                effect="dark"
                size="mini"
                v-if="
                  scope.row.overdueType &&
                    scope.row.status != 1 &&
                    !(scope.row.status == 4 && scope.row.overdueCloseType == 0)
                "
                >{{ $t("message.safeMangeCheck.delay") }}</el-tag
              >
            </div>
          </template>
        </el-table-column>
        <!-- 检查人 -->
        <el-table-column
          width="300"
          align="center"
          :label="
            $t('message.safeMangeCheck.checked') +
              $t('message.safeMangeCheck.people')
          "
        >
          <template slot-scope="scope">
            <p>{{ scope.row.createUserName }}</p>
            <!-- <p>{{ scope.row.createEnterpriseName }}</p> -->
            <p class="table_bottom_txt">{{ scope.row.inspectTime }}</p>
          </template>
        </el-table-column>
        <!-- 隐患信息 -->
        <el-table-column
          width="400"
          align="center"
          :label="
            $t('message.safeMangeCheck.hiddenDanger') +
              $t('message.safeMangeCheck.info')
          "
        >
          <!-- 该区域排查无隐患 -->
          <template slot-scope="scope">
            <p v-if="scope.row.status != 1">
              <el-tag
                class="mr10"
                :type="scope.row.faultLevel == 1 ? 'primary' : 'danger'"
                effect="dark"
                size="mini"
                >{{
                  scope.row.faultLevel == 1
                    ? $t("message.safeMangeCheck.common")
                    : $t("message.safeMangeCheck.great")
                }}</el-tag
              >{{ scope.row.checkContent }}
            </p>
            <p v-else>{{ $t("message.safeMangeCheck.areaHiddenDanger") }}</p>
            <p class="table_bottom_txt">
              <span
                ><i class="el-icon-picture"></i
                >{{ parseImage2(scope.row.imageUrl).length }}</span
              >
              <span
                ><i class="el-icon-location-information"></i
                >{{ scope.row.dutyRegion }}</span
              >
              <el-tag
                class="hiddenDangerLevel"
                type="info"
                effect="dark"
                size="mini"
                v-if="scope.row.status != 1"
                >{{ scope.row.hiddenDangerLevel }}</el-tag
              >
            </p>
          </template>
        </el-table-column>
        <!-- 整改单位 -->
        <el-table-column
          prop="enterpriseName"
          align="center"
          :label="$t('message.safeMangeCheck.changeCompany')"
        ></el-table-column>
        <!-- 整改人 -->
        <el-table-column
          width="200"
          prop="changeUserName"
          align="center"
          :label="$t('message.safeMangeCheck.changePeople')"
        ></el-table-column>
        <!-- 复查人 -->
        <el-table-column
          width="200"
          prop="reviewUserName"
          align="center"
          :label="$t('message.safeMangeCheck.examinePeople')"
        ></el-table-column>
        <!-- 检查类型 -->
        <el-table-column
          width="200"
          prop="inspectTypeName"
          align="center"
          :label="
            $t('message.safeMangeCheck.checked') +
              $t('message.safeMangeCheck.type')
          "
        ></el-table-column>
        <!-- 操作 -->
        <!-- <el-table-column
          width="80"
          prop="id"
          align="center"
          :label="$t('message.safeMangeCheck.operate')"
          v-if="COMPANY != 'nanchang'"
        >
          删除
          <template slot-scope="scope">
            <div class="tableBtns">
              <div @click="detailsPoint(scope.row)" class="operationText last">
                            <i
                            class="el-icon-tickets"
                            style="color: #8dacfa; font-size: 16px; margin-right: 2px"
                            ></i>
                            <span>详情</span>
                        </div>
              <div
                @click.stop="deleteTaskFn(scope.row)"
                class="operationText redText last"
              >
                <i
                  class="el-icon-delete"
                  style="font-size: 16px; margin-right: 2px"
                ></i>
                <span>{{ $t("message.safeMangeCheck.delete") }}</span>
              </div>
            </div>
          </template>
        </el-table-column> -->
      </el-table>
      <el-pagination
        class="pagerBox"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="searchForm.pageNo"
        :page-sizes="$store.state.PAGESIZRS"
        :page-size="searchForm.pageSize"
        layout="total, sizes, prev, pager, next"
        :total="Number(pageTotal)"
      ></el-pagination>
    </div>
    <!-- 新增任务弹窗 -->
    <!-- 查看详情 -->
    <el-dialog
      :modal-append-to-body="false"
      :title="
        $t('message.safeMangeCheck.dialog.look') +
          $t('message.safeMangeCheck.dialog.detail')
      "
      :visible.sync="dialogVisible"
      width="867px"
      :close-on-click-modal="false"
    >
      <div style="height: 600px">
        <vue-scroll>
          <div style="width: 800px">
            <!-- 隐患记录  超期整改 -->
            <el-divider content-position="left">{{
              $t("message.safeMangeCheck.hiddenDanger") +
                $t("message.safeMangeCheck.dialog.records")
            }}</el-divider>
            <el-tag
              type="danger"
              effect="dark"
              size="mini"
              v-if="
                detailData.overdueType &&
                  detailData.status != 1 &&
                  !(detailData.status == 4 && detailData.overdueCloseType == 0)
              "
              style="
                float: right;
                margin-top: -35px;
                z-index: 2;
                position: relative;
              "
              >{{
                $t("message.safeMangeCheck.delay") +
                  $t("message.safeMangeCheck.dialog.change")
              }}</el-tag
            >
            <!-- <div class="topDataBox">
            <p><span>检查结果：{{detailData.status?statusArr[detailData.status-1]:''}}</span><span>责任区域：222</span></p>
            <p><span>检查人：{{detailData.createUserName}}</span><span>检查时间：{{detailData.createTime}}</span></p>
            <el-tag type="danger" effect="dark" size="mini" v-if="detailData.overdueType">超期整改</el-tag>
    </div> -->
            <div class="detailBox">
              <el-row :gutter="20">
                <el-col :span="12">
                  <!-- 检查结果 -->
                  <div class="grid-content">
                    <span class="label">{{
                      $t("message.safeMangeCheck.checked") +
                        $t("message.safeMangeCheck.result") +
                        "："
                    }}</span>
                    <span class="value">{{
                      detailData.status ? statusArr[detailData.status - 1] : ""
                    }}</span>
                  </div>
                </el-col>
                <el-col :span="12">
                  <div class="grid-content">
                    <!-- 详细位置 -->
                    <span class="label">详细位置：</span>
                    <span class="value">{{ detailData.dutyRegion }}</span>
                  </div>
                </el-col>
              </el-row>
              <el-row :gutter="20">
                <el-col :span="12">
                  <div class="grid-content">
                    <span class="label">{{
                      $t("message.safeMangeCheck.checked") +
                        $t("message.safeMangeCheck.people") +
                        "："
                    }}</span>
                    <span class="value">{{ detailData.createUserName }}</span>
                  </div>
                </el-col>
                <el-col :span="12">
                  <div class="grid-content">
                    <span class="label">{{
                      $t("message.safeMangeCheck.checked") +
                        $t("message.safeMangeCheck.time") +
                        "："
                    }}</span>
                    <span class="value">{{ detailData.inspectTime }}</span>
                  </div>
                </el-col>
              </el-row>
              <div>
                <el-row v-if="detailData.status != 1" :gutter="20">
                  <el-col :span="12">
                    <!-- 隐患类别 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.hiddenDanger") +
                          $t("message.safeMangeCheck.level") +
                          "："
                      }}</span>
                      <span class="value"
                        >{{ detailData.checkItem }}/{{
                          detailData.checkSubitem
                        }}</span
                      >
                    </div>
                  </el-col>
                  <el-col :span="12">
                    <!-- 隐患明细 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.hiddenDanger") +
                          $t("message.safeMangeCheck.list") +
                          "："
                      }}</span>
                      <span class="value">{{ detailData.checkContent }}</span>
                    </div>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <!-- 隐患级别 -->
                  <el-col v-if="detailData.status != 1" :span="12">
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.hiddenDanger") +
                          $t("message.safeMangeCheck.level2") +
                          "："
                      }}</span>
                      <span class="value">{{
                        detailData.hiddenDangerLevel
                      }}</span>
                    </div>
                  </el-col>
                  <el-col :span="12">
                    <!-- 补充说明 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.dialog.allInstruction") +
                          "："
                      }}</span>
                      <span class="value">{{ detailData.dangerDesc }}</span>
                    </div>
                  </el-col>
                </el-row>
                <el-row v-if="detailData.status != 1" :gutter="20">
                  <el-col :span="12">
                    <!-- 整改单位 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.changeCompany") + "："
                      }}</span>
                      <span class="value">{{ detailData.enterpriseName }}</span>
                    </div>
                  </el-col>
                  <el-col :span="12">
                    <!-- 整改人 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.changePeople") + "："
                      }}</span>
                      <span class="value">{{ detailData.changeUserName }}</span>
                    </div>
                  </el-col>
                </el-row>
                <el-row v-if="detailData.status != 1" :gutter="20">
                  <el-col :span="12">
                    <!-- 整改时限 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.dialog.change") +
                          $t("message.safeMangeCheck.dialog.timeLimit") +
                          "："
                      }}</span>
                      <span class="value">{{
                        detailData.changeLimitTime
                      }}</span>
                    </div>
                  </el-col>
                  <el-col :span="12">
                    <!-- 事故隐患 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.dialog.event") +
                          $t("message.safeMangeCheck.hiddenDanger") +
                          "："
                      }}</span>
                      <span class="value">{{
                        detailData.faultLevel == 1
                          ? $t("message.safeMangeCheck.common")
                          : $t("message.safeMangeCheck.great")
                      }}</span>
                    </div>
                  </el-col>
                </el-row>
                <el-row v-if="detailData.status != 1" :gutter="20">
                  <el-col :span="12">
                    <!-- 整改要求 -->
                    <div class="grid-content">
                      <span class="label">{{
                        $t("message.safeMangeCheck.dialog.change") +
                          $t("message.safeMangeCheck.dialog.ask") +
                          "："
                      }}</span>
                      <span class="value">{{ detailData.rectifyRequire }}</span>
                    </div>
                  </el-col>
                  <el-col :span="12">
                    <!-- 事故隐患 -->
                    <div class="grid-content">
                      <span class="label">责任区域：</span>
                      <span class="value">{{
                        detailData.hiddenDangerInspectRegionName
                      }}</span>
                    </div>
                  </el-col>
                </el-row>
              </div>
              <el-row :gutter="20">
                <el-col :span="24">
                  <div class="grid-content">
                    <!-- 相关照片 -->
                    <span class="label">{{
                      $t("message.safeMangeCheck.dialog.about") +
                        $t("message.safeMangeCheck.dialog.photo") +
                        "："
                    }}</span>
                    <span class="value">
                      <el-image
                        v-for="(item, index) in parseImage2(
                          detailData.imageUrl
                        )"
                        :key="index"
                        style="width: 100px; height: 100px; margin-right: 10px"
                        :src="item"
                        :preview-src-list="parseImage2(detailData.imageUrl)"
                      >
                      </el-image>
                    </span>
                  </div>
                </el-col>
              </el-row>
            </div>
            <!-- 整改&复查记录 -->
            <el-divider
              content-position="left"
              v-if="rectifyRecordList.length > 0"
              >{{
                $t("message.safeMangeCheck.dialog.change") +
                  "&" +
                  $t("message.safeMangeCheck.dialog.examin") +
                  $t("message.safeMangeCheck.dialog.records")
              }}</el-divider
            >
            <el-timeline class="detailBox" :reverse="true">
              <el-timeline-item
                :timestamp="item.createTime"
                placement="top"
                v-for="(item, index) in rectifyRecordList"
                :key="index"
              >
                <el-card>
                  <!-- 整改人 复查人 -->
                  <p class="grid-content">
                    <span class="label"
                      >{{
                        item.type == 1
                          ? $t("message.safeMangeCheck.changePeople")
                          : $t("message.safeMangeCheck.examinePeople")
                      }}：</span
                    ><span class="value">{{ item.createUserName }}</span>
                  </p>
                  <!-- 整改状态 -->
                  <p class="grid-content" v-if="item.type == 1">
                    <span class="label">{{
                      $t("message.safeMangeCheck.dialog.change") +
                        $t("message.safeMangeCheck.status") +
                        "："
                    }}</span
                    ><span class="value">{{
                      item.status == 2
                        ? $t("message.safeMangeCheck.alreadyChange")
                        : $t("message.safeMangeCheck.unChange")
                    }}</span>
                  </p>
                  <!-- 复查状态 -->
                  <p class="grid-content" v-else>
                    <span class="label">{{
                      $t("message.safeMangeCheck.dialog.examin") +
                        $t("message.safeMangeCheck.status") +
                        "："
                    }}</span
                    ><span class="value">{{
                      item.status == 2
                        ? $t("message.safeMangeCheck.upToStandard")
                        : $t("message.safeMangeCheck.not") +
                          $t("message.safeMangeCheck.upToStandard")
                    }}</span>
                  </p>
                  <!-- 相关说明 -->
                  <p class="grid-content">
                    <span class="label">{{
                      $t("message.safeMangeCheck.dialog.about") +
                        $t("message.safeMangeCheck.dialog.explain") +
                        "："
                    }}</span
                    ><span class="value">{{ item.additionalRemarks }}</span>
                  </p>
                  <!-- 相关照片 -->
                  <div class="grid-content" v-if="item.type == 1">
                    <span class="label">{{
                      $t("message.safeMangeCheck.dialog.about") +
                        $t("message.safeMangeCheck.dialog.photo") +
                        "："
                    }}</span>
                    <span class="value">
                      <el-image
                        v-for="(url, index) in parseImage2(item.fileUrl)"
                        :key="index"
                        style="width: 50px; height: 50px; margin-right: 10px"
                        :src="url"
                        :preview-src-list="parseImage2(item.fileUrl)"
                      >
                      </el-image>
                    </span>
                  </div>
                </el-card>
              </el-timeline-item>
            </el-timeline>
            <!-- 整改回复 -->
            <el-divider
              content-position="left"
              v-if="
                detailData.changeUser == $store.state.userInfo.userId &&
                  detailData.status == 2
              "
              >{{
                $t("message.safeMangeCheck.dialog.change") +
                  $t("message.safeMangeCheck.dialog.anser") +
                  "："
              }}</el-divider
            >
            <!-- 复查回复 -->
            <el-divider
              content-position="left"
              v-if="
                detailData.reviewId == $store.state.userInfo.userId &&
                  detailData.status == 3
              "
              >{{
                $t("message.safeMangeCheck.dialog.examin") +
                  $t("message.safeMangeCheck.dialog.anser") +
                  "："
              }}</el-divider
            >
            <!-- 整改内容 -->
            <el-form
              :model="replyData"
              ref="formData"
              label-width="120px"
              v-if="detailData.status == 2 || detailData.status == 3"
            >
              <el-form-item
                :label="
                  $t('message.safeMangeCheck.dialog.change') +
                    $t('message.safeMangeCheck.dialog.content')
                "
                v-if="
                  detailData.changeUser == $store.state.userInfo.userId &&
                    detailData.status == 2
                "
                prop="inspectTypeId"
              >
                <!-- 请输入整改内容 -->
                <el-input
                  type="textarea"
                  :rows="3"
                  :placeholder="
                    $t('message.safeManage.placeholder') +
                      $t('message.safeMangeCheck.dialog.change') +
                      $t('message.safeMangeCheck.dialog.content')
                  "
                  v-model="replyData.additionalRemarks"
                >
                </el-input>
              </el-form-item>
              <!-- 复查情况 -->
              <el-form-item
                :label="
                  $t('message.safeMangeCheck.dialog.examin') +
                    $t('message.safeMangeCheck.dialog.condition')
                "
                v-if="
                  detailData.reviewId == $store.state.userInfo.userId &&
                    detailData.status == 3
                "
                prop="inspectTypeId"
              >
                <!-- 请输入整改内容 -->
                <el-input
                  type="textarea"
                  :rows="3"
                  :placeholder="
                    $t('message.safeManage.placeholder') +
                      $t('message.safeMangeCheck.dialog.change') +
                      $t('message.safeMangeCheck.dialog.content')
                  "
                  v-model="replyData.additionalRemarks"
                >
                </el-input>
              </el-form-item>
              <!-- 照片 -->
              <el-form-item
                :label="$t('message.safeMangeCheck.dialog.photo')"
                v-if="
                  detailData.changeUser == $store.state.userInfo.userId &&
                    detailData.status == 2
                "
              >
                <el-upload
                  :action="uploadUrl"
                  list-type="picture-card"
                  name="files"
                  :on-remove="
                    (file, fileList) => handleRemove(file, fileList, 1)
                  "
                  :on-success="handleSuccess2"
                  :on-preview="(file) => handlePreview(file)"
                  :limit="5"
                  :file-list="replyData.fileList"
                  ref="upload"
                >
                  <i class="el-icon-plus"></i>
                </el-upload>
              </el-form-item>
            </el-form>
          </div>
        </vue-scroll>
      </div>
      <div
        class="btn-box"
      >
        <el-button type="primary" @click="submitForm2">
          {{
            detailData.reviewId == $store.state.userInfo.userId &&
            detailData.status == 3
              ? $t("message.safeMangeCheck.dialog.pass")
              : $t("message.safeMangeCheck.dialog.confirm")
          }}</el-button
        >
        <el-button
          v-if="
            detailData.reviewId == $store.state.userInfo.userId &&
              detailData.status == 3
          "
          type="danger"
          @click="closeDialog2"
          >{{ $t("message.safeMangeCheck.dialog.back") }}</el-button
        >
        <el-button v-else @click="closeDialog2">{{
          $t("message.safeMangeCheck.dialog.cancel")
        }}</el-button>
      </div>
      <!-- <el-divider content-position="left">复查记录</el-divider> -->
    </el-dialog>
    <!-- 新增检查记录弹窗 -->
    <el-dialog
      :modal-append-to-body="false"
      :title="$t('message.safeMangeCheck.add')"
      :visible.sync="dialogVisible2"
      width="867px"
      @close="close"
      :close-on-click-modal="false"
    >
      <vue-scroll style="height: 640px">
        <div class="dialog-content">
          <el-form
            :model="formData"
            :rules="rules"
            ref="formData"
            label-width="120px"
          >
            <!-- 检查类型 -->
            <el-form-item
              :label="
                $t('message.safeMangeCheck.checked') +
                  $t('message.safeMangeCheck.type')
              "
              prop="inspectTypeId"
              required
            >
              <el-select
                v-model="formData.inspectTypeId"
                :placeholder="$t('message.safeMangeCheck.pleaseChoose')"
              >
                <el-option
                  v-for="item in inspectOptions"
                  :key="item.id"
                  :label="item.inspectTypeName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <!-- 是否需要整改 -->
            <el-form-item
              :label="$t('message.safeMangeCheck.dialog.yesOrNoNeedChange')"
              prop="status"
              required
            >
              <el-radio-group v-model="formData.status">
                <!-- 无需整改 -->
                <el-radio :label="2">是</el-radio>
                <!-- 待整改 -->
                <el-radio :label="1">无需整改</el-radio>
              </el-radio-group>
            </el-form-item>
            <!-- 隐患类型 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="
                $t('message.safeMangeCheck.hiddenDanger') +
                  $t('message.safeMangeCheck.type')
              "
              prop="checkItem"
              required
            >
              <el-select
                v-model="formData.checkItem"
                @change="checkOptions"
                :placeholder="$t('message.safeMangeCheck.pleaseChoose')"
              >
                <el-option
                  v-for="item in inspectOptions2"
                  :key="item.id"
                  :label="item.hiddenDangerName"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <!-- 检查项目 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="
                $t('message.safeMangeCheck.checked') +
                  $t('message.safeMangeCheck.project')
              "
              prop="checkSubitem"
              required
            >
              <!-- <el-select v-model="formData.checkSubitem" placeholder="请选择">
                        <el-option
                        v-for="item in inspectOptions3"
                        :key="item.id"
                        :label="item.hiddenDangerName"
                        :value="item.id">
                        </el-option>
                    </el-select> -->
              <el-cascader
                :options="inspectOptions3"
                v-model="formData.checkSubitem"
                style="width: 100%"
                :props="opts"
                @change="handleChange"
                ref="cascaderAddr"
              ></el-cascader>
              <!-- @expand-change="showSecondTree" -->
            </el-form-item>

            <!-- 检查时间 -->
            <el-form-item
              prop="inspectTime"
              :label="$t('message.safeMangeCheck.dialog.inspectTime')"
            >
              <el-date-picker
                v-model="formData.inspectTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                :placeholder="$t('message.safeMangeCheck.dialog.chooseDate')"
              >
              </el-date-picker>
            </el-form-item>

            <!--  责任区域  -->
            <el-form-item label="责任区域" prop="hiddenDangerInspectRegionId">
              <el-cascader
                v-model="formData.hiddenDangerInspectRegionId"
                style="width: 100%"
                clearable
                ref="formRegion1"
                :options="checkPointList"
                :props="checkPointProps"
                @change="changeRegion"
              ></el-cascader>
            </el-form-item>

            <!-- 隐患内容 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="
                $t('message.safeMangeCheck.hiddenDanger') +
                  $t('message.safeMangeCheck.dialog.content')
              "
            >
              <el-input
                type="textarea"
                :rows="2"
                :placeholder="
                  $t('message.safeManage.placeholder') +
                    $t('message.safeMangeCheck.dialog.content')
                "
                v-model="formData.checkContent"
              >
              </el-input>
            </el-form-item>
            <!-- 事故隐患等级 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="
                $t('message.safeMangeCheck.dialog.event') +
                  $t('message.safeMangeCheck.hiddenDanger') +
                  $t('message.safeMangeCheck.dialog.content')
              "
              prop="faultLevel"
              required
            >
              <el-select
                v-model="formData.faultLevel"
                :placeholder="$t('message.safeMangeCheck.pleaseChoose')"
              >
                <el-option
                  :label="$t('message.safeMangeCheck.common')"
                  :value="1"
                >
                </el-option>
                <el-option
                  :label="$t('message.safeMangeCheck.great')"
                  :value="2"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <!-- 整改要求 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="
                $t('message.safeMangeCheck.dialog.change') +
                  $t('message.safeMangeCheck.dialog.ask')
              "
            >
              <el-input
                type="textarea"
                :rows="2"
                :placeholder="
                  $t('message.safeManage.placeholder') +
                    $t('message.safeMangeCheck.dialog.content')
                "
                v-model="formData.rectifyRequire"
              >
              </el-input>
            </el-form-item>
            <!-- 详细位置 -->
            <el-form-item
              :label="
                $t('message.safeMangeCheck.dialog.detail2') +
                  $t('message.safeMangeCheck.dialog.location')
              "
            >
              <el-input
                :placeholder="
                  $t('message.safeManage.placeholder') +
                    $t('message.safeMangeCheck.dialog.content')
                "
                v-model="formData.dutyRegion"
              >
              </el-input>
            </el-form-item>
            <!-- 整改单位 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="$t('message.safeMangeCheck.changeCompany')"
              props="enterpriseSn"
              required
            >
              <el-select
                v-model="formData.enterpriseSn"
                :placeholder="$t('message.safeMangeCheck.pleaseChoose')"
                @change="enterpriseChange"
              >
                <el-option
                  v-for="(item, index) in subcontractList"
                  :key="index"
                  :label="item.enterpriseName"
                  :value="item.enterpriseSn"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <!-- 整改责任人 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="
                $t('message.safeMangeCheck.dialog.change') +
                  $t('message.safeMangeCheck.dialog.duty') +
                  $t('message.safeMangeCheck.people')
              "
              prop="changeUser"
              required
            >
              <el-select
                v-model="formData.changeUser"
                filterable
                :placeholder="$t('message.safeMangeCheck.pleaseChoose')"
              >
                <el-option
                  v-for="item in crewList"
                  :key="item.userId"
                  :label="item.workerName"
                  :value="item.userId"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <!-- 要求完成时间 -->
            <el-form-item
              v-if="formData.status == 2"
              :label="$t('message.safeMangeCheck.dialog.askFinshTime')"
            >
              <el-date-picker
                v-model="formData.changeLimitTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                :placeholder="$t('message.safeMangeCheck.dialog.chooseDate')"
              >
              </el-date-picker>
            </el-form-item>

            <!-- 补充说明 -->
            <el-form-item
              :label="$t('message.safeMangeCheck.dialog.allInstruction')"
            >
              <el-input
                type="textarea"
                :rows="2"
                :placeholder="
                  $t('message.safeManage.placeholder') +
                    $t('message.safeMangeCheck.dialog.content')
                "
                v-model="formData.dangerDesc"
              >
              </el-input>
            </el-form-item>
            <!-- 图片 -->
            <el-form-item :label="$t('message.safeMangeCheck.dialog.photo')">
              <el-upload
                :action="uploadUrl"
                list-type="picture-card"
                name="files"
                :on-remove="(file, fileList) => handleRemove(file, fileList)"
                :on-success="handleSuccess"
                :on-preview="(file) => handlePreview(file)"
                :limit="5"
                :file-list="fileList1"
                ref="upload"
              >
                <i class="el-icon-plus"></i>
              </el-upload>
            </el-form-item>
          </el-form>
        </div>
      </vue-scroll>
      <div class="btn-box">
        <!-- 确认 取消 -->
        <el-button type="primary" @click="submitForm">{{
          $t("message.safeMangeCheck.dialog.confirm")
        }}</el-button>
        <el-button @click="closeDialog">{{
          $t("message.safeMangeCheck.dialog.cancel")
        }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
//  function getNowWithLine() {
//          var date = new Date();
//          var seperator1 = "-";
//          var seperator2 = ":";
//          var month = date.getMonth() + 1;
//          var strDate = date.getDate();
//          if (month >= 1 && month <= 9) {
//                  month = "0" + month;
//              }
//          if (strDate >= 0 && strDate <= 9) {
//                  strDate = "0" + strDate;
//              }
//          var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
//      return currentdate;
//      }
//      let currentdate = getNowWithLine()
import {
  gethiddenDangerInspectRecordApi,
  getselectHiddenDangerRectifyRecordListApi,
  deletehiddenDangerInspectRecordApi,
  getProjectInspectRecordCountApi,
  getInspectTypeListApi,
  getinspectHiddenDangerLibraryListApi,
  getinspectHiddenDangerItemRecordListApi,
  addHiddenDangerInspectRecordApi,
  addHiddenDangerRectifyRecordApi,
  getSafeRegionListApi,
} from "@/assets/js/api/safeManage.js";
import { getSubcontractListApi } from "@/assets/js/api/quality.js";
import { getProjectChilderSystemUserListApi } from "@/assets/js/api/configManage.js";
export default {
  data() {
    let that = this;
    return {
      hiddenDangerInspectRegionName: "",
      checkPointList: [],
      checkPointProps: {
        value: "id",
        label: "regionName",
        children: "children",
        checkStrictly: true,
      },
      replyData: {
        additionalRemarks: "",
        fileList: [],
      },
      fileList1: [],
      COMPANY: "",
      inspectOptions: [],
      inspectOptions2: [],
      inspectOptions3: [],
      uploadUrl: "",
      formData: {
        hiddenDangerInspectRegionId: "",
        inspectTypeId: "",
        status: 2,
        checkSubitem: "",
        checkSubitem2: "",
        hiddenDangerLevel: "",
        checkContent: "",
        faultLevel: "",
        rectifyRequire: "",
        rectifyRequire2: "",
        dutyRegion: "",
        checkItem: "",
        checkItem2: "",
        changeUser: "",
        enterpriseSn: "",
        changeLimitTime: "",
        inspectTime: "",
      },
      opts: {
        value: "id",
        label: "hiddenDangerName",
        // children: 'children',
        checkStrictly: true,
        lazy: true,
        lazyLoad(node, resolve) {
          console.log(node, that);
          if (node.level == 0) {
            resolve(that.inspectOptions3);
          }
          if (node.level == 1) {
            getinspectHiddenDangerItemRecordListApi({
              libraryId: node.data.id,
            }).then((res) => {
              console.log(res);
              if (res.code == 200) {
                let arr = [];
                res.result.forEach((item) => {
                  arr.push({
                    id: item.id,
                    hiddenDangerName:
                      item.rectifyRequire.split("").length > 50
                        ? item.rectifyRequire.substring(0, 50) + "..."
                        : item.rectifyRequire,
                    checkSubitem: item.hiddenDangerName,
                    checkContent: item.checkContent,
                    val: item.rectifyRequire,
                    hiddenDangerLevel: item.hiddenDangerLevel,
                    leaf: node.level >= 2,
                  });
                });
                resolve(arr);
              }
            });
          } else if (node.level == 2) {
            resolve([]);
          }
        },
      },
      dialogVisible2: false,
      searchForm: {
        status: "",
        inspectStartTime: "",
        inspectEndTime: "",
        pageNo: 1,
        pageSize: 10,
        projectSn: this.$store.state.projectSn,
        itemId: "",
      },
      daterange: [],
      // checkType:[],
      recordList: [],
      pageTotal: 0,
      statusArr: [
        this.$t("message.safeMangeCheck.notChange"),
        this.$t("message.safeMangeCheck.awaitChange"),
        this.$t("message.safeMangeCheck.awaitExamine"),
        this.$t("message.safeMangeCheck.upToStandard"),
        this.$t("message.safeMangeCheck.not") +
          this.$t("message.safeMangeCheck.upToStandard"),
      ],
      dialogVisible: false,
      detailData: {},
      rectifyRecordList: [],
      statictisData: {
        closeNum: 0,
        closeRatio: 0,
        completeRatio: 0,
        inspectNum: 0,
        investigateNum: 0,
        notCloseNum: 0,
        overdueNotCloseNum: 0,
        overdueRectificationNum: 0,
        rectificationNum: 0,
        rectifyCompleteNum: 0,
        reviewNum: 0,
        totalNum: 0,
      },
      projectSn: "",
      userInfo: "",
      fileUrl: "",
      crewList: "", //整改负责人
      subcontractList: "", //整改单位
      rules: {
        hiddenDangerInspectRegionId: [
          {
            // 请选择责任区域
            required: true,
            message: "请选择责任区域",
            trigger: "change",
          },
        ],
        inspectTime: [
          {
            // 请选择检查时间
            required: true,
            message: "请选择检查时间",
            trigger: "change",
          },
        ],
        inspectTypeId: [
          {
            // 请选择检查类型
            required: true,
            message:
              this.$t("message.safeMangeCheck.pleaseChoose") +
              this.$t("message.safeMangeCheck.checked") +
              this.$t("message.safeMangeCheck.type"),
            trigger: "change",
          },
        ],
        checkItem: [
          {
            // 请选择隐患类型
            required: true,
            message:
              this.$t("message.safeMangeCheck.pleaseChoose") +
              this.$t("message.safeMangeCheck.hiddenDanger") +
              this.$t("message.safeMangeCheck.type"),
            trigger: "change",
          },
        ],
        checkSubitem: [
          {
            // 请选择检查项目
            required: true,
            message:
              this.$t("message.safeMangeCheck.pleaseChoose") +
              this.$t("message.safeMangeCheck.checked") +
              this.$t("message.safeMangeCheck.project"),
            trigger: "change",
          },
        ],
        faultLevel: [
          {
            // 请选择事故隐患等级
            required: true,
            message:
              this.$t("message.safeMangeCheck.pleaseChoose") +
              this.$t("message.safeMangeCheck.dialog.event") +
              this.$t("message.safeMangeCheck.hiddenDanger") +
              this.$t("message.safeMangeCheck.level3"),
            trigger: "change",
          },
        ],
        enterpriseSn: [
          {
            // 请选择整改单位
            required: true,
            message:
              this.$t("message.safeMangeCheck.pleaseChoose"),
            trigger: "change",
          },
        ],
        changeUser: [
          {
            // 请选择整改责任人
            required: true,
            message:
              this.$t("message.safeMangeCheck.pleaseChoose") +
              this.$t("message.safeMangeCheck.dialog.change") +
              this.$t("message.safeMangeCheck.dialog.duty") +
              this.$t("message.safeMangeCheck.people"),
            trigger: "change",
          },
        ],
      },
      checkProjectIdList: [],
      enterpriseId: ""
    };
  },
  created() {
    // console.log(this.statusArr)
    this.COMPANY = COMPANY;
    this.projectSn = this.$store.state.projectSn;
    this.userInfo = this.$store.state.userInfo;
    this.uploadUrl = this.$store.state.UPLOADURL;
    this.fileUrl = this.$store.state.FILEURL;
    this.getInspectTypeList();
    this.getinspectHiddenDangerLibraryList();
    this.getEnterprise();
    this.getPositionList();
  },
  mounted() {
    if (this.$route.query.id) {
      this.searchForm.itemId = this.$route.query.id;
    } else {
      this.getStatictisData();
    }
    this.loadList();
  },
  watch: {
    $route(to, from) {
      // console.log('watch')
      // console.log(from.path); //从哪来
      if (this.$route.query.id) {
        this.searchForm.itemId = this.$route.query.id;
      } else {
        this.searchForm.itemId = "";
        this.getStatictisData();
      }
      this.loadList();
    },
  },
  methods: {
    // 整改单位切换
    enterpriseChange(){
      this.formData.enterpriseSn
      if(this.formData.enterpriseSn){
        let findItem = this.subcontractList.find(item => {
          return item.enterpriseSn == this.formData.enterpriseSn
        })
        console.log(findItem)
        this.enterpriseId = findItem.id
        this.getPeopleList();
      }
    },
    //获取新增弹窗--  检查部位下拉
    getPositionList() {
      let data = {
        projectSn: this.projectSn,
      };
      getSafeRegionListApi(data).then((res) => {
        console.log("责任区域级联选择器", res);
        if (res.code == 200) {
          this.checkPointList = res.result;
        }
      });
    },
    //导出
    exportData() {
      window.location.href =
        this.$http.defaults.baseURL +
        "xmgl/download/exporExcelHiddenDangerInspectRecord?projectSn=" +
        this.$store.state.projectSn +
        "&status=" +
        this.searchForm.status +
        "&inspectStartTime=" +
        this.searchForm.inspectStartTime +
        "&inspectEndTime=" +
        this.searchForm.inspectEndTime +
        "&pageNo=" +
        this.searchForm.pageNo +
        "&pageSize=" +
        this.searchForm.pageSize +
        "&itemId=" +
        this.searchForm.itemId;
    },
    //提交
    submitForm() {
      this.$refs["formData"].validate((valid) => {
        // console.log(this.formData.status);
        if (!valid) {
          return;
        } else {
          this.addHiddenDangerInspectRecord();
        }
      });
      // this.dialogVisible2 = false
    },
    submitForm2() {
      let data = {};
      if (
        this.detailData.changeUser == this.$store.state.userInfo.userId &&
        this.detailData.status == 2
      ) {
        let arr = [];
        this.replyData.fileList.forEach((item) => {
          arr.push(item.name);
        });
        data = {
          additionalRemarks: this.replyData.additionalRemarks,
          fileUrl: arr.join(","),
          createUser: this.$store.state.userInfo.userId,
          inspectId: this.detailData.id,
          type: 1,
          status: 2,
        };
        addHiddenDangerRectifyRecordApi(data).then((res) => {
          if (res.code == 200) {
            // 回复成功
            this.$message.success(
              this.$t("message.safeMangeCheck.dialog.answerSuccess") + "！"
            );
            this.getRectifyRecordList(this.detailData.id);
            this.loadList();
          }
        });
      } else if (
        this.detailData.reviewId == this.$store.state.userInfo.userId &&
        this.detailData.status == 3
      ) {
        data = {
          additionalRemarks: this.replyData.additionalRemarks,
          createUser: this.$store.state.userInfo.userId,
          inspectId: this.detailData.id,
          type: 2,
          status: 2,
        };
        addHiddenDangerRectifyRecordApi(data).then((res) => {
          if (res.code == 200) {
            this.$message.success(
              this.$t("message.safeMangeCheck.dialog.answerSuccess") + "！"
            );
            this.getRectifyRecordList(this.detailData.id);
            this.loadList();
          }
        });
      }
      console.log(data);
      this.dialogVisible = false;
    },
    addHiddenDangerInspectRecord() {
      console.log(this.fileList1);
      let imgList = [];
      this.fileList1.forEach((item) => {
        imgList.push(item.name);
      });
      let data = {
        inspectTime: this.formData.inspectTime,
        changeLimitTime: this.formData.changeLimitTime,
        changeUser: this.formData.changeUser,
        checkContent: this.formData.checkContent,
        checkItem: this.formData.checkItem2,
        checkSubitem: this.formData.checkSubitem2,
        createUser: this.$store.state.userInfo.userId,
        dangerDesc: this.formData.dangerDesc,
        dutyRegion: this.formData.dutyRegion,
        enterpriseSn: this.formData.enterpriseSn,
        faultLevel: this.formData.faultLevel,
        hiddenDangerLevel: this.formData.hiddenDangerLevel,
        imageUrl: imgList.join(","),
        inspectTypeId: this.formData.inspectTypeId,
        projectSn: this.projectSn,
        recordType: this.formData.status == 1 ? 2 : 1,
        rectifyRequire: this.formData.rectifyRequire,
        reviewId: this.$store.state.userInfo.userId,
        status: this.formData.status,
        hiddenDangerInspectRegionId: this.formData
          .hiddenDangerInspectRegionId[0],
        hiddenDangerInspectRegionName: this.hiddenDangerInspectRegionName,
      };
      if(this.checkProjectIdList && this.checkProjectIdList.length > 0){
        data.inspectHiddenDangerItemRecordId = this.checkProjectIdList[this.checkProjectIdList.length - 1]
      }
      console.log(data);
      addHiddenDangerInspectRecordApi(data).then((res) => {
        if (res.code == 200) {
          console.log(res);
          this.dialogVisible2 = false;
          this.loadList();
        }
      });
    },
    closeDialog() {
      this.dialogVisible2 = false;
    },
    closeDialog2() {
      if (
        this.detailData.reviewId == this.$store.state.userInfo.userId &&
        this.detailData.status == 3
      ) {
        let data = {
          additionalRemarks: this.replyData.additionalRemarks,
          createUser: this.$store.state.userInfo.userId,
          inspectId: this.detailData.id,
          type: 2,
          status: 1,
        };
        addHiddenDangerRectifyRecordApi(data).then((res) => {
          if (res.code == 200) {
            this.$message.success(
              this.$t("message.safeMangeCheck.dialog.answerSuccess") + "！"
            );
            this.getRectifyRecordList(this.detailData.id);
            this.loadList();
          }
        });
      }
      this.dialogVisible = false;
    },
    close() {
      this.formData = {
        inspectTypeId: "",
        status: 2,
        checkSubitem: "",
        checkContent: "",
        faultLevel: "",
        rectifyRequire: "",
        dutyRegion: "",
        changeUser: "",
        enterpriseSn: "",
        changeLimitTime: new Date(),
      };
      this.fileList1 = [];
    },
    //整改单位
    getEnterprise() {
      let data = {
        enterpriseTypeId: this.subcontractType,
        pageNo: 1,
        pageSize: 999,
        projectSn: this.projectSn,
      };
      getSubcontractListApi(data).then((res) => {
        if (res.code == 200) {
          this.subcontractList = res.result.records;
          console.log(res.result.records);
        }
      });
    },
    //获取去整改人 通知人 检查人 核查人下拉
    getPeopleList() {
      let data = {
        projectSn: this.projectSn,
        enterpriseId: this.enterpriseId
      };
      getProjectChilderSystemUserListApi(data).then((res) => {
        if (res.code == 200) {
          this.crewList = res.result;
        }
      });
    },
    showSecondTree(val) {
      console.log(val);
      getinspectHiddenDangerItemRecordListApi({ libraryId: val[0] }).then(
        (res) => {
          console.log(res);
          if (res.code == 200) {
            let arr = [];
            res.result.forEach((item) => {
              arr.push({
                id: item.id,
                hiddenDangerName: item.rectifyRequire.substring(0, 20),
              });
            });
            // console.log(this.inspectOptions3)
            let arr3 = [...this.inspectOptions3];
            arr3.forEach((item) => {
              if (item.id == val[0]) {
                if (item.children.length == 0) {
                  item.children = arr;
                }
              }
            });
            this.inspectOptions3 = arr3;
            // this.$forceUpdate()
            console.log(this.inspectOptions3);
          }
        }
      );
    },
    handleChange(val) {
      console.log(val);
      if(val) {
        this.checkProjectIdList = val;
      } else {
        this.checkProjectIdList = [];
      }
      console.log(this.$refs["cascaderAddr"].getCheckedNodes()[0]);
      if (this.$refs["cascaderAddr"].getCheckedNodes()[0].data.checkContent) {
        this.formData.checkContent = this.$refs[
          "cascaderAddr"
        ].getCheckedNodes()[0].data.checkContent;
      }
      if (this.$refs["cascaderAddr"].getCheckedNodes()[0].data.val) {
        this.formData.rectifyRequire = this.$refs[
          "cascaderAddr"
        ].getCheckedNodes()[0].data.val;
      }
      if (this.$refs["cascaderAddr"].getCheckedNodes()[0].data.checkSubitem) {
        this.formData.checkSubitem2 = this.$refs[
          "cascaderAddr"
        ].getCheckedNodes()[0].data.checkSubitem;
      }
      if (
        this.$refs["cascaderAddr"].getCheckedNodes()[0].data.hiddenDangerLevel
      ) {
        this.formData.hiddenDangerLevel = this.$refs[
          "cascaderAddr"
        ].getCheckedNodes()[0].data.hiddenDangerLevel;
      }
      // getinspectHiddenDangerItemRecordListApi({libraryId: val[0]}).then(res=>{
      //     console.log(res)
      //     if(res.code == 200){
      //         let arr = []
      //         res.result.forEach(item=>{
      //             arr.push({
      //                 id: item.id,
      //                 hiddenDangerName: item.rectifyRequire.substring(0,20),
      //             })
      //         })
      //         this.inspectOptions3.map(item=>{
      //             if(item.id == val[0]){
      //                 item.children = arr
      //             }
      //         })
      //         console.log(this.inspectOptions3)
      //         // this.$forceUpdate()
      //     }
      // })
    },
    checkOptions(val) {
      console.log(val);
      this.inspectOptions2.forEach((item) => {
        if (item.id == val) {
          this.formData.checkItem2 = item.hiddenDangerName;
          // console.log(item.hiddenDangerName);
          item.children.forEach((item) => {
            item.children = [];
          });
          this.inspectOptions3 = item.children;
        }
      });
    },
    getinspectHiddenDangerLibraryList() {
      getinspectHiddenDangerLibraryListApi({
        sn: this.userInfo.headquartersSn,
      }).then((res) => {
        console.log(res.result);
        this.inspectOptions2 = res.result;
      });
    },
    getInspectTypeList() {
      getInspectTypeListApi({ sn: this.userInfo.headquartersSn }).then(
        (res) => {
          this.inspectOptions = res.result;
        }
      );
    },
    handleRemove(file, fileList, type) {
      if (type == 1) {
        this.replyData.fileList = fileList;
      } else {
        this.fileList1 = fileList;
      }
    },
    handleSuccess(file) {
      console.log(file);
      let data = {
        name: file.data[0].filename,
        url: this.fileUrl + file.data[0].imageUrl,
      };
      this.fileList1.push(data);
    },
    handleSuccess2(file) {
      console.log(file);
      let data = {
        name: file.data[0].filename,
        url: this.fileUrl + file.data[0].imageUrl,
      };
      this.replyData.fileList.push(data);
    },
    //查看图片
    handlePreview(file) {
      this.dialogImageUrl = file.url;
      window.open(file.url);
      var filename = file.name;
      var index1 = filename.lastIndexOf(".");
      var index2 = filename.length;
      var type = filename.substring(index1, index2);
      console.log(type);
      // if (type == '.mp4' || type == '.mp3'){
      //
      // }else {
      //     this.dialogVisible = true;
      // }
    },
    // 添加检查记录
    addData() {
      this.dialogVisible2 = true;
      this.$nextTick(() => {
        this.$refs.formData.clearValidate();
      })
    },
    //获取检查统计
    getStatictisData() {
      getProjectInspectRecordCountApi({
        projectSn: this.searchForm.projectSn,
      }).then((res) => {
        this.statictisData = res.result;
      });
    },
    refreshFn() {
      this.searchForm.status = "";
      this.daterange = [];
      this.searchForm.inspectStartTime = "";
      this.searchForm.inspectEndTime = "";
      this.searchForm.pageNo = 1;
      this.searchForm.pageSize = 10;
      this.loadList();
      if (this.$route.query.id) {
        this.searchForm.itemId = this.$route.query.id;
      } else {
        this.getStatictisData();
      }
    },
    //获取整改和复查记录
    getRectifyRecordList(inspectId) {
      getselectHiddenDangerRectifyRecordListApi({ inspectId: inspectId }).then(
        (res) => {
          console.log(res.result);
          this.rectifyRecordList = res.result;
        }
      );
    },
    //显示检查详细弹框
    showDetailFn(row) {
      console.log(row);
      this.getRectifyRecordList(row.id);
      this.replyData = {
        additionalRemarks: "",
        fileList: [],
      };
      this.detailData = row;
      this.dialogVisible = true;
    },
    changeDate2() {
      if (this.daterange) {
        this.searchForm.inspectStartTime = this.daterange[0];
        this.searchForm.inspectEndTime = this.daterange[1];
      } else {
        this.searchForm.inspectStartTime = "";
        this.searchForm.inspectEndTime = "";
      }
    },
    detailsPoint(item) {},
    loadList(val) {
      if (val && val == 1) {
        this.searchForm.pageNo = 1;
      }
      gethiddenDangerInspectRecordApi(this.searchForm).then((result) => {
        console.log("表格数据", result);
        this.recordList = result.result.records;
        this.pageTotal = result.result.total;
      });
    },
    goBack() {
      this.$router.back();
    },
    handleSizeChange(val) {
      this.searchForm.pageSize = val;
      this.loadList();
    },
    handleCurrentChange(val) {
      this.searchForm.pageNo = val;
      this.loadList();
    },
    parseImage2(urls) {
      let arr = [];
      if (urls) {
        arr = urls.split(",");
      }
      arr.forEach((element, index) => {
        arr[index] = this.$store.state.FILEURL + element;
      });
      return arr;
    },
    deleteTaskFn(item) {
      this.$confirm(
        this.$t("message.safeMangeCheck.dialog.confirmDeleteRecords"),
        this.$t("message.safeMangeCheck.dialog.tip"),
        {
          confirmButtonText: this.$t("message.safeMangeCheck.dialog.confirm"),
          cancelButtonText: this.$t("message.safeMangeCheck.dialog.cancel"),
          type: "warning",
        }
      )
        .then(() => {
          let data = {
            id: item.id,
          };
          deletehiddenDangerInspectRecordApi(data).then((res) => {
            if (res.code == 200) {
              this.loadList();
              this.$message({
                type: "success",
                message:
                  this.$t("message.safeMangeCheck.dialog.deleteSuccess") + "!",
              });
              this.getStatictisData();
            } else {
              this.$message.error(res.message);
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message:
              this.$t("message.safeMangeCheck.dialog.cancelDeleteSuccess") +
              "!",
          });
        });
    },
    changeRegion(val) {
      // console.log(val)
      // console.log(this.checkPointList)
      let currentNode = this.$refs["formRegion1"].getCheckedNodes()[0].data;
      console.log(this.$refs["formRegion1"].getCheckedNodes()[0].data);
      this.formData.changeUser = currentNode.dutyId;
      this.hiddenDangerInspectRegionName = currentNode.regionName;
    },
  },
};
</script>
<style lang="less" scoped>
.statictisBox {
  font-size: 15px;
  margin: 15px;
  p {
    display: inline-block;
    margin-right: 50px;
  }
  .value {
    color: #88e7f0;
  }
}
.filterBox {
  margin: 15px;
}
.table_bottom_txt {
  font-size: 12px;
  opacity: 0.8;
  // margin-top: 12px;
}
.el-icon-picture {
  margin-right: 7px;
}
.el-icon-location-information {
  margin: 0 7px 0 18px;
}
.mr10 {
  margin-right: 10px;
}
.backText {
  font-size: 16px;
}
.jyjzPage .backText {
  margin: -10px 0 14px 0;
  padding: 15px 15px 0;
  /deep/.el-page-header__content {
    color: white;
    font-size: 16px;
  }
  /deep/.el-page-header__title {
    font-size: 16px;
  }
  /deep/.el-page-header__left::after {
    background-color: #7cd3de;
  }
}
.topDataBox {
}
.detailBox {
  .grid-content {
    overflow: hidden;
    margin-bottom: 10px;
    .label {
      float: left;
      width: 80px;
      text-align: right;
    }
    .value {
      float: left;
      width: calc(100% - 80px);
    }
  }
}
.hiddenDangerLevel {
  margin-left: 7px;
}
.dialog-content {
  padding: 0 80px;
  /deep/.el-select {
    width: 100%;
  }
  /deep/.el-date-editor {
    width: 100%;
  }
}
.btn-box {
  height: 50px;
  margin-top: 30px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
/deep/.el-cascader-menu {
  width: 300px;
  box-sizing: border-box;
}
</style>
