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