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