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