<template>
  <view class="content">
    <view class="card">
      <web-view id="webview" v-if="mapUrl" :src="mapUrl"
                style="width: calc(100% - 40upx); height: 300px;margin-left: 20upx;margin-right: 20upx;" :scale="scale"
                :latitude="latitude" :longitude="longitude" :markers="covers"></web-view>
    </view>
    <view :style="{position: 'absolute',width: '100%',top: (statusBarHeight + 300) + 'px'}">
      <view class="card">
        <view class="view-title">
          <u--text text="检测内容" bold></u--text>
        </view>
        <uni-table border stripe emptyText="暂无更多数据" class="mt-10">
          <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.RISKPOINT_ID">
            <uni-td>{{ item.CHECK_CONTENT }}</uni-td>
            <uni-td v-if='item.ISNORMAL=="1"' align="center">
              <view style="color: blue;" @click="HiddenDetail(item.HIDDEN_ID)">不合格</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 class="card">
        <view class="view-title">
          <u--text text="其他隐患信息" bold></u--text>
        </view>
        <uni-table border stripe emptyText="暂无更多数据" class="mt-10">
          <uni-tr>
            <uni-th align="center">隐患描述</uni-th>
            <uni-th align="center" style="font-weight: bold;">操作</uni-th>
          </uni-tr>
          <uni-tr v-for="item in otherHiddenList" :key="item.HIDDEN_ID">
            <uni-td>{{ item.HIDDENDESCR }}</uni-td>
            <uni-td align="center" style="color: blue">
              <view @click="HiddenDetail(item.HIDDEN_ID)">查看</view>
            </uni-td>
          </uni-tr>
        </uni-table>
      </view>
      <view class="card">
        <view class="view-title">
          <u--text text="清单信息" bold></u--text>
        </view>
        <u-cell-group class="mt-10">
          <u-cell>
            <view slot="title" class="title">清单名称</view>
            <view slot="value">{{ form.LIST_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.USERS }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">检查时间</view>
            <view slot="value">{{ form.CHECK_TIME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">所属部门</view>
            <view slot="value">{{ form.DEPARTMENT_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">所属岗位</view>
            <view slot="value">{{ form.POST_NAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">排查周期</view>
            <view slot="value">{{ form.PERIODNAME }}</view>
          </u-cell>
          <u-cell>
            <view slot="title" class="title">清单类型</view>
            <view slot="value">{{ form.TYPENAME }}</view>
          </u-cell>
        </u-cell-group>
      </view>
    </view>
  </view>
</template>

<script>
import {getInspectionReportListManageRecordsDetails} from "../../../api";

let wv;//计划创建的webview

export default {
  data() {
    return {
      CHECKRECORD_ID: '',
      form: {},
      mapUrl: '',
      scale: 13,
      latitude: 39.935866846326036,
      longitude: 119.64918897343684,
      covers: [],
      varList: [],
      hdList: [],
      otherHiddenList: [],
      statusBarHeight: 0,
    }
  },
  onLoad(event) {
    this.CHECKRECORD_ID = event.CHECKRECORD_ID;
    this.getData()
  },
  methods: {
    async getData() {
      let resData = await getInspectionReportListManageRecordsDetails({
        CHECKRECORD_ID: this.CHECKRECORD_ID,
      });
      this.form = resData.pd;
      this.varList = resData.varList;
      this.hdList = resData.hdList;
      this.otherHiddenList = resData.otherHiddenList;
      for (let i = 0; i < resData.hdList.length; i++) {
        console.log(resData.hdList)
        this.covers.push({
          latitude: resData.hdList[i].LATITUDE,
          longitude: resData.hdList[i].LONGITUDE,
          iconPath: '../../../static/map/h.png',
        });
      }
      this.mapUrl = ("/hybrid/html/mapShow.html?covers=" + JSON.stringify(this.covers) + "&title=检查记录详情");
      this.statusBarHeight = uni.$u.sys().statusBarHeight
      this.$nextTick(() => {
        // #ifdef APP-PLUS
        var currentWebview = this.$scope.$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
        setTimeout(() => {
          wv = currentWebview.children()[0]
          wv.setStyle({
            position: 'unset',
            top: this.statusBarHeight + 44,
            height: 300,
            'margin-left': 10,
            'margin-right': 10
          })
        }, 1000); //如果是页面初始化调用时，需要延时一下
        // #endif
      })
    },
    HiddenDetail(HIDDEN_ID) {
      uni.$u.route({
        url: '/pages/general-hidden-management/general-hidden/detail',
        params: {
          HIDDEN_ID,
        }
      })
    },
  }
}
</script>

<style scoped>
</style>
