<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-tr>
      <uni-tr
        v-for="(item, index) in info.contentList"
        :key="item.SPECIAL_RECTIFICATION_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-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.deptList" :key="index">
        <template v-if="item.userList.length > 0">
          <!--        <u-cell-->
          <!--          class="cell_tit"-->
          <!--          title=""-->
          <!--          :value="item.DEPARTMENT_TYPE === '1' ? '牵头单位' : '协调联动单位'"-->
          <!--        />-->
          <u-cell title="责任单位" :value="item.DEPARTMENT_NAME" />
          <!--          <u-cell title="联系人" :value="item.CONTACT_NAME" />-->
          <u-cell title="检查人员">
            <template #label>
              <u-row>
                <view
                  v-for="(user, i) in item.userList"
                  :key="user.SPECIAL_RECTIFICATION_ACTIVITY_TASK_USER_ID"
                >
                  {{ i > 0 ? "," + user.USER_NAME : user.USER_NAME }}
                </view>
              </u-row>
            </template>
          </u-cell>
        </template>
      </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.SPECIAL_RECTIFICATION_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/special_rectification/hidden_view',
                params: {
                  SPECIAL_RECTIFICATION_INSPECT_HIDDEN_ID:
                    item.SPECIAL_RECTIFICATION_INSPECT_HIDDEN_ID,
                },
              })
            "
          />
        </uni-td>
      </uni-tr>
    </uni-table>
  </view>
</template>

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

export default {
  data() {
    return {
      info: {
        imgsList: [],
      },
    };
  },
  onLoad(query) {
    this.fnGetData(query.SPECIAL_RECTIFICATION_INSPECT_ID);
  },
  methods: {
    async fnGetData(SPECIAL_RECTIFICATION_INSPECT_ID) {
      const resData = await getSpecialRectificationInspectionRecordView({
        SPECIAL_RECTIFICATION_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;
    },
    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;
}
titleStyle {
  font-weight: bold;
}
.cell_tit {
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.img-wrap {
  display: flex;
  flex-wrap: wrap;
  > div {
    margin: 15upx;
  }
}
</style>
