<template>
  <n-drawer v-bind="getDrawerOptions" @update:show="updateVisible">
    <n-drawer-content closable title="处理结果">
      <a-card id="pdfCentent" :bordered="false">
        <!-- 河道信息 -->
        <div class="task-message">
          <div class="message-head">河道信息</div>
          <ul class="table-box">
            <li
              v-for="(item, index) in streamColumns"
              :key="index"
              class="table-item"
            >
              <div class="item-title">{{ item.title }}</div>
              <div class="item"><span>{{ detailMessage[item.dataIndex] }}</span></div>
            </li>
          </ul>
        </div>

        <!-- 巡检信息 -->
        <div class="task-message">
          <div class="message-head">巡检信息</div>
          <ul class="inspection-table">
            <li
              v-for="(item, index) in inspectionColumns"
              :key="index"
              class="inspction-table-item"
            >
              <div class="item-title">{{ item.title }}</div>
              <div v-if="item.dataIndex == 'inspectionWay'" class="item">
                <span v-if="detailMessage[item.dataIndex] == 1">无人机</span>
                <span v-if="detailMessage[item.dataIndex] == 2">机场</span>
              </div>
              <div v-else-if="item.dataIndex == 'inspectionType'" class="item">
                <span v-if="detailMessage[item.dataIndex] == 1">常规巡河</span>
                <span v-if="detailMessage[item.dataIndex] == 2">其他</span>
              </div>
              <div v-else class="item">{{ detailMessage[item.dataIndex] }}</div>
            </li>
          </ul>
        </div>

        <!-- 巡检结果 -->
        <div class="task-message">
          <div class="message-head">巡检结果</div>
          <div class="inspection-result">
            <div class="inspection-head">
              <div class="head-item project-box">项目</div>
              <div class="head-item project-content">巡检内容</div>
              <div class="head-item project-result">巡检监测结果</div>
            </div>
            <div class="inspection-mian">
              <ul class="inspection-item">
                <li v-for="(item, index) in resultcolumns" :key="index" class="project-main" style="margin-top: -1px;">
                  <span class="project-name">{{ item.name }}</span>
                  <ul class="project-type">
                    <li v-for="(i, j) in item.type" :key="j" class="type-item" style="margin-bottom: -1px;">
                      <span v-if="i.content.length" class="type-name">{{ i.name }}</span>
                      <ul v-if="i.content.length" class="content-lists">
                        <li v-for="(m,n) in i.content" :key="n" class="content-item">
                          <div class="inspection-content" style="margin-right: -1px;">{{ m.content }}</div>
                          <div class="inspection-count">{{ countObj[m.id] }}</div>
                        </li>
                      </ul>
                    </li>
                  </ul>
                </li>
              </ul>
            </div>
          </div>
        </div>

        <!-- 问题清单 -->
        <div v-if="imageList.length" class="task-message">
          <div class="message-head">问题清单</div>
          <ul class="image-list">
            <li v-for="(item, index) in imageList" :key="index" class="image-item">
              <div class="lon-lat image-index">
                问题{{ index+1 }}
              </div>
              <div class="lon-lat">
                <div class="position-label">
                  <span>坐标</span>
                </div>
                <div class="position-value">
                  <span>{{ item.longitude }}, {{ item.latitude }}</span>
                </div>
              </div>
              <div class="lon-lat">
                <div class="position-label">
                  <span>问题描述</span>
                </div>
                <div class="position-value">
                  <span>{{ item.content }}</span>
                </div>
              </div>
              <div class="lon-lat">
                <div class="position-image-lable">
                  <span>问题图片</span>
                </div>
                <div class="position-value" style="border-left: 1px solid rgba(220,223,230,1)">
                  <img class="problem-img" :src="item.fileImage" alt="">
                </div>
              </div>
              <!-- 处理结果 -->
              <div class="lon-lat image-index">
                处理结果
              </div>
              <div class="lon-lat">
                <div class="position-label">
                  <span>处理人</span>
                </div>
                <div class="position-value">
                  <span>{{ item.handerName }}</span>
                </div>
              </div>
              <div class="lon-lat">
                <div class="position-label">
                  <span>处理时间</span>
                </div>
                <div class="position-value">
                  <span>{{ item.handTime }}</span>
                </div>
              </div>
              <div class="lon-lat">
                <div class="position-label">
                  <span>备注</span>
                </div>
                <div class="position-value">
                  <span>{{ item.handContent }}</span>
                </div>
              </div>
              <div v-for="(i, j) in item.handImg" :key="j" class="lon-lat">
                <div class="position-image-lable">
                  <span>结果图片</span>
                  <span v-show="item.handImg.length>1">{{ j+1 }}</span>
                </div>
                <div class="position-value">
                  <img class="result-img" :src="i" alt="">
                </div>
              </div>
            </li>
          </ul>
        </div>

        <!-- 操作按钮 -->
        <div class="download_box">
          <a-button :loading="downloadFlag" class="export-btn" type="primary" @click="exportReport">下载</a-button>
        </div>
      </a-card></n-drawer-content>
  </n-drawer>
</template>
<script>
import { reactive, computed, toRefs, watch, ref } from 'vue'
import { streamColumns, inspectionColumns } from '../tools/data.js'
export default {
  name: 'TaskLive',
  components: {},
  props: {
    /* 可见 */
    visible: {
      type: Boolean,
      default: false
    },
    /* 选中的数据 */
    data: {
      type: Object,
      default: () => {}
    }
  },
  emits: {
    'update:visible': null
  },
  setup(props, { emit }) {
    const data = reactive({
      downloadFlag: false,
      streamColumns,
      inspectionColumns
    })

    /* 获取抽屉的信息 */
    const getDrawerOptions = computed(() => {
      return {
        show: props.visible,
        width: '100%',
        placement: 'right'
      }
    })

    watch(() => props.visible, (value) => {
      if (!value) {
        // videoRef.value.disposeVideo()
      }
    })

    const updateVisible = function() {
      emit('update:visible', false)
    }

    return {
      getDrawerOptions,
      ...toRefs(data),
      updateVisible
    }
  }
}
</script>
<style scoped>
ul,
li {
  list-style: none;
  padding: 0;
}
* {
  box-sizing: border-box;
}
.task-message {
  width: 100%;
  padding: 0 30px 20px 30px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}
.message-head {
  width: 100%;
  padding: 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
}
.table-box {
  border-top: 1px solid rgba(220,223,230,1);
  border-left: 1px solid rgba(220,223,230,1);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: column;
  width: 800px;
}
.table-item {
  display: flex;
  /* flex-direction: column; */
  justify-content: center;
  align-items: stretch;
  width: 100%;
}
.item {
  /* width: 150px; */
  width: 60%;
  height: 30px;
  text-align: center;
  line-height: 30px;
  border-right: 1px solid rgba(220,223,230,1);
  border-bottom: 1px solid rgba(220,223,230,1);
}
.item-title{
  width: 40%;
  background: rgba(245,247,250,1);
  height: 1.875rem;
  text-align: center;
  line-height: 1.875rem;
  border-right: .0625rem solid rgba(220,223,230,1);
  border-bottom: .0625rem solid rgba(220,223,230,1);
}
.auto-height{
  line-height:20px;
  padding: 5px 0;
  height:unset;
  /* line-height: 100%; */
  vertical-align: middle;
  display:flex;
  align-items: center;
  justify-content: center;
}
.inspection-table {
  border-top: 1px solid rgba(220,223,230,1);
  border-left: 1px solid rgba(220,223,230,1);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: column;
  width: 800px;
}
.inspction-table-item {
  display: flex;
  /* flex-direction: column; */
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* 巡检结果 */
.inspection-result {
  border-top: 1px solid rgba(220,223,230,1);
  border-left: 1px solid rgba(220,223,230,1);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}
.inspection-head {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.head-item {
  padding: 6px;
  text-align: center;
}
.inspection-mian {
  width: 100%;
}
.inspection-item {
  margin-bottom: 0;
}
.project-content{
  width: 370px;
  border-left: 1px solid rgba(220,223,230,1);
  border-right: 1px solid rgba(220,223,230,1);
}
.project-result{
  flex: 1;
  border-right: 1px solid rgba(220,223,230,1);
}
.project-box {
  width: 171px;
  /* border-right: 1px solid rgba(220,223,230,1); */
  border-bottom: 1px solid rgba(220,223,230,1);
}
.project-main {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-right: 1px solid rgba(220,223,230,1);
  border-bottom: 1px solid rgba(220,223,230,1);
}
.project-name {
  width: 70px;
  text-align: center;
}
.type-name {
  width: 100px;
  text-align: center;
}
.type-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-top: 1px solid rgba(220,223,230,1);
  border-left: 1px solid rgba(220,223,230,1);
}

.content-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.inspection-content {
  width: 370px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  border-left: 1px solid rgba(220,223,230,1);
  border-right: 1px solid rgba(220,223,230,1);
  border-bottom: 1px solid rgba(220,223,230,1);
}
.inspection-count {
  width: 160px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  /* border-left: 1px solid rgba(220,223,230,1); */
  border-bottom: 1px solid rgba(220,223,230,1);
}

/* 问题清单 */
.image-list {
  border-top: 1px solid rgba(220,223,230,1);
  border-left: 1px solid rgba(220,223,230,1);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}
.lon-lat {
  border-right: 1px solid rgba(220,223,230,1);
  border-bottom: 1px solid rgba(220,223,230,1);
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.image-index {
  padding-left: 10px;
  font-weight: 600;
  font-size: 16px;
  padding: 5px 15px;
}
.position-label{
  width: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 5px 0;
}
.position-image-lable {
  height: 100%;
  width: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  /* border-right: 1px solid rgba(220,223,230,1); */
  padding: 5px 0;
}
.position-value {
  width: 500px;
  display: flex;
   flex-direction: column;
  justify-content: center;
  align-items: center;
  border-left: 1px solid rgba(220,223,230,1);
  padding: 5px 0;
  min-height: 32px;
}
.problem-img {
  width: 400px;
}
.result-img {
  width: 400px;
  margin-bottom: 10px;
}
.download_box {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

</style>
