import{_ as W,d as L,cl as Q,Q as G,m as s,n as I,r as p,o as n,A as v,x as u,h as t,u as J,co as K,c as f,F as h,y as g,b as O,H as P,cc as S}from"./index.d0c68291.js";import{c as i}from"./createRequset.2a519b90.js";const X={style:{display:"flex","justify-content":"flex-end",width:"100%"}},Y=L({__name:"template-modal",emits:["refresh"],setup(Z,{expose:B,emit:w}){const C=i("account/depart"),D=i("admin/account/list"),k=i("admin/WeTemplate/getTemplate"),U=i("admin/DepartReport/create"),x=i("admin/DepartReport/edit"),R=[{value:"1",label:"\u6BCF\u5929"}],F=Q("crate"),V={report_name:"",template_name:"",template_id:"",template_param:"",push_type:"",depart_id:"",push_arr:[]},T={report_name:[{required:!0,message:"\u8BF7\u8F93\u5165\u6A21\u677F\u540D\u79F0",trigger:"change"}],template_id:[{required:!0,message:"\u8BF7\u9009\u62E9\u5FAE\u4FE1\u6A21\u677F",trigger:"change"}],push_type:[{required:!0,message:"\u8BF7\u9009\u62E9\u63A8\u9001\u7C7B\u578B",trigger:"change"}],push_arr:[{required:!0,message:"\u8BF7\u9009\u62E9\u63A8\u9001\u4EBA",trigger:"change"}],depart_id:[{required:!0,message:"\u8BF7\u9009\u62E9\u90E8\u95E8",trigger:"change"}]},q=G(()=>F.value==="create"?"\u521B\u5EFA\u6A21\u677F":"\u4FEE\u6539\u6A21\u677F"),E=s([]),y=s([]),b=s([]),m=s(!1),M=s(!1),A=s(null),a=s({...V});function N(o){const l=E.value.find(({template_id:r})=>r===o);a.value.template_name=l.title,a.value.template_param=l.content}async function j(){try{await A.value.validate();const l=await(F.value==="update"?x:U)(a.value);l.code===1?(w("refresh"),m.value=!1):S.warning(l.message)}catch{}}return I(async()=>{const o=await k({}),l=await C({size:1e4}),r=await D({size:1e4,depart_id:a.value.depart_id,is_wx:1});r.code===1&&(b.value=r.data.list),o.code===1&&(E.value=o.data),l.code===1&&(y.value=[{id:0,name:"\u5168\u90E8\u90E8\u95E8"},...l.data])}),B({onDisplay:(o,l)=>{m.value=!0,F.value=l,l==="update"?(a.value={...o},a.value.push_arr=o.pusher.map(({user_id:r})=>r),delete a.value.pusher):a.value={...V}}}),(o,l)=>{const r=p("el-input"),d=p("el-form-item"),_=p("el-option"),c=p("el-select"),z=p("el-button"),H=p("el-dialog");return n(),v(H,{modelValue:m.value,"onUpdate:modelValue":l[7]||(l[7]=e=>m.value=e),title:q.value,center:""},{default:u(()=>[t(J(K),{"label-width":"100px",model:a.value,rules:T,ref_key:"formRef",ref:A},{default:u(()=>[t(d,{label:"\u6A21\u677F\u540D\u79F0:",prop:"report_name"},{default:u(()=>[t(r,{modelValue:a.value.report_name,"onUpdate:modelValue":l[0]||(l[0]=e=>a.value.report_name=e),placeholder:"\u6A21\u677F\u540D\u79F0"},null,8,["modelValue"])]),_:1}),t(d,{label:"\u90E8\u95E8:",prop:"depart_id"},{default:u(()=>[t(c,{modelValue:a.value.depart_id,"onUpdate:modelValue":l[1]||(l[1]=e=>a.value.depart_id=e),placeholder:"\u90E8\u95E8",style:{width:"100%"},onChange:o.handleChange},{default:u(()=>[(n(!0),f(h,null,g(y.value,e=>(n(),v(_,{key:e.id,value:e.id,label:e.name},null,8,["value","label"]))),128))]),_:1},8,["modelValue","onChange"])]),_:1}),t(d,{label:"\u5FAE\u4FE1\u6A21\u677F:",prop:"template_id"},{default:u(()=>[t(c,{style:{width:"100%"},modelValue:a.value.template_id,"onUpdate:modelValue":l[2]||(l[2]=e=>a.value.template_id=e),placeholder:"\u5FAE\u4FE1\u6A21\u677F",onChange:N},{default:u(()=>[(n(!0),f(h,null,g(E.value,e=>(n(),v(_,{key:e.template_id,value:e.template_id,label:e.title},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(d,{label:"\u63A8\u9001\u65F6\u95F4:",modelValue:a.value.push_type,"onUpdate:modelValue":l[4]||(l[4]=e=>a.value.push_type=e),prop:"push_type"},{default:u(()=>[t(c,{style:{width:"100%"},placeholder:"\u63A8\u9001\u7C7B\u578B",modelValue:a.value.push_type,"onUpdate:modelValue":l[3]||(l[3]=e=>a.value.push_type=e)},{default:u(()=>[(n(),f(h,null,g(R,e=>t(_,{key:e.value,label:e.label,value:e.value},null,8,["label","value"])),64))]),_:1},8,["modelValue"])]),_:1},8,["modelValue"]),t(d,{label:"\u63A8\u9001\u4EBA:",modelValue:a.value.push_arr,"onUpdate:modelValue":l[6]||(l[6]=e=>a.value.push_arr=e),prop:"push_arr"},{default:u(()=>[t(c,{style:{width:"100%"},placeholder:"\u63A8\u9001\u4EBA",multiple:"",filterable:"",modelValue:a.value.push_arr,"onUpdate:modelValue":l[5]||(l[5]=e=>a.value.push_arr=e)},{default:u(()=>[(n(!0),f(h,null,g(b.value,e=>(n(),v(_,{filterable:"",key:e.id,label:e.nickname,value:e.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["modelValue"]),t(d,null,{default:u(()=>[O("div",X,[t(z,{type:"primary",onClick:j,loading:M.value},{default:u(()=>[P("\u4FDD\u5B58")]),_:1},8,["loading"])])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])}}});var le=W(Y,[["__file","C:/Users/63107/Desktop/projects/report-v3/src/views/template/publicTemplate/components/template-modal.vue"]]);export{le as default};
