goldpankit
Version:
GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。
2 lines (1 loc) • 33.6 kB
JavaScript
import{_ as I,o as n,c as m,F as k,g as C,I as T,t as g,r as i,h as p,w as v,a as c,j as F,b as f,a2 as Q,z as D,A as j,m as K,i as X,a9 as q,k as E,e as M,p as O,l as U,aa as N,y as x,M as Y,E as Z}from"./index-2b5ed492.js";import{Q as ee}from"./QueryModelView-e5478980.js";const le={name:"InstallCheckbox",props:{modelValue:{type:Array},type:{default:"checkbox"},options:{}},data(){return{}},computed:{optionValues(){return this.options.map(e=>e.value)}},watch:{modelValue:{immediate:!0,handler(){this.filterValues(this.modelValue)}},optionValues(){this.filterValues(this.modelValue)}},methods:{handleSelect(e){let t=this.modelValue.findIndex(o=>o===e.value),l=[];t===-1?l=this.modelValue.concat([e.value]):l=this.modelValue.filter((o,s)=>s!==t),this.filterValues(l)},filterValues(e){const t=[];for(const l of e)this.options.find(s=>s.value===l)!=null&&t.push(l);t!==this.modelValue&&(t!=null&&this.modelValue!=null&&t.join(",")===this.modelValue.join(",")||(this.$emit("update:modelValue",t),this.$emit("change",t)))}}},te={key:0,class:"installer-checkbox"},ne=["onClick"],ae={key:1};function oe(e,t,l,o,s,a){return l.options.length>0?(n(),m("ul",te,[(n(!0),m(k,null,C(l.options,r=>(n(),m("li",{key:r.value,class:T({selected:l.modelValue==null?!1:l.modelValue.findIndex(b=>b===r.value)!==-1}),onClick:b=>a.handleSelect(r)},g(r.label),11,ne))),128))])):(n(),m("p",ae,"请先添加选项!"))}const W=I(le,[["render",oe],["__scopeId","data-v-88cce27a"]]);const ie={name:"InstallInput",props:{type:{default:"text"},rows:{default:3}}};function se(e,t,l,o,s,a){const r=i("el-input");return n(),p(r,{type:l.type,rows:l.rows,class:"install-input"},null,8,["type","rows"])}const L=I(ie,[["render",se],["__scopeId","data-v-35abcc78"]]);const ue={name:"InstallRadio",props:{modelValue:{},options:{}},data(){return{optionSettingData:{visible:!1}}},methods:{handleSelect(e){this.$emit("update:modelValue",e),this.$emit("change",e)}}},de={key:0,class:"installer-radio"},re=["onClick"],ce={key:1};function me(e,t,l,o,s,a){return l.options.length>0?(n(),m("ul",de,[(n(!0),m(k,null,C(l.options,r=>(n(),m("li",{key:r.value,class:T({selected:l.modelValue===r.value}),onClick:b=>a.handleSelect(r.value)},g(r.label),11,re))),128))])):(n(),m("p",ce,"请先添加选项!"))}const R=I(ue,[["render",me],["__scopeId","data-v-0d9060ef"]]);const _e={name:"MySqlFieldSelect",props:{modelValue:{},table:{required:!0},multiple:{default:!0}},methods:{handleInput(e){this.$emit("update:modelValue",e.map(t=>this.table.fields.find(l=>l.name===t)).filter(t=>t!=null))}}},pe={class:"option-content"},he={class:"text-info-1"};function fe(e,t,l,o,s,a){const r=i("el-option"),b=i("el-select");return n(),p(b,{class:"mysql-field-select","popper-class":"mysql-field-select__popper",multiple:l.multiple,"model-value":l.modelValue==null?[]:l.modelValue.map(h=>h.name),"onUpdate:modelValue":a.handleInput},{default:v(()=>[(n(!0),m(k,null,C(l.table.fields,h=>(n(),p(r,{value:h.name,label:h.name},{default:v(()=>[c("p",pe,[c("span",null,g(h.name),1),c("span",he,g(h.comment),1)])]),_:2},1032,["value","label"]))),256))]),_:1},8,["multiple","model-value","onUpdate:modelValue"])}const ve=I(_e,[["render",fe],["__scopeId","data-v-3550a1ac"]]);const be={name:"OptionValueInput",props:{modelValue:{},optionSetting:{required:!0}},methods:{emitChange(e){this.$emit("update:model-value",e),this.$emit("input",e)}}},ge={class:"option-value-input"};function ye(e,t,l,o,s,a){const r=i("el-input"),b=i("el-input-number");return n(),m("div",ge,[l.optionSetting.inputType==="input"?(n(),p(r,{key:0,"model-value":l.modelValue,"onUpdate:modelValue":a.emitChange},null,8,["model-value","onUpdate:modelValue"])):l.optionSetting.inputType==="number_input"?(n(),p(b,{key:1,"model-value":l.modelValue,controls:!1,"onUpdate:modelValue":a.emitChange},null,8,["model-value","onUpdate:modelValue"])):l.optionSetting.inputType==="textarea"?(n(),p(r,{key:2,type:"textarea",rows:1,"model-value":l.modelValue,"onUpdate:modelValue":a.emitChange},null,8,["model-value","onUpdate:modelValue"])):F("",!0)])}const Ve=I(be,[["render",ye],["__scopeId","data-v-c1e053d5"]]);const Se={name:"InstallSelect",components:{OptionValueInput:Ve},props:{modelValue:{},options:{},type:{default:"radio"}},data(){return{optionSettingData:{visible:!1}}},computed:{validOptions(){return this.options.filter(e=>e.value.trim()!==""&&e.label.trim()!=="")},currentOption(){return this.validOptions.find(e=>e.value===this.modelValue.value)},optionValues(){return this.validOptions.map(e=>e.value)},currenOptionSettings(){return this.currentOption==null?[]:this.currentOption.settings.map(e=>e.defaultValue)}},watch:{optionValues(){this.handleSelect(this.modelValue.value)},currenOptionSettings(){this.fillSettingValue()},modelValue:{immediate:!0,handler(){this.fillSettingValueFromModelValue()}}},methods:{handleSelect(e){const t=this.validOptions.find(o=>o.value===e);let l={value:null,settings:{}};if(t!=null){const o={};for(const s of t.settings)o[s.name]=s.defaultValue;l={value:e,settings:o}}this.$emit("update:modelValue",l),this.$emit("change",l),this.fillSettingValue()},fillSettingValue(){this.$nextTick(()=>{if(this.currentOption!=null)for(const e of this.currentOption.settings)e.value=e.defaultValue})},fillSettingValueFromModelValue(){for(const e in this.modelValue.settings){const t=this.options.find(o=>o.value===this.modelValue.value);if(t==null)continue;const l=t.settings.find(o=>o.name===e);l!=null&&(l.value=this.modelValue.settings[e])}}}},ke={key:0,class:"installer-select"},Ie={key:1};function Fe(e,t,l,o,s,a){const r=i("el-option"),b=i("el-select"),h=i("el-button"),y=i("OptionValueInput"),V=i("el-form-item"),S=i("el-form"),d=i("el-dialog");return l.options.length>0?(n(),m("div",ke,[f(b,{"model-value":l.modelValue.value,clearable:"",onChange:a.handleSelect},{default:v(()=>[(n(!0),m(k,null,C(a.validOptions,u=>(n(),p(r,{key:u.value,value:u.value,label:u.label},null,8,["value","label"]))),128))]),_:1},8,["model-value","onChange"]),a.currentOption!=null&&a.currentOption.settings.length>0?(n(),p(h,{key:0,type:"primary",icon:"Setting",class:"button-icon",onClick:t[0]||(t[0]=u=>s.optionSettingData.visible=!0)})):F("",!0),a.currentOption!=null?(n(),p(d,{key:1,modelValue:s.optionSettingData.visible,"onUpdate:modelValue":t[2]||(t[2]=u=>s.optionSettingData.visible=u),title:`${a.currentOption.label}设置`,"append-to-body":!0},{default:v(()=>[f(S,null,{default:v(()=>[(n(!0),m(k,null,C(a.currentOption.settings,u=>(n(),p(V,{key:u.name,label:u.label,required:u.required},{default:v(()=>[f(y,{modelValue:l.modelValue.settings[u.name],"onUpdate:modelValue":w=>l.modelValue.settings[u.name]=w,"option-setting":u,onInput:t[1]||(t[1]=w=>e.$emit("change"))},null,8,["modelValue","onUpdate:modelValue","option-setting"])]),_:2},1032,["label","required"]))),128))]),_:1})]),_:1},8,["modelValue","title"])):F("",!0)])):(n(),m("p",Ie,"请先添加选项!"))}const A=I(Se,[["render",Fe],["__scopeId","data-v-a5cf2462"]]);const Ce={name:"InstallNumberInput",props:{type:{default:"text"}}};function we(e,t,l,o,s,a){const r=i("el-input-number");return n(),p(r,{class:"install-number-input",controls:!1})}const P=I(Ce,[["render",we],["__scopeId","data-v-6340b22c"]]),Te={name:"Switch"};function xe(e,t,l,o,s,a){const r=i("el-switch");return n(),p(r)}const H=I(Te,[["render",xe]]);const Me={name:"TableFieldVariableInput",components:{InstallSwitch:H,InstallNumberInput:P,InstallSelect:A,InstallCheckbox:W,InstallRadio:R,InstallInput:L},props:{modelValue:{},variable:{required:!0}}};function $e(e,t,l,o,s,a){const r=i("InstallInput"),b=i("InstallNumberInput"),h=i("InstallSelect"),y=i("InstallCheckbox"),V=i("InstallRadio"),S=i("InstallSwitch");return l.variable.inputType==="input"?(n(),p(r,{key:0,"model-value":l.modelValue,"onUpdate:modelValue":t[0]||(t[0]=d=>e.$emit("update:modelValue",d)),onInput:t[1]||(t[1]=d=>e.$emit("change",d))},null,8,["model-value"])):l.variable.inputType==="number_input"?(n(),p(b,{key:1,"model-value":l.modelValue,"onUpdate:modelValue":t[2]||(t[2]=d=>e.$emit("update:modelValue",d)),onInput:t[3]||(t[3]=d=>e.$emit("change",d))},null,8,["model-value"])):l.variable.inputType==="textarea"?(n(),p(r,{key:2,type:"textarea",rows:1,"model-value":l.modelValue,"onUpdate:modelValue":t[4]||(t[4]=d=>e.$emit("update:modelValue",d)),onInput:t[5]||(t[5]=d=>e.$emit("change",d))},null,8,["model-value"])):l.variable.inputType==="select"?(n(),p(h,{key:3,options:l.variable.options,"model-value":l.modelValue,"onUpdate:modelValue":t[6]||(t[6]=d=>e.$emit("update:modelValue",d)),onChange:t[7]||(t[7]=d=>e.$emit("change",d))},null,8,["options","model-value"])):l.variable.inputType==="checkbox"?(n(),p(y,{key:4,options:l.variable.options,"model-value":l.modelValue,"onUpdate:modelValue":t[8]||(t[8]=d=>e.$emit("update:modelValue",d)),onChange:t[9]||(t[9]=d=>e.$emit("change",d))},null,8,["options","model-value"])):l.variable.inputType==="radio"?(n(),p(V,{key:5,options:l.variable.options,"model-value":l.modelValue,"onUpdate:modelValue":t[10]||(t[10]=d=>e.$emit("update:modelValue",d)),onChange:t[11]||(t[11]=d=>e.$emit("change",d))},null,8,["options","model-value"])):l.variable.inputType==="switch"?(n(),p(S,{key:6,"model-value":l.modelValue,"onUpdate:modelValue":t[12]||(t[12]=d=>e.$emit("update:modelValue",d)),onChange:t[13]||(t[13]=d=>e.$emit("change",d))},null,8,["model-value"])):F("",!0)}const G=I(Me,[["render",$e],["__scopeId","data-v-f253c4c5"]]);const Ke={name:"VariableRemarkIcon",props:{variable:{required:!0}}};function Oe(e,t,l,o,s,a){const r=i("QuestionFilled"),b=i("el-icon"),h=i("el-popover");return l.variable.remark!=null&&l.variable.remark.trim()!==""?(n(),p(h,{key:0,"popper-class":"global-popover",title:"参数说明",placement:"top",width:"255px"},{reference:v(()=>[f(b,null,{default:v(()=>[f(r)]),_:1})]),default:v(()=>[c("p",null,g(l.variable.remark),1)]),_:1})):F("",!0)}const J=I(Ke,[["render",Oe],["__scopeId","data-v-9fef24ee"]]);function $(e){return e==null||e===""||JSON.stringify(e)==="[]"||JSON.stringify(e)==="{}"}function B(e){return e==="input"||e==="textarea"||e==="radio"?"":e==="select"?{value:null,settings:[]}:e==="checkbox"?[]:e==="table"||e==="database"||e==="query_model"?null:""}const Ue={name:"FieldSetting",components:{SortableButton:Q,VariableRemarkIcon:J,TableFieldVariableInput:G,MySqlFieldSelect:ve},props:{table:{required:!0},group:{required:!0},valueKey:{default:"value"}},computed:{tableFields(){return this.table.fields.map(e=>e.name)}},watch:{tableFields(){this.handleSelect(this.group[this.valueKey])}},methods:{handleSort(e){console.log("newFields",e),this.handleSelect(e)},handleSelect(e){e=e.filter(l=>this.table.fields.find(o=>o.name===l.name)!=null);const t=JSON.parse(JSON.stringify(e));for(const l of t){l.origin==null&&(l.origin=JSON.parse(JSON.stringify(l)));for(const o of this.group.children)l[o.name]=$(l[o.name])?o.defaultValue:l[o.name],$(l[o.name])&&(l[o.name]=B(o.inputType))}this.group[this.valueKey]=t,console.log("this.group[this.valueKey]",this.group[this.valueKey]),this.emitChange()},emitChange(){this.$emit("change")},getColumnMinWidth(e){return e.inputType==="select"?"150px":"120px"}},created(){this.handleSelect(this.group[this.valueKey])}},qe={class:"column-header-wrap"},Qe={key:0,class:"required"};function De(e,t,l,o,s,a){const r=i("MySqlFieldSelect"),b=i("SortableButton"),h=i("el-table-column"),y=i("VariableRemarkIcon"),V=i("TableFieldVariableInput"),S=i("el-table"),d=D("sortable");return n(),m(k,null,[c("h5",null,g(l.group.label),1),f(r,{"onUpdate:modelValue":a.handleSelect,"model-value":l.group[l.valueKey],table:l.table,placeholder:"请选择字段"},null,8,["onUpdate:modelValue","model-value","table"]),j((n(),p(S,{size:"small",data:l.group[l.valueKey],"row-key":"name"},{default:v(()=>[f(h,{"class-name":"table-column-sortable",width:"30px",fixed:""},{default:v(()=>[f(b)]),_:1}),f(h,{label:"字段名",width:"100px",prop:"name",fixed:""}),(n(!0),m(k,null,C(l.group.children,u=>(n(),p(h,{key:u.name,label:u.label,"min-width":a.getColumnMinWidth(u)},{header:v(()=>[c("div",qe,[u.required?(n(),m("em",Qe,"*")):F("",!0),c("label",null,g(u.label),1),f(y,{variable:u},null,8,["variable"])])]),default:v(({row:w})=>[f(V,{variable:u,modelValue:w[u.name],"onUpdate:modelValue":_=>w[u.name]=_,onChange:a.emitChange},null,8,["variable","modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label","min-width"]))),128))]),_:1},8,["data"])),[[d,{handle:".sortable-button",data:l.group[l.valueKey],onChange:a.handleSort},"config"]])],64)}const je=I(Ue,[["render",De],["__scopeId","data-v-ed8d68cf"]]);const Ee={name:"TableSelect",components:{FieldSetting:je},props:{modelValue:{},valueKey:{default:"value"},variable:{required:!0}},data(){return{selected:null}},computed:{...K(["tables","globalLoading","currentDatabaseConnect"]),fieldVariableGroup(){return this.variable.children||[]},currentTable(){return this.modelValue==null?null:this.tables.find(e=>e.name===this.modelValue)}},watch:{"globalLoading.tables":{immediate:!0,handler(e){e||this.handleChange(this.modelValue)}}},methods:{...X(["fetchTables"]),handleChange(e){if(!this.globalLoading.tables){if(this.modelValue!==e&&this.fieldVariableGroup.forEach(t=>{t[this.valueKey]=[]}),this.tables.find(t=>t.name===e)==null){this.$emit("update:modelValue",null),this.$emit("change",null);return}this.$emit("update:modelValue",e),this.$emit("change",e)}}}},Ne={class:"table-select"},We={class:"table-select__wrap"},Le={class:"option-content"},Re={class:"text-info-1"},Ae={key:0,class:"connect-error"},Pe={key:1,class:"field-settings"};function He(e,t,l,o,s,a){const r=i("el-option"),b=i("el-select"),h=i("el-button"),y=i("FieldSetting");return n(),m("div",Ne,[c("div",We,[f(b,{"popper-class":"table-select__popper","model-value":l.modelValue,clearable:"",loading:e.globalLoading.tables,"loading-text":"正在获取数据库表,请稍后...",onChange:a.handleChange},{default:v(()=>[(n(!0),m(k,null,C(e.tables,V=>(n(),p(r,{key:V.name,value:V.name,label:V.name},{default:v(()=>[c("p",Le,[c("span",null,g(V.name),1),c("span",Re,g(V.comment),1)])]),_:2},1032,["value","label"]))),128))]),_:1},8,["model-value","loading","onChange"]),f(h,{class:"button-icon",type:"primary",icon:"Refresh",onClick:e.fetchTables},null,8,["onClick"])]),e.currentDatabaseConnect.error!=null?(n(),m("p",Ae,"数据库连接失败:"+g(e.currentDatabaseConnect.error),1)):F("",!0),a.currentTable!=null&&a.fieldVariableGroup.length>0?(n(),m("ul",Pe,[(n(!0),m(k,null,C(a.fieldVariableGroup,V=>(n(),m("li",{key:V.label},[f(y,{"value-key":l.valueKey,table:a.currentTable,group:V,onChange:t[0]||(t[0]=S=>e.$emit("change"))},null,8,["value-key","table","group"])]))),128))])):F("",!0)])}const Ge=I(Ee,[["render",He],["__scopeId","data-v-8ee56717"]]);const Je={name:"QueryModelFieldSelect",props:{modelValue:{},model:{required:!0},multiple:{default:!0},defaultSelectedFieldObjects:{type:Array}},data(){return{focused:!1,tables:[],selectedFields:this.defaultSelectedFieldObjects,currentHoverTable:null,currentHoverField:null,leaveFieldTimeout:null}},watch:{model:{immediate:!0,handler(){this.refreshTables()}}},methods:{focus(){this.focused=!0},deleteField(e,t){const l=this.model.tables.find(s=>s.id===e),o=this.modelValue.filter(s=>`${l.id}.${t}`!==s);this.handleInput(l,o)},handleCheckAllChange(e,t){let l=[];t&&(l=e.fields.map(s=>`${e.id}.${s.name}`));let o=this.modelValue;o=o.filter(s=>!s.startsWith(`${e.id}.`)),o=o.concat(l),this.handleInput(e,o)},handleInput(e,t){const l=t.filter(o=>o.startsWith(`${e.id}.`));e.checkedAll=l.length===e.fields.length,this.selectFields(t)},handleFieldEnter(e){this.leaveFieldTimeout!=null&&clearTimeout(this.leaveFieldTimeout),this.currentHoverField=e},handleFieldLeave(){this.leaveFieldTimeout=setTimeout(()=>{this.currentHoverField=null},500)},handleTableEnter(e){this.currentHoverTable=e},handleTableLeave(){this.currentHoverTable=null},close(){this.focused=!1,this.handleTableLeave(),this.handleFieldLeave()},refreshTables(){this.tables=[];for(const e of this.model.tables){const t=e.fields.filter(l=>l.visible);t.length>0&&this.tables.push({id:e.id,type:e.type,name:e.name,alias:e.alias,fields:t,checkedAll:!1})}this.selectFields(this.modelValue)},selectFields(e){const t=this.__getExistsSelectedFieldsObjects(e);this.selectedFields.splice(0,this.selectedFields.length),this.selectedFields.push.apply(this.selectedFields,t),this.$emit("update:modelValue",this.selectedFields.map(l=>l.table.id+"."+l.name)),this.$emit("fields:change",this.selectedFields)},__getExistsSelectedFieldsObjects(e){const t=e.map(o=>{const s=o.split(".")[0],a=o.split(".")[1],r=this.tables.find(V=>V.id===s);if(r==null)return null;const b=r.fields.find(V=>V.name===a);if(b==null)return null;const h=q(r,["fields"]),y=q(b,["table"]);return y.table=h,y}).filter(o=>o!=null),l=[];for(const o of t){const s=this.selectedFields.findIndex(r=>r.table.id===o.table.id&&r.name===o.name);if(s===-1){l.push(o);continue}const a=this.selectedFields[s];a.alias=o.alias,a.table=o.table,l.push(a)}return l}}},Be=e=>(O("data-v-1178df68"),e=e(),U(),e),ze={class:"model-field-select"},Xe={key:0,class:"placeholder"},Ye=["onMouseenter"],Ze={key:0},el=["onClick"],ll={class:"field-select__tables"},tl=["onMouseenter"],nl={class:"table__header"},al={class:"table__fields-wrap"},ol={class:"table-fields"},il=Be(()=>c("em",null,"AS",-1)),sl={key:0,class:"text-info-1"};function ul(e,t,l,o,s,a){const r=i("Close"),b=i("el-icon"),h=i("el-checkbox"),y=i("el-checkbox-group"),V=i("el-scrollbar"),S=i("el-popover");return n(),m("div",ze,[f(S,{trigger:"click","popper-class":"model-field-select-popper","hide-after":0,persistent:!1,onHide:a.close},{reference:v(()=>[c("ul",{class:T(["selected-preview",{"is-focus":s.focused}]),onClick:t[1]||(t[1]=(...d)=>a.focus&&a.focus(...d))},[s.selectedFields.length===0?(n(),m("li",Xe,"请选择字段")):(n(!0),m(k,{key:1},C(s.selectedFields,d=>(n(),m("li",{key:d.name,class:T({"field-light":s.currentHoverTable!=null&&d.table.id===s.currentHoverTable.id}),onMouseenter:u=>a.handleFieldEnter(d),onMouseleave:t[0]||(t[0]=(...u)=>a.handleFieldLeave&&a.handleFieldLeave(...u))},[c("p",null,g(d.table.alias)+"."+g(d.name),1),d.comment!=null&&d.comment!==""?(n(),m("p",Ze,g(d.comment),1)):F("",!0),c("span",{class:"button-close",onClick:E(u=>a.deleteField(d.table.id,d.name),["stop"])},[f(b,null,{default:v(()=>[f(r)]),_:1})],8,el)],42,Ye))),128))],2)]),default:v(()=>[c("div",ll,[(n(!0),m(k,null,C(s.tables,d=>(n(),m("div",{key:d.alias,class:T(["field-select__table",{"table-main":d.type==="MAIN","table-light":s.currentHoverField!=null&&d.id===s.currentHoverField.table.id}]),onMouseenter:u=>a.handleTableEnter(d),onMouseleave:t[2]||(t[2]=(...u)=>a.handleTableLeave&&a.handleTableLeave(...u))},[c("div",nl,[f(h,{modelValue:d.checkedAll,"onUpdate:modelValue":u=>d.checkedAll=u,onChange:u=>a.handleCheckAllChange(d,u)},{default:v(()=>[c("h4",null,[M(g(d.name)+" ",1),d.name!==d.alias?(n(),m(k,{key:0},[M("AS "+g(d.alias),1)],64)):F("",!0)])]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])]),c("div",al,[f(V,null,{default:v(()=>[c("div",ol,[f(y,{"model-value":l.modelValue,onChange:u=>a.handleInput(d,u)},{default:v(()=>[(n(!0),m(k,null,C(d.fields,u=>(n(),p(h,{label:`${d.id}.${u.name}`,key:u.name},{default:v(()=>[c("p",null,[M(g(u.name)+" ",1),u.alias!==u.name?(n(),m(k,{key:0},[il,M(),c("b",null,g(u.alias),1)],64)):F("",!0)]),u.comment!==""?(n(),m("p",sl,g(u.comment),1)):F("",!0)]),_:2},1032,["label"]))),128))]),_:2},1032,["model-value","onChange"])])]),_:2},1024)])],42,tl))),128))])]),_:1},8,["onHide"])])}const dl=I(Je,[["render",ul],["__scopeId","data-v-1178df68"]]);const rl={name:"QueryModelFieldSetting",components:{VariableRemarkIcon:J,SortableButton:Q,QueryModelFieldSelect:dl,TableFieldVariableInput:G},props:{valueKey:{default:"value"},model:{required:!0},group:{required:!0}},data(){return{selectedFields:[],defaultSelectedFieldObjects:[]}},watch:{model(){this.initSelectedFields()}},methods:{handleSort(){this.initSelectedFields(),this.$refs.fieldSelect.selectFields(this.selectedFields)},initSelectedFields(){this.selectedFields=[],this.defaultSelectedFieldObjects=[];const e=this.group[this.valueKey];e!=null&&e.length>0&&(this.selectedFields=e.map(t=>`${t.table.id}.${t.name}`),this.defaultSelectedFieldObjects=JSON.parse(JSON.stringify(e)))},handleSelect(e){const t=[];for(const l of e){l.origin==null&&(l.origin=JSON.parse(JSON.stringify(l)));for(const o of this.group.children)l[o.name]=$(l[o.name])?o.defaultValue:l[o.name],$(l[o.name])&&(l[o.name]=B(o.inputType));t.push(l)}this.group[this.valueKey].splice(0,this.group[this.valueKey].length),this.group[this.valueKey].push.apply(this.group[this.valueKey],t),this.emitChange()},emitChange(){this.$emit("change")},getColumnMinWidth(e){return e.inputType==="select"?"150px":"120px"},refresh(){this.$refs.fieldSelect.refreshTables()}},created(){this.initSelectedFields()}},cl={key:0,class:"required"};function ml(e,t,l,o,s,a){const r=i("QueryModelFieldSelect"),b=i("SortableButton"),h=i("el-table-column"),y=i("VariableRemarkIcon"),V=i("TableFieldVariableInput"),S=i("el-table"),d=D("sortable");return n(),m(k,null,[c("h5",null,g(l.group.label),1),f(r,{ref:"fieldSelect",modelValue:s.selectedFields,"onUpdate:modelValue":t[0]||(t[0]=u=>s.selectedFields=u),model:l.model,"default-selected-field-objects":s.defaultSelectedFieldObjects,"onFields:change":a.handleSelect},null,8,["modelValue","model","default-selected-field-objects","onFields:change"]),l.group.children.length>0?j((n(),p(S,{key:0,size:"small",data:l.group[l.valueKey],"row-key":u=>`${u.table.id}.${u.name}@${u.alias}`},{default:v(()=>[f(h,{"class-name":"table-column-sortable",width:"30px",fixed:""},{default:v(()=>[f(b)]),_:1}),f(h,{label:"字段名",width:"150px",prop:"name",fixed:""},{default:v(({row:u})=>[c("p",null,g(u.table.alias)+"."+g(u.name),1),c("p",null,g(u.comment),1)]),_:1}),(n(!0),m(k,null,C(l.group.children,u=>(n(),p(h,{key:u.name,label:u.label,"min-width":a.getColumnMinWidth(u)},{header:v(()=>[u.required?(n(),m("em",cl,"*")):F("",!0),c("label",null,g(u.label),1),f(y,{variable:u},null,8,["variable"])]),default:v(({row:w})=>[f(V,{variable:u,modelValue:w[u.name],"onUpdate:modelValue":_=>w[u.name]=_,onChange:a.emitChange},null,8,["variable","modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label","min-width"]))),128))]),_:1},8,["data","row-key"])),[[d,{handle:".sortable-button",data:l.group[l.valueKey],onChange:a.handleSort},"config"]]):F("",!0)],64)}const _l=I(rl,[["render",ml],["__scopeId","data-v-74db6d23"]]);const pl={name:"QueryModelWindow",components:{DataSourceSelect:N,QueryModelView:ee},data(){return{visible:!1}},computed:{...K(["currentDatabase"])},methods:{open(){this.visible=!0},close(){this.visible=!1,this.$emit("close")}}},hl=c("h2",null,"查询模型设计",-1),fl={class:"header__opera"};function vl(e,t,l,o,s,a){const r=i("DataSourceSelect"),b=i("Close"),h=i("el-icon"),y=i("QueryModelView"),V=i("el-dialog");return n(),p(V,{class:"query-model-window",modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=S=>s.visible=S),fullscreen:"","append-to-body":"","show-close":!1},{header:v(()=>[hl,c("div",fl,[f(r,{"model-value":e.currentDatabase},null,8,["model-value"]),f(h,{onClick:a.close},{default:v(()=>[f(b)]),_:1},8,["onClick"])])]),default:v(()=>[f(y,{"database-id":e.currentDatabase},null,8,["database-id"])]),_:1},8,["modelValue"])}const bl=I(pl,[["render",vl]]),gl="/images/database/icon-design.svg";const yl={name:"QueryModelSelect",components:{QueryModelWindow:bl,QueryModelFieldSetting:_l},props:{modelValue:{},valueKey:{default:"value"},variable:{required:!0}},computed:{...K(["models","globalLoading","currentDatabaseConnect"]),fieldVariableGroup(){return this.variable.children||[]},currentModel(){return this.modelValue==null?null:this.models.find(e=>e.id===this.modelValue)}},watch:{"globalLoading.models":{immediate:!0,handler(e){e||this.handleChange(this.modelValue)}},"models.length"(){this.handleChange(this.modelValue)}},methods:{handleChange(e){if(!this.globalLoading.models){if(this.modelValue!==e&&this.fieldVariableGroup.forEach(t=>{t[this.valueKey]=[]}),this.models.find(t=>t.id===e)==null){this.$emit("update:modelValue",null),this.$emit("change",null);return}this.$emit("update:modelValue",e),this.$emit("change")}},refreshFieldSetting(){for(const e of this.fieldVariableGroup){const t=this.$refs[`${e.name}FieldSetting`];t&&t[0]&&t[0].refresh()}}}},z=e=>(O("data-v-6d47634a"),e=e(),U(),e),Vl={class:"query-model-select"},Sl={class:"option-content"},kl={class:"text-info-1"},Il=z(()=>c("img",{src:gl,alt:"查询模型"},null,-1)),Fl=z(()=>c("p",null,null,-1)),Cl={key:0,class:"connect-error"},wl={key:1,class:"field-settings"};function Tl(e,t,l,o,s,a){const r=i("el-option"),b=i("el-select"),h=i("el-button"),y=i("QueryModelWindow"),V=i("QueryModelFieldSetting");return n(),m(k,null,[c("div",Vl,[f(b,{"popper-class":"model-select__popper","model-value":l.modelValue,clearable:"",onChange:a.handleChange},{default:v(()=>[(n(!0),m(k,null,C(e.models,S=>(n(),p(r,{key:S.id,value:S.id,label:S.name},{default:v(()=>[c("p",Sl,[c("span",null,g(S.name),1),c("span",kl,g(S.comment),1)])]),_:2},1032,["value","label"]))),128))]),_:1},8,["model-value","onChange"]),f(h,{class:"button-icon",type:"primary",onClick:t[0]||(t[0]=S=>e.$refs.queryModelWindow.open())},{default:v(()=>[Il]),_:1}),Fl,f(y,{ref:"queryModelWindow",onClose:a.refreshFieldSetting},null,8,["onClose"])]),e.currentDatabaseConnect.error!=null?(n(),m("p",Cl,"数据库连接失败:"+g(e.currentDatabaseConnect.error),1)):F("",!0),a.currentModel!=null&&a.fieldVariableGroup.length>0?(n(),m("ul",wl,[(n(!0),m(k,null,C(a.fieldVariableGroup,S=>(n(),m("li",{key:S.label},[f(V,{ref_for:!0,ref:`${S.name}FieldSetting`,"value-key":l.valueKey,model:a.currentModel,group:S,onChange:t[1]||(t[1]=d=>e.$emit("change"))},null,8,["value-key","model","group"])]))),128))])):F("",!0)],64)}const xl=I(yl,[["render",Tl],["__scopeId","data-v-6d47634a"]]);const Ml={name:"VariableInput",components:{InstallNumberInput:P,InstallSelect:A,DataSourceSelect:N,QueryModelSelect:xl,TableSelect:Ge,InstallCheckbox:W,InstallRadio:R,InstallInput:L,InstallSwitch:H},props:{variable:{required:!0},valueKey:{default:"value"}},computed:{inputType(){return this.variable.inputType}}},$l={class:"variable-input"};function Kl(e,t,l,o,s,a){const r=i("InstallInput"),b=i("InstallNumberInput"),h=i("InstallSelect"),y=i("InstallCheckbox"),V=i("InstallRadio"),S=i("InstallSwitch"),d=i("DataSourceSelect"),u=i("TableSelect"),w=i("QueryModelSelect");return n(),m("div",$l,[l.variable.inputType==="input"?(n(),p(r,{key:0,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[0]||(t[0]=_=>l.variable[l.valueKey]=_),onInput:t[1]||(t[1]=_=>e.$emit("change",_))},null,8,["modelValue"])):l.variable.inputType==="number_input"?(n(),p(b,{key:1,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[2]||(t[2]=_=>l.variable[l.valueKey]=_),onInput:t[3]||(t[3]=_=>e.$emit("change",_))},null,8,["modelValue"])):l.variable.inputType==="textarea"?(n(),p(r,{key:2,type:"textarea",modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[4]||(t[4]=_=>l.variable[l.valueKey]=_),onInput:t[5]||(t[5]=_=>e.$emit("change",_))},null,8,["modelValue"])):l.variable.inputType==="select"?(n(),p(h,{key:3,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[6]||(t[6]=_=>l.variable[l.valueKey]=_),options:l.variable.options,onChange:t[7]||(t[7]=_=>e.$emit("change",_))},null,8,["modelValue","options"])):l.variable.inputType==="checkbox"?(n(),p(y,{key:4,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[8]||(t[8]=_=>l.variable[l.valueKey]=_),options:l.variable.options,onChange:t[9]||(t[9]=_=>e.$emit("change",_))},null,8,["modelValue","options"])):l.variable.inputType==="radio"?(n(),p(V,{key:5,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[10]||(t[10]=_=>l.variable[l.valueKey]=_),options:l.variable.options,onChange:t[11]||(t[11]=_=>e.$emit("change",_))},null,8,["modelValue","options"])):l.variable.inputType==="switch"?(n(),p(S,{key:6,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[12]||(t[12]=_=>l.variable[l.valueKey]=_),onInput:t[13]||(t[13]=_=>e.$emit("change",_))},null,8,["modelValue"])):l.variable.inputType==="datasource"?(n(),p(d,{key:7,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[14]||(t[14]=_=>l.variable[l.valueKey]=_),"with-prefix":!1,"with-block":!0,onChange:t[15]||(t[15]=_=>e.$emit("change",_))},null,8,["modelValue"])):l.variable.inputType==="table"?(n(),p(u,{key:8,variable:l.variable,"value-key":l.valueKey,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[16]||(t[16]=_=>l.variable[l.valueKey]=_),onChange:t[17]||(t[17]=_=>e.$emit("change",_))},null,8,["variable","value-key","modelValue"])):l.variable.inputType==="query_model"?(n(),p(w,{key:9,variable:l.variable,"value-key":l.valueKey,modelValue:l.variable[l.valueKey],"onUpdate:modelValue":t[18]||(t[18]=_=>l.variable[l.valueKey]=_),onChange:t[19]||(t[19]=_=>e.$emit("change",_))},null,8,["variable","value-key","modelValue"])):F("",!0)])}const tt=I(Ml,[["render",Kl],["__scopeId","data-v-ea68e2f3"]]);const Ol={name:"ServiceCodeErrorWindow",data(){return{visible:!1,error:null}},methods:{open(e){this.error=e,this.visible=!0}}},Ul={class:"window-header-wrap"},ql={class:"title"},Ql={class:"tip"},Dl={class:"window-content-wrap"};function jl(e,t,l,o,s,a){const r=i("CircleCloseFilled"),b=i("el-icon"),h=i("el-dialog");return n(),p(h,{modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=y=>s.visible=y),width:"1000px",class:"service-code-error-window","show-close":!1},{header:v(()=>[c("div",Ul,[c("div",ql,[f(b,null,{default:v(()=>[f(r)]),_:1}),c("h5",null,g(e.$t("service.serviceCodeErrorTitle")),1)]),c("p",Ql,g(e.$t("service.serviceCodeErrorTip")),1)])]),default:v(()=>[c("div",Dl,[c("p",null,"at "+g(s.error.position),1),c("pre",null,g(s.error.message),1)])]),_:1},8,["modelValue"])}const nt=I(Ol,[["render",jl]]);function at(e){return x.post("/plugin/initialize",e)}function ot(e){return x.post("/plugin/profile",e)}function it(e){return x.post("/plugin/files",e)}function st(e){return x.post("/plugin/config",e)}function ut(e){return x.post("/plugin/config/save",e)}function dt(e){return x.post("/plugin/file/setting/save",e)}function rt(e){return x.post("/plugin/variables/save",e)}function El(e){return x.post("/plugin/list",e,{baseURL:"/remote-api"})}const Nl={name:"MarkdownWindow",components:{MarkdownEditor:Y},data(){return{visible:!1,title:"",content:""}},methods:{open(e,t){this.visible=!0,this.title=e,this.content=t}}};function Wl(e,t,l,o,s,a){const r=i("MarkdownEditor"),b=i("el-dialog");return n(),p(b,{title:s.title,modelValue:s.visible,"onUpdate:modelValue":t[0]||(t[0]=h=>s.visible=h),class:"markdown-window",width:"850px","append-to-body":""},{default:v(()=>[f(r,{"model-value":s.content,readonly:!0,"without-padding":!0},null,8,["model-value"])]),_:1},8,["title","modelValue"])}const Ll=I(Nl,[["render",Wl]]);const Rl={name:"PluginSelector",components:{Empty:Z,MarkdownWindow:Ll},props:{modelValue:{required:!0,type:Array},space:{required:!0},service:{required:!0},majorVersion:{required:!0}},data(){return{loading:!1,currentTab:"selected",plugins:[]}},computed:{selectedCount(){return this.plugins.filter(e=>e.supportedPreset&&this.modelValue.findIndex(t=>t.name===e.name)!==-1).length},emptyTip(){return this.currentTab==="selected"?"可在插件市场选择需要的插件!":"暂无插件!"},filteredPlugins(){return this.currentTab==="selected"?this.plugins.filter(e=>e.supportedPreset&&this.modelValue.findIndex(t=>t.name===e.name)!==-1):this.plugins.filter(e=>e.supportedPreset)}},watch:{majorVersion(){this.fetchList(),this.$emit("update:modelValue",[]),this.$emit("change",[])}},methods:{switchPlugin(e){let t=[...this.modelValue],l=t.findIndex(o=>o.name===e.name);l===-1?t.push({name:e.name}):t.splice(l,1),this.$emit("update:modelValue",t),this.$emit("change",t)},fetchList(){if(this.majorVersion===""){this.plugins=[];return}this.loading=!0,El({space:this.space,service:this.service,majorVersion:this.majorVersion}).then(e=>{this.plugins=e}).catch(e=>{this.$tip.apiFailed(e)}).finally(()=>{this.loading=!1})}},created(){this.fetchList()}},Al=e=>(O("data-v-7977bc54"),e=e(),U(),e),Pl={class:"plugin-selector"},Hl={class:"tabs"},Gl={key:0,class:"plugin-list"},Jl=["onClick"],Bl=Al(()=>c("em",null,null,-1)),zl=[Bl],Xl={class:"info"},Yl={class:"opera"};function Zl(e,t,l,o,s,a){const r=i("el-button"),b=i("Empty"),h=i("MarkdownWindow");return n(),m("div",Pl,[c("ul",Hl,[c("li",{class:T({selected:s.currentTab==="all"}),onClick:t[0]||(t[0]=y=>s.currentTab="all")},"插件市场",2),c("li",{class:T({selected:s.currentTab==="selected"}),onClick:t[1]||(t[1]=y=>s.currentTab="selected")},"已选择("+g(a.selectedCount)+")",3)]),a.filteredPlugins.length>0?(n(),m("ul",Gl,[(n(!0),m(k,null,C(a.filteredPlugins,y=>(n(),m("li",{key:y.id,onClick:V=>a.switchPlugin(y)},[c("span",{class:T(["checkbox",{checked:l.modelValue.find(V=>V.name===y.name)!=null}])},zl,2),c("div",Xl,[c("h6",null,g(y.label),1),c("p",null,"最新版本:"+g(y.lastVersion),1),c("p",null,g(y.introduce),1)]),c("div",Yl,[f(r,{size:"default",type:"text",onClick:E(V=>e.$refs.markdownWindow.open(y.label,y.description),["stop"])},{default:v(()=>[M("查看介绍")]),_:2},1032,["onClick"])])],8,Jl))),128))])):(n(),p(b,{key:1,description:a.emptyTip},null,8,["description"])),f(h,{ref:"markdownWindow"},null,512)])}const ct=I(Rl,[["render",Zl],["__scopeId","data-v-7977bc54"]]);export{je as F,R as I,ve as M,Ve as O,ct as P,nt as S,J as V,tt as a,L as b,W as c,ot as d,st as e,El as f,B as g,it as h,$ as i,dt as j,at as k,rt as l,ut as s};