gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<script setup lang="ts">
import type { CarouselProperty } from './config';
 
import { IconifyIcon } from '..\..\..\..\..\..\..\..\packages\icons\src';
 
import { useVModel } from '@vueuse/core';
import {
  Form,
  FormItem,
  InputNumber,
  Radio,
  RadioButton,
  RadioGroup,
  Slider,
  Switch,
  Tooltip,
} from 'ant-design-vue';
 
import UploadFile from '#/components/upload/file-upload.vue';
import UploadImg from '#/components/upload/image-upload.vue';
import { AppLinkInput, Draggable } from '#/views/mall/promotion/components';
 
import ComponentContainerProperty from '../../component-container-property.vue';
 
/** 轮播图属性面板 */
defineOptions({ name: 'CarouselProperty' });
 
const props = defineProps<{ modelValue: CarouselProperty }>();
 
const emit = defineEmits(['update:modelValue']);
 
const formData = useVModel(props, 'modelValue', emit);
</script>
 
<template>
  <ComponentContainerProperty v-model="formData.style">
    <Form
      :model="formData"
      :label-col="{ style: { width: '80px' } }"
      label-align="right"
    >
      <p class="text-base font-bold">样式设置:</p>
      <div class="flex flex-col gap-2 rounded-md p-4 shadow-lg">
        <FormItem label="样式">
          <RadioGroup v-model:value="formData.type">
            <Tooltip class="item" title="默认" placement="bottom">
              <RadioButton value="default">
                <IconifyIcon icon="system-uicons:carousel" class="size-6" />
              </RadioButton>
            </Tooltip>
            <Tooltip class="item" title="卡片" placement="bottom">
              <RadioButton value="card">
                <IconifyIcon icon="ic:round-view-carousel" class="size-6" />
              </RadioButton>
            </Tooltip>
          </RadioGroup>
        </FormItem>
        <FormItem label="高度">
          <InputNumber
            v-model:value="formData.height"
            class="mr-[10px] !w-1/2"
          />
          px
        </FormItem>
        <FormItem label="指示器">
          <RadioGroup v-model:value="formData.indicator">
            <Radio value="dot">小圆点</Radio>
            <Radio value="number">数字</Radio>
          </RadioGroup>
        </FormItem>
        <FormItem label="是否轮播">
          <Switch v-model:checked="formData.autoplay" />
        </FormItem>
        <FormItem label="播放间隔" v-if="formData.autoplay">
          <Slider
            v-model:value="formData.interval"
            :max="10"
            :min="0.5"
            :step="0.5"
          />
          <p class="text-info">单位:秒</p>
        </FormItem>
      </div>
      <p class="text-base font-bold">内容设置:</p>
      <div class="flex flex-col gap-2 rounded-md p-4 shadow-lg">
        <Draggable v-model="formData.items" :empty-item="{ type: 'img' }">
          <template #default="{ element }">
            <FormItem label="类型" name="type">
              <RadioGroup v-model:value="element.type">
                <Radio value="img">图片</Radio>
                <Radio value="video">视频</Radio>
              </RadioGroup>
            </FormItem>
            <FormItem label="图片" v-if="element.type === 'img'">
              <UploadImg
                v-model="element.imgUrl"
                draggable="false"
                height="80px"
                width="100%"
                class="min-w-20"
                :show-description="false"
              />
            </FormItem>
            <template v-else>
              <FormItem label="封面">
                <UploadImg
                  v-model="element.imgUrl"
                  draggable="false"
                  :show-description="false"
                  height="80px"
                  width="100%"
                  class="min-w-20"
                />
              </FormItem>
              <FormItem label="视频">
                <UploadFile
                  v-model="element.videoUrl"
                  :file-type="['mp4']"
                  :limit="1"
                  :file-size="100"
                  class="min-w-20"
                />
              </FormItem>
            </template>
            <FormItem label="链接">
              <AppLinkInput v-model="element.url" />
            </FormItem>
          </template>
        </Draggable>
      </div>
    </Form>
  </ComponentContainerProperty>
</template>