ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script setup lang="ts">
import { computed } from 'vue';
 
import { useGlobSetting } from '@jnpf/hooks';
import { urlToBase64 } from '@jnpf/utils';
 
const props = defineProps(['floatImage']);
 
const globSetting = useGlobSetting();
const getActionPrefix = computed(() => globSetting.reportApiURL);
const imageSourceList = [
  { fullName: '本地上传', id: 1 },
  { fullName: 'URL路径', id: 2 },
];
 
function onSourceChange(type) {
  props.floatImage.imageType = Number(type) === 2 ? 'URL' : 'BASE64';
  props.floatImage.option.src = '';
}
function onChange(val) {
  urlToBase64(getActionPrefix.value + val).then((base64) => {
    props.floatImage.imageType = 'BASE64';
    props.floatImage.option.src = base64;
  });
}
</script>
 
<template>
  <a-collapse-panel>
    <template #header>基础设置</template>
    <a-form-item label="图片来源">
      <jnpf-radio
        v-model:value="floatImage.option.source"
        :options="imageSourceList"
        option-type="button"
        button-style="solid"
        @change="onSourceChange"
        class="right-radio-more" />
    </a-form-item>
    <a-form-item v-if="floatImage.option.source == 2">
      <template #label>图片地址<BasicHelp text="地址以http://或https://为开头" /></template>
      <a-input v-model:value="floatImage.option.src" placeholder="请输入" />
    </a-form-item>
    <a-form-item label="上传图片" v-else>
      <JnpfUploadImgSingle v-model:value="floatImage.option.src" :action-prefix="getActionPrefix" action="/api/Report/data/upload/file" @change="onChange" />
    </a-form-item>
  </a-collapse-panel>
</template>