goview_vue/dist/static/js/index-9703cacc.js
2023-06-06 13:24:29 +08:00

2 lines
9.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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