UNPKG

goldpankit

Version:

GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。

7 lines 59.7 kB
import{C as E}from"./CompilerSelect-1ffaffb2.js";import{_ as $,r,o as m,h as k,w as s,b as i,c as y,F as z,j as N,a3 as Y,Q as G,N as H,a as o,J as U,t as _,a4 as X,T as L,e as v,a5 as oe,a6 as B,g as P,M as re,E as ue,k as W,a7 as de,B as J,K as me,a8 as ce,p as x,l as M,A as Z,$ as pe,a9 as K}from"./index-3e8fc5cf.js";import{g as he,h as fe,i as ee,e as j,j as be,c as te,k as _e}from"./service-13e64073.js";import{c as ve,d as ge,i as le,b as O,s as ie,e as ye}from"./plugin-bccc39d8.js";import{c as ne}from"./QueryModelView-02a3ba77.js";import{p as ke}from"./service.version-ed199669.js";import{O as Ve,a as Q}from"./ServiceCodeErrorWindow-d129634c.js";const Ce={name:"InputTypeSelect",props:{withGroup:{default:!1}}};function Se(e,t,l,p,n,a){const u=r("el-option"),d=r("el-select");return m(),k(d,{class:"input-type-select"},{default:s(()=>[i(u,{value:"input",label:"Input"}),i(u,{value:"number_input",label:"Number Input"}),i(u,{value:"textarea",label:"Textarea"}),i(u,{value:"select",label:"Select"}),i(u,{value:"checkbox",label:"Checkbox"}),i(u,{value:"radio",label:"Radio"}),i(u,{value:"switch",label:"Switch"}),l.withGroup?N("",!0):(m(),y(z,{key:0},[i(u,{value:"datasource",label:"Data Source"}),i(u,{value:"table",label:"Table"}),i(u,{value:"query_model",label:"Query Model"})],64))]),_:1})}const A=$(Ce,[["render",Se],["__scopeId","data-v-72eb8421"]]);const Te={name:"SettingFiles",components:{SortableButton:Y,CompilerSelect:E,InputTypeSelect:A,FormItemTip:G},props:{space:{required:!0},service:{required:!0},plugin:{required:!1}},data(){return{currentNode:null,files:[]}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},fetchFilesApi(){return this.isPlugin?ve:he},saveFileSettingApi(){return this.isPlugin?ge:fe}},methods:{fetchFiles(){this.fetchFilesApi(this.unique).then(e=>{this.files=e.map(t=>(t.withoutIfNotExists=t.withoutIfNotExists==null?!1:t.withoutIfNotExists,t)),H(this.files)}).catch(e=>{this.$tip.apiFailed(e)})},saveFileSetting(){this.saveTimeout!=null&&clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(()=>{this.saveFileSettingApi({...this.unique,type:this.currentNode.type,path:this.currentNode.path,relativePath:this.currentNode.relativePath,compiler:this.currentNode.compiler,withoutIfNotExists:this.currentNode.withoutIfNotExists,enableExpress:this.currentNode.enableExpress,variables:this.currentNode.variables.filter(e=>e.name.trim().length>0)}).then(()=>{}).catch(e=>{this.$tip.apiFailed(e)})},300)},createVariable(){this.currentNode.variables.push({name:"",value:"",compiler:"static",remark:""})},deleteVariable(e){this.currentNode.variables.splice(e,1)},handleNodeClick(e){this.currentNode=e},isFlagFile(e){return e.compiler!=null&&e.compiler!==""||e.withoutIfNotExists!=null&&e.withoutIfNotExists!==!1||e.enableExpress!=null&&e.enableExpress!==""||this.__hasFlagFile(e.children)},__hasFlagFile(e){if(e==null||e.length===0)return!1;for(const t of e)if(this.isFlagFile(t))return!0;return!1}},created(){this.fetchFiles()}},Re={class:"tree"},Ie={class:"files-wrap"},we={class:"search-wrap"},$e={class:"node-label"},Ne={class:"file-setting"},Fe={class:"content-wrap"},ze={key:1,class:"setting-holder"},qe={class:"holder-wrap"};function De(e,t,l,p,n,a){const u=r("el-input"),d=r("Document"),b=r("el-icon"),C=r("Folder"),I=r("el-tree"),h=r("CompilerSelect"),T=r("el-form-item"),R=r("el-switch"),F=r("FormItemTip"),g=r("el-form");return m(),y("div",Re,[o("div",Ie,[o("div",we,[i(u,{placeholder:e.$t("service.settings.file.filterKeyword")},null,8,["placeholder"])]),i(I,{data:n.files,"highlight-current":!0,"empty-text":e.$t("service.settings.file.noFiles"),onNodeClick:a.handleNodeClick},{default:s(({node:c,data:f})=>[o("span",$e,[f.type==="FILE"?(m(),k(b,{key:0},{default:s(()=>[i(d)]),_:1})):f.type==="DIRECTORY"?(m(),k(b,{key:1},{default:s(()=>[i(C)]),_:1})):N("",!0),o("span",{class:U(["filename",{"flag-file":a.isFlagFile(f)}])},_(f.label),3)])]),_:1},8,["data","empty-text","onNodeClick"])]),o("div",Ne,[o("h4",null,_(e.$t("service.settings.file.fileSetting")),1),o("div",Fe,[n.currentNode!=null?(m(),k(g,{key:0},{default:s(()=>[i(T,{label:e.$t("service.settings.file.compiler")},{default:s(()=>[i(h,{modelValue:n.currentNode.compiler,"onUpdate:modelValue":t[0]||(t[0]=c=>n.currentNode.compiler=c),onChange:a.saveFileSetting},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(T,{label:"只有文件在项目中存在时才生效"},{default:s(()=>[i(R,{modelValue:n.currentNode.withoutIfNotExists,"onUpdate:modelValue":t[1]||(t[1]=c=>n.currentNode.withoutIfNotExists=c),onChange:a.saveFileSetting},null,8,["modelValue","onChange"])]),_:1}),i(T,{label:"启用表达式"},{default:s(()=>[i(u,{modelValue:n.currentNode.enableExpress,"onUpdate:modelValue":t[2]||(t[2]=c=>n.currentNode.enableExpress=c),type:"textarea",rows:8,placeholder:e.$t("service.settings.file.enableExpressHolder"),onInput:a.saveFileSetting},null,8,["modelValue","placeholder","onInput"]),n.currentNode.type==="FILE"?(m(),k(F,{key:0,content:"当表达式结果为true字符串时,才会保留该文件!"})):(m(),k(F,{key:1,content:"当表达式结果为true字符串时,会保留该目录下的子文件/目录,但依然会移除该目录!否则整个目录都会被删除!"}))]),_:1})]),_:1})):(m(),y("div",ze,[o("div",qe,[o("h5",null,_(e.$t("service.settings.file.fileSetting")),1),o("p",null,_(e.$t("service.settings.file.fileSettingHolder")),1)])]))])])])}const Jl=$(Te,[["render",De],["__scopeId","data-v-8d90c0b4"]]);const Ee={name:"InitializeView",components:{DatabaseTypeSelect:X,CompilerSelect:E,DirectorySelect:L},props:{spaceName:{required:!0},serviceName:{required:!0},serviceLabel:{required:!1},pluginName:{required:!1},pluginLabel:{required:!1}},data(){return{form:{space:this.spaceName,name:null,version:"1.0.0",compiler:"static",supportedDatabases:[],codespace:""}}},computed:{isInitPlugin(){return this.pluginName!=null}},methods:{initialize(){let e;this.isInitPlugin?e=le({...this.form,service:this.serviceName,name:this.pluginName,label:this.pluginLabel}):e=ee({...this.form,name:this.serviceName,label:this.serviceLabel}),e.then(()=>{this.$emit("initialized",this.form)}).catch(t=>{this.$tip.apiFailed(t)})},fetchConfig(e){let t;this.isInitPlugin?(console.log("查询插件配置",e),t=O({codespace:e})):t=j({codespace:e}),t.then(l=>{l!=null&&(this.form.version=l.version||this.form.version,this.form.compiler=l.compiler||this.form.compiler,this.form.supportedDatabases=l.supportedDatabases||this.form.supportedDatabases)}).catch(l=>{this.$tip.apiFailed(l)})}}},Ue={class:"initialize-wrap"},xe={class:"tip"},Me={class:"directory-select-wrap"},je={class:"opera-bottom"};function Oe(e,t,l,p,n,a){const u=r("DirectorySelect"),d=r("el-button");return m(),y("div",Ue,[o("div",xe,[o("h3",null,_(e.$t("service.settings.initialize.initializeService")),1),o("p",null,_(e.$t("service.settings.initialize.initializeServiceTip")),1)]),o("div",Me,[i(u,{modelValue:n.form.codespace,"onUpdate:modelValue":t[0]||(t[0]=b=>n.form.codespace=b),title:e.$t("service.settings.initialize.selectServiceCodespace"),height:"235px",onChange:a.fetchConfig},null,8,["modelValue","title","onChange"])]),o("div",je,[i(d,{type:"primary",onClick:a.initialize},{default:s(()=>[v(_(e.$t("service.settings.initialize.initializeService")),1)]),_:1},8,["onClick"])])])}const Ql=$(Ee,[["render",Oe],["__scopeId","data-v-315f5e85"]]);const Ae={name:"BuildCommandTypeSelect"};function Be(e,t,l,p,n,a){const u=r("el-option"),d=r("el-select");return m(),k(d,{class:"build-command-type-select"},{default:s(()=>[i(u,{value:"Node",label:"Node"}),i(u,{value:"MySQL",label:"MySQL"}),i(u,{value:"Markdown",label:"Markdown"})]),_:1})}const Pe=$(Ae,[["render",Be],["__scopeId","data-v-3ad07c21"]]);const We={name:"ServiceFileSelectWindow",props:{title:{default:"选择文件"},serviceConfig:{required:!0}},data(){return{visible:!1,paths:[],files:[],selectedFilepath:null}},methods:{open(){console.log("open"),this.visible=!0,this.paths=[this.__getProjectName()],this.__fetchFiles(),this.selectedFilepath=null},confirmSelect(){this.visible=!1;let e=`${this.paths.slice(1).join("/")}/${this.selectedFilepath}`;e.startsWith("/")||(e="/"+e),this.$emit("change",e)},cancelSelect(){this.visible=!1},changePath(e){if(e===this.paths.length-1)return;const t=this.paths.slice(0,e+1);this.__fetchFiles(t,()=>{this.paths.splice(e+1),this.selectedFilepath=null})},openOrSelectFile(e){if(e.type==="DIRECTORY"){const t=JSON.parse(JSON.stringify(this.paths));t.push(e.path),this.__fetchFiles(t,()=>{this.paths.push(e.path),this.selectedFilepath=null});return}this.selectedFilepath=e.path},__fetchFiles(e,t){oe(this.__getAbsolutePath(e)).then(l=>{this.files=l,H(this.files),t&&t()}).catch(l=>{this.$tip.apiFailed(l)})},__getProjectName(){return B.split(this.serviceConfig.codespace).pop()},__getAbsolutePath(e){e==null&&(e=JSON.parse(JSON.stringify(this.paths))),e.shift();let t=B.join([this.serviceConfig.codespace,...e]);return(this.serviceConfig.translator.filepath!=null&&this.serviceConfig.translator.filepath.trim()!==""||this.serviceConfig.translator.content!=null&&this.serviceConfig.translator.content.trim()!=="")&&(t=B.join([this.serviceConfig.codespace,this.serviceConfig.translator.output,...e])),t}}},Ge=["id"],Le={class:"paths"},Je=["onClick"],Qe={class:"files"},Ke=["onClick"],Ye={class:"opera"};function He(e,t,l,p,n,a){const u=r("el-button"),d=r("Folder"),b=r("Document"),C=r("el-icon"),I=r("el-dialog");return m(),k(I,{modelValue:n.visible,"onUpdate:modelValue":t[0]||(t[0]=h=>n.visible=h),"show-close":!1,class:"service-file-select-window","append-to-body":""},{header:s(({close:h,titleId:T,titleClass:R})=>[o("h4",{id:T,class:U(R)},_(l.title),11,Ge),i(u,{class:"button-icon",icon:"Refresh",onClick:a.__fetchFiles},null,8,["onClick"])]),default:s(()=>[o("ul",Le,[(m(!0),y(z,null,P(n.paths,(h,T)=>(m(),y("li",{key:h,onClick:R=>a.changePath(T)},_(h),9,Je))),128))]),o("div",Qe,[o("ul",null,[(m(!0),y(z,null,P(n.files,h=>(m(),y("li",{key:h.path,class:U({"is-file":h.type==="FILE",selected:n.selectedFilepath===h.path}),onClick:T=>a.openOrSelectFile(h)},[i(C,null,{default:s(()=>[h.type==="DIRECTORY"?(m(),k(d,{key:0})):(m(),k(b,{key:1}))]),_:2},1024),o("p",null,_(h.path),1)],10,Ke))),128))])]),o("div",Ye,[i(u,{onClick:a.cancelSelect},{default:s(()=>[v("Cancel")]),_:1},8,["onClick"]),i(u,{type:"primary",disabled:n.selectedFilepath==null,onClick:a.confirmSelect},{default:s(()=>[v("Confirm Select")]),_:1},8,["disabled","onClick"])])]),_:1},8,["modelValue"])}const Xe=$(We,[["render",He]]);const Ze={name:"BuildList",components:{ServiceFileSelectWindow:Xe,DirectorySelect:L,MarkdownEditor:re,Empty:ue,BuildCommandTypeSelect:Pe},props:{builds:{required:!0,type:Array},withUnbuild:{default:!1},serviceConfig:{required:!0}},data(){return{actives:[],varIndex:1,selectFileData:{currentBuild:null}}},watch:{builds:{immediate:!0,handler(){this.__handleBuildList("builds")}},unbuilds:{immediate:!0,handler(){this.__handleBuildList("unbuilds")}}},methods:{handleKeypress(e){console.log(e.keyCode),e.stopPropagation()},handleFileChange(e){this.selectFileData.currentBuild.__filepath=e,this.handleSave()},create(){const e=""+Math.random();this.builds.push({id:e,name:this.__generateBuildName(),type:"Node",contentType:"string",content:"",__readonly:!1,__filepath:""}),this.actives.push(e)},handleChangeType(e,t){t==="Markdown"&&(e.contentType="string"),this.handleSave()},handleSave(){this.$emit("save")},deleteBuild(e){this.builds.splice(e,1),this.handleSave()},openSelectFileWindow(e){this.selectFileData.currentBuild=e,this.$refs.serviceFileSelectWindow.open()},__generateBuildName(){let e;for(;;)if(e=`${this.withUnbuild?"un":""}build${this.varIndex}`,this.varIndex++,this.builds.findIndex(t=>t.name===e)===-1)return e},__handleBuildList(e){this[e]!=null&&this[e].forEach(t=>{t.id=""+Math.random(),t.contentType==="file"&&(t.__filepath=t.content,t.content=""),t.__readonly=!0})}}},et={class:"service-build-list"},tt={class:"toolbar"},lt={key:0},it={key:1},nt={class:"title-wrap"},at={class:"opera"},st=["onClick"],ot={key:0,class:"holder"},rt={key:1},ut={key:1,class:"markdown-wrap"};function dt(e,t,l,p,n,a){const u=r("el-button"),d=r("el-input"),b=r("el-form-item"),C=r("BuildCommandTypeSelect"),I=r("el-form"),h=r("el-tab-pane"),T=r("el-tabs"),R=r("MarkdownEditor"),F=r("Empty"),g=r("ServiceFileSelectWindow");return m(),y("div",et,[o("div",tt,[l.withUnbuild?(m(),y("p",lt,_(e.$t("service.settings.build.unBuildTip")),1)):(m(),y("p",it,_(e.$t("service.settings.build.buildTip")),1)),i(u,{type:"primary",onClick:a.create},{default:s(()=>[v(_(e.$t("common.create")),1)]),_:1},8,["onClick"])]),l.builds.length>0?(m(!0),y(z,{key:0},P(l.builds,(c,f)=>(m(),y("ul",{key:c.id},[o("li",null,[o("div",nt,[i(I,{model:c},{default:s(()=>[i(b,{label:"名称",required:""},{default:s(()=>[i(d,{class:"name",modelValue:c.name,"onUpdate:modelValue":w=>c.name=w,onClick:t[0]||(t[0]=W(()=>{},["stop"])),onKeypress:a.handleKeypress,onInput:a.handleSave},null,8,["modelValue","onUpdate:modelValue","onKeypress","onInput"])]),_:2},1024),i(b,{label:"类型",class:"build-type",required:""},{default:s(()=>[i(C,{class:"type",modelValue:c.type,"onUpdate:modelValue":w=>c.type=w,onChange:w=>a.handleChangeType(c,w)},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1024)]),_:2},1032,["model"]),o("div",at,[i(u,{icon:"Delete",link:"",type:"danger",onClick:W(w=>a.deleteBuild(f),["stop"])},{default:s(()=>[v(_(e.$t("common.delete")),1)]),_:2},1032,["onClick"])])]),c.type!=="Markdown"?(m(),k(T,{key:0,modelValue:c.contentType,"onUpdate:modelValue":w=>c.contentType=w},{default:s(()=>[i(h,{name:"string",label:"文本"},{default:s(()=>[i(d,{modelValue:c.content,"onUpdate:modelValue":w=>c.content=w,type:"textarea",placeholder:e.$t("service.settings.build.buildCommand"),rows:5,onInput:a.handleSave},null,8,["modelValue","onUpdate:modelValue","placeholder","onInput"])]),_:2},1024),i(h,{name:"file",label:"文件"},{default:s(()=>[o("div",{class:"select-holder",onClick:w=>a.openSelectFileWindow(c)},[c.__filepath==null||c.__filepath===""?(m(),y("p",ot,_(e.$t("common.clickToSelectFile")),1)):(m(),y("p",rt,_(c.__filepath),1))],8,st)]),_:2},1024)]),_:2},1032,["modelValue","onUpdate:modelValue"])):(m(),y("div",ut,[i(R,{modelValue:c.content,"onUpdate:modelValue":w=>c.content=w,placeholder:"输入内容将作为构建步骤进行展示",onInput:a.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]))])]))),128)):(m(),k(F,{key:1})),i(g,{ref:"serviceFileSelectWindow","service-config":l.serviceConfig,onChange:a.handleFileChange},null,8,["service-config","onChange"])])}const mt=$(Ze,[["render",dt],["__scopeId","data-v-5a5d45ab"]]);function ct(){return new Worker("/assets/editor.worker-9a091e5f.js")}function pt(){return new Worker("/assets/ts.worker-6f3611ff.js")}self.MonacoEnvironment={getWorker(e,t){return t==="typescript"||t==="javascript"?new pt:new ct}};const ht={name:"Translator",props:{data:{required:!0}},data(){return{saveTimeout:null,filepathCodeEditor:{fullscreen:!1},contentCodeEditor:{fullscreen:!1}}},methods:{handleSave(){this.saveTimeout!=null&&clearTimeout(this.saveTimeout),this.saveTimeout=setTimeout(()=>{this.$emit("save")},300)},exitFullScreen(){this.filepathCodeEditor.fullscreen=!1,this.contentCodeEditor.fullscreen=!1},__initEditor(e,t){const l=de.create(document.querySelector(e),{value:this.data[t],language:"javascript",tabSize:2,readOnly:!1,automaticLayout:!0,fontSize:15,minimap:{enabled:!0}});l.onDidChangeModelContent(p=>{this.data[t]=l.getValue(),this.handleSave()})}},mounted(){this.__initEditor(".translator .filepath-code-editor","filepath"),this.__initEditor(".translator .content-code-editor","content"),document.addEventListener("keydown",e=>{e.key==="Escape"&&this.exitFullScreen()})}},S=e=>(x("data-v-1dfe6d18"),e=e(),M(),e),ft={class:"translator"},bt={class:"translator-item"},_t=S(()=>o("h3",null,"文件路径翻译函数",-1)),vt={class:"code"},gt=S(()=>o("em",null,"function",-1)),yt=S(()=>o("em",null,"(",-1)),kt=S(()=>o("span",null,": 文件路径",-1)),Vt=S(()=>o("span",null,": 文件名",-1)),Ct=S(()=>o("span",null,": 文件后缀",-1)),St=S(()=>o("em",null,")",-1)),Tt=S(()=>o("em",null,"{",-1)),Rt=S(()=>o("p",null,"}",-1)),It={class:"translator-item"},wt=S(()=>o("h3",null,"文件内容翻译函数",-1)),$t={class:"code"},Nt=S(()=>o("em",null,"function",-1)),Ft=S(()=>o("em",null,"(",-1)),zt=S(()=>o("span",null,": 文件路径",-1)),qt=S(()=>o("span",null,": 文件名",-1)),Dt=S(()=>o("span",null,": 文件后缀",-1)),Et=S(()=>o("span",null,": 文件设置",-1)),Ut=S(()=>o("br",null,null,-1)),xt=S(()=>o("span",null,": 文件内容",-1)),Mt=S(()=>o("em",null,")",-1)),jt=S(()=>o("em",null,"{",-1)),Ot=S(()=>o("p",null,"}",-1)),At={class:"toolbar"};function Bt(e,t,l,p,n,a){const u=r("el-button");return m(),y("div",ft,[o("div",bt,[_t,o("p",vt,[gt,v(" translate "),yt,v("filepath"),kt,v(", filename"),Vt,v(", suffix"),Ct,St,v(),Tt,i(u,{type:"primary",onClick:t[0]||(t[0]=d=>n.filepathCodeEditor.fullscreen=!n.filepathCodeEditor.fullscreen)},{default:s(()=>[v("全屏")]),_:1})]),o("div",{class:U(["editor filepath-code-editor",{fullscreen:n.filepathCodeEditor.fullscreen}])},null,2),Rt]),o("div",It,[wt,o("p",$t,[Nt,v(" translate "),Ft,v("filepath"),zt,v(", filename"),qt,v(", suffix"),Dt,v(", setting"),Et,v(","),Ut,v("     content"),xt,Mt,v(),jt,i(u,{type:"primary",onClick:t[1]||(t[1]=d=>n.contentCodeEditor.fullscreen=!n.contentCodeEditor.fullscreen)},{default:s(()=>[v("全屏")]),_:1})]),o("div",{class:U(["editor content-code-editor",{fullscreen:n.contentCodeEditor.fullscreen}])},null,2),Ot]),J(o("div",At,[o("h3",null,_(n.filepathCodeEditor.fullscreen?"文件路径编译函数":"文件内容编译函数"),1),o("img",{src:ce,onClick:t[2]||(t[2]=(...d)=>a.exitFullScreen&&a.exitFullScreen(...d))})],512),[[me,n.filepathCodeEditor.fullscreen||n.contentCodeEditor.fullscreen]])])}const Pt=$(ht,[["render",Bt],["__scopeId","data-v-1dfe6d18"]]);const Wt={name:"BasicSetting",components:{Translator:Pt,FormItemTip:G,BuildList:mt,DirectorySelect:L,DatabaseTypeSelect:X,CompilerSelect:E},props:{space:{required:!0},service:{required:!0},plugin:{required:!1},serviceConfig:{}},data(){return{isWorking:{clone:!1},newCodespace:{changing:!1,value:""},originForm:null,form:{name:"",label:"",version:"",minServiceVersion:"",private:!1,receivable:!1,compiler:"",introduce:"",repository:"",branch:"",supportedDatabases:[],tableFieldDefinitions:[],builds:[],unbuilds:[],prices:[{type:"free",value:0}],translator:{output:"",settings:[]},codespace:""}}},computed:{isPlugin(){return this.plugin!=null},clonable(){return this.form.repository.trim()!==""&&this.form.branch.trim()!==""}},methods:{initData(){for(const e in this.form)e==="label"&&(this.form.label=this.serviceConfig.label||this.serviceConfig.name||this.form.label),this.form[e]=this.serviceConfig[e]||this.form[e];this.form.translator!=null&&(this.form.translator.filepath=this.form.translator.filepath||"",this.form.translator.content=this.form.translator.content||"",this.form.translator.settings&&delete this.form.translator.settings),this.originForm=JSON.parse(JSON.stringify(this.form))},initialize(){this.form.codespace=this.newCodespace.value;let e;this.isPlugin?e=le({space:this.space,service:this.service,name:this.plugin,...this.form}):e=ee({space:this.space,name:this.service,...this.form}),e.then(()=>{this.newCodespace.changing=!1,this.$emit("initialized",this.form)}).catch(t=>{this.$tip.apiFailed(t)})},handleBranchInput(e){(e.startsWith("v")||e.startsWith("V"))&&(e=e.substring(1)),ne(null,e,t=>{t||(this.form.version=e),this.saveConfig()})},clone(){this.isWorking.clone||this.alert(this.$t("gitClone.cloneTip"),this.$t("common.importantTip"),{showCancelButton:!0,cancelButtonText:this.$t("common.cancel"),confirmButtonText:this.$t("gitClone.confirm"),confirmButtonClass:"danger-button"}).then(()=>{this.isWorking.clone=!0,be({space:this.space,service:this.service,plugin:this.plugin}).then(()=>{this.alert(this.$t("gitClone.cloneSuccess")).then(()=>{window.location.reload()}).catch(()=>{})}).catch(e=>{this.alert(this.$t("gitClone.cloneFailed",{message:e.message}),this.$t("gitClone.cloneFailedTitle")).catch(()=>{})}).finally(()=>{this.isWorking.clone=!1})}).catch(()=>{})},changePriceType(e){e==="free"&&(this.form.prices[0].value=0),this.saveConfig()},changeCodespace(){this.newCodespace.changing=!0,this.newCodespace.value=this.form.codespace},fetchConfig(e){let t;this.isPlugin?t=O({codespace:e}):t=j({codespace:e}),t.then(l=>{l!=null&&(this.form.name=l.name||this.form.name,this.form.label=l.label||l.name||this.form.label,this.form.version=l.version||this.form.version,this.form.minServiceVersion=l.minServiceVersion||this.form.minServiceVersion,this.form.introduce=l.introduce||this.form.introduce,this.form.compiler=l.compiler||this.form.compiler,this.form.prices=l.prices||this.form.prices,this.form.supportedDatabases=l.supportedDatabases||this.form.supportedDatabases,this.form.builds=l.builds||this.form.builds,this.form.unbuilds=l.unbuilds||this.form.unbuilds,this.form.translator=l.translator||this.form.translator)}).catch(l=>{this.$tip.apiFailed(l)})},saveConfig(){if(this.newCodespace.changing)return;let e,t;this.isPlugin?(t=ie,e={space:this.space,service:this.service,plugin:this.plugin}):(t=te,e={space:this.space,service:this.service},delete this.form.minServiceVersion),t({...e,...this.form,builds:this.form.builds.map(l=>({name:l.name,type:l.type,content:l.contentType==="file"?l.__filepath:l.content,contentType:l.contentType})),unbuilds:this.form.unbuilds.map(l=>({name:l.name,type:l.type,content:l.contentType==="file"?l.__filepath:l.content,contentType:l.contentType}))}).then(()=>{this.originForm=JSON.parse(JSON.stringify(this.form))}).catch(l=>{this.$tip.apiFailed(l)})}},created(){this.initData()}},Gt=e=>(x("data-v-7639046f"),e=e(),M(),e),Lt={class:"basic-setting"},Jt={class:"wrap"},Qt={class:"repository-input-wrap"},Kt=Gt(()=>o("span",null,"/",-1)),Yt={key:0,class:"codespace-wrap"},Ht={key:0,class:"opera-wrap"};function Xt(e,t,l,p,n,a){const u=r("el-input"),d=r("el-form-item"),b=r("FormItemTip"),C=r("CompilerSelect"),I=r("DatabaseTypeSelect"),h=r("el-button"),T=r("el-checkbox"),R=r("Translator"),F=r("BuildList"),g=r("DirectorySelect"),c=r("el-form");return m(),y("div",Lt,[o("div",Jt,[i(c,{model:n.form},{default:s(()=>[l.plugin==null?(m(),y(z,{key:0},[i(d,{label:e.$t("service.settings.name"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.name,"onUpdate:modelValue":t[0]||(t[0]=f=>n.form.name=f),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.label"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.label,"onUpdate:modelValue":t[1]||(t[1]=f=>n.form.label=f),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)):(m(),y(z,{key:1},[i(d,{label:e.$t("plugin.name"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.name,"onUpdate:modelValue":t[2]||(t[2]=f=>n.form.name=f),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),i(d,{label:e.$t("plugin.label"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.label,"onUpdate:modelValue":t[3]||(t[3]=f=>n.form.label=f),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)),i(d,{label:e.$t("service.settings.version"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.version,"onUpdate:modelValue":t[4]||(t[4]=f=>n.form.version=f),onInput:a.saveConfig},null,8,["modelValue","onInput"]),i(b,{content:"如1.0.0.0,其中最后一个版本号不触发升级提醒!"})]),_:1},8,["label"]),a.isPlugin?(m(),k(d,{key:2,label:"最低兼容的服务版本号",prop:"minServiceVersion"},{default:s(()=>[i(u,{modelValue:n.form.minServiceVersion,"onUpdate:modelValue":t[5]||(t[5]=f=>n.form.minServiceVersion=f),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1})):N("",!0),i(d,{label:e.$t("service.settings.compiler"),prop:"compiler",required:""},{default:s(()=>[i(C,{modelValue:n.form.compiler,"onUpdate:modelValue":t[6]||(t[6]=f=>n.form.compiler=f),onChange:a.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.supportedDatabases"),prop:"supportedDatabases"},{default:s(()=>[i(I,{modelValue:n.form.supportedDatabases,"onUpdate:modelValue":t[7]||(t[7]=f=>n.form.supportedDatabases=f),onChange:a.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.repository"),prop:"repository"},{default:s(()=>[o("div",Qt,[i(u,{class:"repository-input",modelValue:n.form.repository,"onUpdate:modelValue":t[8]||(t[8]=f=>n.form.repository=f),onInput:a.saveConfig},null,8,["modelValue","onInput"]),Kt,i(u,{class:"branch-input",modelValue:n.form.branch,"onUpdate:modelValue":t[9]||(t[9]=f=>n.form.branch=f),placeholder:e.$t("gitClone.branch"),onInput:a.handleBranchInput},null,8,["modelValue","placeholder","onInput"]),i(h,{type:"primary",disabled:n.isWorking.clone||!a.clonable,loading:n.isWorking.clone,onClick:a.clone},{default:s(()=>[v(_(e.$t("gitClone.clone")),1)]),_:1},8,["disabled","loading","onClick"])])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.introduce"),prop:"introduce",required:""},{default:s(()=>[i(u,{type:"textarea",rows:5,modelValue:n.form.introduce,"onUpdate:modelValue":t[10]||(t[10]=f=>n.form.introduce=f),onInput:a.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.otherSettings"),class:"item-other-settings"},{default:s(()=>[o("div",null,[i(T,{modelValue:n.form.private,"onUpdate:modelValue":t[11]||(t[11]=f=>n.form.private=f),label:"私有",onChange:a.saveConfig},null,8,["modelValue","onChange"])])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.translator.translator"),prop:"translator"},{default:s(()=>[i(R,{data:n.form.translator,onSave:a.saveConfig},null,8,["data","onSave"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.installBuilds"),prop:"builds"},{default:s(()=>[i(F,{builds:n.form.builds,"service-config":l.serviceConfig,onSave:a.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.uninstallBuilds"),prop:"unbuilds"},{default:s(()=>[i(F,{builds:n.form.unbuilds,"with-unbuild":!0,"service-config":l.serviceConfig,onSave:a.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.codespace"),prop:"codespace"},{default:s(()=>[n.newCodespace.changing?(m(),k(g,{key:1,title:e.$t("service.settings.selectNewCodespace"),modelValue:n.newCodespace.value,"onUpdate:modelValue":t[12]||(t[12]=f=>n.newCodespace.value=f),onChange:a.fetchConfig},null,8,["title","modelValue","onChange"])):(m(),y("div",Yt,[o("p",null,_(n.form.codespace),1),i(h,{type:"primary",onClick:a.changeCodespace},{default:s(()=>[v(_(e.$t("service.settings.changeCodespace")),1)]),_:1},8,["onClick"])]))]),_:1},8,["label"])]),_:1},8,["model"]),n.newCodespace.changing?(m(),y("div",Ht,[i(h,{onClick:t[13]||(t[13]=f=>n.newCodespace.changing=!1)},{default:s(()=>[v(_(e.$t("common.cancel")),1)]),_:1}),i(h,{type:"primary",onClick:a.initialize},{default:s(()=>[v(_(e.$t("service.settings.reinitialize")),1)]),_:1},8,["onClick"])])):N("",!0)])])}const Kl=$(Wt,[["render",Xt],["__scopeId","data-v-7639046f"]]),Zt={name:"PublishWindow",components:{FormItemTip:G},data(){return{visible:!1,isWorking:!1,space:null,service:null,plugin:null,form:{version:"",publishDescription:""}}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},fetchConfigApi(){return this.isPlugin?j:O},saveConfigApi(){return this.isPlugin?ie:te}},methods:{open(e,t,l){this.space=e,this.service=t,this.plugin=l,this.visible=!0,this.fetchConfig()},getRules(){return{version:[{required:!0,message:this.$t("form.isRequired",{value:this.$t("service.versionNumber")})},{validator:ne,message:this.$t("form.isIncorrect",{field:this.$t("service.versionNumber")})}],publishDescription:[{required:!0,message:this.$t("form.isRequired",{value:this.$t("service.versionDescription")})}]}},fetchConfig(){this.fetchConfigApi(this.unique).then(e=>{this.form.version=e.version}).catch(e=>{this.$tip.apiFailed(e)})},saveConfig(){this.saveConfigApi({...this.unique,version:this.form.version}).catch(e=>{this.$tip.apiFailed(e)})},publish(){this.$refs.form.validate().then(()=>{this.isWorking||(this.isWorking=!0,ke({...this.unique,publishDescription:this.form.publishDescription}).then(()=>{this.visible=!1,this.$message.success("发布成功")}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.isWorking=!1}))})}}},el={class:"dialog-footer"};function tl(e,t,l,p,n,a){const u=r("el-input"),d=r("FormItemTip"),b=r("el-form-item"),C=r("el-form"),I=r("el-button"),h=r("el-dialog"),T=Z("loading");return m(),k(h,{modelValue:n.visible,"onUpdate:modelValue":t[3]||(t[3]=R=>n.visible=R),class:"publish-window",title:e.$t("service.settings.publishVersion"),width:"500px",draggable:"","close-on-press-escape":!1,"close-on-click-modal":!1},{footer:s(()=>[o("span",el,[i(I,{disabled:n.isWorking,onClick:t[2]||(t[2]=R=>n.visible=!1)},{default:s(()=>[v(_(e.$t("common.cancel")),1)]),_:1},8,["disabled"]),i(I,{type:"primary",disabled:n.isWorking,onClick:a.publish},{default:s(()=>[v(_(e.$t("service.settings.publish")),1)]),_:1},8,["disabled","onClick"])])]),default:s(()=>[J((m(),k(C,{ref:"form",model:n.form,rules:a.getRules()},{default:s(()=>[i(b,{label:e.$t("service.versionNumber"),prop:"version",required:""},{default:s(()=>[i(u,{modelValue:n.form.version,"onUpdate:modelValue":t[0]||(t[0]=R=>n.form.version=R),onInput:a.saveConfig},{prefix:s(()=>[v("v")]),_:1},8,["modelValue","onInput"]),i(d,{content:"如1.0.0.0,其中最后一个版本号不触发升级提醒!"})]),_:1},8,["label"]),i(b,{label:e.$t("service.versionDescription"),prop:"publishDescription",required:""},{default:s(()=>[i(u,{type:"textarea",rows:5,modelValue:n.form.publishDescription,"onUpdate:modelValue":t[1]||(t[1]=R=>n.form.publishDescription=R)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["model","rules"])),[[T,n.isWorking]])]),_:1},8,["modelValue","title"])}const Yl=$(Zt,[["render",tl]]);const ll={name:"OptionSettingWindow",components:{OptionValueInput:Ve},data(){return{visible:!1,option:null}},methods:{open(e){this.option=e,this.visible=!0},add(){this.option.settings.push({label:"",name:"",inputType:"input",required:!0,defaultValue:""})},deleteSetting(e){this.option.settings.splice(e,1),this.emitChange()},emitChange(){this.$emit("change")}}},il={class:"toolbar"};function nl(e,t,l,p,n,a){const u=r("el-button"),d=r("el-input"),b=r("el-table-column"),C=r("el-option"),I=r("el-select"),h=r("el-switch"),T=r("OptionValueInput"),R=r("el-table"),F=r("el-dialog");return m(),k(F,{modelValue:n.visible,"onUpdate:modelValue":t[0]||(t[0]=g=>n.visible=g),title:e.$t("service.settings.variable.optionSettings"),"append-to-body":"",class:"option-setting-window"},{default:s(()=>[o("div",il,[i(u,{icon:"Plus",type:"primary",onClick:a.add},{default:s(()=>[v(_(e.$t("common.add")),1)]),_:1},8,["onClick"])]),i(R,{data:n.option.settings},{default:s(()=>[i(b,{prop:"label",label:e.$t("service.settings.variable.label")},{default:s(({row:g})=>[i(d,{modelValue:g.label,"onUpdate:modelValue":c=>g.label=c,onInput:a.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(b,{prop:"name",label:e.$t("service.settings.variable.name")},{default:s(({row:g})=>[i(d,{modelValue:g.name,"onUpdate:modelValue":c=>g.name=c,onInput:a.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(b,{prop:"inputType",label:e.$t("service.settings.variable.inputType")},{default:s(({row:g})=>[i(I,{modelValue:g.inputType,"onUpdate:modelValue":c=>g.inputType=c,onChange:a.emitChange},{default:s(()=>[i(C,{value:"input",label:"Input"}),i(C,{value:"number_input",label:"Number Input"}),i(C,{value:"textarea",label:"Textarea"})]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])]),_:1},8,["label"]),i(b,{prop:"required",label:e.$t("service.settings.variable.required")},{default:s(({row:g})=>[i(h,{modelValue:g.required,"onUpdate:modelValue":c=>g.required=c},null,8,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),i(b,{prop:"defaultValue",label:e.$t("service.settings.variable.defaultValue")},{default:s(({row:g})=>[i(T,{"option-setting":g,modelValue:g.defaultValue,"onUpdate:modelValue":c=>g.defaultValue=c,onInput:a.emitChange},null,8,["option-setting","modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(b,{width:"60px"},{default:s(({row:g,$index:c})=>[i(u,{icon:"Delete",onClick:f=>a.deleteSetting(c)},null,8,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1},8,["modelValue","title"])}const al=$(ll,[["render",nl]]),sl={name:"VariableSettingForm",components:{OptionSettingWindow:al,SortableButton:Y,VariableInput:Q,CompilerSelect:E,InputTypeSelect:A},props:{variable:{required:!0},rootVariable:{required:!0},variableGroup:{default:!1}},computed:{withGroup(){return this.variableGroup!=null}},watch:{"variable.defaultValue":function(){this.handleFieldVariableValues(),this.handleChange()},"variable.name":function(){this.handleFieldVariableValues(),this.handleChange()}},methods:{focus(){this.$refs.labelInput.focus()},handleChange(){this.$emit("change")},handleDefaultValueChange(){this.handleFieldVariableValues(),this.$emit("change")},handleFieldVariableValues(){if(this.rootVariable!==this.variable&&(this.rootVariable.inputType==="query_model"||this.rootVariable.inputType==="table")){for(const e of this.rootVariable.children)if(e.defaultValue!=null)for(const t of e.defaultValue){t[this.variable.name]=this.variable.defaultValue;for(const l in t){if(l==="origin")continue;e.children.find(n=>n.name===l)==null&&!t.origin.hasOwnProperty(l)&&delete t[l]}}}},createOption(){this.variable.options.push({value:"",label:"",remark:"",settings:[]}),this.handleChange()},deleteOption(e){this.variable.options.splice(e,1),this.handleChange()},handleInputTypeChange(){let e=this.variable.defaultValue;if(e!=null&&e.value!=null&&(e=e.value),e instanceof Array&&(e=e[0]),typeof e=="number"&&(e=e+""),this.variable.inputType==="number_input"){let t=Number(parseInt(e));isNaN(t)&&(t=0),this.variable.defaultValue=t}else if(this.variable.inputType==="select"){const t=this.variable.options.find(l=>l.value===e);this.variable.defaultValue={value:t==null?null:e,settings:t==null?[]:t.settings}}else this.variable.inputType==="checkbox"?this.variable.defaultValue=[]:this.variable.inputType==="radio"?this.variable.defaultValue="":this.variable.inputType==="datasource"||this.variable.inputType==="table"||this.variable.inputType==="query_model"?this.variable.defaultValue=null:this.variable.defaultValue=e;this.handleChange()},handleOptionSorted(e){this.variable.options=[],this.$nextTick(()=>{this.variable.options=e,this.handleChange()})}}},ol=o("label",null,"值选项列表",-1),rl={class:"opera"};function ul(e,t,l,p,n,a){const u=r("el-input"),d=r("el-form-item"),b=r("InputTypeSelect"),C=r("el-button"),I=r("SortableButton"),h=r("el-table-column"),T=r("el-table"),R=r("OptionSettingWindow"),F=r("VariableInput"),g=r("el-switch"),c=r("CompilerSelect"),f=r("el-form"),w=Z("sortable");return m(),k(f,{model:l.variable},{default:s(()=>[i(d,{label:"变量提示",required:""},{default:s(()=>[i(u,{ref:"labelInput",modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=V=>l.variable.label=V),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1}),i(d,{label:"变量名",required:""},{default:s(()=>[i(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=V=>l.variable.name=V),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1}),i(d,{label:"输入类型",required:""},{default:s(()=>[i(b,{modelValue:l.variable.inputType,"onUpdate:modelValue":t[2]||(t[2]=V=>l.variable.inputType=V),"with-group":a.withGroup,onChange:a.handleInputTypeChange},null,8,["modelValue","with-group","onChange"])]),_:1}),l.variable.inputType==="select"||l.variable.inputType==="checkbox"||l.variable.inputType==="radio"?(m(),k(d,{key:0,class:"item-options",required:""},{label:s(()=>[o("div",null,[ol,o("div",rl,[i(C,{size:"default",type:"primary",onClick:a.createOption},{default:s(()=>[v("添加")]),_:1},8,["onClick"])])])]),default:s(()=>[J((m(),k(T,{data:l.variable.options},{default:s(()=>[i(h,{"class-name":"table-column-sortable",width:"30px",fixed:""},{default:s(()=>[i(I)]),_:1}),i(h,{label:"*名称","min-width":"200px"},{default:s(({row:V})=>[i(u,{modelValue:V.label,"onUpdate:modelValue":q=>V.label=q,size:"large",type:"textarea",rows:1,onInput:a.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1}),i(h,{label:"*"+e.$t("service.settings.variable.optionValue"),"min-width":"120px"},{default:s(({row:V})=>[i(u,{modelValue:V.value,"onUpdate:modelValue":q=>V.value=q,onInput:a.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),i(h,{label:e.$t("common.remark"),"min-width":"150px"},{default:s(({row:V})=>[i(u,{modelValue:V.remark,"onUpdate:modelValue":q=>V.remark=q,type:"textarea",rows:1,onInput:a.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),l.variable.options.length>0?(m(),k(h,{key:0,"min-width":l.variable.inputType==="select"?"120px":"60px",fixed:"right"},{default:s(({row:V,$index:q})=>[l.variable.inputType==="select"?(m(),k(C,{key:0,icon:"Setting",class:"button-icon",onClick:se=>e.$refs.optionSettingWindow.open(V)},null,8,["onClick"])):N("",!0),i(C,{icon:"Delete",class:"button-icon",onClick:se=>a.deleteOption(q)},null,8,["onClick"])]),_:1},8,["min-width"])):N("",!0)]),_:1},8,["data"])),[[w,{handle:".sortable-button",data:l.variable.options,onChange:a.handleOptionSorted},"config"]]),i(R,{ref:"optionSettingWindow",onChange:a.handleChange},null,8,["onChange"])]),_:1})):N("",!0),i(d,{label:"默认值"},{default:s(()=>[i(F,{variable:l.variable,"value-key":"defaultValue",onChange:a.handleDefaultValueChange},null,8,["variable","onChange"])]),_:1}),i(d,{label:e.$t("service.settings.variable.required")},{default:s(()=>[i(g,{modelValue:l.variable.required,"onUpdate:modelValue":t[3]||(t[3]=V=>l.variable.required=V),onChange:a.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.variable.hidden")},{default:s(()=>[i(g,{modelValue:l.variable.hidden,"onUpdate:modelValue":t[4]||(t[4]=V=>l.variable.hidden=V),onChange:a.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"]),l.variable.inputType!=="number_input"&&l.variable.inputType!=="table"&&l.variable.inputType!=="query_model"&&l.variable.inputType!=="datasource"&&l.rootVariable.inputType!=="query_model"&&l.rootVariable.inputType!=="table"?(m(),k(d,{key:1,label:"编译器"},{default:s(()=>[i(c,{modelValue:l.variable.compiler,"onUpdate:modelValue":t[5]||(t[5]=V=>l.variable.compiler=V),onChange:a.handleChange},null,8,["modelValue","onChange"])]),_:1})):N("",!0),i(d,{label:e.$t("common.remark")},{default:s(()=>[i(u,{modelValue:l.variable.remark,"onUpdate:modelValue":t[6]||(t[6]=V=>l.variable.remark=V),type:"textarea",rows:3,onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const dl=$(sl,[["render",ul]]),ml={name:"VariableGroupSettingForm",components:{VariableInput:Q,CompilerSelect:E,InputTypeSelect:A},props:{variable:{required:!0}},methods:{changeScope(){if(this.variable.type==="group")for(const e of this.variable.children)e.scope=this.variable.scope;this.handleChange()},handleChange(){this.$emit("change")}}};function cl(e,t,l,p,n,a){const u=r("el-input"),d=r("el-form-item"),b=r("el-form");return m(),k(b,{model:l.variable},{default:s(()=>[i(d,{label:e.$t("service.settings.variable.groupLabel"),required:""},{default:s(()=>[i(u,{modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=C=>l.variable.label=C),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),i(d,{label:e.$t("service.settings.variable.groupName"),required:""},{default:s(()=>[i(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=C=>l.variable.name=C),onInput:a.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const pl=$(ml,[["render",cl]]);const hl={name:"Variables",components:{VariableGroupSettingForm:pl,VariableSettingForm:dl,VariableInput:Q,I18nInput:pe,InputTypeSelect:A,CompilerSelect:E},props:{space:{required:!0},service:{required:!0},plugin:{required:!1}},data(){return{isWorking:{save:!1},timeout:{save:null},varIndex:1,groupIndex:1,currentVariable:null,currentGroup:null,currentRootVariable:null,variables:[],dragData:{target:null}}},computed:{isPlugin(){return this.plugin!=null},unique(){return this.isPlugin?{space:this.space,service:this.service,plugin:this.plugin}:{space:this.space,service:this.service}},saveVariablesApi(){return this.isPlugin?ye:_e},fetchConfigApi(){return this.isPlugin?O:j}},methods:{selectVariable(e,t){this.currentVariable=null,this.$nextTick(()=>{this.currentVariable=e,this.currentGroup=null,this.currentRootVariable=null,t.level>2?(this.currentRootVariable=t.parent.parent.data,this.currentGroup=t.parent.data):t.level>1?(this.currentRootVariable=t.parent.data,this.currentGroup=t.parent.data):this.currentRootVariable=t.data})},createChild(e){if(e.type==="group"){this.createVariable(e);return}if(e.inputType==="query_model"){this.createGroup(e,[]);return}e.inputType==="table"&&this.createGroup(e,[])},createVariable(e){const t=this.__generateVariableName(e==null?this.variables:e.children),l={id:K(),type:"variable",name:t,label:t,inputType:"input",required:!1,hidden:!1,defaultValue:"",compiler:"static",remark:"",options:[]};e!=null?e.children.push(l):this.variables.push(l),this.saveVariables(),this.$nextTick(()=>{const p=this.$refs.tree.getNode(l);this.selectVariable(l,p),this.$refs.tree.setCurrentKey(l.id),this.$nextTick(()=>{this.$refs.variableSettingForm.focus()})})},createGroup(e,t){const l=this.__generateGroupName(),p={id:K(),type:"group",name:l,label:l,children:[],defaultValue:t};e==null?this.variables.push(p):(e.children==null&&(e.children=[]),e.children.push(p)),this.currentVariable=p,this.saveVariables()},saveVariables(){this.timeout.save!=null&&clearTimeout(this.timeout.save),this.timeout.save=setTimeout(()=>{this.saveVariablesApi({...this.unique,variables:this.getVariables()}).then(()=>{}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.timeout.save=null})},300)},fetchVariables(){this.fetchConfigApi({...this.unique}).then(e=>{this.variables=e.variables.map(t=>this.__getInitVariable(t))}).catch(e=>{this.$tip.apiFailed(e)})},getVariables(){return this.variables.filter(t=>t.name.trim().length>0&&t.label.trim().length>0).map(t=>this.__getSaveVariable(t))},deleteVariable(){const e=this.currentVariable.type==="variable"?"变量":"变量组";this.deleteConfirm(`确认删除 ${e} 「${this.currentVariable.label}」?删除后无法恢复!`).then(()=>{if(this.currentRootVariable!==this.currentVariable&&(this.currentRootVariable.inputType==="query_model"||this.currentRootVariable.inputType==="table")&&this.currentGroup!=null){const l=this.currentGroup.children.findIndex(p=>p.id===this.currentVariable.id);if(l===-1)return;this.currentGroup.children.splice(l,1);for(const p of this.currentRootVariable.children)for(const n of p.defaultValue)for(const a in n){if(a==="origin")continue;p.children.find(d=>d.name===a)==null&&!n.origin.hasOwnProperty(a)&&delete n[a]}this.currentVariable=null,this.saveVariables();return}if(this.currentGroup!=null){const l=this.currentGroup.children.findIndex(p=>p.id===this.currentVariable.id);if(l===-1)return;this.currentGroup.children.splice(l,1),this.currentVariable=null,this.saveVariables();return}const t=this.variables.findIndex(l=>l.id===this.currentVariable.id);t!==-1&&(this.variables.splice(t,1),this.currentVariable=null,this.saveVariables())}).catch(t=>{if(t!=="cancel")throw new Error(t)})},handleDragStart(e){this.dragData.target=e.data},handleDrop(){this.saveVariables()},allowDrag(){return!0},allowDrop(e,t,l){return e.data.type==="variable"?!(t.data.type==="variable"&&l==="inner"):e.data.type==="group"?t.data.type!=="variable":!1},__getValidOptions(e){return e.filter(t=>t.value.trim().length>0&&t.label.trim().length>0)},__getInitVariable(e){const t=JSON.parse(JSON.stringify(e));return t.type==="group"?(t.children=t.children==null?[]:t.children.map(l=>(l.options=l.options==null?[]:l.options,this.__getInitVariable(l))),t):(t.options=t.options==null?[]:t.options,t.options.forEach(l=>{l.settings=l.settings==null?[]:l.settings}),t.inputType==="select"&&(JSON.stringify(t.defaultValue.settings)==="{}"||t.options.forEach(l=>{l.settings=l.settings.map(p=>({...p,value:t.defaultValue.settings[p.name]}))})),t)},__getSaveVariable(e){const t=JSON.parse(JSON.stringify(e));return t.type==="group"?(t.children=t.children.map(l=>this.__getSaveVariable(l)),t):t.inputType==="number_input"?(t.defaultValue=parseInt(t.defaultValue),t):t.inputType==="query_model"||t.inputType==="table"?(t.children!=null&&t.children.length>0&&(t.children=t.children.map(l=>(l.children=l.children.map(p=>({...this.__getSaveVariable(p),origin:void 0,table:void 0})),l))),delete t.options,t):t.inputType==="select"?(t.options=this.__getValidOptions(t.options),t.options.forEach(l=>{l.settings=l.settings.filter(p=>p.name.trim()!==""&&p.label.trim()!=="")}),t.options.forEach(l=>{l.settings.forEach(p=>{delete p.value})}),t):t.inputType==="radio"||t.inputType==="checkbox"?(t.options=this.__getValidOptions(t.options),t.options.forEach(l=>{delete l.settings}),t):(delete t.options,t)},__generateVariableName(e){let t;for(;;)if(t=`var${this.varIndex}`,this.varIndex++,e.findIndex(l=>l.type==="variable"&&l.name===t)===-1)return t},__generateGroupName(){let e;for(;;)if(e=`group${this.groupIndex}`,this.groupIndex++,this.variables.findIndex(t=>t.type==="group"&&t.name===e)===-1)return e}},created(){this.fetchVariables()}},ae=e=>(x("data-v-aaadc8ba"),e=e(),M(),e),fl={class:"tree"},bl={class:"variables-wrap"},_l={class:"tools"},vl={class:"title"},gl={key:0,class:"opera"},yl={class:"variable-setting"},kl={class:"title"},Vl=ae(()=>o("h4",null,"变量设置",-1)),Cl={class:"content-wrap"},Sl={key:1,class:"variable-holder"},Tl=ae(()=>o("h5",null,"变量和变量组设置",-1));function Rl(e,t,l,p,n,a){const u=r("el-button"),d=r("el-tree"),b=r("VariableSettingForm"),C=r("VariableGroupSettingForm");return m(),y("div",fl,[o("div",bl,[o("div",_l,[i(u,{icon:"Plus",type:"primary",onClick:t[0]||(t[0]=I=>a.createVariable())},{default:s(()=>[v(_(e.$t("service.settings.variable.addVariable")),1)]),_:1}),i(u,{icon:"Plus",type:"primary",onClick:t[1]||(t[1]=I=>a.createGroup(null,"service"))},{default:s(()=>[v(_(e.$t("service.settings.variable.addGroup")),1)]),_:1})]),i(d,{ref:"tree",class:"variables","expand-on-click-node":!1,"default-expand-all":!0,"highlight-current":!0,data:n.variables,"node-key":"id",onNodeClick:a.selectVariable,draggable:"","allow-drop":a.allowDrop,"allow-drag":a.allowDrag,"empty-text":e.$t("service.settings.variable.noVariables"),onNodeDragStart:a.handleDragStart,onNodeDrop:a.handleDrop},{default:s(({node:I,data:h})=>[o("div",vl,[o("span",null,_(h.label),1),h.type==="group"||h.inputType==="query_model"||h.inputType==="table"?(m(),y("div",gl,[i(u,{class:"button-icon",icon:"Plus",size:"small",onClick:W(T=>a.createChild(h),["stop"])},null,8,["onClick"])])):N("",!0)])]),_:1},8,["data","onNodeClick","allow-drop","allow-drag","empty-text","onNodeDragStart","onNodeDrop"])]),o("div",yl,[o("div",kl,[Vl,n.currentVariable!=null?(m(),k(u,{key:0,size:"default",type:"danger",link:"",onClick:a.deleteVariable},{default:s(()=>[v("删除变量")]),_:1},8,["onClick"])):N("",!0)]),o("div",Cl,[n.currentVariable!=null?(m(),y(z,{key:0},[n.currentVariable.type==="variable"?(m(),k(b,{key:0,ref:"variableSettingForm",variable:n.currentVariable,"variable-group":n.currentGroup,"root-variable":n.currentRootVariable,onChange:a.saveVariables},null,8,["variable","variable-group","root-variable","onChange"])):N("",!0),n.currentVariable.type==="group"?(m(),k(C,{key:1,variable:n.currentVariable,onChange:a.saveVariables},null,8,["variable","onChange"])):N("",!0)],64)):(m(),y("div",Sl,[Tl,o("p",null,"点击左侧变量来打开变量或变量组设置。如无法获取变量值,请留意"+_(l.plugin==null?"服务":"插件")+"设置中选择的编译器。",1)]))])])])}const Hl=$(hl,[["render",Rl],["__scopeId","data-v-aaadc8ba"]]);const Il={name:"SystemVariableTable",data(){return{variableData:{date:[{name:"_yyyy",enRemark:"",zhRemark:"年(固定4位)",demo:"${_yyyy} => 1993"},{name:"_MM",enRemark:"",zhRemark:"月(固定2位)",demo:"${_MM} => 08"},{name:"_dd",enRemark:"",zhRemark:"日前(固定2位)",demo:"${_dd} => 13"},{name:"_hh",enRemark:"",zhRemark:"时(固定2位)",demo:"${_hh} => 00"},{name:"_mm",enRemark:"",zhRemark:"分(固定2位)",demo:"${_mm} => 00"},{name:"_ss",enRemark:"",zhRemark:"秒(固定2位)",demo:"${_ss} => 00"},{name:"_sss",enRemark:"",zhRemark:"毫秒(固定3位)",demo:"${_sss} => 000"}],mysqlTable:[{name:"name",enRemark:"",zhRemark:"原始表名",demo:"${myTable.name} => MY_TABLE"},{name:"camelCaseName",enRemark:"",zhRemark:"表名(驼峰命名法)",demo:"${myTable.camelCaseName} => myTable"},{name:"kebabCaseName",enRemark:"",zhRemark:"表名(中划线命名法)",demo:"${myTable.kebabCaseName} => my-table"},{name:"pascalCaseName",enRemark:"",zhRemark:"表名(帕斯卡命名法)",demo:"${myTable.pascalCaseName} => MyTable"},{name:"underScoreCaseName",enRemark:"",zhRemark:"表名(下划线命名法)",demo:"${myTable.underScoreCaseName} => my_table"},{name:"alias",enRemark:"",zhRemark:"表别名,默认与表名一致",demo:"${myTable.alias} => MY_ALIAS"},{name:"camelCaseAlias",enRemark:"",zhRemark:"表别名(驼峰命名法)",demo:"${myTable.camelCaseAlias} => myAlias"},{name:"kebabCaseAlias",enRemark:"",zhRemark:"表别名(中划线命名法)",demo:"${myTable.kebabCaseAlias} => my-alias"},{name:"pascalCaseAlias",enRemark:"",zhRemark:"表别名(帕斯卡命名法)",demo:"${myTable.pascalCaseAlias} => MyAlias"},{name:"underScoreCaseAlias",enRemark:"",zhRemark:"表名(下划线命名法)",demo:"${myTable.underScoreCaseAlias} => my_alias"},{name:"comment",enRemark:"",zhRemark:"表注释",demo:"${myTable.comment}"},{name:"pk",enRemark:"",zhRemark:"表字段数组",type:"Array",demo:`<#if myTable.pk??> \${myTable.pk.name} </#list>`},{name:"fields",enRemark:"",zhRemark:"表字段数组",type:"Array",demo:`<#list myTable.fields as field> \${field.name} </#list>`},{name:"fields.name",enRemark:"",zhRemark:"字段原始名称",type:"String",demo:`<#list myTable.fields as field> \${field.name} </#list>`},{name:"fields.camelCaseName",enRemark:"",zhRemark:"字段名称(驼峰命名法)",ty