import { defineComponent, onMounted, onUnmounted, reactive } from "vue";
import { css } from "@linaria/core";

import { useCtx } from "../../context";

export default defineComponent({
  setup() {
    const ctx = useCtx();
    const countTotal = (type: string) => {
      let res: any = ctx.list.backendList.state.list.filter((e: any) => {
        return e.type == type;
      });
      return res.length;
    };
    return () => (
      <div class={ViewStyle}>
        <div class="table_header">
          <div class="title">文物统计</div>
        </div>
        <div class={"total_view"}>
          <div class={"item tot"}>
            <div class={"txt"}>文物总计</div>
            <div class={"num"}>{ctx.list.backendList.state.total}</div>
          </div>
          <div class={"item model"}>
            <div class={"txt"}>模型展示</div>
            <div class={"num"}>{countTotal("3D")}</div>
          </div>
          <div class={"item img"}>
            <div class={"txt"}>图片展示</div>
            <div class={"num"}>{countTotal("img")}</div>
          </div>
          <div class={"item video"}>
            <div class={"txt"}>视频展示</div>
            <div class={"num"}>{countTotal("video")}</div>
          </div>
        </div>
      </div>
    );
  },
});

const ViewStyle = css`
  padding: 20px;
  .table_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    .title {
      font-size: 18px;
      font-weight: bold;
    }
  }
  .ant-table-thead > tr > th,
  .ant-table-tbody > tr > td {
    text-align: center;
  }
  .thumbnail {
    width: 120px;
    object-fit: contain;
  }
  .total_view {
    display: flex;
    align-items: center;
    .item {
      padding: 0.3rem 0.4rem;
      margin-right: 0.2rem;
      text-align: center;
      color: #fff;
      &.tot {
        background-color: #2f2e32;
      }
      &.model {
        background-color: #30445d;
      }
      &.img {
        background-color: #525357;
      }
      &.video {
        background-color: #6a213f;
      }
      .txt {
        font-size: 0.16rem;
      }
      .num {
        margin-top: 0.1rem;
        font-size: 0.2rem;
        font-weight: bold;
      }
    }
  }
`;
