<template>
  <view class="content">
    <view class="card">
      <view class="card">
        <view class="view-title">
          <u--text text="检测内容" bold></u--text>
        </view>
        <view class="mt-10">
          <uni-table border stripe emptyText="暂无更多数据">
            <uni-tr>
              <uni-th align="center">检测内容</uni-th>
              <uni-th align="center">状态</uni-th>
            </uni-tr>
            <uni-tr v-for="item in varList" :key="item.id">
              <uni-td>{{ item.checkContent }}</uni-td>
              <uni-td v-if='item.isNormal === "1"' align="center">
                <view style="color: blue;" @click="HiddenDetail(item.hiddenId)">不合格</view>
              </uni-td>
              <uni-td v-else-if='item.isNormal === "2"' align="center">
                <view style="color: blue;">已忽略</view>
              </uni-td>
              <uni-td v-else align="center">
                <template v-if="item.imgCount > 0 && isTongyong">
                  <view style="color: blue;">合格</view>
                </template>
                <template v-else>合格</template>
              </uni-td>
            </uni-tr>
          </uni-table>
        </view>
      </view>
      <view class="card">
        <view class="view-title">
          <u--text text="其他隐患信息" bold></u--text>
        </view>
        <view class="mt-10">
          <uni-table border stripe emptyText="暂无更多数据">
            <uni-tr>
              <uni-th align="center">隐患描述</uni-th>
              <uni-th align="center">操作</uni-th>
            </uni-tr>
            <uni-tr v-for="item in otherHiddenList" :key="item.hiddenId">
              <uni-td>{{ item.hiddendescr }}</uni-td>
              <uni-td align="center">
                <view style="color: blue" @click="HiddenDetail(item.hiddenId)">查看</view>
              </uni-td>
            </uni-tr>
          </uni-table>
        </view>
      </view>
      <view class="card">
        <view class="view-title">
          <u--text text="清单信息" bold></u--text>
        </view>
        <view class="mt-10">
          <u-cell-group>
            <u-cell>
              <view slot="title" class="title">清单名称</view>
              <view slot="value">{{ form.name }}</view>
            </u-cell>
            <u-cell>
              <view slot="title" class="title">排查清单类型</view>
              <view slot="value">{{ form.screenTypeName }}</view>
            </u-cell>
            <u-cell>
              <view slot="title" class="title">检查人</view>
              <view slot="value">{{ form.userNames }}</view>
            </u-cell>
            <u-cell>
              <view slot="title" class="title">检查时间</view>
              <view slot="value">{{ form.checkTime }}</view>
            </u-cell>
            <u-cell>
              <view slot="title" class="title">所属部门</view>
              <view slot="value">{{ form.departmentName }}</view>
            </u-cell>
            <u-cell>
              <view slot="title" class="title">所属岗位</view>
              <view slot="value">{{ form.postName }}</view>
            </u-cell>
            <u-cell>
              <view slot="title" class="title">排查周期</view>
              <view slot="value">{{ form.periodicityName }}</view>
            </u-cell>
            <u-cell>
              <view slot="title" class="title">清单类型</view>
              <view slot="value">{{ form.inspectionsTypeName }}</view>
            </u-cell>
          </u-cell-group>
        </view>
      </view>
      <view class="mt-10">
        <u-button
            type="primary"
            shape="circle"
            text="清单位置"
            @click="
            $u.route({
              url: '/pages/branch-self-report/index/map',
              params: { id },
            })
          "
        />
      </view>
    </view>
  </view>
</template>

<script>
import {
  getChecklistInspectionStatusRecordViewOtherHiddenDangerList,
  getInspectionReportListManageRecordsDetails
} from "@/api";

export default {
  data() {
    return {
      id: '',
      form: {},
      varList: [],
      otherHiddenList: [],
    }
  },
  onLoad(event) {
    this.id = event.id;
    this.getData()
  },
  methods: {
    async getData() {
      const { data: resData } = await getInspectionReportListManageRecordsDetails({
        id: this.id,
      });
      this.form = resData;
      this.varList = resData?.inspectionItemList;
      const { data } = await getChecklistInspectionStatusRecordViewOtherHiddenDangerList({
        checkrecordId: this.id,
      })
      this.otherHiddenList = data;
    },
    HiddenDetail(HIDDEN_ID) {
      uni.$u.route({
        url: '/pages/general-hidden-management/general-hidden/detail',
        params: {
          HIDDEN_ID,
        }
      })
    },
  }
}
</script>

<style scoped>
</style>
