1 |
- import{h as A,y as L,r as z,B as R,p as a,l as g,a6 as j,M as f,N as u,q as p,k as m,ay as J,a0 as b,T as h,U as E,$ as T,o as F,V as C,a4 as v,W as M,J as O,ah as Q,t as _,a7 as W}from"./vue-a39e6937.js";import{F as $}from"./index-f0d8af94.js";import{_ as H,i as X,p as Y,d as Z,a as ee}from"./add.vue_vue_type_script_setup_true_lang-7e2aaee1.js";import{r as te}from"./router-1773feb7.js";import{b as oe}from"./validate-4ecec794.js";import{f as ne,u as ae,g as S,_ as re}from"./index-ba596ae9.js";import"./index-434d719f.js";import"./controllerUrls-941681c3.js";import"./index-7e56a0fa.js";const le={class:"default-main"},ie={class:"config-form-item"},se={class:"config-form-item-name"},de={class:"del-config-form-item"},ue={key:0,class:"send-test-mail"},ce=["onClick"],fe=A({name:"routine/config"}),pe=A({...fe,setup(me){const{t:s}=ne(),B=ae(),y=L(),e=z({loading:!0,config:[],remark:"",configGroup:{},activeTab:"",showAddForm:!1,rules:{},form:{},quickEntrance:{},formKey:S()}),K=()=>{X().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 n in e.configGroup){e.activeTab=n;break}let o={},r={};for(const n in e.config)for(const l in e.config[n].list){if(e.config[n].list[l].rule){let x=e.config[n].list[l].rule.split(","),V=[];x.forEach(w=>{V.push(oe({name:w,title:e.config[n].list[l].title}))}),r=Object.assign(r,{[e.config[n].list[l].name]:V})}o[e.config[n].list[l].name]=e.config[n].list[l].type=="number"?parseFloat(e.config[n].list[l].value):e.config[n].list[l].value}e.form=o,e.rules=r,e.formKey=S()}).catch(()=>{e.loading=!1})},D=i=>{if(i=="add_config")return e.showAddForm=!0,!1},k=i=>{i&&i.validate(o=>{if(o){const r={};for(const n in e.config)if(n==e.activeTab)for(const l in e.config[n].list)r[e.config[n].list[l].name]=e.form[e.config[n].list[l].name]??"";Y("edit",r).then(()=>{for(const n in B.$state)r[n]&&B.$state[n]!=r[n]&&(B.$state[n]=r[n])})}})},I=i=>{Z([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 O({type:"error",message:s("routine.config.Please enter the correct mail configuration")}),!1;Q.prompt(s("routine.config.Please enter the recipient email address"),s("routine.config.Test mail sending"),{confirmButtonText:s("routine.config.send out"),cancelButtonText:s("Cancel"),inputPattern:/[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,inputErrorMessage:s("routine.config.Please enter the correct email address"),beforeClose:(i,o,r)=>{i==="confirm"?(o.confirmButtonLoading=!0,o.confirmButtonText=s("routine.config.Sending"),ee(e.form,o.inputValue).then(n=>{r()}).catch(n=>{r()})):r()}})};return R(()=>{K()}),(i,o)=>{const r=_("Icon"),n=_("el-popconfirm"),l=_("el-button"),x=_("el-tab-pane"),V=_("el-tabs"),w=_("el-col"),q=_("el-card"),G=_("el-row"),P=W("loading");return a(),g("div",le,[j((a(),f(G,{gutter:20},{default:u(()=>[p(w,{class:"xs-mb-20",xs:24,sm:16},{default:u(()=>[e.loading?v("",!0):(a(),f(m(J),{ref_key:"formRef",ref:y,onKeyup:o[7]||(o[7]=b(d=>k(y.value),["enter"])),model:e.form,rules:e.rules,"label-position":"top",key:e.formKey},{default:u(()=>[p(V,{modelValue:e.activeTab,"onUpdate:modelValue":o[6]||(o[6]=d=>e.activeTab=d),type:"border-card","before-leave":D},{default:u(()=>[(a(!0),g(h,null,E(e.config,(d,U)=>(a(),f(x,{class:"config-tab-pane",key:U,name:U,label:d.title},{default:u(()=>[(a(!0),g(h,null,E(d.list,(t,_e)=>(a(),g("div",ie,[t.group==e.activeTab?(a(),g(h,{key:0},[t.type=="number"?(a(),f($,{label:t.title,type:t.type,modelValue:e.form[t.name],"onUpdate:modelValue":c=>e.form[t.name]=c,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"?(a(),f($,{label:t.title,type:t.type,onKeyup:[o[0]||(o[0]=b(T(()=>{},["stop"]),["enter"])),o[1]||(o[1]=b(T(c=>k(y.value),["ctrl"]),["enter"]))],modelValue:e.form[t.name],"onUpdate:modelValue":c=>e.form[t.name]=c,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"?(a(),f($,{label:t.title,type:t.type,onKeyup:[o[2]||(o[2]=b(T(()=>{},["stop"]),["enter"])),o[3]||(o[3]=b(T(c=>k(y.value),["ctrl"]),["enter"]))],modelValue:e.form[t.name],"onUpdate:modelValue":c=>e.form[t.name]=c,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"])):(a(),f($,{label:t.title,type:t.type,modelValue:e.form[t.name],"onUpdate:modelValue":c=>e.form[t.name]=c,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"])),F("div",se,"$"+C(t.name),1),F("div",de,[t.allow_del?(a(),f(n,{key:0,onConfirm:c=>I(t),confirmButtonText:m(s)("delete"),title:m(s)("routine.config.Are you sure to delete the configuration item?")},{reference:u(()=>[p(r,{class:"close-icon",size:"15",name:"el-icon-Close"})]),_:2},1032,["onConfirm","confirmButtonText","title"])):v("",!0)])],64)):v("",!0)]))),256)),d.name=="mail"?(a(),g("div",ue,[p(l,{onClick:o[4]||(o[4]=t=>N())},{default:u(()=>[M(C(m(s)("routine.config.Test mail sending")),1)]),_:1})])):v("",!0),p(l,{type:"primary",onClick:o[5]||(o[5]=t=>k(y.value))},{default:u(()=>[M(C(m(s)("Save")),1)]),_:1})]),_:2},1032,["name","label"]))),128)),p(x,{name:"add_config",class:"config-tab-pane config-tab-pane-add",label:m(s)("routine.config.Add configuration item")},null,8,["label"])]),_:1},8,["modelValue"])]),_:1},8,["model","rules"]))]),_:1}),p(w,{xs:24,sm:8},{default:u(()=>[p(q,{header:m(s)("routine.config.Quick configuration entry")},{default:u(()=>[(a(!0),g(h,null,E(e.quickEntrance,d=>(a(),f(l,{class:"config_quick_entrance"},{default:u(()=>[F("div",{onClick:U=>m(te)(d.value)},C(d.key),9,ce)]),_:2},1024))),256))]),_:1},8,["header"])]),_:1})]),_:1})),[[P,e.loading]]),e.loading?v("",!0):(a(),f(H,{key:0,modelValue:e.showAddForm,"onUpdate:modelValue":o[8]||(o[8]=d=>e.showAddForm=d),"config-group":e.configGroup},null,8,["modelValue","config-group"]))])}}});const Te=re(pe,[["__scopeId","data-v-a1186bc3"]]);export{Te as default};
|