Files
machartaa_admin_dist/dist/assets/index-abe26286.js
T
2025-11-02 13:34:35 +03:30

2 lines
4.8 KiB
JavaScript

import{d as N,r as s,i as P,o as V,c as D,b as c,w as b,a as d,e as O,a2 as j,L as w,a0 as m,a3 as A}from"./index-706ae190.js";import{_ as S}from"./BasicModal.vue_vue_type_style_index_0_lang-5554ff78.js";import{_ as U}from"./BasicMainCard-f2a5ccca.js";import{_ as X}from"./BaseTable.vue_vue_type_style_index_0_lang-cf2448d3.js";import{_ as q}from"./button.vue_vue_type_style_index_0_lang-ceadaa26.js";import{g as E,a as F}from"./competition-e7d8af57.js";import{t as I}from"./useDataTime-c7ca02f3.js";import{u as J}from"./useBaseTable-3aeb2499.js";import{I as W}from"./Icon-28ffeb1b.js";import{_ as z}from"./index-43605b9d.js";import"./styleChecker-340ade5c.js";import"./index-1e6892e5.js";import"./index-d20bae83.js";import"./colors-28bdd148.js";import"./raf-11ded367.js";import"./index-dd47f070.js";import"./debounce-a561c15c.js";import"./index-7841bb4d.js";import"./index-abd2a61d.js";import"./pickAttrs-79e8d088.js";import"./objectDestructuringEmpty-24e23e90.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./index-ac535007.js";import"./index-8096f4ad.js";import"./useState-96fc4e3c.js";import"./Col-dfb51626.js";import"./usePrefix-ba531a41.js";import"./index-c4f252cc.js";import"./index-79523c96.js";import"./SearchOutlined-24a77ba1.js";import"./EyeOutlined-f4940de3.js";import"./eagerComputed-0df24eaf.js";import"./CheckOutlined-de32f6ea.js";const G=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:t=>t.record.index+1},{title:"نام مسابقه",dataIndex:"match_title",key:"match_title"},{title:"شرح مسابقه",dataIndex:"match_description",key:"match_description",customRender:t=>{const n=t.record.match_description;return n?n.length>50?n.substring(0,50)+"...":n:"-"}},{title:"نام کاربر",dataIndex:"user_name",key:"user_name"},{title:"شماره همراه",dataIndex:"user_mobile",key:"user_mobile"},{title:"امتیاز کسب شده",dataIndex:"score",key:"score",align:"center",customRender:t=>t.record.score||0},{title:"تاریخ",dataIndex:"created_at",key:"created_at",customRender:t=>I(t.record.created_at)}],H={class:"flex justify-between items-center mb-4"},K=d("h2",null,"امتیازات و برندگان مسابقات",-1),Q={class:"space-y-4"},Y=d("div",{class:"mb-1 text-sm text-gray-600"},"انتخاب مسابقه",-1),Pe=N({__name:"index",setup(t){const n=z,B=s(null),[M,Z]=J(),u=s(!1),o=s(void 0),_=s([]),f=s(!1),v=s(!1),T=s({columns:G,api:E,defaultPageLimit:20});async function y(){try{f.value=!0;const a=await F();_.value=(a||[]).map(e=>({label:e.title||`مسابقه ${e.id}`,value:e.id}))}catch(a){console.error("Error loading matchs:",a),m.error("خطا در بارگذاری لیست مسابقات")}finally{f.value=!1}}function C(){o.value=void 0,u.value=!0,_.value.length===0&&y()}function k(){u.value=!1,o.value=void 0}async function R(){if(!o.value){m.warning("لطفاً مسابقه را انتخاب کنید");return}try{v.value=!0;const a={page:1,limit:1e4,filters:[{field:"match_id",op:"eq",value:o.value,cr:"and",hidden:!1,type:"number"}]},p=(await E(a)).rows||[];if(p.length===0){m.warning("برای این مسابقه برنده‌ای یافت نشد");return}const g=p.map((r,L)=>({ردیف:L+1,"نام مسابقه":r.match_title||"","شرح مسابقه":r.match_description||"","نام کاربر":r.user_name||"","شماره همراه":r.user_mobile||"","امتیاز کسب شده":r.score||0,تاریخ:I(r.created_at||"")})),l=await A(()=>import("./xlsx-6ed613d4.js"),[]),x=l.utils.json_to_sheet(g),i=l.utils.book_new();l.utils.book_append_sheet(i,x,"برندگان");const h=_.value.find(r=>r.value===o.value),$=`برندگان_${(h==null?void 0:h.label)||`مسابقه_${o.value}`}_${new Date().getTime()}.xlsx`;l.writeFile(i,$),m.success("فایل اکسل با موفقیت دانلود شد"),k()}catch(a){console.error("Error exporting to Excel:",a),m.error("خطا در تولید فایل اکسل")}finally{v.value=!1}}return P(()=>{y()}),(a,e)=>{const p=q,g=X,l=U,x=S;return V(),D("div",null,[c(l,null,{default:b(()=>[d("div",H,[K,c(p,{onClick:C,style:{backgroundColor:"#217346",borderColor:"#217346",color:"#fff"},class:"excel-export-btn"},{default:b(()=>[c(W,{icon:"vuesax-linear:document-download",class:"mr-1"}),O(" خروجی اکسل ")]),_:1})]),c(g,j(T.value,{ref_key:"table",ref:B,onRegister:w(M)}),null,16,["onRegister"])]),_:1}),c(x,{visible:u.value,"onUpdate:visible":e[1]||(e[1]=i=>u.value=i),title:"خروجی اکسل برندگان مسابقه",onOk:R,onCancel:k,confirmLoading:v.value},{default:b(()=>[d("div",Q,[d("div",null,[Y,c(w(n),{value:o.value,"onUpdate:value":e[0]||(e[0]=i=>o.value=i),options:_.value,placeholder:"لطفاً مسابقه را انتخاب کنید",loading:f.value,class:"w-full","allow-clear":""},null,8,["value","options","loading"])])])]),_:1},8,["visible","confirmLoading"])])}}});export{Pe as default};