Commit f2e6d56fbdce1dcbd632aa1eca790c9f78311ac5

Authored by fengwotao
2 parents 5a547b6a ba4c5747

Merge branch 'main_dev' into ft

@@ -91,7 +91,7 @@ export const saveDataViewList = (data: object) => { @@ -91,7 +91,7 @@ export const saveDataViewList = (data: object) => {
91 */ 91 */
92 export const uploadFile = async (file: FormData, mode: ErrorMessageMode = 'modal') => { 92 export const uploadFile = async (file: FormData, mode: ErrorMessageMode = 'modal') => {
93 return defHttp.post( 93 return defHttp.post(
94 - { url: Api.FILE_UPLOAD, params: file }, 94 + { url: Api.FILE_UPLOAD, params: file},
95 { 95 {
96 errorMessageMode: mode 96 errorMessageMode: mode
97 } 97 }
@@ -33,6 +33,8 @@ const option = shallowReactive({ @@ -33,6 +33,8 @@ const option = shallowReactive({
33 dataset: '' 33 dataset: ''
34 }) 34 })
35 35
  36 +
  37 +
36 const getStyle = (radius: number) => { 38 const getStyle = (radius: number) => {
37 return { 39 return {
38 borderRadius: `${radius}px`, 40 borderRadius: `${radius}px`,
@@ -40,12 +42,44 @@ const getStyle = (radius: number) => { @@ -40,12 +42,44 @@ const getStyle = (radius: number) => {
40 } 42 }
41 } 43 }
42 44
  45 +async function getBase64(imgUrl: string): Promise<string> {
  46 + return new Promise(resolve => {
  47 + let xhr = new XMLHttpRequest();
  48 + xhr.open('get', imgUrl, true);
  49 + xhr.responseType = 'blob';
  50 + xhr.onload = function() {
  51 + if (this.status == 200) {
  52 + //得到一个blob对象
  53 + let blob = this.response;
  54 + // 重点2
  55 + let oFileReader = new FileReader();
  56 + oFileReader.onloadend = function(e) {
  57 + // 结果
  58 + const base64 = e.target?.result as string
  59 + resolve(base64)
  60 + };
  61 + oFileReader.readAsDataURL(blob);
  62 + }
  63 + };
  64 + xhr.send();
  65 + })
  66 +}
  67 +
43 // 编辑更新 68 // 编辑更新
44 watch( 69 watch(
45 () => props.chartConfig.option.dataset, 70 () => props.chartConfig.option.dataset,
46 - (newData: any) => { 71 + async (newData: any) => {
  72 + // const base64 = await getBase64(newData)
  73 + // option.dataset = base64
  74 + const reg = /^https?/ig
  75 + if(reg.test(newData)){
  76 + const base64 = await getBase64(newData)
  77 + option.dataset = base64
  78 + return
  79 + }
47 option.dataset = newData 80 option.dataset = newData
48 - }, 81 +
  82 + },
49 { 83 {
50 immediate: true 84 immediate: true
51 } 85 }