沙钢智慧能源系统前端代码
houzhongjian
2024-10-09 314507f8ddadd9c66e98d260c3b2a5dad1a04015
提交 | 用户 | 时间
314507 1 <template>
H 2   <div class="tab-bar">
3     <!-- 表单 -->
4     <el-form :model="formData" label-width="80px">
5       <el-form-item label="主题" prop="theme">
6         <el-select v-model="formData!.theme" @change="handleThemeChange">
7           <el-option
8             v-for="(theme, index) in THEME_LIST"
9             :key="index"
10             :label="theme.name"
11             :value="theme.id"
12           >
13             <template #default>
14               <div class="flex items-center justify-between">
15                 <Icon :icon="theme.icon" :color="theme.color" />
16                 <span>{{ theme.name }}</span>
17               </div>
18             </template>
19           </el-option>
20         </el-select>
21       </el-form-item>
22       <el-form-item label="默认颜色">
23         <ColorInput v-model="formData!.style.color" />
24       </el-form-item>
25       <el-form-item label="选中颜色">
26         <ColorInput v-model="formData!.style.activeColor" />
27       </el-form-item>
28       <el-form-item label="导航背景">
29         <el-radio-group v-model="formData!.style.bgType">
30           <el-radio-button label="color">纯色</el-radio-button>
31           <el-radio-button label="img">图片</el-radio-button>
32         </el-radio-group>
33       </el-form-item>
34       <el-form-item label="选择颜色" v-if="formData!.style.bgType === 'color'">
35         <ColorInput v-model="formData!.style.bgColor" />
36       </el-form-item>
37       <el-form-item label="选择图片" v-if="formData!.style.bgType === 'img'">
38         <UploadImg v-model="formData!.style.bgImg" width="100%" height="50px" class="min-w-200px">
39           <template #tip> 建议尺寸 375 * 50 </template>
40         </UploadImg>
41       </el-form-item>
42
43       <el-text tag="p">图标设置</el-text>
44       <el-text type="info" size="small"> 拖动左上角的小圆点可对其排序, 图标建议尺寸 44*44 </el-text>
45       <Draggable v-model="formData.items" :limit="5">
46         <template #default="{ element }">
47           <div class="m-b-8px flex items-center justify-around">
48             <div class="flex flex-col items-center justify-between">
49               <UploadImg
50                 v-model="element.iconUrl"
51                 width="40px"
52                 height="40px"
53                 :show-delete="false"
54                 :show-btn-text="false"
55               />
56               <el-text size="small">未选中</el-text>
57             </div>
58             <div>
59               <UploadImg
60                 v-model="element.activeIconUrl"
61                 width="40px"
62                 height="40px"
63                 :show-delete="false"
64                 :show-btn-text="false"
65               />
66               <el-text>已选中</el-text>
67             </div>
68           </div>
69           <el-form-item prop="text" label="文字" label-width="48px" class="m-b-8px!">
70             <el-input v-model="element.text" placeholder="请输入文字" />
71           </el-form-item>
72           <el-form-item prop="url" label="链接" label-width="48px" class="m-b-0!">
73             <AppLinkInput v-model="element.url" />
74           </el-form-item>
75         </template>
76       </Draggable>
77     </el-form>
78   </div>
79 </template>
80
81 <script setup lang="ts">
82 import { TabBarProperty, THEME_LIST } from './config'
83 import { usePropertyForm } from '@/components/DiyEditor/util'
84 // 底部导航栏
85 defineOptions({ name: 'TabBarProperty' })
86
87 const props = defineProps<{ modelValue: TabBarProperty }>()
88 const emit = defineEmits(['update:modelValue'])
89 const { formData } = usePropertyForm(props.modelValue, emit)
90
91 // 要的主题
92 const handleThemeChange = () => {
93   const theme = THEME_LIST.find((theme) => theme.id === formData.value.theme)
94   if (theme?.color) {
95     formData.value.style.activeColor = theme.color
96   }
97 }
98 </script>
99
100 <style lang="scss" scoped></style>