2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
var U=(m,I,f)=>new Promise((L,h)=>{var T=a=>{try{b(f.next(a))}catch(g){h(g)}},i=a=>{try{b(f.throw(a))}catch(g){h(g)}},b=a=>a.done?L(a.value):Promise.resolve(a.value).then(T,i);b((f=f.apply(m,I)).next())});import{d as _e,k as pe,j as O,ae as me,aF as k,J as fe,r as s,o as d,c as E,b as e,w as t,u as n,n as y,a6 as V,Q as ge,e as u,t as $,cx as D,U as ve,D as S,d0 as Ce,F as H,q as M,E as P,ad as be,aL as we,R as ye,s as he,x as ke,h as Ee}from"./index-4ec2ce15.js";import{F as N}from"./fileTypeEnum-21359a08.js";import{u as Se,E as _}from"./chartEditStore-bfc6c223.js";/* empty css */import{l as Ie}from"./index-64867e41.js";import{i as Y}from"./icon-42fa39e7.js";import{_ as Le}from"./StylesSetting.vue_vue_type_script_setup_true_lang-cf4b6b74.js";import{b as Te}from"./project.api-0931840b.js";import"./plugin-ae137233.js";import"./SettingItem-35031211.js";import"./SettingItemBox-f60eaa4e.js";import"./CollapseItem.vue_vue_type_script_setup_true_lang-77b092a0.js";const xe=""+new URL("../png/noImage.png",import.meta.url).href,ze=m=>(he("data-v-340a9d3c"),m=m(),ke(),m),Re={class:"go-canvas-setting"},Fe={class:"upload-box"},Ue=["src"],Oe={class:"upload-img"},$e=ze(()=>y("img",{src:xe},null,-1)),De={class:"picker-height"},Pe=_e({__name:"index",setup(m){const{ColorPaletteIcon:I}=Y.ionicons5,{ScaleIcon:f,FitToScreenIcon:L,FitToHeightIcon:h,FitToWidthIcon:T}=Y.carbon,i=Se(),b=pe(),a=i.getEditCanvasConfig,g=i.getEditCanvas,x=O(),z=O(!1),R=O(0),K=Ie(()=>me(()=>import("./index-0e64ad2a.js"),["./index-0e64ad2a.js","./index-4ec2ce15.js","../css/index-9c2eb289.css","./chartEditStore-bfc6c223.js","./plugin-ae137233.js","./icon-42fa39e7.js","./index-64867e41.js","../css/index-d825de9b.css","../css/index-39f06c17.css"],import.meta.url)),X=[{label:"应用颜色",value:0},{label:"应用背景",value:1}],j=[{key:"ChartTheme",title:"主题颜色",icon:I,render:K}],q=[{key:k.FIT,title:"自适应",icon:f,desc:"自适应比例展示,页面会有留白"},{key:k.SCROLL_Y,title:"Y轴滚动",icon:T,desc:"X轴铺满,Y轴自适应滚动"},{key:k.SCROLL_X,title:"X轴滚动",icon:h,desc:"Y轴铺满,X轴自适应滚动"},{key:k.FULL,title:"铺满",icon:L,desc:"强行拉伸画面,填充所有视图"}];fe(()=>a.selectColor,c=>{R.value=c?0:1},{immediate:!0});const A=c=>c>50,G=()=>{i.computedScale()},J=l=>U(this,[l],function*({file:c}){x.value=[];const r=c.file.type;return c.file.size>1024*1024*D?(window.$message.warning(`图片超出 ${D}M 限制,请重新上传!`),!1):r!==N.PNG&&r!==N.JPEG&&r!==N.GIF?(window.$message.warning("文件格式不符合,请重新上传!"),!1):!0}),W=c=>{a.selectColor=c==0},Q=()=>{i.setEditCanvasConfig(_.BACKGROUND_IMAGE,void 0),i.setEditCanvasConfig(_.SELECT_COLOR,!0)},Z=()=>{z.value=!0,setTimeout(()=>{z.value=!1})},ee=()=>{i.setEditCanvasConfig(_.BACKGROUND,void 0),a.backgroundImage&&i.setEditCanvasConfig(_.SELECT_COLOR,!1),Z()},te=c=>{const{file:l}=c;be(()=>U(this,null,function*(){if(l.file){const r=new File([l.file],`${we()}_index_background.png`,{type:l.file.type});let v=new FormData;v.append("object",r);const p=yield Te(v);if(p&&p.code===ye.SUCCESS){p.data.fileurl?i.setEditCanvasConfig(_.BACKGROUND_IMAGE,`${p.data.fileurl}?time=${new Date().getTime()}`):i.setEditCanvasConfig(_.BACKGROUND_IMAGE,`${b.getFetchInfo.OSSUrl||""}${p.data.fileName}?time=${new Date().getTime()}`),i.setEditCanvasConfig(_.SELECT_COLOR,!1);return}window.$message.error("添加图片失败,请稍后重试!")}else window.$message.error("添加图片失败,请稍后重试!")}))},ae=c=>{i.setEditCanvasConfig(_.PREVIEW_SCALE_TYPE,c)};return(c,l)=>{const r=s("n-input-number"),v=s("n-form-item"),p=s("n-form"),w=s("n-text"),oe=s("n-upload-dragger"),ne=s("n-upload"),se=s("n-color-picker"),C=s("n-space"),le=s("n-select"),F=s("n-button"),B=s("n-icon"),ie=s("n-tooltip"),ce=s("n-button-group"),re=s("n-divider"),de=s("n-tab-pane"),ue=s("n-tabs");return d(),E("div",Re,[e(p,{inline:"","label-width":45,size:"small","label-placement":"left"},{default:t(()=>[e(v,{label:"宽度"},{default:t(()=>[e(r,{size:"small",value:n(a).width,"onUpdate:value":[l[0]||(l[0]=o=>n(a).width=o),G],disabled:n(g).lockScale,validator:A},null,8,["value","disabled"])]),_:1}),e(v,{label:"高度"},{default:t(()=>[e(r,{size:"small",value:n(a).height,"onUpdate:value":[l[1]||(l[1]=o=>n(a).height=o),G],disabled:n(g).lockScale,validator:A},null,8,["value","disabled"])]),_:1})]),_:1}),y("div",Fe,[e(ne,{"file-list":x.value,"onUpdate:fileList":l[2]||(l[2]=o=>x.value=o),"show-file-list":!1,customRequest:te,onBeforeUpload:J},{default:t(()=>[e(oe,null,{default:t(()=>[n(a).backgroundImage?(d(),E("img",{key:0,class:"upload-show",src:n(a).backgroundImage,alt:"背景"},null,8,Ue)):V("",!0),ge(y("div",Oe,[$e,e(w,{class:"upload-desc",depth:"3"},{default:t(()=>[u(" 背景图需小于 "+$(n(D))+"M ,格式为 png/jpg/gif 的文件 ",1)]),_:1})],512),[[ve,!n(a).backgroundImage]])]),_:1})]),_:1},8,["file-list"])]),e(C,{vertical:"",size:12},{default:t(()=>[e(C,null,{default:t(()=>[e(w,null,{default:t(()=>[u("背景颜色")]),_:1}),y("div",De,[z.value?V("",!0):(d(),S(se,{key:0,size:"small",style:{width:"250px"},value:n(a).background,"onUpdate:value":l[3]||(l[3]=o=>n(a).background=o),showPreview:!0,swatches:n(Ce)},null,8,["value","swatches"]))])]),_:1}),e(C,null,{default:t(()=>[e(w,null,{default:t(()=>[u("应用类型")]),_:1}),e(le,{size:"small",style:{width:"250px"},value:R.value,"onUpdate:value":[l[4]||(l[4]=o=>R.value=o),W],disabled:!n(a).backgroundImage,options:X},null,8,["value","disabled"])]),_:1}),e(C,null,{default:t(()=>[e(w,null,{default:t(()=>[u("背景控制")]),_:1}),e(F,{class:"clear-btn",size:"small",disabled:!n(a).backgroundImage,onClick:Q},{default:t(()=>[u(" 清除背景 ")]),_:1},8,["disabled"]),e(F,{class:"clear-btn",size:"small",disabled:!n(a).background,onClick:ee},{default:t(()=>[u(" 清除颜色 ")]),_:1},8,["disabled"])]),_:1}),e(C,null,{default:t(()=>[e(w,null,{default:t(()=>[u("适配方式")]),_:1}),e(ce,null,{default:t(()=>[(d(),E(H,null,M(q,o=>e(F,{key:o.key,type:n(a).previewScaleType===o.key?"primary":"tertiary",ghost:"",size:"small",onClick:Ne=>ae(o.key)},{default:t(()=>[e(ie,{"show-arrow":!1,trigger:"hover"},{trigger:t(()=>[e(B,{class:"select-preview-icon",size:"18"},{default:t(()=>[(d(),S(P(o.icon)))]),_:2},1024)]),default:t(()=>[u(" "+$(o.desc),1)]),_:2},1024)]),_:2},1032,["type","onClick"])),64))]),_:1})]),_:1})]),_:1}),e(n(Le),{isCanvas:!0,chartStyles:n(a)},null,8,["chartStyles"]),e(re,{style:{margin:"10px 0"}}),e(ue,{class:"tabs-box",size:"small",type:"segment"},{default:t(()=>[(d(),E(H,null,M(j,o=>e(de,{key:o.key,name:o.key,size:"small","display-directive":"show:lazy"},{tab:t(()=>[e(C,null,{default:t(()=>[y("span",null,$(o.title),1),e(B,{size:"16",class:"icon-position"},{default:t(()=>[(d(),S(P(o.icon)))]),_:2},1024)]),_:2},1024)]),default:t(()=>[(d(),S(P(o.render)))]),_:2},1032,["name"])),64))]),_:1})])}}});const Qe=Ee(Pe,[["__scopeId","data-v-340a9d3c"]]);export{Qe as default};
|