Commit 1ed798e18c7aad59a74e2368a54d8418c546260c

Authored by fengwotao
1 parent c7243377

feat:大屏新增背景选择

... ... @@ -21,7 +21,6 @@
21 21 ></n-input-number>
22 22 </n-form-item>
23 23 </n-form>
24   -
25 24 <n-card class="upload-box">
26 25 <n-upload
27 26 v-model:file-list="uploadFileListRef"
... ... @@ -42,6 +41,17 @@
42 41 </n-card>
43 42 <n-space vertical :size="12">
44 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 55 <n-text>背景颜色</n-text>
46 56 <div class="picker-height">
47 57 <n-color-picker
... ... @@ -132,7 +142,7 @@ import { FileTypeEnum } from '@/enums/fileTypeEnum'
132 142 import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
133 143 import { EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
134 144 import { StylesSetting } from '@/components/Pages/ChartItemSetting'
135   -import { UploadCustomRequestOptions } from 'naive-ui'
  145 +import { UploadCustomRequestOptions, SelectOption } from 'naive-ui'
136 146 import { fileToUrl, loadAsyncComponent } from '@/utils'
137 147 import { PreviewScaleEnum } from '@/enums/styleEnum'
138 148 import { icon } from '@/plugins'
... ... @@ -150,6 +160,23 @@ const selectColorValue = ref(0)
150 160
151 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 181 const selectColorOptions = [
155 182 {
... ... @@ -242,6 +269,12 @@ const selectColorValueHandle = (value: number) => {
242 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 279 const clearImage = () => {
247 280 chartEditStore.setEditCanvasConfig(EditCanvasConfigEnum.BACKGROUND_IMAGE, undefined)
... ... @@ -331,8 +364,8 @@ $uploadHeight: 193px;
331 364 padding-right: 2.25em;
332 365 }
333 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 370 .tabs-box {
338 371 margin-top: 20px;
... ...