template-modal.bcc8044e.js 6.0 KB

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