<template>
  <view class="container">
    <u-divider
      text="基本信息"
      text-position="left"
      text-color="rgb(42, 86, 247)"
      line-color="rgb(42, 86, 247)"
      dashed
    />
    <u-cell-group>
      <u-cell title="公司名称" :value="info.CORP_NAME" />
      <u-cell title="地址">
        <template #label>{{ info.CORP_ADDRESS }}</template>
      </u-cell>
      <u-cell title="姓名" :value="info.LR_NAME" />
      <u-cell title="联系电话" :value="info.LR_PHONE" />
      <u-cell title="编号" :value="info.INSPECTNO" />
      <u-cell title="场所" :value="info.INSPECT_PLACE" />
      <u-cell title="类型" :value="info.INSPECTTYPENAME" />
      <u-cell title="帮扶时间" :value="info.INSPECTTIME" />
      <u-cell
        title="是否邀请专家"
        :value="info.HASEXPERTS === '1' ? '是' : '否'"
      />
      <u-cell title="现场照片">
        <template #label>
          <div class="img-wrap">
            <div v-for="item in info.imgsList" :key="item.FILEPATH">
              <u--image
                :show-loading="true"
                :src="item.FILEPATH"
                width="80px"
                height="80px"
                @click="fnPreview(item.FILEPATH)"
              />
            </div>
          </div>
        </template>
      </u-cell>
    </u-cell-group>
    <u-divider
      text="帮扶内容"
      text-position="left"
      text-color="rgb(42, 86, 247)"
      line-color="rgb(42, 86, 247)"
      dashed
    />
    <uni-table border stripe empty-text="暂无更多数据" class="mt-10 mb-10">
      <uni-tr>
        <uni-th align="center" width="50">序号</uni-th>
        <uni-th align="center" width="80">内容来源</uni-th>
        <uni-th align="center">帮扶内容</uni-th>
        <uni-th align="center" width="70">操作</uni-th>
      </uni-tr>
      <uni-tr
        v-for="(item, index) in info.contentList"
        :key="item.SUPERVISE_INSPECT_CONTENT_ID"
      >
        <uni-td align="center">{{ index + 1 }}</uni-td>
        <uni-td>{{
          item.INSPECT_CONTENT_SOURCE === 2 ? "手动录入" : "帮扶标准"
        }}</uni-td>
        <uni-td>{{ item.INSPECT_CONTENT }}</uni-td>
        <uni-td v-if="item.INSPECT_STATE === '1'" >合格</uni-td>
        <uni-td v-else-if="item.INSPECT_STATE === '2'">不合格</uni-td>
        <uni-td v-else></uni-td>
      </uni-tr>
    </uni-table>
    <u-divider
      text="帮扶人员"
      text-position="left"
      text-color="rgb(42, 86, 247)"
      line-color="rgb(42, 86, 247)"
      dashed
    />
    <u-cell-group>
      <view v-for="(item, index) in info.userList" :key="index">
        <u-cell title="帮扶部门" :value="item.INSPECT_DEPARTMENT_NAME" />
        <u-cell title="帮扶人员" :value="item.INSPECT_USER_NAME" />
      </view>
    </u-cell-group>
    <u-divider
      text="帮扶隐患"
      text-position="left"
      text-color="rgb(42, 86, 247)"
      line-color="rgb(42, 86, 247)"
      dashed
    />
    <uni-table border stripe empty-text="暂无更多数据">
      <uni-tr>
        <uni-th align="center" width="50">序号</uni-th>
        <uni-th align="center">所属帮扶</uni-th>
        <uni-th align="center">隐患描述</uni-th>
        <uni-th align="center" width="50">操作</uni-th>
      </uni-tr>
      <uni-tr
        v-for="(item, index) in info.hiddenList"
        :key="item.SUPERVISE_INSPECT_HIDDEN_ID"
      >
        <uni-td align="center">{{ index + 1 }}</uni-td>
        <uni-td>{{ item.INSPECT_CONTENT }}</uni-td>
        <uni-td>{{ item.HIDDENDESCR }}</uni-td>
        <uni-td align="center">
          <u-icon
            name="eye-fill"
            size="20"
            @click="
              $u.route({
                url: '/pages/supervision_inspection/hidden_view',
                params: {
                  SUPERVISE_INSPECT_HIDDEN_ID: item.SUPERVISE_INSPECT_HIDDEN_ID,
                },
              })
            "
          />
        </uni-td>
      </uni-tr>
    </uni-table>
  </view>
</template>

<script>
import { getSupervisionInspectionRecordView } from "@/api";

export default {
  data() {
    return {
      info: {
        imgsList: [],
      },
    };
  },
  onLoad(query) {
    this.fnGetData(query.SUPERVISE_INSPECT_ID);
  },
  methods: {
    async fnGetData(SUPERVISE_INSPECT_ID) {
      const resData = await getSupervisionInspectionRecordView({
        SUPERVISE_INSPECT_ID,
      });
      for (let i = 0; i < resData.pd.imgsList.length; i++) {
        resData.pd.imgsList[i].FILEPATH =
          this.$filePath + resData.pd.imgsList[i].FILEPATH;
      }
      this.info = resData.pd;
      // this.info.INSPECTNO = "秦开应急" + resData.pd.INSPECTNO + "号";
    },
    fnPreview(current) {
      uni.previewImage({
        current,
        urls: this.info.imgsList.map((item) => item.FILEPATH),
      });
    },
  },
};
</script>

<style scoped lang="scss">
.container {
  padding: 20upx;
}
.u-icon {
  justify-content: center;
}
.img-wrap {
  display: flex;
  flex-wrap: wrap;
  > div {
    margin: 15upx;
  }
}
</style>
