1 |
- import{d as R,a2 as j,a as z,r as O,o as Q,aF as Z,aI as H,A as J,K as p,aq as W,e as r,f as g,am as X,y as f,L as c,ac as y,F as V,ae as w,t as h,i as E,u as _,j as m,C as b,B as F,m as D,Z as Y,as as ee}from"./vue-A59npLRR.js";import{F as C}from"./index-r6iTpmP6.js";import{_ as te,i as oe,p as ne,d as ae,a as re}from"./add.vue_vue_type_script_setup_true_lang-eHoSnGbd.js";import{u as le,b as I,E as S,_ as ie}from"./index-EwE51S_X.js";import{r as se}from"./router-SYMbkQDJ.js";import{b as de}from"./validate-_EUdkMt3.js";import"./index-K8IR974I.js";import"./baTable-MdxYOkAk.js";import"./index-XALue448.js";import"./echarts-cxb9vJr1.js";const ce={class:"default-main"},ue={class:"config-form-item"},fe={class:"config-form-item-name"},pe={class:"del-config-form-item"},me={key:0,class:"send-test-mail"},ge=["onClick"],_e=R({name:"routine/config",__name:"index",setup(ye){const{t:l}=j(),T=le(),$=z(),e=O({loading:!0,config:[],remark:"",configGroup:{},activeTab:"",showAddForm:!1,rules:{},form:{},quickEntrance:{},formKey:I()}),K=()=>{oe().then(i=>{e.config=i.data.list,e.remark=i.data.remark,e.configGroup=i.data.configGroup,e.quickEntrance=i.data.quickEntrance,e.loading=!1;for(const a in e.configGroup){e.activeTab=a;break}let o={},n={};for(const a in e.config)for(const s in e.config[a].list){if(e.config[a].list[s].rule){let k=e.config[a].list[s].rule.split(","),x=[];k.forEach(B=>{x.push(de({name:B,title:e.config[a].list[s].title}))}),n=Object.assign(n,{[e.config[a].list[s].name]:x})}o[e.config[a].list[s].name]=e.config[a].list[s].type=="number"?parseFloat(e.config[a].list[s].value):e.config[a].list[s].value}e.form=o,e.rules=n,e.formKey=I()}).catch(()=>{e.loading=!1})},M=i=>{if(i=="add_config")return e.showAddForm=!0,!1},v=()=>{$.value&&$.value.validate(i=>{if(i){const o={};for(const n in e.config)if(n==e.activeTab)for(const a in e.config[n].list)o[e.config[n].list[a].name]=e.form[e.config[n].list[a].name]??"";ne("edit",o).then(()=>{for(const n in T.$state)o[n]&&T.$state[n]!=o[n]&&(T.$state[n]=o[n]);o.backend_entrance!=S&&(window.open(window.location.href.replace(S,o.backend_entrance)),window.close())})}})},q=i=>{ae([i.id]).then(()=>{K()})},N=()=>{if(!e.form.smtp_server||!e.form.smtp_port||!e.form.smtp_user||!e.form.smtp_pass||!e.form.smtp_sender_mail)return Y({type:"error",message:l("routine.config.Please enter the correct mail configuration")}),!1;ee.prompt(l("routine.config.Please enter the recipient email address"),l("routine.config.Test mail sending"),{confirmButtonText:l("routine.config.send out"),cancelButtonText:l("Cancel"),inputPattern:/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,inputErrorMessage:l("routine.config.Please enter the correct email address"),beforeClose:(i,o,n)=>{i==="confirm"?(o.confirmButtonLoading=!0,o.confirmButtonText=l("routine.config.Sending"),re(e.form,o.inputValue).then(a=>{n()}).catch(a=>{n()})):n()}})};return Q(()=>{K()}),Z(()=>{}),H(()=>{}),J(()=>{}),(i,o)=>{const n=p("Icon"),a=p("el-popconfirm"),s=p("el-button"),k=p("el-tab-pane"),x=p("el-tabs"),B=p("el-form"),A=p("el-col"),P=p("el-card"),G=p("el-row"),L=W("loading");return r(),g("div",ce,[X((r(),f(G,{gutter:20},{default:c(()=>[m(A,{class:"xs-mb-20",xs:24,sm:16},{default:c(()=>[e.loading?b("",!0):(r(),f(B,{ref_key:"formRef",ref:$,onKeyup:o[7]||(o[7]=y(d=>v(),["enter"])),model:e.form,rules:e.rules,"label-position":"top",key:e.formKey},{default:c(()=>[m(x,{modelValue:e.activeTab,"onUpdate:modelValue":o[6]||(o[6]=d=>e.activeTab=d),type:"border-card","before-leave":M},{default:c(()=>[(r(!0),g(V,null,F(e.config,(d,U)=>(r(),f(k,{class:"config-tab-pane",key:U,name:U,label:d.title},{default:c(()=>[(r(!0),g(V,null,F(d.list,(t,be)=>(r(),g("div",ue,[t.group==e.activeTab?(r(),g(V,{key:0},[t.type=="number"?(r(),f(C,{label:t.title,type:t.type,modelValue:e.form[t.name],"onUpdate:modelValue":u=>e.form[t.name]=u,modelModifiers:{number:!0},attr:{prop:t.name,...t.extend},"input-attr":{placeholder:t.tip,...t.input_extend},data:{tip:t.tip},key:"number-"+t.id},null,8,["label","type","modelValue","onUpdate:modelValue","attr","input-attr","data"])):t.type=="editor"?(r(),f(C,{label:t.title,type:t.type,onKeyup:[o[0]||(o[0]=y(w(()=>{},["stop"]),["enter"])),o[1]||(o[1]=y(w(u=>v(),["ctrl"]),["enter"]))],modelValue:e.form[t.name],"onUpdate:modelValue":u=>e.form[t.name]=u,attr:{prop:t.name,...t.extend},"input-attr":{placeholder:t.tip,style:{zIndex:99},...t.input_extend},data:{tip:t.tip},key:"editor-"+t.id},null,8,["label","type","modelValue","onUpdate:modelValue","attr","input-attr","data"])):t.type=="textarea"?(r(),f(C,{label:t.title,type:t.type,onKeyup:[o[2]||(o[2]=y(w(()=>{},["stop"]),["enter"])),o[3]||(o[3]=y(w(u=>v(),["ctrl"]),["enter"]))],modelValue:e.form[t.name],"onUpdate:modelValue":u=>e.form[t.name]=u,attr:{prop:t.name,...t.extend},"input-attr":{placeholder:t.tip,rows:3,...t.input_extend},data:{tip:t.tip},key:"textarea-"+t.id},null,8,["label","type","modelValue","onUpdate:modelValue","attr","input-attr","data"])):(r(),f(C,{label:t.title,type:t.type,modelValue:e.form[t.name],"onUpdate:modelValue":u=>e.form[t.name]=u,attr:{prop:t.name,...t.extend},"input-attr":{placeholder:t.tip,...t.input_extend},data:{tip:t.tip,content:t.content?t.content:{}},key:"other-"+t.id},null,8,["label","type","modelValue","onUpdate:modelValue","attr","input-attr","data"])),E("div",fe,"$"+h(t.name),1),E("div",pe,[t.allow_del?(r(),f(a,{key:0,onConfirm:u=>q(t),confirmButtonText:_(l)("Delete"),title:_(l)("routine.config.Are you sure to delete the configuration item?")},{reference:c(()=>[m(n,{class:"close-icon",size:"15",name:"el-icon-Close"})]),_:2},1032,["onConfirm","confirmButtonText","title"])):b("",!0)])],64)):b("",!0)]))),256)),d.name=="mail"?(r(),g("div",me,[m(s,{onClick:o[4]||(o[4]=t=>N())},{default:c(()=>[D(h(_(l)("routine.config.Test mail sending")),1)]),_:1})])):b("",!0),m(s,{type:"primary",onClick:o[5]||(o[5]=t=>v())},{default:c(()=>[D(h(_(l)("Save")),1)]),_:1})]),_:2},1032,["name","label"]))),128)),m(k,{name:"add_config",class:"config-tab-pane config-tab-pane-add",label:_(l)("routine.config.Add configuration item")},null,8,["label"])]),_:1},8,["modelValue"])]),_:1},8,["model","rules"]))]),_:1}),m(A,{xs:24,sm:8},{default:c(()=>[m(P,{header:_(l)("routine.config.Quick configuration entry")},{default:c(()=>[(r(!0),g(V,null,F(e.quickEntrance,d=>(r(),f(s,{class:"config_quick_entrance"},{default:c(()=>[E("div",{onClick:U=>_(se)({name:d.value})},h(d.key),9,ge)]),_:2},1024))),256))]),_:1},8,["header"])]),_:1})]),_:1})),[[L,e.loading]]),e.loading?b("",!0):(r(),f(te,{key:0,modelValue:e.showAddForm,"onUpdate:modelValue":o[8]||(o[8]=d=>e.showAddForm=d),"config-group":e.configGroup},null,8,["modelValue","config-group"]))])}}}),Ue=ie(_e,[["__scopeId","data-v-964f3a62"]]);export{Ue as default};
|