import{d as ee,S as P,h as x,V as G,a6 as ue,cZ as B,G as te,r as a,o as g,c as I,u as r,A as F,w as e,b as t,e as s,m as i,F as J,bm as ie,a5 as K,f as oe,a7 as de,cT as ce,aH as _e,cR as fe,aG as pe,aK as me,b0 as ve,M as X,p as Z,t as D,N as Q,be as ge,$ as ye}from"./index-1516528a.js";import{d as W}from"./chartEditStore-1ca904d4.js";import{i as L}from"./icon-4e6026ee.js";import{T as O,D as $}from"./index-226a342c.js";import{u as ne}from"./useTargetData.hook-eb09b1f6.js";import{M as we}from"./EditorWorker-3b871bdd.js";import"./editorWorker-1611c17d.js";import{g as be}from"./plugin-12e5bbaa.js";import{F as Y}from"./fileTypeEnum-21359a08.js";const xe={class:"go-ml-4"},Ce={class:"editor-data-show"},Se={class:"editor-data-show"},Te={class:"editor-data-show"},ke={class:"go-flex-items-center"},Fe=ee({__name:"index",setup(R){const{DocumentTextIcon:f}=L.ionicons5,{FilterIcon:q,FilterEditIcon:N}=L.carbon,{targetData:p,chartEditStore:y}=ne();P(p.value.request),P(y.getRequestGlobalConfig);const u=x(!1),m=x(p.value.filter||"return data"),w=x(!1),C=x(""),E=async()=>{try{const _=await ie(K(p.value.request),K(y.getRequestGlobalConfig));if(_){C.value=_;return}window.$message.warning("没有拿到返回值,请检查接口!")}catch(_){console.error(_),window.$message.warning("数据异常,请检查参数!")}},V=G(()=>{try{const _=new Function("data","res",m.value),o=ue(C.value),l=_(o==null?void 0:o.data,o);return w.value=!1,B(l)}catch(_){return w.value=!0,`过滤函数错误,日志:${_}`}}),j=()=>{u.value=!0},H=()=>{be({message:"是否删除过滤器",onPositiveCallback:()=>{p.value.filter=void 0}})},U=()=>{u.value=!1},z=()=>{if(w.value){window.$message.error("过滤函数错误,无法进行保存");return}p.value.filter=m.value,U()};return te(()=>u.value,_=>{_&&(E(),m.value=p.value.filter||"return data")}),(_,o)=>{const l=a("n-code"),n=a("n-icon"),c=a("n-button"),d=a("n-space"),b=a("n-card"),T=a("n-text"),k=a("n-tag"),h=a("n-divider"),A=a("n-scrollbar"),M=a("n-modal");return g(),I(J,null,[r(p).filter?(g(),F(b,{key:0},{footer:e(()=>[t(d,{justify:"end"},{default:e(()=>[t(c,{type:"primary",tertiary:"",size:"small",onClick:j},{icon:e(()=>[t(n,null,{default:e(()=>[t(r(N))]),_:1})]),default:e(()=>[o[2]||(o[2]=s(" 编辑 "))]),_:1,__:[2]}),t(c,{tertiary:"",size:"small",onClick:H},{default:e(()=>o[3]||(o[3]=[s(" 删除 ")])),_:1,__:[3]})]),_:1})]),default:e(()=>[o[4]||(o[4]=i("p",null,[i("span",{class:"func-keyword"},"function"),s("  filter(data, res)  {")],-1)),i("div",xe,[t(l,{code:r(p).filter,language:"typescript"},null,8,["code"])]),o[5]||(o[5]=i("p",null,"}",-1))]),_:1,__:[4,5]})):(g(),F(c,{key:1,class:"go-ml-3",onClick:j},{icon:e(()=>[t(n,null,{default:e(()=>[t(r(q))]),_:1})]),default:e(()=>[o[6]||(o[6]=s(" 新增过滤器 "))]),_:1,__:[6]})),t(M,{class:"go-chart-data-monaco-editor",show:u.value,"onUpdate:show":o[1]||(o[1]=S=>u.value=S),"mask-closable":!1,closeOnEsc:!1},{default:e(()=>[t(b,{bordered:!1,role:"dialog",size:"small","aria-modal":"true",style:{width:"1000px",height:"600px"}},{header:e(()=>[t(d,null,{default:e(()=>[t(T,null,{default:e(()=>o[7]||(o[7]=[s("过滤器函数编辑器")])),_:1,__:[7]})]),_:1})]),"header-extra":e(()=>o[8]||(o[8]=[])),action:e(()=>[t(d,{justify:"space-between"},{default:e(()=>[i("div",ke,[t(k,{bordered:!1,type:"primary"},{icon:e(()=>[t(n,{component:r(f)},null,8,["component"])]),default:e(()=>[o[14]||(o[14]=s(" 规则 "))]),_:1,__:[14]}),t(T,{class:"go-ml-2",depth:"2"},{default:e(()=>o[15]||(o[15]=[s("过滤器默认处理接口返回值的「data」字段")])),_:1,__:[15]})]),t(d,null,{default:e(()=>[t(c,{size:"medium",onClick:U},{default:e(()=>o[16]||(o[16]=[s("取消")])),_:1,__:[16]}),t(c,{size:"medium",type:"primary",onClick:z},{default:e(()=>o[17]||(o[17]=[s("保存")])),_:1,__:[17]})]),_:1})]),_:1})]),default:e(()=>[t(d,{size:"small",vertical:""},{default:e(()=>[t(d,{justify:"space-between"},{default:e(()=>[i("div",null,[t(d,{vertical:""},{default:e(()=>[t(k,{type:"info"},{default:e(()=>o[9]||(o[9]=[i("span",{class:"func-keyword"},"function",-1),s("  filter(data, res)  { ")])),_:1,__:[9]}),t(r(we),{modelValue:m.value,"onUpdate:modelValue":o[0]||(o[0]=S=>m.value=S),width:"460px",height:"380px",language:"javascript"},null,8,["modelValue"]),t(k,{type:"info"},{default:e(()=>o[10]||(o[10]=[s("}")])),_:1,__:[10]})]),_:1})]),t(h,{vertical:"",style:{height:"480px"}}),t(A,{style:{"max-height":"480px"}},{default:e(()=>[t(d,{size:15,vertical:""},{default:e(()=>[i("div",Ce,[t(d,null,{default:e(()=>{var S;return[t(T,{depth:"3"},{default:e(()=>o[11]||(o[11]=[s("默认过滤数据(data):")])),_:1,__:[11]}),t(l,{code:r(B)((S=C.value)==null?void 0:S.data)||"暂无",language:"json","word-wrap":!0},null,8,["code"])]}),_:1})]),i("div",Se,[t(d,null,{default:e(()=>[t(T,{depth:"3"},{default:e(()=>o[12]||(o[12]=[s("接口返回数据(res):")])),_:1,__:[12]}),t(l,{code:r(B)(C.value)||"暂无",language:"json","word-wrap":!0},null,8,["code"])]),_:1})]),i("div",Te,[t(d,null,{default:e(()=>[t(T,{depth:"3"},{default:e(()=>o[13]||(o[13]=[s("过滤器结果:")])),_:1,__:[13]}),t(l,{code:V.value||"暂无",language:"json","word-wrap":!0},null,8,["code"])]),_:1})])]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["show"])],64)}}});const Re=oe(Fe,[["__scopeId","data-v-eac7a30e"]]),Ee=R=>{const f=x();return{uploadFileListRef:f,beforeUpload:({file:y})=>{f.value=[];const u=y.file.type;return u!==Y.JSON&&u!==Y.TXT?(window.$message.warning("仅支持上传 【JSON】 格式文件,请重新上传!"),!1):!0},customRequest:y=>{const{file:u}=y;de(()=>{u.file?ce(u.file).then(m=>{R.value.option.dataset=_e(m)}):window.$message.error("导入数据失败,请稍后重试或联系管理员!")})},download:()=>{try{window.$message.success("下载中,请耐心等待..."),fe(pe(R.value.option.dataset),void 0,"json")}catch{window.$message.error("下载失败,数据错误!")}}}},he=ee({__name:"index",props:{show:{type:Boolean,required:!1},ajax:{type:Boolean,required:!0}},setup(R){const{targetData:f}=ne(),q=["字段","映射","状态"],{HelpOutlineIcon:N}=L.ionicons5,{DocumentAddIcon:p,DocumentDownloadIcon:y}=L.carbon,u=x(),m=x(),w=x(),C=x(!1),{uploadFileListRef:E,customRequest:V,beforeUpload:j,download:H}=Ee(f),U=G(()=>f.value.request.requestDataType!==me.STATIC),z=G(()=>f.value.chartConfig.chartFrame===W.ECHARTS),_=l=>{let n=$.SUCCESS;for(let c=0;c{try{return m.value.map((l,n)=>n===0?{field:"通用标识",mapping:l,result:$.NULL}:{field:`数据项-${n}`,mapping:l,result:_(l)})}catch{return[]}};return te(()=>{var l,n;return(n=(l=f.value)==null?void 0:l.option)==null?void 0:n.dataset},l=>{var n,c;l&&((c=(n=f==null?void 0:f.value)==null?void 0:n.chartConfig)==null?void 0:c.chartFrame)===W.ECHARTS?(u.value=l,z.value&&(m.value=l.dimensions,w.value=o())):l!=null?(w.value=null,u.value=l):(C.value=!0,u.value="此组件无数据源"),ve(l)&&(w.value=null)},{immediate:!0}),(l,n)=>{const c=a("n-badge"),d=a("n-text"),b=a("n-space"),T=a("n-table"),k=a("n-timeline-item"),h=a("n-icon"),A=a("n-button"),M=a("n-upload"),S=a("n-tooltip"),le=a("n-code"),ae=a("n-card"),se=a("n-timeline");return g(),F(se,{class:"go-chart-configurations-timeline"},{default:e(()=>[X(t(k,{type:"info",title:r(O).MAPPING},{default:e(()=>[t(T,{striped:""},{default:e(()=>[i("thead",null,[i("tr",null,[(g(),I(J,null,Z(q,v=>i("th",{key:v},D(v),1)),64))])]),i("tbody",null,[(g(!0),I(J,null,Z(w.value,(v,re)=>(g(),I("tr",{key:re},[i("td",null,D(v.field),1),i("td",null,D(v.mapping),1),i("td",null,[v.result===0?(g(),F(b,{key:0},{default:e(()=>[t(c,{dot:"",type:"success"}),t(d,null,{default:e(()=>n[1]||(n[1]=[s("无")])),_:1,__:[1]})]),_:1})):(g(),F(b,{key:1},{default:e(()=>[t(c,{dot:"",type:v.result===1?"success":"error"},null,8,["type"]),t(d,null,{default:e(()=>[s("匹配"+D(v.result===1?"成功":"失败"),1)]),_:2},1024)]),_:2},1024))])]))),128))])]),_:1})]),_:1},8,["title"]),[[Q,z.value&&w.value]]),X(t(k,{color:"#97846c",title:r(O).FILTER},{default:e(()=>[t(b,{size:18,vertical:""},{default:e(()=>[t(d,{depth:"3"},{default:e(()=>n[2]||(n[2]=[s("过滤器默认处理接口返回值的「data」字段")])),_:1,__:[2]}),t(r(Re))]),_:1})]),_:1},8,["title"]),[[Q,U.value]]),t(k,{type:"success",title:r(O).CONTENT},{default:e(()=>[t(b,{vertical:""},{default:e(()=>[t(b,{class:"source-btn-box"},{default:e(()=>[t(M,{"file-list":r(E),"onUpdate:fileList":n[0]||(n[0]=v=>ge(E)?E.value=v:null),"show-file-list":!1,customRequest:r(V),onBeforeUpload:r(j)},{default:e(()=>[t(b,null,{default:e(()=>[R.ajax?ye("",!0):(g(),F(A,{key:0,class:"sourceBtn-item",disabled:C.value},{icon:e(()=>[t(h,null,{default:e(()=>[t(r(p))]),_:1})]),default:e(()=>[n[3]||(n[3]=s(" 导入(json / txt) "))]),_:1,__:[3]},8,["disabled"]))]),_:1})]),_:1},8,["file-list","customRequest","onBeforeUpload"]),i("div",null,[t(A,{class:"sourceBtn-item",disabled:C.value,onClick:r(H)},{icon:e(()=>[t(h,null,{default:e(()=>[t(r(y))]),_:1})]),default:e(()=>[n[4]||(n[4]=s(" 下载 "))]),_:1,__:[4]},8,["disabled","onClick"]),t(S,{trigger:"hover"},{trigger:e(()=>[t(h,{class:"go-ml-1",size:"21",depth:3},{default:e(()=>[t(r(N))]),_:1})]),default:e(()=>[t(d,{depth:"3"},{default:e(()=>n[5]||(n[5]=[s("点击【下载】查看完整数据")])),_:1,__:[5]})]),_:1})])]),_:1}),t(ae,{size:"small"},{default:e(()=>[t(le,{code:r(B)(u.value),language:"json"},null,8,["code"])]),_:1})]),_:1})]),_:1},8,["title"])]),_:1})}}});const Ie=oe(he,[["__scopeId","data-v-f6d90859"]]);export{Ie as C};