Files
Lucky_Wheel/apps/admin/dist/assets/PrizeListView-DVU9hmdY.js
T

2 lines
22 KiB
JavaScript
Raw Normal View History

2026-09-10 22:37:29 +03:30
import{c as t,I as Ue,d as Ve,h,j as Le,a as w,w as n,e as c,s as v,q as U,N as Me,i as Ne,m as O,r as p,o as s,f as u,G as Pe,z as Re,R as $e,B as Fe,t as C,D as ue,F as pe,b as f,E as He,V as je,p as We,W as qe,g as de,X as ce,M as Be,y as _,_ as Ze}from"./index-Dx9ODHpC.js";import{t as R,a as q,p as $}from"./farsi-number-stB7JMN0.js";import{P as Ye}from"./PauseCircleOutlined-Bifiy1P2.js";import{M as Xe}from"./MoreOutlined-BVlNw6dC.js";import{U as Ge}from"./UploadOutlined-Byko1TmG.js";var Je={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M885.2 446.3l-.2-.8-112.2-285.1c-5-16.1-19.9-27.2-36.8-27.2H281.2c-17 0-32.1 11.3-36.9 27.6L139.4 443l-.3.7-.2.8c-1.3 4.9-1.7 9.9-1 14.8-.1 1.6-.2 3.2-.2 4.8V830a60.9 60.9 0 0060.8 60.8h627.2c33.5 0 60.8-27.3 60.9-60.8V464.1c0-1.3 0-2.6-.1-3.7.4-4.9 0-9.6-1.3-14.1zm-295.8-43l-.3 15.7c-.8 44.9-31.8 75.1-77.1 75.1-22.1 0-41.1-7.1-54.8-20.6S436 441.2 435.6 419l-.3-15.7H229.5L309 210h399.2l81.7 193.3H589.4zm-375 76.8h157.3c24.3 57.1 76 90.8 140.4 90.8 33.7 0 65-9.4 90.3-27.2 22.2-15.6 39.5-37.4 50.7-63.6h156.5V814H214.4V480.1z"}}]},name:"inbox",theme:"outlined"};function me(S){for(var x=1;x<arguments.length;x++){var I=arguments[x]!=null?Object(arguments[x]):{},g=Object.keys(I);typeof Object.getOwnPropertySymbols=="function"&&(g=g.concat(Object.getOwnPropertySymbols(I).filter(function(m){return Object.getOwnPropertyDescriptor(I,m).enumerable}))),g.forEach(function(m){Qe(S,m,I[m])})}return S}function Qe(S,x,I){return x in S?Object.defineProperty(S,x,{value:I,enumerable:!0,configurable:!0,writable:!0}):S[x]=I,S}var J=function(x,I){var g=me({},x,I.attrs);return t(Ue,me({},g,{icon:Je}),null)};J.displayName="InboxOutlined";J.inheritAttrs=!1;const Ke={key:0,style:{"text-align":"center",padding:"40px"}},et={key:3},tt={key:0},at={key:5},nt={key:0,style:{color:"#888","font-size":"12px"}},lt={class:"dropdown-action-item"},ot={class:"dropdown-action-item"},it={class:"dropdown-action-item text-danger"},st={style:{"margin-top":"4px","font-size":"12px",display:"flex","align-items":"center","justify-content":"space-between"}},rt={style:{background:"#f8fafc",border:"1px dashed #cbd5e1","border-radius":"8px",padding:"12px 14px","margin-bottom":"16px"}},ut={style:{display:"flex",gap:"8px","align-items":"center"}},pt={style:{display:"flex",gap:"12px","align-items":"center"}},dt={key:0,style:{"margin-top":"8px"}},ct=["src"],mt={style:{display:"flex","align-items":"center",gap:"10px","margin-top":"8px"}},ft=Ve({__name:"PrizeListView",setup(S){const x=Me(),I=Ne(),g=h(x.params.campaignId||""),m=h(null),B=h(!1),V=h([]),F=h(!1),Z=h(!1),M=h(!1),L=h(null),a=de({title:"",description:"",type:"DISCOUNT_CODE",stockType:"LIMITED",initialStock:100,remainingStock:100,weight:10,segmentColor:"#FF6B6B",image:"",sortOrder:1,status:"ACTIVE",smsTemplate:""}),fe=ce(()=>{const l=$(a.weight,1),d=V.value.reduce((y,T)=>L.value&&T.id===L.value?y:y+((T.status==="ACTIVE"||T.isActive)&&T.weight||0),0)+l;if(d<=0)return"۰";const r=(l/d*100).toFixed(1);return R(r)});function ge(l){l==="NO_PRIZE"&&(a.stockType="UNLIMITED",(!a.title||a.title.trim()==="")&&(a.title="پوچ (دفعه بعد)"))}const k=de({prizeId:"",prizeTitle:"",currentStock:0,change:0,reason:""}),Q=ce(()=>V.value.reduce((l,e)=>l+(e.status==="ACTIVE"||e.isActive?e.weight:0),0));async function G(){if(g.value)try{const l=await O.get(`/admin/campaigns/${g.value}`);m.value=l.data}catch{}}const N=h(!1);async function ye(){var l,e;if(g.value){if(V.value.length<1){_.warning("برای فعال‌سازی کمپین، حداقل یک جایزه فعال تعریف کنید.");return}N.value=!0;try{await O.patch(`/admin/campaigns/${g.value}`,{status:"ACTIVE"}),_.success("کمپین با موفقیت فعال و منتشر شد! هم‌اکنون برای کاربران در دسترس است."),await G()}catch(d){const r=((e=(l=d.response)==null?void 0:l.data)==null?void 0:e.message)||d.message||"خطا در فعال‌سازی کمپین.";_.error(Array.isArray(r)?r.join(" | "):r)}finally{N.value=!1}}}async function ve(){var l,e;if(