<script setup>
  // import Sheet from '@/components/Sheet.vue'
  import { ref, reactive, computed, onMounted, watch } from 'vue'
  import Sheet from './Sheet.vue';
  // 定义 props
  const props = defineProps({
    TableInfo:{
      type:Object,
      default:{}
    }
  })

  //手机端pc端不同样式
  const dynamicSty = computed(()=>{
    return isMobile() ? 'mobile-sty' : 'pc-sty';
  })
  //判断是否是手机设备
 function isMobile() {
		// 判断是否是移动设备的正则表达式
		const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
	
		// 获取用户代理信息
		const userAgent = navigator.userAgent;
	
		// 使用正则表达式检查用户代理信息
		return mobileRegex.test(userAgent);
  }
  









</script>

<template>
  <div class="sheet-show-wrapper">
    <div :class="['table-wrapper',dynamicSty ]" >
      
      <Sheet
        :limit="{
            disabled:true
        }"
        :sheetInfo="{
            ExcelInfoId: TableInfo.ExcelInfoId,
            ExcelName: TableInfo.ExcelName,
            ExcelClassifyId: TableInfo.ExcelClassifyId,
            Source: TableInfo.Source
        }"
        :option="{
            data: [{
            ...JSON.parse(TableInfo.Content),
            scrollTop: 0,
            scrollLeft: 0
            }]
        }"
        >
      </Sheet>
    </div>

    <div class="tool sheet-bottom">
      <div class="sheet-source" 
        v-if="TableInfo.SourcesFrom&&JSON.parse(TableInfo.SourcesFrom).isShow"
        :style="`
          color: ${ JSON.parse(TableInfo.SourcesFrom).color };
          font-size: ${ JSON.parse(TableInfo.SourcesFrom).fontSize }px;
        `"
      >
          source：<em>{{ JSON.parse(TableInfo.SourcesFrom).text}}</em>
      </div>
    </div>
  </div>
</template>

<style lang='scss' scoped>
.sheet-show-wrapper {
  max-width: 1200px;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
  background: #fff;
  .tool{
    // text-align: right;
    margin-top: 5px;
    span{
        cursor: pointer;
    }
  }
  .sheet-bottom{
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
    padding: 0 10px;
    .sheet-source{
      width: 30%;
      min-width: 150px;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .right-btns {
      display: flex;
      align-items: center;
      gap:15px;
      color: #666;
    }
  }
}
</style>
<style scoped lang="scss">
.table td,th {
  width: 104px;
  min-width: 104px;
  height: 35px;
  background: #fff;
  text-align: center;
  word-break: break-all;
  border: none;
  outline-color: #dcdfe6;
  outline-style: solid;
  outline-width: 1px;
  word-wrap: break-word;
  word-break: break-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;

  &.td-chose::after {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    content: "";
    display: block;
    outline: 0;
    border: 2px solid #0033FF;
    box-shadow: 0 0 5px rgba(73, 177, 249, .5)
  }
  // &.td-col-select::after {
  //   position: absolute;
  //   top: 0;
  //   left: 0;
  //   right: 0;
  //   bottom: 0;
  //   content: "";
  //   display: block;
  //   outline: 0;
  //   border: 1px solid rgb(24, 173, 24);
  //   border-bottom: none;
  //   border-top: none;
  // }
  // &.td-row-select::after {
  //   position: absolute;
  //   top: 0;
  //   left: 0;
  //   right: 0;
  //   bottom: 0;
  //   content: "";
  //   display: block;
  //   outline: 0;
  //   border: 1px solid rgb(24, 173, 24);
  //   border-left: none;
  //   border-right: none;
  // }
  &.insert {
    background: #FFEFDD;
  }
  .edbname-td {
    &:hover {
      text-decoration: underline;
    }
  }
  &.fix-col {
    position:sticky;
    left: 0;
    z-index: 98; // 表格右键操作弹窗为99
  }
}

.th-tg {
  background: #EBEEF5;
  &:hover {
    cursor: pointer;
    background: #ddd;
    /* border: 2px solid #409eff; */
  }
  &.sm {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
  }
}
//整行选中
tr {
  // position: relative;
  // &.choose-all::after {
  //   position: absolute;
  //   top: 0;
  //   left: 0;
  //   right: 0;
  //   bottom: 0;
  //   content: "";
  //   display: block;
  //   outline: 0;
  //   border: 2px solid #5897fb;
  //   box-shadow: 0 0 5px rgba(73, 177, 249, .5)
  // }
  &.fix {
    position:sticky;
    top: 0;
    z-index: 98; // 表格右键操作弹窗为99
  }
} 

.el-icon-sort {
  color: #409eff;
  cursor: pointer;
  font-size: 16px;
}

</style>
<style lang='scss' scoped>
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgb(239, 239, 239);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #888;
}
::-webkit-scrollbar-corner {
  background: #666;
}
.table-wrapper {
  max-width: calc(100vw - 20px);
  height: calc(100vh - 400px);
  margin: 0 auto;
  // margin-right: -5px;
  overflow: auto;
}
table {
  width: 100%;
  font-size: 14px;
  color: #333;
  td,
  th {
    // min-width: 120px;
    word-break: break-all;
    word-wrap: break-word;
    line-height: 1.2em;
    border: 1px solid #dcdfe6;
    // height: 40px;
    text-align: center;
    border-left: none;
    border-top: none;
    &:first-child {
			border-left: 1px solid #dcdfe6;
		}
  }

  .data-cell{
    color: #333;
    &.one-bg {
      background-color: #EFEEF1;
    }
    &.two-bg {
      background-color: #fff;
    }
  }

  .thead-sticky {
    position: sticky;
    top: 0;
  }

  .head-column {
    background-color: #505B78;
    color: #fff;
  }
  .split-word {
    span { display: inline; }
  }
}

.no-water{
  td,
  th {
    background-color: #fff;
  }
  .head-column {
    background-color: #505B78;
    color: #fff;
  }
}

.pc-sty table {
  table-layout: auto;
  td,th {
    width: auto;
    height: auto;
    padding: 0.4em 0;
  }
}

.mobile-sty table {
  table-layout: auto;
  td,th {
    min-width: 120px;
    height: 40px;
  }
}
.background-watermark{
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 100%;
}
</style>