goldpankit
Version:
GoldPanKit是一款极速研发套件,可在套件中快速构建各类技术框架和项目。开源作者可发布自己的项目,并为其设定金额,实现开源项目的盈利。
2 lines (1 loc) • 28.4 kB
JavaScript
import{_ as k,o as n,c,F as S,f as F,I as T,t as g,r as a,g as p,w as b,a as _,i as I,b as y,m as K,G as q,a7 as B,A as D,B as Q,e as x,p as O,k as U,a2 as P,a8 as $}from"./index-10e8cffd.js";import{Q as z}from"./QueryModelView-1fd7c538.js";const X={name:"InstallCheckbox",props:{modelValue:{type:Array},type:{default:"checkbox"},options:{}},data(){return{}},computed:{optionValues(){return this.options.map(l=>l.value)}},watch:{modelValue:{immediate:!0,handler(){this.filterValues(this.modelValue)}},optionValues(){this.filterValues(this.modelValue)}},methods:{handleSelect(l){let t=this.modelValue.findIndex(d=>d===l.value),e=[];t===-1?e=this.modelValue.concat([l.value]):e=this.modelValue.filter((d,i)=>i!==t),this.filterValues(e)},filterValues(l){const t=[];for(const e of l)this.options.find(i=>i.value===e)!=null&&t.push(e);t!==this.modelValue&&(t!=null&&this.modelValue!=null&&t.join(",")===this.modelValue.join(",")||(this.$emit("update:modelValue",t),this.$emit("change",t)))}}},Y={key:0,class:"installer-checkbox"},Z=["onClick"],ee={key:1};function le(l,t,e,d,i,o){return e.options.length>0?(n(),c("ul",Y,[(n(!0),c(S,null,F(e.options,r=>(n(),c("li",{key:r.value,class:T({selected:e.modelValue==null?!1:e.modelValue.findIndex(f=>f===r.value)!==-1}),onClick:f=>o.handleSelect(r)},g(r.label),11,Z))),128))])):(n(),c("p",ee,"Please add options first."))}const N=k(X,[["render",le],["__scopeId","data-v-24b20c0d"]]);const te={name:"InstallInput",props:{type:{default:"text"},rows:{default:3}}};function ne(l,t,e,d,i,o){const r=a("el-input");return n(),p(r,{type:e.type,rows:e.rows,class:"install-input"},null,8,["type","rows"])}const W=k(te,[["render",ne],["__scopeId","data-v-35abcc78"]]);const ae={name:"InstallRadio",props:{modelValue:{},options:{}},data(){return{optionSettingData:{visible:!1}}},methods:{handleSelect(l){this.$emit("update:modelValue",l),this.$emit("change",l)}}},oe={key:0,class:"installer-radio"},ie=["onClick"],se={key:1};function ue(l,t,e,d,i,o){return e.options.length>0?(n(),c("ul",oe,[(n(!0),c(S,null,F(e.options,r=>(n(),c("li",{key:r.value,class:T({selected:e.modelValue===r.value}),onClick:f=>o.handleSelect(r.value)},g(r.label),11,ie))),128))])):(n(),c("p",se,"Please add options first."))}const R=k(ae,[["render",ue],["__scopeId","data-v-801a3273"]]);const de={name:"MySqlFieldSelect",props:{modelValue:{},table:{required:!0},multiple:{default:!0}},methods:{handleInput(l){this.$emit("update:modelValue",l.map(t=>this.table.fields.find(e=>e.name===t)).filter(t=>t!=null))}}},re={class:"option-content"},ce={class:"text-info-1"};function me(l,t,e,d,i,o){const r=a("el-option"),f=a("el-select");return n(),p(f,{class:"mysql-field-select","popper-class":"mysql-field-select__popper",multiple:e.multiple,"model-value":e.modelValue==null?[]:e.modelValue.map(v=>v.name),"onUpdate:modelValue":o.handleInput},{default:b(()=>[(n(!0),c(S,null,F(e.table.fields,v=>(n(),p(r,{value:v.name,label:v.name},{default:b(()=>[_("p",re,[_("span",null,g(v.name),1),_("span",ce,g(v.comment),1)])]),_:2},1032,["value","label"]))),256))]),_:1},8,["multiple","model-value","onUpdate:modelValue"])}const _e=k(de,[["render",me],["__scopeId","data-v-af47228f"]]);const he={name:"OptionValueInput",props:{modelValue:{},optionSetting:{required:!0}},methods:{emitChange(l){this.$emit("update:model-value",l),this.$emit("input",l)}}},pe={class:"option-value-input"};function ve(l,t,e,d,i,o){const r=a("el-input"),f=a("el-input-number");return n(),c("div",pe,[e.optionSetting.inputType==="input"?(n(),p(r,{key:0,"model-value":e.modelValue,"onUpdate:modelValue":o.emitChange},null,8,["model-value","onUpdate:modelValue"])):e.optionSetting.inputType==="number_input"?(n(),p(f,{key:1,"model-value":e.modelValue,controls:!1,"onUpdate:modelValue":o.emitChange},null,8,["model-value","onUpdate:modelValue"])):e.optionSetting.inputType==="textarea"?(n(),p(r,{key:2,type:"textarea",rows:1,"model-value":e.modelValue,"onUpdate:modelValue":o.emitChange},null,8,["model-value","onUpdate:modelValue"])):I("",!0)])}const be=k(he,[["render",ve],["__scopeId","data-v-c1e053d5"]]);const fe={name:"InstallSelect",components:{OptionValueInput:be},props:{modelValue:{},options:{},type:{default:"radio"}},data(){return{optionSettingData:{visible:!1}}},computed:{validOptions(){return this.options.filter(l=>l.value.trim()!==""&&l.label.trim()!=="")},currentOption(){return this.validOptions.find(l=>l.value===this.modelValue.value)},optionValues(){return this.validOptions.map(l=>l.value)},currenOptionSettings(){return this.currentOption==null?[]:this.currentOption.settings.map(l=>l.defaultValue)}},watch:{optionValues(){this.handleSelect(this.modelValue.value)},currenOptionSettings(){this.fillSettingValue()},modelValue:{immediate:!0,handler(){this.fillSettingValueFromModelValue()}}},methods:{handleSelect(l){const t=this.validOptions.find(d=>d.value===l);let e={value:null,settings:{}};if(t!=null){const d={};for(const i of t.settings)d[i.name]=i.defaultValue;e={value:l,settings:d}}this.$emit("update:modelValue",e),this.$emit("change",e),this.fillSettingValue()},fillSettingValue(){this.$nextTick(()=>{if(this.currentOption!=null)for(const l of this.currentOption.settings)l.value=l.defaultValue})},fillSettingValueFromModelValue(){for(const l in this.modelValue.settings){const t=this.options.find(d=>d.value===this.modelValue.value);if(t==null)continue;const e=t.settings.find(d=>d.name===l);e!=null&&(e.value=this.modelValue.settings[l])}}}},ye={key:0,class:"install-radio-select"},ge={key:1};function Ve(l,t,e,d,i,o){const r=a("el-option"),f=a("el-select"),v=a("el-button"),V=a("OptionValueInput"),C=a("el-form-item"),u=a("el-form"),s=a("el-dialog");return e.options.length>0?(n(),c("div",ye,[y(f,{"model-value":e.modelValue.value,clearable:"",onChange:o.handleSelect},{default:b(()=>[(n(!0),c(S,null,F(o.validOptions,h=>(n(),p(r,{key:h.value,value:h.value,label:h.label},null,8,["value","label"]))),128))]),_:1},8,["model-value","onChange"]),o.currentOption!=null&&o.currentOption.settings.length>0?(n(),p(v,{key:0,type:"primary",icon:"Setting",class:"button-icon",onClick:t[0]||(t[0]=h=>i.optionSettingData.visible=!0)})):I("",!0),o.currentOption!=null?(n(),p(s,{key:1,modelValue:i.optionSettingData.visible,"onUpdate:modelValue":t[2]||(t[2]=h=>i.optionSettingData.visible=h),title:`${o.currentOption.label}${l.$t("service.settingsForSelectType")}`,"append-to-body":!0},{default:b(()=>[y(u,null,{default:b(()=>[(n(!0),c(S,null,F(o.currentOption.settings,h=>(n(),p(C,{key:h.name,label:h.label,required:h.required},{default:b(()=>[y(V,{modelValue:e.modelValue.settings[h.name],"onUpdate:modelValue":w=>e.modelValue.settings[h.name]=w,"option-setting":h,onInput:t[1]||(t[1]=w=>l.$emit("change"))},null,8,["modelValue","onUpdate:modelValue","option-setting"])]),_:2},1032,["label","required"]))),128))]),_:1})]),_:1},8,["modelValue","title"])):I("",!0)])):(n(),c("p",ge,"Please add options first."))}const E=k(fe,[["render",Ve],["__scopeId","data-v-f7bbb9b8"]]);const Se={name:"InstallNumberInput",props:{type:{default:"text"}}};function ke(l,t,e,d,i,o){const r=a("el-input-number");return n(),p(r,{class:"install-number-input",controls:!1})}const A=k(Se,[["render",ke],["__scopeId","data-v-6340b22c"]]),Ie={name:"Switch"};function Ce(l,t,e,d,i,o){const r=a("el-switch");return n(),p(r)}const H=k(Ie,[["render",Ce]]);const Fe={name:"TableFieldVariableInput",components:{InstallSwitch:H,InstallNumberInput:A,InstallSelect:E,InstallCheckbox:N,InstallRadio:R,InstallInput:W},props:{modelValue:{},variable:{required:!0}}};function we(l,t,e,d,i,o){const r=a("InstallInput"),f=a("InstallNumberInput"),v=a("InstallSelect"),V=a("InstallCheckbox"),C=a("InstallRadio"),u=a("InstallSwitch");return e.variable.inputType==="input"?(n(),p(r,{key:0,"model-value":e.modelValue,"onUpdate:modelValue":t[0]||(t[0]=s=>l.$emit("update:modelValue",s)),onInput:t[1]||(t[1]=s=>l.$emit("change",s))},null,8,["model-value"])):e.variable.inputType==="number_input"?(n(),p(f,{key:1,"model-value":e.modelValue,"onUpdate:modelValue":t[2]||(t[2]=s=>l.$emit("update:modelValue",s)),onInput:t[3]||(t[3]=s=>l.$emit("change",s))},null,8,["model-value"])):e.variable.inputType==="textarea"?(n(),p(r,{key:2,type:"textarea",rows:1,"model-value":e.modelValue,"onUpdate:modelValue":t[4]||(t[4]=s=>l.$emit("update:modelValue",s)),onInput:t[5]||(t[5]=s=>l.$emit("change",s))},null,8,["model-value"])):e.variable.inputType==="select"?(n(),p(v,{key:3,options:e.variable.options,"model-value":e.modelValue,"onUpdate:modelValue":t[6]||(t[6]=s=>l.$emit("update:modelValue",s)),onChange:t[7]||(t[7]=s=>l.$emit("change",s))},null,8,["options","model-value"])):e.variable.inputType==="checkbox"?(n(),p(V,{key:4,options:e.variable.options,"model-value":e.modelValue,"onUpdate:modelValue":t[8]||(t[8]=s=>l.$emit("update:modelValue",s)),onChange:t[9]||(t[9]=s=>l.$emit("change",s))},null,8,["options","model-value"])):e.variable.inputType==="radio"?(n(),p(C,{key:5,options:e.variable.options,"model-value":e.modelValue,"onUpdate:modelValue":t[10]||(t[10]=s=>l.$emit("update:modelValue",s)),onChange:t[11]||(t[11]=s=>l.$emit("change",s))},null,8,["options","model-value"])):e.variable.inputType==="switch"?(n(),p(u,{key:6,"model-value":e.modelValue,"onUpdate:modelValue":t[12]||(t[12]=s=>l.$emit("update:modelValue",s)),onChange:t[13]||(t[13]=s=>l.$emit("change",s))},null,8,["model-value"])):I("",!0)}const J=k(Fe,[["render",we],["__scopeId","data-v-f253c4c5"]]);function M(l){return l==null||l===""||l.trim&&l.trim()===""||JSON.stringify(l)==="[]"||JSON.stringify(l)==="{}"}function G(l){return l==="input"||l==="textarea"||l==="radio"?"":l==="select"?{value:null,settings:[]}:l==="checkbox"?[]:l==="table"||l==="database"||l==="query_model"?null:""}const xe={name:"VariableRemarkIcon",props:{variable:{required:!0}}};function Te(l,t,e,d,i,o){const r=a("QuestionFilled"),f=a("el-icon"),v=a("el-popover");return e.variable.remark!=null&&e.variable.remark.trim()!==""?(n(),p(v,{key:0,"popper-class":"variable-remark-icon",title:"参数说明",placement:"top",width:"255px"},{reference:b(()=>[y(f,null,{default:b(()=>[y(r)]),_:1})]),default:b(()=>[_("p",null,g(e.variable.remark),1)]),_:1})):I("",!0)}const L=k(xe,[["render",Te],["__scopeId","data-v-5814def3"]]);const Me={name:"FieldSetting",components:{VariableRemarkIcon:L,TableFieldVariableInput:J,MySqlFieldSelect:_e},props:{valueKey:{default:"value"},table:{required:!0},group:{required:!0}},methods:{handleSelect(l){for(const t of l){t.origin==null&&(t.origin=JSON.parse(JSON.stringify(t)));for(const e of this.group.children)t[e.name]=M(t[e.name])?e.defaultValue:t[e.name],M(t[e.name])&&(t[e.name]=G(e.inputType))}this.group[this.valueKey]=l,this.emitChange()},emitChange(){this.$emit("change")},getColumnMinWidth(l){return l.inputType==="select"?"150px":"120px"}}},Ke={class:"column-header-wrap"},Oe={key:0,class:"required"};function Ue(l,t,e,d,i,o){const r=a("MySqlFieldSelect"),f=a("el-table-column"),v=a("VariableRemarkIcon"),V=a("TableFieldVariableInput"),C=a("el-table");return n(),c(S,null,[_("h5",null,g(e.group.label),1),y(r,{"onUpdate:modelValue":o.handleSelect,"model-value":e.group[e.valueKey],table:e.table,placeholder:"Select fields"},null,8,["onUpdate:modelValue","model-value","table"]),y(C,{size:"small",data:e.group[e.valueKey]},{default:b(()=>[y(f,{label:"字段名",width:"100px",prop:"name",fixed:""}),(n(!0),c(S,null,F(e.group.children,u=>(n(),p(f,{key:u.name,label:u.label,"min-width":o.getColumnMinWidth(u)},{header:b(()=>[_("div",Ke,[u.required?(n(),c("em",Oe,"*")):I("",!0),_("label",null,g(u.label),1),y(v,{variable:u},null,8,["variable"])])]),default:b(({row:s})=>[y(V,{variable:u,modelValue:s[u.name],"onUpdate:modelValue":h=>s[u.name]=h,onChange:o.emitChange},null,8,["variable","modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label","min-width"]))),128))]),_:1},8,["data"])],64)}const qe=k(Me,[["render",Ue],["__scopeId","data-v-7d284e02"]]);const De={name:"TableSelect",components:{FieldSetting:qe},props:{modelValue:{},valueKey:{default:"value"},variable:{required:!0}},data(){return{selected:null,databases:[],tables:[]}},computed:{...K(["currentProject","currentDatabase"]),fieldVariableGroup(){return this.variable.children||[]}},watch:{currentDatabase(){this.fetchTables()}},methods:{handleChange(l){this.selected=this.tables.find(t=>t.name===l),this.fieldVariableGroup.forEach(t=>{t[this.valueKey]=[]}),this.$emit("update:modelValue",l),this.$emit("change",l)},emitChange(){this.$emit("change")},fetchDatabases(){q().then(l=>{this.databases=l,this.fetchTables()}).catch(l=>{this.$tip.apiFailed(l)})},fetchTables(){const l=this.databases.find(t=>t.id===this.currentDatabase);if(l==null){this.tables=[];return}B({host:l.host,port:l.port,user:l.username,password:l.password,database:l.schema}).then(t=>{this.tables=t,this.modelValue!=null&&(this.selected=this.tables.find(e=>e.name===this.modelValue),this.selected==null&&this.handleChange(null))}).catch(t=>{this.$tip.apiFailed(t)})}},created(){this.fetchDatabases()}},Qe={class:"option-content"},$e={class:"text-info-1"},Ne={key:0,class:"field-settings"};function We(l,t,e,d,i,o){const r=a("el-option"),f=a("el-select"),v=a("FieldSetting");return n(),c(S,null,[y(f,{class:"table-select","popper-class":"table-select__popper","model-value":e.modelValue,clearable:"",onChange:o.handleChange},{default:b(()=>[(n(!0),c(S,null,F(i.tables,V=>(n(),p(r,{key:V.name,value:V.name,label:V.name},{default:b(()=>[_("p",Qe,[_("span",null,g(V.name),1),_("span",$e,g(V.comment),1)])]),_:2},1032,["value","label"]))),128))]),_:1},8,["model-value","onChange"]),i.selected!=null&&o.fieldVariableGroup.length>0?(n(),c("ul",Ne,[(n(!0),c(S,null,F(o.fieldVariableGroup,V=>(n(),c("li",{key:V.label},[y(v,{"value-key":e.valueKey,table:i.selected,group:V,onChange:o.emitChange},null,8,["value-key","table","group","onChange"])]))),128))])):I("",!0)],64)}const Re=k(De,[["render",We],["__scopeId","data-v-624bbd32"]]);const Ee={name:"QueryModelFieldSelect",props:{modelValue:{},model:{required:!0},multiple:{default:!0}},data(){return{focused:!1,tables:[],selectedFields:[],currentHoverTable:null,currentHoverField:null,leaveFieldTimeout:null}},watch:{model:{immediate:!0,handler(){this.__handleTables()}},modelValue:{immediate:!0,handler(){this.selectedFields.splice(0,this.selectedFields.length),this.selectedFields.push.apply(this.selectedFields,this.__getSelectedFieldsObjects(this.modelValue))}}},methods:{focus(){this.focused=!0},handleFieldSorted(){this.$emit("update:modelValue",this.selectedFields.map(l=>`${l.table.id}.${l.name}`)),this.$emit("fields:change",this.selectedFields)},handleCheckAllChange(l,t){let e=[];t&&(e=l.fields.map(i=>`${l.id}.${i.name}`));let d=this.modelValue;d=d.filter(i=>!i.startsWith(`${l.id}.`)),d=d.concat(e),this.handleInput(l,d)},handleInput(l,t){const e=t.filter(i=>i.startsWith(`${l.id}.`));l.checkedAll=e.length===l.fields.length;let d=this.__getSelectedFieldsObjects(t);this.selectedFields.splice(0,this.selectedFields.length),this.selectedFields.push.apply(this.selectedFields,d),this.$emit("update:modelValue",t),this.$emit("fields:change",this.selectedFields)},handleFieldEnter(l){this.leaveFieldTimeout!=null&&clearTimeout(this.leaveFieldTimeout),this.currentHoverField=l},handleFieldLeave(){this.leaveFieldTimeout=setTimeout(()=>{this.currentHoverField=null},500)},handleTableEnter(l){this.currentHoverTable=l},handleTableLeave(){this.currentHoverTable=null},close(){this.focused=!1,this.handleTableLeave(),this.handleFieldLeave()},__handleTables(){this.tables=[];for(const l of this.model.tables){const t=l.fields.filter(e=>e.visible);t.length>0&&this.tables.push({id:l.id,type:l.type,name:l.name,alias:l.alias,fields:t,checkedAll:!1})}},__getSelectedFieldsObjects(l){return l.map(t=>{const e=t.split(".")[0],d=t.split(".")[1],i=this.model.tables.find(v=>v.id===e),o=i.fields.find(v=>v.name===d);if(o==null)return null;const r=JSON.parse(JSON.stringify(i)),f=JSON.parse(JSON.stringify(o));return delete r.fields,f.table=r,f}).filter(t=>t!=null)}}},j=l=>(O("data-v-738452e6"),l=l(),U(),l),Ae={class:"model-field-select"},He={key:0,class:"placeholder"},Je=["onMouseenter"],Ge=j(()=>_("em",null,"AS",-1)),Le={key:0},je={class:"field-select__tables"},Be=["onMouseenter"],Pe={class:"table__header"},ze={class:"table__fields-wrap"},Xe={class:"table-fields"},Ye=j(()=>_("em",null,"AS",-1)),Ze={key:0,class:"text-info-1"};function el(l,t,e,d,i,o){const r=a("el-checkbox"),f=a("el-checkbox-group"),v=a("el-scrollbar"),V=a("el-popover"),C=D("sortable");return n(),c("div",Ae,[y(V,{trigger:"click","popper-class":"model-field-select-popper","hide-after":0,persistent:!1,onHide:o.close},{reference:b(()=>[Q((n(),c("ul",{class:T(["selected-preview",{"is-focus":i.focused}]),onClick:t[1]||(t[1]=(...u)=>o.focus&&o.focus(...u))},[i.selectedFields.length===0?(n(),c("li",He,"请选择")):(n(!0),c(S,{key:1},F(i.selectedFields,u=>(n(),c("li",{key:u.name,class:T({"field-light":i.currentHoverTable!=null&&u.table.id===i.currentHoverTable.id}),onMouseenter:s=>o.handleFieldEnter(u),onMouseleave:t[0]||(t[0]=(...s)=>o.handleFieldLeave&&o.handleFieldLeave(...s))},[_("p",null,[x(g(u.table.alias)+"."+g(u.name)+" ",1),u.alias!==u.name?(n(),c(S,{key:0},[Ge,x(),_("b",null,g(u.alias),1)],64)):I("",!0)]),u.comment!=null&&u.comment!==""?(n(),c("p",Le,g(u.comment),1)):I("",!0)],42,Je))),128))],2)),[[C,{data:i.selectedFields,onChange:o.handleFieldSorted},"config"]])]),default:b(()=>[_("div",je,[(n(!0),c(S,null,F(i.tables,u=>(n(),c("div",{key:u.alias,class:T(["field-select__table",{"table-main":u.type==="MAIN","table-light":i.currentHoverField!=null&&u.id===i.currentHoverField.table.id}]),onMouseenter:s=>o.handleTableEnter(u),onMouseleave:t[2]||(t[2]=(...s)=>o.handleTableLeave&&o.handleTableLeave(...s))},[_("div",Pe,[y(r,{modelValue:u.checkedAll,"onUpdate:modelValue":s=>u.checkedAll=s,onChange:s=>o.handleCheckAllChange(u,s)},{default:b(()=>[_("h4",null,g(u.name)+" AS "+g(u.alias),1)]),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])]),_("div",ze,[y(v,null,{default:b(()=>[_("div",Xe,[y(f,{"model-value":e.modelValue,onChange:s=>o.handleInput(u,s)},{default:b(()=>[(n(!0),c(S,null,F(u.fields,s=>(n(),p(r,{label:`${u.id}.${s.name}`,key:s.name},{default:b(()=>[_("p",null,[x(g(s.name)+" ",1),s.alias!==s.name?(n(),c(S,{key:0},[Ye,x(),_("b",null,g(s.alias),1)],64)):I("",!0)]),s.comment!==""?(n(),c("p",Ze,g(s.comment),1)):I("",!0)]),_:2},1032,["label"]))),128))]),_:2},1032,["model-value","onChange"])])]),_:2},1024)])],42,Be))),128))])]),_:1},8,["onHide"])])}const ll=k(Ee,[["render",el],["__scopeId","data-v-738452e6"]]);const tl={name:"QueryModelFieldSetting",components:{VariableRemarkIcon:L,SortableButton:P,QueryModelFieldSelect:ll,TableFieldVariableInput:J},props:{valueKey:{default:"value"},model:{required:!0},group:{required:!0}},data(){return{selectedFields:[]}},watch:{model(){this.initSelectedFields()}},methods:{handleSort(){this.initSelectedFields(),this.emitChange()},initSelectedFields(){this.selectedFields=[];const l=this.group[this.valueKey];l!=null&&l.length>0&&(this.selectedFields=l.map(t=>`${t.table.id}.${t.name}`))},handleSelect(l){const t=[];for(const e of l){e.origin==null&&(e.origin=JSON.parse(JSON.stringify(e)));for(const d of this.group.children)e[d.name]=M(e[d.name])?d.defaultValue:e[d.name],M(e[d.name])&&(e[d.name]=G(d.inputType));t.push(e)}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(l){return l.inputType==="select"?"150px":"120px"}},created(){this.initSelectedFields()}},nl=l=>(O("data-v-f9e87003"),l=l(),U(),l),al=nl(()=>_("em",null,"AS",-1)),ol={key:0,class:"required"};function il(l,t,e,d,i,o){const r=a("QueryModelFieldSelect"),f=a("SortableButton"),v=a("el-table-column"),V=a("VariableRemarkIcon"),C=a("TableFieldVariableInput"),u=a("el-table"),s=D("sortable");return n(),c(S,null,[_("h5",null,g(e.group.label),1),y(r,{modelValue:i.selectedFields,"onUpdate:modelValue":t[0]||(t[0]=h=>i.selectedFields=h),model:e.model,placeholder:"Select fields","onFields:change":o.handleSelect},null,8,["modelValue","model","onFields:change"]),e.group.children.length>0?Q((n(),p(u,{key:0,size:"small",data:e.group[e.valueKey],"row-key":h=>`${h.table.id}.${h.name}@${h.alias}`},{default:b(()=>[y(v,{width:"25px",fixed:""},{default:b(()=>[y(f)]),_:1}),y(v,{label:"字段名",width:"150px",prop:"name",fixed:""},{default:b(({row:h})=>[_("p",null,[x(g(h.table.alias)+"."+g(h.name)+" ",1),h.alias!==h.name?(n(),c(S,{key:0},[al,x(),_("b",null,g(h.alias),1)],64)):I("",!0)]),_("p",null,g(h.comment),1)]),_:1}),(n(!0),c(S,null,F(e.group.children,h=>(n(),p(v,{key:h.name,label:h.label,"min-width":o.getColumnMinWidth(h)},{header:b(()=>[h.required?(n(),c("em",ol,"*")):I("",!0),_("label",null,g(h.label),1),y(V,{variable:h},null,8,["variable"])]),default:b(({row:w})=>[y(C,{variable:h,modelValue:w[h.name],"onUpdate:modelValue":m=>w[h.name]=m,onChange:o.emitChange},null,8,["variable","modelValue","onUpdate:modelValue","onChange"])]),_:2},1032,["label","min-width"]))),128))]),_:1},8,["data","row-key"])),[[s,{data:e.group[e.valueKey],onChange:o.handleSort},"config"]]):I("",!0)],64)}const sl=k(tl,[["render",il],["__scopeId","data-v-f9e87003"]]);const ul={name:"QueryModelWindow",components:{DataSourceSelect:$,QueryModelView:z},data(){return{visible:!1}},computed:{...K(["currentDatabase"])},methods:{open(){this.visible=!0},close(){this.visible=!1,this.$emit("close")}}},dl=_("h2",null,"查询模型设计",-1),rl={class:"header__opera"};function cl(l,t,e,d,i,o){const r=a("DataSourceSelect"),f=a("Close"),v=a("el-icon"),V=a("QueryModelView"),C=a("el-dialog");return n(),p(C,{"custom-class":"query-model-window",modelValue:i.visible,"onUpdate:modelValue":t[0]||(t[0]=u=>i.visible=u),fullscreen:"","append-to-body":"","show-close":!1},{header:b(()=>[dl,_("div",rl,[y(r,{"model-value":l.currentDatabase},null,8,["model-value"]),y(v,{onClick:o.close},{default:b(()=>[y(f)]),_:1},8,["onClick"])])]),default:b(()=>[y(V)]),_:1},8,["modelValue"])}const ml=k(ul,[["render",cl]]),_l="/images/database/icon-design.svg";const hl={name:"QueryModelSelect",components:{QueryModelWindow:ml,QueryModelFieldSetting:sl},props:{modelValue:{},valueKey:{default:"value"},variable:{required:!0}},data(){return{databases:[],models:[],selected:null}},computed:{...K(["currentProject","currentDatabase"]),fieldVariableGroup(){return this.variable.children||[]}},watch:{currentDatabase(){this.fetchModels()}},methods:{handleChange(l){this.selected=this.models.find(t=>t.id===l),this.fieldVariableGroup.forEach(t=>{t[this.valueKey]=[]}),this.$emit("update:modelValue",l),this.emitChange()},emitChange(){this.$emit("change")},fetchDatabases(){q().then(l=>{this.databases=l,this.fetchModels()}).catch(l=>{this.$tip.apiFailed(l)})},fetchModels(){const l=this.databases.find(t=>t.id===this.currentDatabase);if(l==null){this.models=[];return}this.models=l.models,this.modelValue!=null&&(this.selected=this.models.find(t=>t.id===this.modelValue),this.selected==null&&this.handleChange(null))}},created(){this.fetchDatabases()}},pl=l=>(O("data-v-0179f899"),l=l(),U(),l),vl={class:"query-model-select"},bl={class:"option-content"},fl={class:"text-info-1"},yl=pl(()=>_("img",{src:_l},null,-1)),gl={key:0,class:"field-settings"};function Vl(l,t,e,d,i,o){const r=a("el-option"),f=a("el-select"),v=a("el-button"),V=a("QueryModelWindow"),C=a("QueryModelFieldSetting");return n(),c(S,null,[_("div",vl,[y(f,{class:"model-select","popper-class":"model-select__popper","model-value":e.modelValue,clearable:"",onChange:o.handleChange},{default:b(()=>[(n(!0),c(S,null,F(i.models,u=>(n(),p(r,{key:u.id,value:u.id,label:u.name},{default:b(()=>[_("p",bl,[_("span",null,g(u.name),1),_("span",fl,g(u.comment),1)])]),_:2},1032,["value","label"]))),128))]),_:1},8,["model-value","onChange"]),y(v,{class:"button-icon",type:"primary",onClick:t[0]||(t[0]=u=>l.$refs.queryModelWindow.open())},{default:b(()=>[yl]),_:1}),y(V,{ref:"queryModelWindow",onClose:o.fetchDatabases},null,8,["onClose"])]),i.selected!=null&&o.fieldVariableGroup.length>0?(n(),c("ul",gl,[(n(!0),c(S,null,F(o.fieldVariableGroup,u=>(n(),c("li",{key:u.label},[y(C,{"value-key":e.valueKey,model:i.selected,group:u,onChange:o.emitChange},null,8,["value-key","model","group","onChange"])]))),128))])):I("",!0)],64)}const Sl=k(hl,[["render",Vl],["__scopeId","data-v-0179f899"]]);const kl={name:"VariableInput",components:{InstallNumberInput:A,InstallSelect:E,DataSourceSelect:$,QueryModelSelect:Sl,TableSelect:Re,InstallCheckbox:N,InstallRadio:R,InstallInput:W,InstallSwitch:H},props:{variable:{required:!0},valueKey:{default:"value"}},computed:{inputType(){return this.variable.inputType}}},Il={class:"variable-input"};function Cl(l,t,e,d,i,o){const r=a("InstallInput"),f=a("InstallNumberInput"),v=a("InstallSelect"),V=a("InstallCheckbox"),C=a("InstallRadio"),u=a("InstallSwitch"),s=a("DataSourceSelect"),h=a("TableSelect"),w=a("QueryModelSelect");return n(),c("div",Il,[e.variable.inputType==="input"?(n(),p(r,{key:0,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[0]||(t[0]=m=>e.variable[e.valueKey]=m),onInput:t[1]||(t[1]=m=>l.$emit("change",m))},null,8,["modelValue"])):e.variable.inputType==="number_input"?(n(),p(f,{key:1,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[2]||(t[2]=m=>e.variable[e.valueKey]=m),onInput:t[3]||(t[3]=m=>l.$emit("change",m))},null,8,["modelValue"])):e.variable.inputType==="textarea"?(n(),p(r,{key:2,type:"textarea",modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[4]||(t[4]=m=>e.variable[e.valueKey]=m),onInput:t[5]||(t[5]=m=>l.$emit("change",m))},null,8,["modelValue"])):e.variable.inputType==="select"?(n(),p(v,{key:3,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[6]||(t[6]=m=>e.variable[e.valueKey]=m),options:e.variable.options,onChange:t[7]||(t[7]=m=>l.$emit("change",m))},null,8,["modelValue","options"])):e.variable.inputType==="checkbox"?(n(),p(V,{key:4,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[8]||(t[8]=m=>e.variable[e.valueKey]=m),options:e.variable.options,onChange:t[9]||(t[9]=m=>l.$emit("change",m))},null,8,["modelValue","options"])):e.variable.inputType==="radio"?(n(),p(C,{key:5,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[10]||(t[10]=m=>e.variable[e.valueKey]=m),options:e.variable.options,onChange:t[11]||(t[11]=m=>l.$emit("change",m))},null,8,["modelValue","options"])):e.variable.inputType==="switch"?(n(),p(u,{key:6,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[12]||(t[12]=m=>e.variable[e.valueKey]=m),onInput:t[13]||(t[13]=m=>l.$emit("change",m))},null,8,["modelValue"])):e.variable.inputType==="datasource"?(n(),p(s,{key:7,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[14]||(t[14]=m=>e.variable[e.valueKey]=m),"with-prefix":!1,"with-block":!0,onChange:t[15]||(t[15]=m=>l.$emit("change",m))},null,8,["modelValue"])):e.variable.inputType==="table"?(n(),p(h,{key:8,variable:e.variable,"value-key":e.valueKey,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[16]||(t[16]=m=>e.variable[e.valueKey]=m),onChange:t[17]||(t[17]=m=>l.$emit("change",m))},null,8,["variable","value-key","modelValue"])):e.variable.inputType==="query_model"?(n(),p(w,{key:9,variable:e.variable,"value-key":e.valueKey,modelValue:e.variable[e.valueKey],"onUpdate:modelValue":t[18]||(t[18]=m=>e.variable[e.valueKey]=m),onChange:t[19]||(t[19]=m=>l.$emit("change",m))},null,8,["variable","value-key","modelValue"])):I("",!0)])}const ql=k(kl,[["render",Cl],["__scopeId","data-v-ea68e2f3"]]);const Fl={name:"ServiceCodeErrorWindow",data(){return{visible:!1,error:null}},methods:{open(l){this.error=l,this.visible=!0}}},wl={class:"window-header-wrap"},xl={class:"title"},Tl={class:"tip"},Ml={class:"window-content-wrap"};function Kl(l,t,e,d,i,o){const r=a("CircleCloseFilled"),f=a("el-icon"),v=a("el-dialog");return n(),p(v,{modelValue:i.visible,"onUpdate:modelValue":t[0]||(t[0]=V=>i.visible=V),width:"1000px","custom-class":"service-code-error-window","show-close":!1},{header:b(()=>[_("div",wl,[_("div",xl,[y(f,null,{default:b(()=>[y(r)]),_:1}),_("h5",null,g(l.$t("service.serviceCodeErrorTitle")),1)]),_("p",Tl,g(l.$t("service.serviceCodeErrorTip")),1)])]),default:b(()=>[_("div",Ml,[_("p",null,"at "+g(i.error.position),1),_("pre",null,g(i.error.message),1)])]),_:1},8,["modelValue"])}const Dl=k(Fl,[["render",Kl]]);export{qe as F,R as I,_e as M,be as O,Dl as S,L as V,ql as a,W as b,N as c,G as g,M as i};