UNPKG

goldpankit

Version:

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

1 lines 63.3 kB
import{C as D}from"./CompilerSelect-7aabdd8e.js";import{_ as R,r as o,o as c,g as y,w as n,b as a,c as V,F,i as N,a1 as G,K as J,a as r,H as P,t as p,a2 as Y,R as j,e as T,a3 as oe,a4 as M,f as U,E as H,j as A,p as x,k as L,z as K,A as X,Y as re,a5 as Q}from"./index-ea6b6181.js";import{g as ue,h as de,i as Z,e as B,j as me,c as ee,k as ce}from"./service-13aca3c0.js";import{c as pe,d as he,i as te,b as E,s as le,e as fe}from"./plugin-48f79614.js";import{a as ae}from"./form.check-189b470c.js";import{p as be}from"./service.version-aeeb6e53.js";import{O as _e,a as W}from"./ServiceCodeErrorWindow-febfc003.js";const ve={name:"InputTypeSelect",props:{withGroup:{default:!1}}};function ge(e,t,l,h,s,i){const u=o("el-option"),m=o("el-select");return c(),y(m,{class:"input-type-select"},{default:n(()=>[a(u,{value:"input",label:"Input"}),a(u,{value:"number_input",label:"Number Input"}),a(u,{value:"textarea",label:"Textarea"}),a(u,{value:"select",label:"Select"}),a(u,{value:"checkbox",label:"Checkbox"}),a(u,{value:"radio",label:"Radio"}),a(u,{value:"switch",label:"Switch"}),l.withGroup?N("",!0):(c(),V(F,{key:0},[a(u,{value:"datasource",label:"Data Source"}),a(u,{value:"table",label:"Table"}),a(u,{value:"query_model",label:"Query Model"})],64))]),_:1})}const O=R(ve,[["render",ge],["__scopeId","data-v-72eb8421"]]);const ye={name:"SettingFiles",components:{SortableButton:G,CompilerSelect:D,InputTypeSelect:O},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?pe:ue},saveFileSettingApi(){return this.isPlugin?he:de}},methods:{fetchFiles(){this.fetchFilesApi(this.unique).then(e=>{this.files=e.map(t=>(t.withoutIfNotExists=t.withoutIfNotExists==null?!1:t.withoutIfNotExists,t)),J(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!==""||e.variables.length>0},handleSorted(e){this.currentNode.variables=[],this.$nextTick(()=>{this.currentNode.variables=e,this.saveFileSetting()})}},created(){this.fetchFiles()}},Ve={class:"tree"},Ce={class:"files-wrap"},ke={class:"search-wrap"},Se={class:"node-label"},Te={class:"file-setting"},Ie={class:"content-wrap"},Re={key:1,class:"setting-holder"},we={class:"holder-wrap"};function Ne(e,t,l,h,s,i){const u=o("el-input"),m=o("Document"),f=o("el-icon"),C=o("Folder"),I=o("el-tree"),b=o("CompilerSelect"),k=o("el-form-item"),w=o("el-switch"),g=o("el-form");return c(),V("div",Ve,[r("div",Ce,[r("div",ke,[a(u,{placeholder:e.$t("service.settings.file.filterKeyword")},null,8,["placeholder"])]),a(I,{data:s.files,"highlight-current":!0,"empty-text":e.$t("service.settings.file.noFiles"),onNodeClick:i.handleNodeClick},{default:n(({node:v,data:_})=>[r("span",Se,[_.type==="FILE"?(c(),y(f,{key:0},{default:n(()=>[a(m)]),_:1})):_.type==="DIRECTORY"?(c(),y(f,{key:1},{default:n(()=>[a(C)]),_:1})):N("",!0),r("span",{class:P(["filename",{"flag-file":i.isFlagFile(_)}])},p(_.label),3)])]),_:1},8,["data","empty-text","onNodeClick"])]),r("div",Te,[r("h4",null,p(e.$t("service.settings.file.fileSetting")),1),r("div",Ie,[s.currentNode!=null?(c(),y(g,{key:0},{default:n(()=>[a(k,{label:e.$t("service.settings.file.compiler")},{default:n(()=>[a(b,{modelValue:s.currentNode.compiler,"onUpdate:modelValue":t[0]||(t[0]=v=>s.currentNode.compiler=v),"with-follow-service":!0,onChange:i.saveFileSetting},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(k,{label:"只有文件在项目中存在时才生效"},{default:n(()=>[a(w,{modelValue:s.currentNode.withoutIfNotExists,"onUpdate:modelValue":t[1]||(t[1]=v=>s.currentNode.withoutIfNotExists=v),onChange:i.saveFileSetting},null,8,["modelValue","onChange"])]),_:1}),a(k,{label:e.$t("service.settings.file.enableExpress")},{default:n(()=>[a(u,{modelValue:s.currentNode.enableExpress,"onUpdate:modelValue":t[2]||(t[2]=v=>s.currentNode.enableExpress=v),type:"textarea",rows:8,placeholder:e.$t("service.settings.file.enableExpressHolder"),onInput:i.saveFileSetting},null,8,["modelValue","placeholder","onInput"])]),_:1},8,["label"])]),_:1})):(c(),V("div",Re,[r("div",we,[r("h5",null,p(e.$t("service.settings.file.fileSetting")),1),r("p",null,p(e.$t("service.settings.file.fileSettingHolder")),1)])]))])])])}const Nl=R(ye,[["render",Ne],["__scopeId","data-v-7b11a224"]]);const Fe={name:"InitializeView",components:{DatabaseTypeSelect:Y,CompilerSelect:D,DirectorySelect:j},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=te({...this.form,service:this.serviceName,name:this.pluginName,label:this.pluginLabel}):e=Z({...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=E({codespace:e})):t=B({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)})}}},Ae={class:"initialize-wrap"},$e={class:"tip"},ze={class:"directory-select-wrap"},De={class:"opera-bottom"};function qe(e,t,l,h,s,i){const u=o("DirectorySelect"),m=o("el-button");return c(),V("div",Ae,[r("div",$e,[r("h3",null,p(e.$t("service.settings.initialize.initializeService")),1),r("p",null,p(e.$t("service.settings.initialize.initializeServiceTip")),1)]),r("div",ze,[a(u,{modelValue:s.form.codespace,"onUpdate:modelValue":t[0]||(t[0]=f=>s.form.codespace=f),title:e.$t("service.settings.initialize.selectServiceCodespace"),height:"235px",onChange:i.fetchConfig},null,8,["modelValue","title","onChange"])]),r("div",De,[a(m,{type:"primary",size:"large",onClick:i.initialize},{default:n(()=>[T(p(e.$t("service.settings.initialize.initializeService")),1)]),_:1},8,["onClick"])])])}const Fl=R(Fe,[["render",qe],["__scopeId","data-v-848197ab"]]);const Ue={name:"BuildCommandTypeSelect"};function Be(e,t,l,h,s,i){const u=o("el-option"),m=o("el-select");return c(),y(m,{class:"build-command-type-select"},{default:n(()=>[a(u,{value:"Node",label:"Node"}),a(u,{value:"MySQL",label:"MySQL"})]),_:1})}const Ee=R(Ue,[["render",Be],["__scopeId","data-v-3b21c3bd"]]);const Oe={name:"ServiceFileSelectWindow",props:{title:{default:"Select Service File"},serviceConfig:{required:!0}},data(){return{visible:!1,paths:[],files:[],selectedFilepath:null}},methods:{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,J(this.files),t&&t()}).catch(l=>{this.$tip.apiFailed(l)})},__getProjectName(){return M.split(this.serviceConfig.codespace).pop()},__getAbsolutePath(e){e==null&&(e=JSON.parse(JSON.stringify(this.paths))),e.shift();let t=M.join([this.serviceConfig.codespace,...e]);return this.serviceConfig.translator.settings.length>0&&(t=M.join([this.serviceConfig.codespace,this.serviceConfig.translator.output,...e])),t}}},Me=["id"],Pe={class:"paths"},je=["onClick"],xe={class:"files"},Le=["onClick"],We={class:"opera"};function Qe(e,t,l,h,s,i){const u=o("el-button"),m=o("Folder"),f=o("Document"),C=o("el-icon"),I=o("el-dialog");return c(),y(I,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=b=>s.visible=b),"show-close":!1,"custom-class":"service-file-select-window","append-to-body":""},{header:n(({close:b,titleId:k,titleClass:w})=>[r("h4",{id:k,class:P(w)},p(l.title),11,Me),a(u,{class:"button-icon",icon:"Refresh",onClick:i.__fetchFiles},null,8,["onClick"])]),default:n(()=>[r("ul",Pe,[(c(!0),V(F,null,U(s.paths,(b,k)=>(c(),V("li",{key:b,onClick:w=>i.changePath(k)},p(b),9,je))),128))]),r("div",xe,[r("ul",null,[(c(!0),V(F,null,U(s.files,b=>(c(),V("li",{key:b.path,class:P({"is-file":b.type==="FILE",selected:s.selectedFilepath===b.path}),onClick:k=>i.openOrSelectFile(b)},[a(C,null,{default:n(()=>[b.type==="DIRECTORY"?(c(),y(m,{key:0})):(c(),y(f,{key:1}))]),_:2},1024),r("p",null,p(b.path),1)],10,Le))),128))])]),r("div",We,[a(u,{size:"large",onClick:i.cancelSelect},{default:n(()=>[T("Cancel")]),_:1},8,["onClick"]),a(u,{type:"primary",size:"large",disabled:s.selectedFilepath==null,onClick:i.confirmSelect},{default:n(()=>[T("Confirm Select")]),_:1},8,["disabled","onClick"])])]),_:1},8,["modelValue"])}const Ge=R(Oe,[["render",Qe]]);const Je={name:"BuildList",components:{ServiceFileSelectWindow:Ge,DirectorySelect:j,Empty:H,BuildCommandTypeSelect:Ee},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:{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)},handleChange(e){for(const t of this.builds){const l=e.find(h=>h===t.id)!=null;t.__readonly=!l}},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})}}},Ye={class:"service-build-list"},He={class:"toolbar"},Ke={key:0},Xe={key:1},Ze={class:"title-wrap"},et={key:0,class:"view"},tt={class:"name"},lt={class:"type"},at={key:1,class:"edit"},nt={class:"opera"},it=["onClick"],st={key:0,class:"holder"},ot={key:1};function rt(e,t,l,h,s,i){const u=o("el-button"),m=o("el-input"),f=o("el-form-item"),C=o("BuildCommandTypeSelect"),I=o("el-form"),b=o("el-tab-pane"),k=o("el-tabs"),w=o("el-collapse-item"),g=o("el-collapse"),v=o("Empty"),_=o("ServiceFileSelectWindow");return c(),V("div",Ye,[r("div",He,[l.withUnbuild?(c(),V("p",Ke,p(e.$t("service.settings.build.unBuildTip")),1)):(c(),V("p",Xe,p(e.$t("service.settings.build.buildTip")),1)),a(u,{type:"primary",onClick:i.create},{default:n(()=>[T(p(e.$t("common.create")),1)]),_:1},8,["onClick"])]),l.builds.length>0?(c(),y(g,{key:0,modelValue:s.actives,"onUpdate:modelValue":t[2]||(t[2]=S=>s.actives=S),onChange:i.handleChange},{default:n(()=>[(c(!0),V(F,null,U(l.builds,(S,q)=>(c(),y(w,{key:S.id,name:S.id},{title:n(()=>[r("div",Ze,[S.__readonly?(c(),V("div",et,[r("p",tt,p(S.name),1),r("p",lt,p(S.type),1)])):(c(),V("div",at,[a(I,{model:S},{default:n(()=>[a(f,{label:e.$t("common.name"),required:""},{default:n(()=>[a(m,{class:"name",modelValue:S.name,"onUpdate:modelValue":d=>S.name=d,onClick:t[0]||(t[0]=A(()=>{},["stop"])),onKeypress:t[1]||(t[1]=A(()=>{},["stop"])),onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1032,["label"]),a(f,{label:e.$t("common.type"),required:""},{default:n(()=>[a(C,{class:"type",modelValue:S.type,"onUpdate:modelValue":d=>S.type=d,onChange:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label"])]),_:2},1032,["model"])])),r("div",nt,[a(u,{icon:"Delete",onClick:A(d=>i.deleteBuild(q),["stop"])},{default:n(()=>[T(p(e.$t("common.delete")),1)]),_:2},1032,["onClick"])])])]),default:n(()=>[a(k,{modelValue:S.contentType,"onUpdate:modelValue":d=>S.contentType=d},{default:n(()=>[a(b,{name:"string",label:e.$t("service.settings.build.input")},{default:n(()=>[a(m,{modelValue:S.content,"onUpdate:modelValue":d=>S.content=d,type:"textarea",placeholder:e.$t("service.settings.build.buildCommand"),rows:5,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","placeholder","onInput"])]),_:2},1032,["label"]),a(b,{name:"file",label:e.$t("service.settings.build.file")},{default:n(()=>[r("div",{class:"select-holder",onClick:d=>i.openSelectFileWindow(S)},[S.__filepath==null||S.__filepath===""?(c(),V("p",st,p(e.$t("common.clickToSelectFile")),1)):(c(),V("p",ot,p(S.__filepath),1))],8,it)]),_:2},1032,["label"])]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["name"]))),128))]),_:1},8,["modelValue","onChange"])):(c(),y(v,{key:1})),a(_,{ref:"serviceFileSelectWindow","service-config":l.serviceConfig,onChange:i.handleFileChange},null,8,["service-config","onChange"])])}const ut=R(Je,[["render",rt],["__scopeId","data-v-a44c5960"]]);const dt={name:"TranslatorTypeSelect"};function mt(e,t,l,h,s,i){const u=o("el-option"),m=o("el-select");return c(),y(m,{class:"translator-type-select"},{default:n(()=>[a(u,{value:"pattern",label:e.$t("service.settings.translator.pattern")},null,8,["label"]),a(u,{value:"code",label:e.$t("service.settings.translator.code")},null,8,["label"])]),_:1})}const ct=R(dt,[["render",mt],["__scopeId","data-v-f6d00470"]]);const pt={name:"TranslatorList",components:{TranslatorTypeSelect:ct,Empty:H},props:{space:{required:!0},service:{required:!0},plugin:{required:!0},translator:{required:!0}},data(){return{actives:[],varIndex:1}},computed:{translators(){return this.translator.settings}},watch:{translators:{immediate:!0,handler(){this.translators.forEach(e=>{e.id=""+Math.random(),e.__readonly=!0})}}},methods:{add(){const e=""+Math.random();this.translator.settings.push({id:e,name:this.__generateTranslatorName(),type:"pattern",path:".*",source:"",target:"",code:" return {filepath: filepath, content: content};",__readonly:!1}),this.actives.push(e)},deleteTranslator(e){this.translator.settings.splice(e,1),this.handleSave()},handleChange(e){for(const t of this.translators){const l=e.find(h=>h===t.id)!=null;t.__readonly=!l}},handleSave(){this.$emit("save")},__generateTranslatorName(){let e;for(;;)if(e=`translator${this.varIndex}`,this.varIndex++,this.translators.findIndex(t=>t.name===e)===-1)return e}}},ne=e=>(x("data-v-6ba15df0"),e=e(),L(),e),ht={class:"translator-setting"},ft={class:"toolbar"},bt={class:"opera"},_t={class:"title-wrap"},vt={key:0,class:"view"},gt={class:"name"},yt={class:"path"},Vt={class:"type"},Ct={key:1,class:"edit"},kt={class:"opera"},St=ne(()=>r("p",{class:"code"},[r("em",{class:"keyword"},"function"),T(),r("em",null,"translate"),T(" ("),r("em",null,"filepath"),T(", "),r("em",null,"content"),T(", "),r("em",null,"fileSetting"),T(") {")],-1)),Tt=ne(()=>r("p",null,"}",-1));function It(e,t,l,h,s,i){const u=o("el-button"),m=o("el-input"),f=o("el-form-item"),C=o("TranslatorTypeSelect"),I=o("el-form"),b=o("el-collapse-item"),k=o("el-collapse"),w=o("Empty");return c(),V("div",ht,[r("div",ft,[r("p",null,p(e.$t("service.settings.translator.translatorTip")),1),r("div",bt,[a(u,{type:"primary",onClick:i.add},{default:n(()=>[T(p(e.$t("common.add")),1)]),_:1},8,["onClick"])])]),i.translators.length>0?(c(),y(k,{key:0,modelValue:s.actives,"onUpdate:modelValue":t[4]||(t[4]=g=>s.actives=g),onChange:i.handleChange},{default:n(()=>[(c(!0),V(F,null,U(i.translators,(g,v)=>(c(),y(b,{key:g.id,name:g.id},{title:n(()=>[r("div",_t,[g.__readonly?(c(),V("div",vt,[r("p",gt,p(g.name),1),r("p",yt,p(g.path),1),r("p",Vt,p(g.type),1)])):(c(),V("div",Ct,[a(I,{model:g},{default:n(()=>[a(f,{label:e.$t("common.name"),required:""},{default:n(()=>[a(m,{class:"name",modelValue:g.name,"onUpdate:modelValue":_=>g.name=_,onClick:t[0]||(t[0]=A(()=>{},["stop"])),onKeypress:t[1]||(t[1]=A(()=>{},["stop"])),onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1032,["label"]),a(f,{label:e.$t("service.settings.translator.path"),required:""},{default:n(()=>[a(m,{class:"path",modelValue:g.path,"onUpdate:modelValue":_=>g.path=_,onClick:t[2]||(t[2]=A(()=>{},["stop"])),onKeypress:t[3]||(t[3]=A(()=>{},["stop"])),onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1032,["label"]),a(f,{label:e.$t("service.settings.translator.type"),required:""},{default:n(()=>[a(C,{class:"type",modelValue:g.type,"onUpdate:modelValue":_=>g.type=_,onChange:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label"])]),_:2},1032,["model"])])),r("div",kt,[a(u,{icon:"Delete",onClick:A(_=>i.deleteTranslator(v),["stop"])},{default:n(()=>[T("Delete")]),_:2},1032,["onClick"])])])]),default:n(()=>[g.type==="pattern"?(c(),y(I,{key:0},{default:n(()=>[a(f,{label:"Source",required:""},{default:n(()=>[a(m,{modelValue:g.source,"onUpdate:modelValue":_=>g.source=_,type:"textarea",rows:1,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1024),a(f,{label:"Target",required:""},{default:n(()=>[a(m,{modelValue:g.target,"onUpdate:modelValue":_=>g.target=_,type:"textarea",rows:1,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1024)]),_:2},1024)):g.type==="code"?(c(),V(F,{key:1},[St,a(m,{modelValue:g.code,"onUpdate:modelValue":_=>g.code=_,type:"textarea",rows:5,onInput:i.handleSave},null,8,["modelValue","onUpdate:modelValue","onInput"]),Tt],64)):N("",!0)]),_:2},1032,["name"]))),128))]),_:1},8,["modelValue","onChange"])):(c(),y(w,{key:1}))])}const Rt=R(pt,[["render",It],["__scopeId","data-v-6ba15df0"]]),wt="data:image/png;base64,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";const Nt={name:"BasicSetting",components:{TranslatorList:Rt,BuildList:ut,DirectorySelect:j,DatabaseTypeSelect:Y,CompilerSelect:D},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.originForm=JSON.parse(JSON.stringify(this.form))},initialize(){this.form.codespace=this.newCodespace.value;let e;this.isPlugin?e=te({space:this.space,service:this.service,name:this.plugin,...this.form}):e=Z({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)),ae(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,me({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=E({codespace:e}):t=B({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=le,e={space:this.space,service:this.service,plugin:this.plugin}):(t=ee,e={space:this.space,service:this.service},delete this.form.minServiceVersion),t({...e,...this.form,translator:{...this.form.translator,settings:this.form.translator.settings.filter(l=>l.type==="code"&&l.code.trim().length>0||l.type==="pattern"&&l.source.trim()!==""&&l.target.trim()!=="").map(l=>({name:l.name,path:l.path.trim().length===0?".*":l.path,type:l.type,source:l.type==="pattern"?l.source:"",target:l.type==="pattern"?l.target:"",code:l.type==="code"?l.code:""}))},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()}},ie=e=>(x("data-v-fd32b7e4"),e=e(),L(),e),Ft={class:"basic-setting"},At={class:"wrap"},$t={class:"repository-input-wrap"},zt=ie(()=>r("span",null,"/",-1)),Dt=ie(()=>r("span",null,[r("img",{src:wt})],-1)),qt={key:0,class:"codespace-wrap"},Ut={key:0,class:"opera-wrap"};function Bt(e,t,l,h,s,i){const u=o("el-input"),m=o("el-form-item"),f=o("CompilerSelect"),C=o("DatabaseTypeSelect"),I=o("el-button"),b=o("el-radio-button"),k=o("el-radio-group"),w=o("el-input-number"),g=o("el-checkbox"),v=o("TranslatorList"),_=o("BuildList"),S=o("DirectorySelect"),q=o("el-form");return c(),V("div",Ft,[r("div",At,[a(q,{model:s.form},{default:n(()=>[l.plugin==null?(c(),V(F,{key:0},[a(m,{label:e.$t("service.settings.name"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.name,"onUpdate:modelValue":t[0]||(t[0]=d=>s.form.name=d),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.label"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.label,"onUpdate:modelValue":t[1]||(t[1]=d=>s.form.label=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)):(c(),V(F,{key:1},[a(m,{label:e.$t("plugin.name"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.name,"onUpdate:modelValue":t[2]||(t[2]=d=>s.form.name=d),disabled:""},null,8,["modelValue"])]),_:1},8,["label"]),a(m,{label:e.$t("plugin.label"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.label,"onUpdate:modelValue":t[3]||(t[3]=d=>s.form.label=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"])],64)),a(m,{label:e.$t("service.settings.version"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.version,"onUpdate:modelValue":t[4]||(t[4]=d=>s.form.version=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"]),i.isPlugin?(c(),y(m,{key:2,label:"最低兼容的服务版本号",prop:"minServiceVersion"},{default:n(()=>[a(u,{modelValue:s.form.minServiceVersion,"onUpdate:modelValue":t[5]||(t[5]=d=>s.form.minServiceVersion=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1})):N("",!0),a(m,{label:e.$t("service.settings.compiler"),prop:"compiler",required:""},{default:n(()=>[a(f,{modelValue:s.form.compiler,"onUpdate:modelValue":t[6]||(t[6]=d=>s.form.compiler=d),onChange:i.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.supportedDatabases"),prop:"supportedDatabases"},{default:n(()=>[a(C,{modelValue:s.form.supportedDatabases,"onUpdate:modelValue":t[7]||(t[7]=d=>s.form.supportedDatabases=d),onChange:i.saveConfig},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.repository"),prop:"repository"},{default:n(()=>[r("div",$t,[a(u,{class:"repository-input",modelValue:s.form.repository,"onUpdate:modelValue":t[8]||(t[8]=d=>s.form.repository=d),onInput:i.saveConfig},null,8,["modelValue","onInput"]),zt,a(u,{class:"branch-input",modelValue:s.form.branch,"onUpdate:modelValue":t[9]||(t[9]=d=>s.form.branch=d),placeholder:e.$t("gitClone.branch"),onInput:i.handleBranchInput},null,8,["modelValue","placeholder","onInput"]),a(I,{type:"primary",disabled:s.isWorking.clone||!i.clonable,loading:s.isWorking.clone,onClick:i.clone},{default:n(()=>[T(p(e.$t("gitClone.clone")),1)]),_:1},8,["disabled","loading","onClick"])])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.introduce"),prop:"introduce",required:""},{default:n(()=>[a(u,{type:"textarea",rows:5,modelValue:s.form.introduce,"onUpdate:modelValue":t[10]||(t[10]=d=>s.form.introduce=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.charge"),prop:"prices[0].type",required:""},{default:n(()=>[a(k,{modelValue:s.form.prices[0].type,"onUpdate:modelValue":t[11]||(t[11]=d=>s.form.prices[0].type=d),onChange:i.changePriceType},{default:n(()=>[(c(!0),V(F,null,U(e.$const.getServiceLeaseTypes(e.$t),d=>(c(),y(b,{key:d.code,label:d.code},{default:n(()=>[T(p(d.label),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue","onChange"])]),_:1},8,["label"]),s.form.prices[0].type!=="free"?(c(),y(m,{key:3,label:"Price",prop:"prices[0].value",class:"item-price",required:""},{default:n(()=>[Dt,a(w,{controls:!1,modelValue:s.form.prices[0].value,"onUpdate:modelValue":t[12]||(t[12]=d=>s.form.prices[0].value=d),onInput:i.saveConfig},null,8,["modelValue","onInput"])]),_:1})):N("",!0),a(m,{label:e.$t("service.settings.otherSettings"),class:"item-other-settings"},{default:n(()=>[r("div",null,[a(g,{modelValue:s.form.private,"onUpdate:modelValue":t[13]||(t[13]=d=>s.form.private=d),label:"Is a private service",onChange:i.saveConfig},null,8,["modelValue","onChange"])])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.translator.translator"),prop:"translator"},{default:n(()=>[a(v,{space:l.space,service:l.service,plugin:l.plugin,translator:s.form.translator,onSave:i.saveConfig},null,8,["space","service","plugin","translator","onSave"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.installBuilds"),prop:"builds"},{default:n(()=>[a(_,{builds:s.form.builds,"service-config":l.serviceConfig,onSave:i.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.uninstallBuilds"),prop:"unbuilds"},{default:n(()=>[a(_,{builds:s.form.unbuilds,"with-unbuild":!0,"service-config":l.serviceConfig,onSave:i.saveConfig},null,8,["builds","service-config","onSave"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.codespace"),prop:"codespace"},{default:n(()=>[s.newCodespace.changing?(c(),y(S,{key:1,title:e.$t("service.settings.selectNewCodespace"),modelValue:s.newCodespace.value,"onUpdate:modelValue":t[14]||(t[14]=d=>s.newCodespace.value=d),onChange:i.fetchConfig},null,8,["title","modelValue","onChange"])):(c(),V("div",qt,[r("p",null,p(s.form.codespace),1),a(I,{type:"primary",onClick:i.changeCodespace},{default:n(()=>[T(p(e.$t("service.settings.changeCodespace")),1)]),_:1},8,["onClick"])]))]),_:1},8,["label"])]),_:1},8,["model"]),s.newCodespace.changing?(c(),V("div",Ut,[a(I,{size:"large",onClick:t[15]||(t[15]=d=>s.newCodespace.changing=!1)},{default:n(()=>[T(p(e.$t("common.cancel")),1)]),_:1}),a(I,{size:"large",type:"primary",onClick:i.initialize},{default:n(()=>[T(p(e.$t("service.settings.reinitialize")),1)]),_:1},8,["onClick"])])):N("",!0)])])}const Al=R(Nt,[["render",Bt],["__scopeId","data-v-fd32b7e4"]]),Et={name:"PublishWindow",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?B:E},saveConfigApi(){return this.isPlugin?le:ee}},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:ae,message:this.$t("form.isIncorrect",{field:this.$t("service.versionNumber")})}],publishDescription:[{required:!0,message:this.$t("form.isRequired",{value:this.$t("service.versionDescription")}),trigger:"blur"}]}},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,be({...this.unique,publishDescription:this.form.publishDescription}).then(()=>{this.visible=!1,this.$message.success("发布成功")}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.isWorking=!1}))})}}},Ot={class:"dialog-footer"};function Mt(e,t,l,h,s,i){const u=o("el-input"),m=o("el-form-item"),f=o("el-form"),C=o("el-button"),I=o("el-dialog"),b=K("loading");return c(),y(I,{modelValue:s.visible,"onUpdate:modelValue":t[3]||(t[3]=k=>s.visible=k),class:"publish-window",title:e.$t("service.settings.publishVersion"),width:"500px",draggable:"","close-on-press-escape":!1,"close-on-click-modal":!1},{footer:n(()=>[r("span",Ot,[a(C,{onClick:t[2]||(t[2]=k=>s.visible=!1)},{default:n(()=>[T(p(e.$t("common.cancel")),1)]),_:1}),a(C,{type:"primary",disabled:s.isWorking,onClick:i.publish},{default:n(()=>[T(p(e.$t("service.settings.publish")),1)]),_:1},8,["disabled","onClick"])])]),default:n(()=>[X((c(),y(f,{ref:"form",model:s.form,rules:i.getRules()},{default:n(()=>[a(m,{label:e.$t("service.versionNumber"),prop:"version",required:""},{default:n(()=>[a(u,{modelValue:s.form.version,"onUpdate:modelValue":t[0]||(t[0]=k=>s.form.version=k),onInput:i.saveConfig},{prefix:n(()=>[T("v")]),_:1},8,["modelValue","onInput"])]),_:1},8,["label"]),a(m,{label:e.$t("service.versionDescription"),prop:"publishDescription",required:""},{default:n(()=>[a(u,{type:"textarea",rows:5,modelValue:s.form.publishDescription,"onUpdate:modelValue":t[1]||(t[1]=k=>s.form.publishDescription=k)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["model","rules"])),[[b,s.isWorking]])]),_:1},8,["modelValue","title"])}const $l=R(Et,[["render",Mt]]);const Pt={name:"OptionSettingWindow",components:{OptionValueInput:_e},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")}}},jt={class:"toolbar"};function xt(e,t,l,h,s,i){const u=o("el-button"),m=o("el-input"),f=o("el-table-column"),C=o("el-option"),I=o("el-select"),b=o("el-switch"),k=o("OptionValueInput"),w=o("el-table"),g=o("el-dialog");return c(),y(g,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=v=>s.visible=v),title:e.$t("service.settings.variable.optionSettings"),"append-to-body":"","custom-class":"option-setting-window"},{default:n(()=>[r("div",jt,[a(u,{icon:"Plus",type:"primary",onClick:i.add},{default:n(()=>[T(p(e.$t("common.add")),1)]),_:1},8,["onClick"])]),a(w,{data:s.option.settings},{default:n(()=>[a(f,{prop:"label",label:e.$t("service.settings.variable.label")},{default:n(({row:v})=>[a(m,{modelValue:v.label,"onUpdate:modelValue":_=>v.label=_,onInput:i.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(f,{prop:"name",label:e.$t("service.settings.variable.name")},{default:n(({row:v})=>[a(m,{modelValue:v.name,"onUpdate:modelValue":_=>v.name=_,onInput:i.emitChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(f,{prop:"inputType",label:e.$t("service.settings.variable.inputType")},{default:n(({row:v})=>[a(I,{modelValue:v.inputType,"onUpdate:modelValue":_=>v.inputType=_,onChange:i.emitChange},{default:n(()=>[a(C,{value:"input",label:"Input"}),a(C,{value:"number_input",label:"Number Input"}),a(C,{value:"textarea",label:"Textarea"})]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])]),_:1},8,["label"]),a(f,{prop:"required",label:e.$t("service.settings.variable.required")},{default:n(({row:v})=>[a(b,{modelValue:v.required,"onUpdate:modelValue":_=>v.required=_},null,8,["modelValue","onUpdate:modelValue"])]),_:1},8,["label"]),a(f,{prop:"defaultValue",label:e.$t("service.settings.variable.defaultValue")},{default:n(({row:v})=>[a(k,{"option-setting":v,modelValue:v.defaultValue,"onUpdate:modelValue":_=>v.defaultValue=_,onInput:i.emitChange},null,8,["option-setting","modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(f,{width:"60px"},{default:n(({row:v,$index:_})=>[a(u,{icon:"Delete",onClick:S=>i.deleteSetting(_)},null,8,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1},8,["modelValue","title"])}const Lt=R(Pt,[["render",xt]]),Wt={name:"VariableSettingForm",components:{OptionSettingWindow:Lt,SortableButton:G,VariableInput:W,CompilerSelect:D,InputTypeSelect:O},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:{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(s=>s.name===l)==null&&!t.origin.hasOwnProperty(l)&&delete t[l]}}}},createOption(){this.variable.options.push({value:"",label:"",remark:"",settings:[]})},deleteOption(e){this.variable.options.splice(e,1)},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()})}}},Qt={class:"opera"};function Gt(e,t,l,h,s,i){const u=o("el-input"),m=o("el-form-item"),f=o("InputTypeSelect"),C=o("el-button"),I=o("SortableButton"),b=o("el-table-column"),k=o("el-table"),w=o("OptionSettingWindow"),g=o("VariableInput"),v=o("el-switch"),_=o("CompilerSelect"),S=o("el-form"),q=K("sortable");return c(),y(S,{model:l.variable},{default:n(()=>[a(m,{label:e.$t("service.settings.variable.label"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=d=>l.variable.label=d),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.variable.name"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=d=>l.variable.name=d),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.variable.inputType"),required:""},{default:n(()=>[a(f,{modelValue:l.variable.inputType,"onUpdate:modelValue":t[2]||(t[2]=d=>l.variable.inputType=d),"with-group":i.withGroup,onChange:i.handleInputTypeChange},null,8,["modelValue","with-group","onChange"])]),_:1},8,["label"]),l.variable.inputType==="select"||l.variable.inputType==="checkbox"||l.variable.inputType==="radio"?(c(),y(m,{key:0,label:e.$t("service.settings.variable.options"),class:"item-options",required:""},{label:n(()=>[r("div",null,[r("label",null,p(e.$t("service.settings.variable.options")),1),r("div",Qt,[a(C,{type:"primary",onClick:i.createOption},{default:n(()=>[T(p(e.$t("common.add")),1)]),_:1},8,["onClick"])])])]),default:n(()=>[X((c(),y(k,{data:l.variable.options},{default:n(()=>[a(b,{width:"25px"},{default:n(()=>[a(I)]),_:1}),a(b,{label:"*"+e.$t("service.settings.variable.optionLabel"),"min-width":"200px"},{default:n(({row:d})=>[a(u,{modelValue:d.label,"onUpdate:modelValue":$=>d.label=$,type:"textarea",rows:1,onInput:i.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(b,{label:"*"+e.$t("service.settings.variable.optionValue"),"min-width":"120px"},{default:n(({row:d})=>[a(u,{modelValue:d.value,"onUpdate:modelValue":$=>d.value=$,onInput:i.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),a(b,{label:e.$t("common.remark"),"min-width":"150px"},{default:n(({row:d})=>[a(u,{modelValue:d.remark,"onUpdate:modelValue":$=>d.remark=$,type:"textarea",rows:1,onInput:i.handleChange},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:1},8,["label"]),l.variable.options.length>0?(c(),y(b,{key:0,"min-width":l.variable.inputType==="select"?"120px":"60px",fixed:"right"},{default:n(({row:d,$index:$})=>[l.variable.inputType==="select"?(c(),y(C,{key:0,icon:"Setting",class:"button-icon",onClick:se=>e.$refs.optionSettingWindow.open(d)},null,8,["onClick"])):N("",!0),a(C,{icon:"Delete",class:"button-icon",onClick:se=>i.deleteOption($)},null,8,["onClick"])]),_:1},8,["min-width"])):N("",!0)]),_:1},8,["data"])),[[q,{data:l.variable.options,onChange:i.handleOptionSorted},"config"]]),a(w,{ref:"optionSettingWindow",onChange:i.handleChange},null,8,["onChange"])]),_:1},8,["label"])):N("",!0),a(m,{label:e.$t("service.settings.variable.defaultValue")},{default:n(()=>[a(g,{variable:l.variable,"value-key":"defaultValue",onChange:i.handleDefaultValueChange},null,8,["variable","onChange"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.variable.required")},{default:n(()=>[a(v,{modelValue:l.variable.required,"onUpdate:modelValue":t[3]||(t[3]=d=>l.variable.required=d),onChange:i.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.variable.hidden")},{default:n(()=>[a(v,{modelValue:l.variable.hidden,"onUpdate:modelValue":t[4]||(t[4]=d=>l.variable.hidden=d),onChange:i.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"?(c(),y(m,{key:1,label:e.$t("service.settings.variable.compiler")},{default:n(()=>[a(_,{modelValue:l.variable.compiler,"onUpdate:modelValue":t[5]||(t[5]=d=>l.variable.compiler=d),onChange:i.handleChange},null,8,["modelValue","onChange"])]),_:1},8,["label"])):N("",!0),a(m,{label:e.$t("common.remark")},{default:n(()=>[a(u,{modelValue:l.variable.remark,"onUpdate:modelValue":t[6]||(t[6]=d=>l.variable.remark=d),type:"textarea",rows:3,onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const Jt=R(Wt,[["render",Gt]]),Yt={name:"VariableGroupSettingForm",components:{VariableInput:W,CompilerSelect:D,InputTypeSelect:O},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 Ht(e,t,l,h,s,i){const u=o("el-input"),m=o("el-form-item"),f=o("el-form");return c(),y(f,{model:l.variable},{default:n(()=>[a(m,{label:e.$t("service.settings.variable.groupLabel"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.label,"onUpdate:modelValue":t[0]||(t[0]=C=>l.variable.label=C),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"]),a(m,{label:e.$t("service.settings.variable.groupName"),required:""},{default:n(()=>[a(u,{modelValue:l.variable.name,"onUpdate:modelValue":t[1]||(t[1]=C=>l.variable.name=C),onInput:i.handleChange},null,8,["modelValue","onInput"])]),_:1},8,["label"])]),_:1},8,["model"])}const Kt=R(Yt,[["render",Ht]]);const Xt={name:"Variables",components:{VariableGroupSettingForm:Kt,VariableSettingForm:Jt,VariableInput:W,I18nInput:re,InputTypeSelect:O,CompilerSelect:D},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?fe:ce},fetchConfigApi(){return this.isPlugin?E:B}},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:Q(),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()},createGroup(e,t){const l=this.__generateGroupName(),h={id:Q(),type:"group",name:l,label:l,children:[],defaultValue:t};e==null?this.variables.push(h):(e.children==null&&(e.children=[]),e.children.push(h)),this.currentVariable=h,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})},1e3)},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"?"variable":"variable group";this.deleteConfirm(`Do you want to delete the ${e} named 「${this.currentVariable.name}」?`).then(()=>{if(this.currentRootVariable!==this.currentVariable&&(this.currentRootVariable.inputType==="query_model"||this.currentRootVariable.inputType==="table")&&this.currentGroup!=null){const l=this.currentGroup.children.findIndex(h=>h.id===this.currentVariable.id);if(l===-1)return;this.currentGroup.children.splice(l,1);for(const h of this.currentRootVariable.children)for(const s of h.defaultValue)for(const i in s){if(i==="origin")continue;h.children.find(m=>m.name===i)==null&&!s.origin.hasOwnProperty(i)&&delete s[i]}this.currentVariable=null,this.saveVariables();return}if(this.currentGroup!=null){const l=this.currentGroup.children.findIndex(h=>h.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(h=>({...h,value:t.defaultValue.settings[h.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(h=>this.__getSaveVariable(h)),l))),delete t.options,t):t.inputType==="select"?(t.options=this.__getValidOptions(t.options),t.options.forEach(l=>{l.settings=l.settings.filter(h=>h.name.trim()!==""&&h.label.trim()!=="")}),t.options.forEach(l=>