Commit 1ed798e18c7aad59a74e2368a54d8418c546260c

Authored by fengwotao
1 parent c7243377

feat:大屏新增背景选择

@@ -21,7 +21,6 @@ @@ -21,7 +21,6 @@
21 ></n-input-number> 21 ></n-input-number>
22 </n-form-item> 22 </n-form-item>
23 </n-form> 23 </n-form>
24 -  
25 <n-card class="upload-box"> 24 <n-card class="upload-box">
26 <n-upload 25 <n-upload
27 v-model:file-list="uploadFileListRef" 26 v-model:file-list="uploadFileListRef"
@@ -42,6 +41,17 @@ @@ -42,6 +41,17 @@
42 </n-card> 41 </n-card>
43 <n-space vertical :size="12"> 42 <n-space vertical :size="12">
44 <n-space> 43 <n-space>
  44 + <n-text>背景选择</n-text>
  45 + <n-select
  46 + size="small"
  47 + placeholder="请选择您要使用的背景"
  48 + style="width: 250px"
  49 + v-model:value="bgSelectValue"
  50 + :options="selectBgOptions"
  51 + @update:value="selectBgValueHandle"
  52 + />
  53 + </n-space>
  54 + <n-space>
45 <n-text>背景颜色</n-text> 55 <n-text>背景颜色</n-text>
46 <div class="picker-height"> 56 <div class="picker-height">
47 <n-color-picker 57 <n-color-picker
@@ -132,7 +142,7 @@ import { FileTypeEnum } from '@/enums/fileTypeEnum' @@ -132,7 +142,7 @@ import { FileTypeEnum } from '@/enums/fileTypeEnum'
132 import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' 142 import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
133 import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d' 143 import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
134 import { StylesSetting } from '@/components/Pages/ChartItemSetting' 144 import { StylesSetting } from '@/components/Pages/ChartItemSetting'
135 -import { UploadCustomRequestOptions } from 'naive-ui' 145 +import { UploadCustomRequestOptions, SelectOption } from 'naive-ui'
136 import { fileToUrl, loadAsyncComponent } from '@/utils' 146 import { fileToUrl, loadAsyncComponent } from '@/utils'
137 import { PreviewScaleEnum } from '@/enums/styleEnum' 147 import { PreviewScaleEnum } from '@/enums/styleEnum'
138 import { icon } from '@/plugins' 148 import { icon } from '@/plugins'
@@ -150,6 +160,23 @@ const selectColorValue = ref(0) @@ -150,6 +160,23 @@ const selectColorValue = ref(0)
150 160
151 const ChartThemeColor = loadAsyncComponent(() => import('./components/ChartThemeColor/index.vue')) 161 const ChartThemeColor = loadAsyncComponent(() => import('./components/ChartThemeColor/index.vue'))
152 162
  163 +//背景选择配置项
  164 +const bgSelectValue = ref('')
  165 +
  166 +const selectBgOptions = ref<Array<SelectOption>>([])
  167 +
  168 +//待封装成传文件夹名字获取下面所有图片
  169 +const getFetchImages = () => {
  170 + const imagesModules = import.meta.globEager('@/assets/images/chart/background/*')
  171 + for (const key in imagesModules) {
  172 + selectBgOptions.value.push({
  173 + label: imagesModules[key]?.default.slice(36),
  174 + value: imagesModules[key]?.default
  175 + })
  176 + }
  177 +}
  178 +getFetchImages()
  179 +
153 // 默认应用类型 180 // 默认应用类型
154 const selectColorOptions = [ 181 const selectColorOptions = [
155 { 182 {
@@ -242,6 +269,12 @@ const selectColorValueHandle = (value: number) => { @@ -242,6 +269,12 @@ const selectColorValueHandle = (value: number) => {
242 canvasConfig.selectColor = value == 0 269 canvasConfig.selectColor = value == 0
243 } 270 }
244 271
  272 +//选择背景
  273 +const selectBgValueHandle = (value: string) => {
  274 + bgSelectValue.value = value
  275 + canvasConfig.backgroundImage = value
  276 +}
  277 +
245 // 清除背景 278 // 清除背景
246 const clearImage = () => { 279 const clearImage = () => {
247 chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.BACKGROUND_IMAGE, undefined) 280 chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.BACKGROUND_IMAGE, undefined)
@@ -331,8 +364,8 @@ $uploadHeight: 193px; @@ -331,8 +364,8 @@ $uploadHeight: 193px;
331 padding-right: 2.25em; 364 padding-right: 2.25em;
332 } 365 }
333 .select-preview-icon { 366 .select-preview-icon {
334 - padding-right: .68em;  
335 - padding-left: .68em; 367 + padding-right: 0.68em;
  368 + padding-left: 0.68em;
336 } 369 }
337 .tabs-box { 370 .tabs-box {
338 margin-top: 20px; 371 margin-top: 20px;