<template>
  <CollapseItem name="数据设置" :expanded="true">
    <SettingItemBox name="主题设置">
      <SettingItem name="背景颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.backgroud"
        ></n-color-picker>
      </SettingItem>
      <SettingItem name="上方边距">
        <n-input-number
          v-model:value="optionData.dataStyle.margintop"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="左侧边距">
        <n-input-number
          v-model:value="optionData.dataStyle.marginleft"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
    </SettingItemBox>

    <SettingItemBox name="切换按钮设置">
      <SettingItem name="切换按钮颜色1">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.buttonColor1"
        ></n-color-picker>
      </SettingItem>
      <SettingItem name="切换按钮颜色2">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.buttonColor2"
        ></n-color-picker>
      </SettingItem>
      <SettingItem name="切换按钮大小">
        <n-input-number
          v-model:value="optionData.dataStyle.buttonSize"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
    </SettingItemBox>

    <SettingItemBox name="标题设置">
      <SettingItem name="是否显示标题栏">
        <n-space>
          <n-switch v-model:value="optionData.dataStyle.showTitle" size="small"></n-switch>
        </n-space>
      </SettingItem>
      <SettingItem name="标题字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.titleColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem name="标题字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.titleFontSize"
          :min="0"
          size="small"
          placeholder="标题字体大小"
        ></n-input-number>
      </SettingItem>
      <SettingItem name="与标题的间隔距离">
        <n-input-number
          v-model:value="optionData.dataStyle.titleMarginTop"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
    </SettingItemBox>

    <n-tag type="primary">编辑页面修改视频数据配置后，请在预览页面查看效果</n-tag>
    <SettingItemBox name="视频设置">
      <SettingItem>
        <n-checkbox v-model:checked="optionData.dataStyle.videoloop" size="small">
          循环播放
        </n-checkbox>
      </SettingItem>
      <SettingItem>
        <n-checkbox v-model:checked="optionData.dataStyle.videomuted" size="small">
          静音
        </n-checkbox>
      </SettingItem>
      <SettingItem name="视频类型">
        <n-select v-model:value="optionData.dataStyle.videofit" size="small" :options="fitList" />
      </SettingItem>
      <!-- <SettingItem name="视频宽度">
        <n-input-number
          v-model:value="optionData.dataStyle.videowidth"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="视频高度">
        <n-input-number
          v-model:value="optionData.dataStyle.videoheight"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem> -->
    </SettingItemBox>

    <SettingItemBox name="边框设置">
      <SettingItem name="边框颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.borderColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.borderColor = dataStyleClone.borderColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="边框宽度">
        <n-input-number
          v-model:value="optionData.dataStyle.borderWidth"
          size="small"
          :min="0"
        ></n-input-number>
      </SettingItem>
      <SettingItem name="边框距离">
        <n-input-number
          v-model:value="optionData.dataStyle.padding"
          size="small"
          :min="0"
        ></n-input-number>
      </SettingItem>
    </SettingItemBox>

    <SettingItemBox name="标题栏样式设置">
      <SettingItem name="标题底色（始）">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.titleColorStop1"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.titleColorStop1 = dataStyleClone.titleColorStop1"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="标题底色（终）">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.titleColorStop2"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.titleColorStop2 = dataStyleClone.titleColorStop2"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="标题右边颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.titleRightrColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.titleRightrColor = dataStyleClone.titleRightrColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="无人机标记颜色(始)">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.iconColorStop1"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.iconColorStop1 = dataStyleClone.iconColorStop1"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="无人机标记颜色(终)">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.iconColorStop2"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.iconColorStop2 = dataStyleClone.iconColorStop2"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="无人机边框颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.iconStrokeColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.iconStrokeColor = dataStyleClone.iconStrokeColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="无人机填充颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.iconFillColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.iconFillColor = dataStyleClone.iconFillColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="标记下方矩形颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.iconBottomColor"
        ></n-color-picker>
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.iconBottomColor = dataStyleClone.iconBottomColor"
        >
          恢复默认
        </n-button>
      </SettingItem>

      <!-- <SettingItem name="标题宽度">
        <n-input-number
          v-model:value="optionData.dataStyle.titleWidth"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="标题高度">
        <n-input-number
          v-model:value="optionData.dataStyle.titleHeight"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem> -->
    </SettingItemBox>
  </CollapseItem>
</template>

<script setup lang="ts">
  import { PropType, watch, ref } from 'vue';
  import { option } from './config';
  import { cloneDeep } from 'lodash-es';
  import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting';

  const props = defineProps({
    optionData: {
      type: Object as PropType<typeof option>,
      required: true,
    },
  });

  // 适应类型
  const fitList = [
    {
      value: 'fill',
      label: 'fill',
    },
    {
      value: 'contain',
      label: 'contain',
    },
    {
      value: 'cover',
      label: 'cover',
    },
    {
      value: 'scale-down',
      label: 'scale-down',
    },
    {
      value: 'none',
      label: 'none',
    },
  ];

  const dataStyleClone = {
    borderColor: '#008000',
    titleColorStop1: '#1F6B55',
    titleColorStop2: '#0A392A',
    titleRightrColor: '#00611A',
    iconColorStop1: '#73F095',
    iconColorStop2: '#BBFDB5',
    iconStrokeColor: '#00611A',
    iconFillColor: '#0A251E',
    iconBottomColor: '#0E4030',
  };
</script>
