2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
var me=Object.defineProperty,fe=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var ve=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var le=(l,d,u)=>d in l?me(l,d,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[d]=u,Q=(l,d)=>{for(var u in d||(d={}))ve.call(d,u)&&le(l,u,d[u]);if(oe)for(var u of oe(d))he.call(d,u)&&le(l,u,d[u]);return l},Y=(l,d)=>fe(l,ge(d));var se=(l,d,u)=>new Promise((q,x)=>{var b=r=>{try{v(u.next(r))}catch(y){x(y)}},_=r=>{try{v(u.throw(r))}catch(y){x(y)}},v=r=>r.done?q(r.value):Promise.resolve(r.value).then(b,_);v((u=u.apply(l,d)).next())});import{d as L,j as $,J as X,r as o,o as i,D as H,w as t,b as e,e as h,c as C,n as f,u as a,h as V,be as ie,O as _e,$ as Z,a1 as G,a6 as te,F as J,q as ae,av as de,t as A,s as be,x as ye,l as qe,d2 as B,aQ as W,d1 as re,aR as M,ad as xe,L as we,aN as ce,ab as K,b8 as Pe,cB as De,bs as Ie,bt as Ce}from"./index-4ec2ce15.js";import{i as ee}from"./icon-42fa39e7.js";/* empty css */import{S as T}from"./SettingItemBox-f60eaa4e.js";import{r as Se}from"./chartEditStore-bfc6c223.js";import{n as ke}from"./noData-e5cefb25.js";import{u as ne}from"./useTargetData.hook-06bbbd45.js";import{g as pe}from"./plugin-ae137233.js";import"./index-8433d189.js";import{R as Re,a as $e}from"./pondIndex.vue_vue_type_style_index_0_scoped_bc18493e_lang-51a9fc87.js";import"./EditorWorker-43e8cbc4.js";import"./editorWorker-43a98755.js";import"./chartLayoutStore-810503fe.js";import{l as Oe}from"./index-96c3a075.js";import{u as Ee}from"./useSync.hook-dcdbd18a.js";import{S as j}from"./SettingItem-35031211.js";import{C as He}from"./index-9703cacc.js";import"./index-64867e41.js";import"./CollapseItem.vue_vue_type_script_setup_true_lang-77b092a0.js";import"./index.esm.min-2eecdcbd.js";import"./fileTypeEnum-21359a08.js";import"./project.api-0931840b.js";const Te={class:"go-pr-3"},Ue={key:1},Ne=L({__name:"pondIndex",props:{modelShow:Boolean,targetDataRequest:Object},emits:["update:modelShow","editSaveHandle"],setup(l,{emit:d}){const u=l,{dataSyncUpdate:q}=Ee();$();const x=$(),b=$(!1);X(()=>u.modelShow,r=>{b.value=r});const _=()=>{d("update:modelShow",!1)},v=()=>{var r,y;if(!((r=u.targetDataRequest)!=null&&r.dataPondName)){window.$message.warning("请在左下角输入名称!"),(y=x.value)==null||y.focus();return}pe({message:"保存内容将同步修改所有使用此接口的组件, 是否继续?",isMaskClosable:!0,transformOrigin:"center",onPositiveCallback:()=>{d("update:modelShow",!1),d("editSaveHandle",u.targetDataRequest),q()}})};return(r,y)=>{const w=o("n-space"),p=o("n-scrollbar"),P=o("n-tag"),D=o("n-input"),I=o("n-button"),O=o("n-card"),E=o("n-modal");return i(),H(E,{class:"go-chart-data-request",show:b.value,"onUpdate:show":y[1]||(y[1]=g=>b.value=g),"mask-closable":!1,closeOnEsc:!1},{default:t(()=>[e(O,{bordered:!1,role:"dialog",size:"small","aria-modal":"true",style:{width:"1000px",height:"800px"}},{header:t(()=>[]),"header-extra":t(()=>[]),action:t(()=>[e(w,{justify:"space-between"},{default:t(()=>[l.targetDataRequest?(i(),H(w,{key:0},{default:t(()=>[e(P,{bordered:!1,type:"primary"},{default:t(()=>[h("名称:")]),_:1}),e(D,{value:l.targetDataRequest.dataPondName,"onUpdate:value":y[0]||(y[0]=g=>l.targetDataRequest.dataPondName=g),ref_key:"inputInstRef",ref:x,type:"text",size:"small",autofocus:!0,clearable:!0,minlength:1,maxlength:16,placeholder:"请输入名称"},null,8,["value"])]),_:1})):(i(),C("span",Ue)),e(w,null,{default:t(()=>[e(I,{onClick:_},{default:t(()=>[h("取消")]),_:1}),e(I,{type:"primary",onClick:v},{default:t(()=>[h("保存")]),_:1})]),_:1})]),_:1})]),default:t(()=>[e(p,{style:{"max-height":"718px"}},{default:t(()=>[f("div",Te,[e(w,{vertical:""},{default:t(()=>{var g;return[e(a(Re)),e(a($e),{"target-data-request":(g=l.targetDataRequest)==null?void 0:g.dataPondRequestConfig},null,8,["target-data-request"])]}),_:1})])]),_:1})]),_:1})]),_:1},8,["show"])}}}),ze=V(Ne,[["__scopeId","data-v-bc18493e"]]),Be=l=>(be("data-v-43dfb7fe"),l=l(),ye(),l),Ae={class:"go-chart-data-pond-list"},Fe={class:"pond-item-box"},je=Be(()=>f("span",null," 创建 ",-1)),Le=["onClick"],Me={class:"item-content"},Ge={class:"item-content-body"},Ve=["onClick"],Je=L({__name:"index",emits:["createPond","deletePond"],setup(l,{emit:d}){ie(D=>({"1013e1a5":y.value}));const{DuplicateOutlineIcon:u,TrashIcon:q}=ee.ionicons5,x=_e(),{chartEditStore:b,targetData:_}=ne(),{requestDataPond:v}=Z(b.getRequestGlobalConfig),r=G(()=>_.value.request.requestDataPondId),y=G(()=>x.getAppTheme),w=()=>{d("createPond",!0)},p=(D,I)=>{D.stopPropagation(),D.preventDefault(),d("deletePond",I)},P=D=>{_.value.request.requestDataPondId=D.dataPondId};return(D,I)=>{const O=o("n-timeline-item"),E=o("n-timeline"),g=o("n-icon"),N=o("n-button"),U=o("n-divider"),n=o("n-a"),s=o("n-text"),m=o("n-space"),k=o("n-tag"),S=o("n-ellipsis"),z=o("n-scrollbar");return i(),C("div",Ae,[e(E,{class:"pond-item-timeline",style:{width:"20px"}},{default:t(()=>[e(O,{type:"info"}),e(O,{type:"success"})]),_:1}),f("div",Fe,[e(N,{class:"create-btn go-py-4",ghost:"",onClick:w},{icon:t(()=>[e(g,null,{default:t(()=>[e(a(u))]),_:1})]),default:t(()=>[je]),_:1}),e(U,{style:{margin:"10px 0"}}),a(v).length?te("",!0):(i(),H(m,{key:0,justify:"center"},{default:t(()=>[e(s,{class:"not-layer-text",depth:3},{default:t(()=>[h(" 暂无数据内容, "),e(n,{onClick:w},{default:t(()=>[h("立即创建")]),_:1})]),_:1})]),_:1})),e(z,{style:{"max-height":"490px"}},{default:t(()=>[(i(!0),C(J,null,ae(a(v),c=>(i(),C("div",{key:c.dataPondId,class:de([{select:c.dataPondId===r.value},"pond-item"]),onClick:F=>P(c)},[f("div",Me,[f("div",Ge,[f("div",null,[e(k,{class:"go-mr-1",type:c.dataPondId===r.value?"warning":"",bordered:!1},{default:t(()=>[h(" 名称 ")]),_:2},1032,["type"]),e(S,{style:{"max-width":"180px"}},{default:t(()=>[h(A(c.dataPondName||"暂无"),1)]),_:2},1024)]),f("div",null,[e(k,{class:"go-mr-1",type:c.dataPondId===r.value?"warning":"",bordered:!1},{default:t(()=>[h(" 地址 ")]),_:2},1032,["type"]),e(S,{style:{"max-width":"180px"}},{default:t(()=>[h(A(c.dataPondRequestConfig.requestUrl||"暂无"),1)]),_:2},1024)])]),f("div",{class:"item-content-icon go-transition-quick",onClick:F=>p(F,c)},[e(g,null,{default:t(()=>[e(a(q))]),_:1})],8,Ve)]),f("div",{class:de({"select-modal":c.dataPondId===r.value})},null,2)],10,Le))),128))]),_:1})])])}}});const Qe=V(Je,[["__scopeId","data-v-43dfb7fe"]]),Ye=f("thead",null,[f("tr",null,[f("th",null,"key"),f("th",null,"value")])],-1),ue=L({__name:"displayTable",props:{target:Object},setup(l){const d=l,u={key:"",value:""},q=qe({content:[]});return X(()=>d.target,x=>{q.content=[];for(const b in x)q.content.push({key:b,value:x[b]});q.content.length||(q.content=[JSON.parse(JSON.stringify(u))])},{immediate:!0,deep:!0}),(x,b)=>{const _=o("n-table");return i(),H(_,{bordered:!1,"single-line":!1,size:"small",style:{"border-bottom-right-radius":"7px","border-bottom-left-radius":"7px"}},{default:t(()=>[Ye,f("tbody",null,[(i(!0),C(J,null,ae(q.content,(v,r)=>(i(),C("tr",{key:r},[f("td",null,A(v.key||"暂无"),1),f("td",null,A(v.value||"暂无"),1)]))),128))])]),_:1})}}}),We={class:"go-chart-data-display"},Xe={class:"go-mr-3"},Ke={key:0},Ze={class:"go-mt-3"},et={key:0},tt={key:1},at={key:1},nt=L({__name:"index",props:{globalData:Object,targetData:Object},setup(l){const d=l,{HelpOutlineIcon:u,FlashIcon:q,PulseIcon:x}=ee.ionicons5,{requestUrl:b,requestInterval:_,requestHttpType:v,requestContentType:r,requestSQLContent:y,requestParams:w,requestParamsBodyType:p,requestIntervalUnit:P}=Z(d.targetData.dataPondRequestConfig);B.HEADER;const D={[W.DEFAULT]:"普通请求",[W.SQL]:"SQL 请求"},I=$(B.PARAMS);return(O,E)=>{const g=o("n-input"),N=o("n-icon"),U=o("n-divider"),n=o("n-tab"),s=o("n-tabs"),m=o("n-text"),k=o("n-card"),S=o("n-code"),z=o("n-scrollbar");return i(),C("div",We,[e(z,{style:{"max-height":"570px"}},{default:t(()=>[f("div",Xe,[f("div",null,[e(a(T),{name:"主体信息"},{default:t(()=>[e(a(j),{name:"接口名称"},{default:t(()=>{var c;return[e(g,{size:"small",placeholder:((c=l.targetData)==null?void 0:c.dataPondName)||"暂无",disabled:!0},null,8,["placeholder"])]}),_:1}),e(a(j),{name:"接口类型"},{default:t(()=>[e(g,{size:"small",placeholder:a(v)||"暂无",disabled:!0},null,8,["placeholder"])]),_:1})]),_:1}),e(a(T),null,{default:t(()=>[e(a(j),{name:"组件间隔"},{default:t(()=>[e(g,{size:"small",placeholder:`${a(_)||"暂无"}`,disabled:!0},{suffix:t(()=>[h(A(l.targetData&&a(re)[a(P)]),1)]),_:1},8,["placeholder"])]),_:1}),e(a(j),{name:"全局间隔(默认)"},{default:t(()=>{var c;return[e(g,{size:"small",placeholder:`${((c=l.globalData)==null?void 0:c.requestInterval)||"暂无"}`,disabled:!0},{suffix:t(()=>[h(A(l.globalData&&a(re)[l.globalData.requestIntervalUnit]),1)]),_:1},8,["placeholder"])]}),_:1})]),_:1}),e(a(T),{name:"源地址",alone:!0},{default:t(()=>{var c;return[e(g,{size:"small",placeholder:((c=l.globalData)==null?void 0:c.requestOriginUrl)||"暂无",disabled:!0},{prefix:t(()=>[e(N,{component:a(x)},null,8,["component"])]),_:1},8,["placeholder"])]}),_:1}),e(a(T),{name:"接口地址",alone:!0},{default:t(()=>[e(g,{size:"small",placeholder:a(b)||"暂无",disabled:!0},{prefix:t(()=>[e(N,{component:a(q)},null,8,["component"])]),_:1},8,["placeholder"])]),_:1})]),e(U),e(a(T),{name:"类型"},{default:t(()=>[e(a(j),{name:"配置类型"},{default:t(()=>[e(g,{size:"small",placeholder:l.targetData&&D[a(r)],disabled:!0},null,8,["placeholder"])]),_:1}),a(r)===a(W).DEFAULT?(i(),H(a(j),{key:0,name:"body 类型"},{default:t(()=>[e(g,{size:"small",placeholder:l.targetData&&a(p),disabled:!0},null,8,["placeholder"])]),_:1})):te("",!0)]),_:1}),a(r)===a(W).DEFAULT?(i(),C("div",Ke,[e(s,{type:"line",animated:"",value:I.value,"onUpdate:value":E[0]||(E[0]=c=>I.value=c)},{default:t(()=>[(i(!0),C(J,null,ae(a(B),c=>(i(),H(n,{key:c,name:c,tab:c},{default:t(()=>[h(A(c),1)]),_:2},1032,["name","tab"]))),128))]),_:1},8,["value"]),f("div",Ze,[I.value!==a(B).BODY?(i(),C("div",et,[e(ue,{class:"go-my-3",target:a(w)[I.value]},null,8,["target"])])):(i(),C("div",tt,[a(p)===a(M).NONE?(i(),H(k,{key:0,class:"go-mt-3 go-pb-3"},{default:t(()=>[e(m,{depth:"3"},{default:t(()=>[h("该接口没有 Body 体")]),_:1})]),_:1})):a(p)===a(M).FORM_DATA||a(p)===a(M).X_WWW_FORM_URLENCODED?(i(),H(ue,{key:1,class:"go-my-3",target:a(w)[a(B).BODY][a(p)]},null,8,["target"])):a(p)===a(M).JSON?(i(),H(k,{key:2,size:"small",style:{"padding-bottom":"7px"}},{default:t(()=>[e(S,{code:a(w)[a(B).BODY][a(p)]||"暂无内容",language:"json"},null,8,["code"])]),_:1})):a(p)===a(M).XML?(i(),H(S,{key:3,code:a(w)[a(B).BODY][a(p)]||"",language:"html"},null,8,["code"])):te("",!0)]))])])):(i(),C("div",at,[e(a(T),{name:"键名"},{default:t(()=>[e(m,null,{default:t(()=>[h("sql")]),_:1})]),_:1}),e(a(T),{name:"键值"},{default:t(()=>[e(S,{code:a(y).sql||"",language:"sql"},null,8,["code"])]),_:1})]))])]),_:1})])}}});const ot=V(nt,[["__scopeId","data-v-cc877db2"]]),lt={class:"pond-content"},st={key:1,class:"no-data go-flex-center"},dt=["src"],rt=L({__name:"index",props:{modelShow:Boolean},emits:["update:modelShow","sendHandle"],setup(l,{emit:d}){const u=l,{PencilIcon:q}=ee.ionicons5,{chartEditStore:x,targetData:b}=ne(),{requestDataPond:_}=Z(x.getRequestGlobalConfig),v=$(!1),r=$(!1),y=$(!1),w=$(!1),p=$(),P=G(()=>{var m,k;const n=(k=(m=b==null?void 0:b.value)==null?void 0:m.request)==null?void 0:k.requestDataPondId;return n?_.value.filter(S=>n===S.dataPondId)[0]:void 0});X(()=>u.modelShow,n=>{r.value=n}),X(()=>P.value,n=>{y.value=!0,p.value=n,xe(()=>{y.value=!1})},{immediate:!0});const D=(n=!1)=>{w.value=!!n,v.value=!0},I=()=>{const n=we();p.value={dataPondId:n,dataPondName:n,dataPondRequestConfig:Oe.cloneDeep(Y(Q({},Se),{requestDataType:ce.Pond}))},D()},O=n=>{w.value?E(n):g(n),w.value=!1,v.value=!1},E=n=>{try{const s=_.value.findIndex(m=>m.dataPondId===n.dataPondId);s!==-1?(_.value.splice(s,1,n),x.getComponentList.forEach(m=>{m.request.requestDataType===ce.Pond&&m.request.requestDataPondId===n.dataPondId&&(m.request=Y(Q({},K(n.dataPondRequestConfig)),{requestDataPondId:n.dataPondId}))}),window.$message.success("保存成功!")):window.$message.error("编辑失败,请稍后重试!")}catch(s){window.$message.error("编辑失败,请稍后重试!")}},g=n=>{try{p.value?(_.value.unshift(n),window.$message.success("创建成功!")):window.$message.error("创建失败,请稍后重试!")}catch(s){window.$message.error("创建失败,请稍后重试!")}},N=n=>{pe({message:"删除数据后,需手动处理使用改接口的组件,是否继续?",isMaskClosable:!0,transformOrigin:"center",onPositiveCallback:()=>{const s=_.value.findIndex(m=>m.dataPondId===n.dataPondId);s!==-1?(_.value.splice(s,1),window.$message.success("删除成功!")):window.$message.error("删除失败,请稍后重试!")}})},U=()=>{P.value&&(b.value.request=Y(Q({},K(P.value.dataPondRequestConfig)),{requestDataPondId:P.value.dataPondId})),d("update:modelShow",!1),d("sendHandle")};return(n,s)=>{const m=o("n-text"),k=o("n-icon"),S=o("n-button"),z=o("n-space"),c=o("n-card"),F=o("n-modal");return i(),C(J,null,[e(F,{class:"go-chart-data-pond-control",show:r.value,"onUpdate:show":s[1]||(s[1]=R=>r.value=R),"mask-closable":!1},{default:t(()=>[e(c,{bordered:!1,role:"dialog",size:"small","aria-modal":"true",style:{width:"900px",height:"650px"}},{header:t(()=>[]),"header-extra":t(()=>[]),action:t(()=>[e(z,{justify:"space-between"},{default:t(()=>[e(S,{type:"info",secondary:"",disabled:!P.value,onClick:s[0]||(s[0]=R=>D(!0))},{icon:t(()=>[e(k,null,{default:t(()=>[e(a(q))]),_:1})]),default:t(()=>[h(" 编辑内容 ")]),_:1},8,["disabled"]),e(S,{type:"primary",onClick:U},{default:t(()=>[h("保存 & 发送请求")]),_:1})]),_:1})]),default:t(()=>[f("div",lt,[P.value&&!y.value?(i(),H(a(ot),{key:0,targetData:P.value,globalData:a(x).getRequestGlobalConfig},null,8,["targetData","globalData"])):(i(),C("div",st,[f("img",{src:a(ke),alt:"暂无数据"},null,8,dt),e(m,{depth:3},{default:t(()=>[h("暂未选择公共接口")]),_:1})])),e(a(Qe),{onCreatePond:I,onDeletePond:N})])]),_:1})]),_:1},8,["show"]),e(a(ze),{modelShow:v.value,"onUpdate:modelShow":s[2]||(s[2]=R=>v.value=R),targetDataRequest:p.value,isEdit:w.value,onEditSaveHandle:O},null,8,["modelShow","targetDataRequest","isEdit"])],64)}}});const ct=V(rt,[["__scopeId","data-v-f251a5df"]]),ut={class:"go-chart-data-pond"},it={class:"go-absolute-center"},_t=L({__name:"index",setup(l){ie(n=>({"74c9eabc":g.value}));const d=_e(),{HelpOutlineIcon:u,FlashIcon:q,PulseIcon:x,FishIcon:b}=ee.ionicons5,{targetData:_,chartEditStore:v}=ne(),{requestDataPond:r,requestInterval:y,requestIntervalUnit:w}=Z(v.getRequestGlobalConfig),p=$(!1),P=$(!1),D=$(!1);let I=0,O;const E=G(()=>{const n=_.value.request.requestDataPondId;return n?r.value.filter(m=>n===m.dataPondId)[0]:void 0}),g=G(()=>d.getAppTheme),N=()=>{P.value=!0},U=()=>se(this,null,function*(){var n;if(!((n=_.value)!=null&&n.request)){window.$message.warning("请选择一个公共接口!");return}p.value=!0;try{const s=yield Ie(K(_.value.request),K(v.getRequestGlobalConfig));if(p.value=!1,s){!(s!=null&&s.data)&&!_.value.filter&&window.$message.warning("您的数据不符合默认格式,请配置过滤器!"),_.value.option.dataset=Ce(s==null?void 0:s.data,s,_.value.filter),D.value=!0;return}window.$message.warning("没有拿到返回值,请检查接口!")}catch(s){console.error(s),p.value=!1,window.$message.warning("数据异常,请检查参数!")}});return Pe(()=>{var s;const n=(s=_.value)==null?void 0:s.filter;O!==n&&I&&(O=n,U()),I++}),De(()=>{O=null}),(n,s)=>{const m=o("n-icon"),k=o("n-input"),S=o("n-button"),z=o("n-card"),c=o("n-tooltip"),F=o("go-skeleton");return i(),C(J,null,[f("div",ut,[e(z,{class:"n-card-shallow"},{default:t(()=>[e(a(T),{name:"请求名称",alone:!0},{default:t(()=>{var R;return[e(k,{size:"small",placeholder:((R=E.value)==null?void 0:R.dataPondName)||"暂无",disabled:!0},{prefix:t(()=>[e(m,{component:a(b)},null,8,["component"])]),_:1},8,["placeholder"])]}),_:1}),e(a(T),{name:"接口地址",alone:!0},{default:t(()=>{var R;return[e(k,{size:"small",placeholder:((R=E.value)==null?void 0:R.dataPondRequestConfig.requestUrl)||"暂无",disabled:!0},{prefix:t(()=>[e(m,{component:a(q)},null,8,["component"])]),_:1},8,["placeholder"])]}),_:1}),f("div",{class:"edit-text",onClick:N},[f("div",it,[e(S,{type:"primary",secondary:""},{default:t(()=>[h("编辑配置")]),_:1})])])]),_:1})]),e(a(T),{alone:!0},{name:t(()=>[h(" 测试 "),e(c,{trigger:"hover"},{trigger:t(()=>[e(m,{size:"21",depth:3},{default:t(()=>[e(a(u))]),_:1})]),default:t(()=>[h(" 默认赋值给 dataset 字段 ")]),_:1})]),default:t(()=>[e(S,{type:"primary",ghost:"",onClick:U},{icon:t(()=>[e(m,null,{default:t(()=>[e(a(q))]),_:1})]),default:t(()=>[h(" 发送请求 ")]),_:1})]),_:1}),e(a(He),{show:D.value&&!p.value,ajax:!0},null,8,["show"]),e(F,{load:p.value,repeat:3},null,8,["load"]),e(a(ct),{modelShow:P.value,"onUpdate:modelShow":s[0]||(s[0]=R=>P.value=R),onSendHandle:U},null,8,["modelShow"])],64)}}});const Ut=V(_t,[["__scopeId","data-v-8bb854f3"]]);export{Ut as default};
|