<!-- 巡查记录抽屉 -->
<script>
export default {
  name: '',
  props: {
    drawerVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      tableData: [
        { content: '张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三', photos: '编辑', delete: '删除' },
        { content: '张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
        { content: '张三', photos: '编辑', delete: '删除' },
      ]
    }
  },
  methods: {
    handleSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        if (rowIndex < 4 || (rowIndex > 4 && rowIndex < 9) || (rowIndex > 8 && rowIndex < 11) || (rowIndex > 10 && rowIndex < 13) || (rowIndex > 12 && rowIndex < 18)) {
          if (rowIndex === 0 || rowIndex === 5 || rowIndex === 9 || rowIndex === 11 || rowIndex === 13) {
            return {
              rowspan: [4, 4, 2, 2, 5][[0, 5, 9, 11, 13].indexOf(rowIndex)],
              colspan: 1
            };
          } else {
            return {
              rowspan: 0,
              colspan: 0
            };
          }
        }
      }
    },
  }
}
</script>

<template>
  <div>
    <div class="masking" :class="drawerVisible ? 'masking-in' : ''">
      <div class="close-btn" @click="$emit('close-drawer');
      ">
        <i class="el-icon-arrow-right"></i>
      </div>
      <div class="drawer-title">
        <span>巡查记录</span>
      </div>
      <div class="center-table">
        <el-table :data="tableData" height="636" border style="width: 100%" :span-method="handleSpanMethod">
          <el-table-column align="center" class="first-column" label="工程部位" width="264">
            <template slot-scope="scope">
              <div v-if="scope.$index == 0">
                <div class="box1">
                  <div class="item1">一、堤身</div>
                  <div class="item2">堤顶</div>
                  <div class="item3">堤坡</div>
                  <div class="item4">迎水坡</div>
                  <div class="item5">背水坡</div>
                  <div class="item6">护坡结构</div>
                  <div class="item7">堤脚</div>
                </div>
              </div>
              <div v-if="scope.$index == 4">二、护坡地和堤防工程保护范围</div>
              <div v-if="scope.$index == 5">
                <div class="box2">
                  <div class="item1">三、堤岸防护工程</div>
                  <div class="item2">坡式</div>
                  <div class="item3">墙式</div>
                  <div class="item4">护脚</div>
                  <div class="item5">滩岸</div>
                </div>
              </div>
              <div v-if="scope.$index == 9">
                <div class="box3">
                  <div class="item1">四、防渗排水设施</div>
                  <div class="item2">防渗设施</div>
                  <div class="item3">排水设施</div>
                </div>
              </div>
              <div v-if="scope.$index == 11">
                <div class="box3">
                  <div class="item1">五、交叉建筑物及接连段</div>
                  <div class="item2">连接段</div>
                  <div class="item3">交叉建筑物</div>
                </div>
              </div>
              <div v-if="scope.$index == 13">
                <div class="box4">
                  <div class="item1">六、管理设施</div>
                  <div class="item2">观测设施</div>
                  <div class="item3">交通通信设施</div>
                  <div class="item4">信息化设施</div>
                  <div class="item5">标识标牌</div>
                  <div class="item6">管理房</div>
                </div>
              </div>
              <div v-if="scope.$index == 18">七、生物防护工程</div>
              <div v-if="scope.$index == 19">八、其他</div>
            </template>
          </el-table-column>
          <el-table-column prop="content" align="center" class-name="column-item" label="检查内容" min-width="200" />
          <el-table-column v-if="!this.$route.query.editor" prop="photos" align="center" class-name="column-item"
            label="打卡图片" width="150" />
          <el-table-column v-if="!this.$route.query.editor" align="center" class-name="column-item" label="检查记录">
            <el-table-column prop="isNormal" align="center" class-name="column-item" label="是否正常" width="150" />
            <el-table-column prop="problems" align="center" class-name="column-item" label="存在问题" width="150" />
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
.masking {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  left: 120%;
  z-index: 2;
  background-color: #fff;
  transition: left 0.5s ease-in-out;
  box-shadow: -8px 0px 38px 0px rgba(0, 0, 0, 0.6);

  .close-btn {
    width: 32px;
    height: 32px;
    position: absolute;
    top: 48px;
    left: -16px;
    background-color: #fff;
    border: 1px solid #DCDCDC;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;

    i {
      color: #36b29e;
    }
  }

  .drawer-title {
    width: 100%;
    height: 64px;
    line-height: 64px;
    padding-left: 16px;
    border-bottom: 1px solid #e7e7e7;
  }

  .center-table {
    padding: 16px;


    .box1 {
      height: 352x;
      display: grid;
      grid-template-columns: repeat(3, 88px);
      grid-template-rows: repeat(8, 44px);

      .item1 {
        grid-row: 1 / 9;
        grid-column: 1;
        line-height: 352px;
        justify-content: center;
        align-content: center;
        border-right: 1px solid #f4f9f7;
      }

      .item2 {
        grid-row: 1/3;
        grid-column: 2/ 4;
        line-height: 88px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item3 {
        grid-row: 3/7;
        grid-column: 2;
        line-height: 176px;
        justify-content: center;
        align-content: center;
        border-right: 1px solid #f4f9f7;
      }

      .item4 {
        line-height: 44px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item5 {
        line-height: 44px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item6 {
        grid-row: 7/5;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
      }


      .item7 {
        grid-row: 9/7;
        grid-column: 2/4;
        line-height: 88px;
        justify-content: center;
        align-content: center;
        border-top: 1px solid #f4f9f7;
      }
    }

    .box2 {
      height: 352px;
      display: grid;
      grid-template-columns: repeat(3, 88px);
      grid-template-rows: repeat(8, 44px);

      .item1 {
        grid-row: 1 / 9;
        grid-column: 1/3;
        line-height: 352px;
        justify-content: center;
        align-content: center;
        border-right: 1px solid #f4f9f7;
      }

      .item2 {
        grid-row: 1/3;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item3 {
        grid-row: 3/5;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item4 {
        grid-row: 5/7;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item5 {
        grid-row: 7/9;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
      }
    }

    .box3 {
      height: 176px;
      display: grid;
      grid-template-columns: repeat(3, 88px);
      grid-template-rows: repeat(8, 44px);

      .item1 {
        grid-row: 1 / 5;
        grid-column: 1/3;
        line-height: 176px;
        justify-content: center;
        align-content: center;
        border-right: 1px solid #f4f9f7;
      }

      .item2 {
        grid-row: 1/3;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item3 {
        grid-row: 3/5;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
      }
    }

    .box4 {
      height: 440px;
      display: grid;
      grid-template-columns: repeat(3, 88px);
      grid-template-rows: repeat(8, 44px);

      .item1 {
        grid-row: 1 / 10;
        grid-column: 1/3;
        line-height: 440px;
        justify-content: center;
        align-content: center;
        border-right: 1px solid #f4f9f7;
      }

      .item2 {
        grid-row: 1/3;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
        border-bottom: 1px solid #f4f9f7;
      }

      .item3 {
        grid-row: 3/5;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
      }

      .item4 {
        grid-row: 5/7;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
      }

      .item5 {
        grid-row: 7/9;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
      }

      .item6 {
        grid-row: 9/11;
        grid-column: 3;
        line-height: 88px;
        justify-content: center;
        align-content: center;
      }
    }
  }
}

.masking-in {
  left: 50%;
}

/deep/.el-table__body tr td {
  padding: 0;
  height: 88px !important;
}

/deep/ .cell {
  padding: 0 !important;
}

/deep/.column-item {
  padding-left: 10px !important;
}

/deep/.column-item .cell {
  padding: 18;
  max-height: 70px !important;
  overflow: auto;
}
</style>