import{_ as Q}from"./index.vue_vue_type_script_setup_true_lang-C2H7PsW9.js";import{_ as A}from"./index-BdFxm7qE.js";import{x as K,s as R,k as H,r as f,l as J,y as O,E as s,I as p,G as v,O as o,u as t,F as l,ae as $,K as c,C as I,an as W,j as E,z as n}from"./vue-vendor-vBC20LeU.js";import{_ as X,t as Y,a as Z}from"./edit.vue_vue_type_script_setup_true_lang-oK8CbzR0.js";import{J as ee,F as te,H as le,i as ae,k as ne,G as se,K as oe,M as ie,p as re,a as me}from"./element-plus-DckSU5ni.js";import"./index-D7dBOFlH.js";import"./axios-CG2WSiiR.js";const de={class:"sms-template"},ue={class:"wd-card-header"},pe={class:"flex mt-4 justify-end"},ce=K({name:"MessageTemplate"}),Ce=K({...ce,setup(_e){const V=R(),b=R(),i=H({page:1,limit:10,template_name:"",template_key:""}),D=f(0),y=f([]),k=f(!1),T=f([]),w=f(!0),m=f({id:{label:"ID",visible:!0},template_name:{label:"模板名称",visible:!0},template_key:{label:"模板键名",visible:!0},template_value:{label:"模板值",visible:!0},create_time:{label:"创建时间",visible:!0},operation:{label:"操作",visible:!0}}),_=async()=>{k.value=!0,Y(i).then(r=>{T.value=r.data||[],D.value=r.total||0,k.value=!1}).catch(()=>{k.value=!1})},C=()=>{i.page=1,_()},M=()=>{V.value?.resetFields(),C()},U=r=>{y.value=r},L=()=>{b.value?.open("add"),b.value?.setFormData()},F=r=>{b.value?.open("edit"),b.value?.setFormData(r||y.value[0])},B=r=>{const e=r||y.value.map(h=>h.id);re.confirm(`是否确认删除模板ID为 ${e} 的数据项吗？`,"提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{await Z({id:e}),me.success("删除成功"),_()}).catch(()=>{})};return J(()=>{_()}),(r,e)=>{const h=ae,x=le,d=ne,N=se,S=te,q=A,u=oe,P=ie,j=Q,g=W("perms"),z=ee;return n(),O("div",de,[t(w)?(n(),s(S,{key:0,class:"!border-none mb-4",shadow:"never"},{default:l(()=>[o(N,{class:"mb-[-16px]",ref_key:"queryFormRef",ref:V,model:t(i),inline:""},{default:l(()=>[o(x,{class:"w-[260px]",label:"模板名称",prop:"template_name"},{default:l(()=>[o(h,{modelValue:t(i).template_name,"onUpdate:modelValue":e[0]||(e[0]=a=>t(i).template_name=a),placeholder:"请输入模板名称",clearable:"",onKeyup:$(C,["enter"])},null,8,["modelValue"])]),_:1}),o(x,{class:"w-[260px]",label:"模板键名",prop:"template_key"},{default:l(()=>[o(h,{modelValue:t(i).template_key,"onUpdate:modelValue":e[1]||(e[1]=a=>t(i).template_key=a),placeholder:"请输入模板键名",clearable:"",onKeyup:$(C,["enter"])},null,8,["modelValue"])]),_:1}),o(x,null,{default:l(()=>[o(d,{type:"primary",onClick:C},{default:l(()=>[...e[7]||(e[7]=[c("搜索",-1)])]),_:1}),o(d,{onClick:M},{default:l(()=>[...e[8]||(e[8]=[c("重置",-1)])]),_:1})]),_:1})]),_:1},8,["model"])]),_:1})):p("",!0),v((n(),s(S,{class:"!border-none",shadow:"never"},{default:l(()=>[I("div",ue,[v((n(),s(d,{type:"primary",icon:"Plus",onClick:L},{default:l(()=>[...e[9]||(e[9]=[c(" 新增模板 ",-1)])]),_:1})),[[g,["message.smsTemplate/create"]]]),v((n(),s(d,{type:"warning",icon:"Edit",disabled:t(y).length!=1,onClick:e[2]||(e[2]=a=>F())},{default:l(()=>[...e[10]||(e[10]=[c(" 修改 ",-1)])]),_:1},8,["disabled"])),[[g,["message.smsTemplate/update"]]]),v((n(),s(d,{type:"danger",icon:"Delete",disabled:t(y).length==0,onClick:e[3]||(e[3]=a=>B())},{default:l(()=>[...e[11]||(e[11]=[c(" 删除 ",-1)])]),_:1},8,["disabled"])),[[g,["message.smsTemplate/delete"]]]),o(q,{showSearch:t(w),"onUpdate:showSearch":e[4]||(e[4]=a=>E(w)?w.value=a:null),columns:t(m),"onUpdate:columns":e[5]||(e[5]=a=>E(m)?m.value=a:null),onRefresh:_},null,8,["showSearch","columns"])]),o(P,{size:"large",data:t(T),onSelectionChange:U},{default:l(()=>[o(u,{type:"selection",width:"55",align:"center"}),t(m).id.visible?(n(),s(u,{key:0,prop:"id",label:"ID",width:"80",align:"center"})):p("",!0),t(m).template_name.visible?(n(),s(u,{key:1,prop:"template_name",label:"模板名称","min-width":"160",align:"center"})):p("",!0),t(m).template_key.visible?(n(),s(u,{key:2,prop:"template_key",label:"模板键名","min-width":"200",align:"center"})):p("",!0),t(m).template_value.visible?(n(),s(u,{key:3,prop:"template_value",label:"模板值","min-width":"200",align:"center"})):p("",!0),t(m).create_time.visible?(n(),s(u,{key:4,prop:"create_time",label:"创建时间","min-width":"160",align:"center"})):p("",!0),t(m).operation.visible?(n(),s(u,{key:5,label:"操作",width:"120",align:"center",fixed:"right"},{default:l(({row:a})=>[v((n(),s(d,{type:"primary",link:"",onClick:G=>F(a)},{default:l(()=>[...e[12]||(e[12]=[c(" 编辑 ",-1)])]),_:1},8,["onClick"])),[[g,["message.smsTemplate/update"]]]),v((n(),s(d,{type:"danger",link:"",onClick:G=>B(a.id)},{default:l(()=>[...e[13]||(e[13]=[c(" 删除 ",-1)])]),_:1},8,["onClick"])),[[g,["message.smsTemplate/delete"]]])]),_:1})):p("",!0)]),_:1},8,["data"]),I("div",pe,[o(j,{modelValue:t(i),"onUpdate:modelValue":e[6]||(e[6]=a=>E(i)?i.value=a:null),total:t(D),onChange:_},null,8,["modelValue","total"])])]),_:1})),[[z,t(k)]]),o(X,{ref_key:"editRef",ref:b,onSuccess:_},null,512)])}}});export{Ce as default};
