<template>
  <div class="WeiXingYaoGan">
    <div class="list">
      <div v-for="item in option.dataset" :key="item.key">
        <Xinxi
          :style="{ marginBottom: `${option.dataStyle.listMarginbottom}px` }"
          :item="item"
          :dataStyle="option.dataStyle"
        />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { computed, PropType, toRefs, watch, reactive, ref } from 'vue';
  import { CreateComponentType } from '@/packages/index.d';
  import { icon } from '@/plugins';
  import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
  import { useChartDataFetch } from '@/hooks';
  import Xinxi from './svg/xinxi.vue';

  const props = defineProps({
    chartConfig: {
      type: Object as PropType<CreateComponentType>,
      required: true,
    },
  });

  const { w, h } = toRefs(props.chartConfig.attr);

  const option = reactive({
    dataset: props.chartConfig.option.dataset,
    dataStyle: props.chartConfig.option.dataStyle,
  });

  watch(
    () => w,
    () => {
      option.dataStyle.listWidth =
        w.value - option.dataStyle.marginleft - option.dataStyle.marginright;
    },
    {
      immediate: true,
      deep: true,
    },
  );
  watch(
    () => option.dataStyle.listWidth,
    () => {
      option.dataStyle.listHeight = 110 * (option.dataStyle.listWidth / 360);
    },
    {
      immediate: true,
      deep: true,
    },
  );
</script>

<style lang="scss" scoped>
  .WeiXingYaoGan {
    overflow: auto;
    width: v-bind('`${w}px`');
    height: v-bind('`${h}px`');
  }

  .WeiXingYaoGan::-webkit-scrollbar {
    display: none;
  }

  .WeiXingYaoGan {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .list {
    margin-top: v-bind('`${option.dataStyle.margintop}px`');
    margin-bottom: v-bind('`${option.dataStyle.marginbottom}px`');
    margin-left: v-bind('`${option.dataStyle.marginleft}px`');
    margin-right: v-bind('`${option.dataStyle.marginright}px`');
  }

  // .xinxi {
  //   margin-bottom: v-bind('`${option.dataStyle.listMarginbottom}px`');
  // }
</style>
