<template>
  <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
    <BasicTable
      class="w-3/4 xl:w-4/5"
      @register="registerTable"
      @fetch-success="onFetchSuccess"
      :searchInfo="searchInfo"
    >
    <template #bodyCell="{ column, record }">
      <template v-if="column.key === 'action'">
        <span class="btnbox openbox">打开报告</span>
        <span class="btnbox downloadbox">下载报告</span>
      </template>
    </template>
    </BasicTable>
    <div class="rightBox w-3/4 xl:w-1/5">
      <div class="title"></div>
      <div class="textbox fw-b">独立展示区</div>
      <div class="contentbox">
        <div class="contentli" v-for="(item, index) in imgsArr">
          <div class="flex jc-sb ai-c">
            <span class="fortext">缺陷类型{{ index + 1 }}</span>
            <div class="handlebox fz-12">
              <span :class="['cursor', { active: item.show }]" @click="item.show = true">展开</span>
              <span>/</span>
              <span :class="['cursor', { active: !item.show }]" @click="item.show = false">收起</span>
            </div>
          </div>
          <img v-if="item.show" class="img" :src="item.src" />
        </div>
      </div>
    </div>
  </PageWrapper>
</template>
<script lang="ts" setup>
  import { reactive, nextTick, ref } from 'vue';

  import { BasicTable, useTable } from '@/components/Table';
  import { getButtonList } from '@/api/demo/system';
  import { PageWrapper } from '@/components/Page';

  import { columns, searchFormSchema } from './index.data';
  import { useMessage } from '@/hooks/web/useMessage';

  const { createConfirm, createMessage } = useMessage();
  defineOptions({ name: 'workreport' });
  const searchInfo = reactive<Recordable>({});
  const imgsArr = ref([
    { show: true , src: '/public/banner.png' },
    { show: true , src: '/public/default.png' },
    { show: true , src: '/public/banner1.png' },
  ])

  const [registerTable, { reload, expandAll, getSelectRows, clearSelectedRowKeys }] = useTable({
    title: '工作报告',
    // api: getButtonList,
    columns,
    rowKey: 'id',
    formConfig: {
      labelWidth: 120,
      schemas: searchFormSchema,
    },
    striped: false,
    useSearchForm: true,
    showTableSetting: true,
    bordered: true,
    rowSelection: false,
    showIndexColumn: false,
    actionColumn: {
      width: 200,
      title: '操作',
      dataIndex: 'action',
    },
    handleSearchInfoFn(info) {
      return info;
    },
  });

  function onFetchSuccess() {
    // 演示默认展开所有表项
    nextTick(expandAll);
  }
</script>
<style scoped>
.flex{
  display: flex;
}
.jc-sb{
  justify-content: space-between;
}
.ai-c{
  align-items: center;
}
.cursor{
  cursor: pointer;
}
.fz-12{
  font-size: 12px;
}
.fw-b{
  font-weight: bold;
}
.rightBox{
  margin-left: -16px;
  padding: 16px 0;
  .title{
    width: 100%;
    height: 58px;
    background-color: #fff;
    padding: 12px 10px 6px;
    border-radius: 2px;
    margin-bottom: 16px;
  }
  .textbox{
    text-align: center;
    height: 40px;
    line-height: 40px;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 15px;
    margin-left: 16px;
  }
  .contentbox{
    height: calc(100% - 135px);
    margin-left: 16px;
    overflow: auto;
    .contentli{
      background: #fff;
      margin-bottom: 10px;
      padding: 16px;
      border-radius: 5px;
      .handlebox{
        .active{
          color: #6F84EE;
        }
      }
      .img{
        width: 100%;
        margin-top: 15px;
        border-radius: 3px;
      }
    }
  }
}
.btnbox{
  display: inline-block;
  padding: 3px 6px;
  color: #fff;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
}
.openbox{
  background: #E9671A;
  margin-right: 10px;
}
.downloadbox{
  background: #3A57E8;
}
</style>