<template>
  <div class="custom-creation-record">
    <div class="label-box">
      <span
        :class="{
          active: item.value == DefaultTable,
        }"
        @click="changeTable(item)"
        v-for="item in label_list"
        :key="item.value"
        >{{ item.label }}</span
      >
    </div>
    <div class="real-table-parent">
      <div v-show="DefaultTable == 'img'">
        <MappingRecord :DefaultTable="DefaultTable"></MappingRecord>
      </div>
      <template v-if="is_first">
        <div v-show="DefaultTable == 'text'">
          <CopywritingRecord :DefaultTable="DefaultTable"></CopywritingRecord>
        </div>
      </template>
    </div>
  </div>
</template>

<script lang="ts" setup>
import MappingRecord from './components/MappingRecord.vue';
import CopywritingRecord from './components/CopywritingRecord.vue';
import { ref } from 'vue';
// 默认展示绘图记录
const DefaultTable = ref<'img' | 'text'>('img');
const is_first = ref(false);
const reset_num = ref(1);
const label_list = [
  {
    label: '绘图记录',
    value: 'img',
  },
  {
    label: '文案记录',
    value: 'text',
  },
];

const changeTable = (item: any) => {
  is_first.value = true;
  if (item.value != DefaultTable.value) {
    // 通知表格请求数据
    reset_num.value += 1;
  }
  DefaultTable.value = item.value;
};
</script>

<style lang="less">
@import '@/style/variables.less';
.custom-creation-record {
  padding-top: @page-padding-top;
  .label-box {
    font-weight: 600;
    font-size: @font-size-18;
    margin-bottom: 16px;
    transition: all 0.3s;
    .active {
      color: #00f9f9;
      transition: all 0.3s;
    }
    span {
      cursor: pointer;
    }
    & > :not(:first-child) {
      margin-left: 12px;
    }
  }
  .real-table-parent {
    background-color: #2d2d2d;
    padding: 20px 40px;
  }
}
</style>
