Files
tehran_taj/apps/admin-panel/dist/assets/wallet-BDrkgqLe.js
T
2026-09-25 19:12:39 +03:30

2 lines
3.9 KiB
JavaScript

import{d as V,u as P,v as S,x as _,b as I,a as M,w as r,i as R,y as f,r as c,o as k,c as t,A as j,n as C,f as O,l as W,z as m}from"./index-CaCGCy-S.js";import{_ as z}from"./_plugin-vue_export-helper-DlAUqK2U.js";const A={class:"grid-2"},D={class:"grid-2"},b="لطفا مقدار را وارد کنید",Q=V({__name:"wallet",setup(T){const U=P(),B=i=>!!U.hasPermission(i),p=W(!1),l=f({expire:void 0,percent:void 0}),s=f({birthday_expire:void 0,birthday_credit:void 0}),o=f({}),d=f({});async function v(){var i,e;if(Object.keys(o).forEach(a=>delete o[a]),(l.expire===void 0||l.expire===null)&&(o.expire=b),(l.percent===void 0||l.percent===null)&&(o.percent=b),!Object.keys(o).length)try{p.value=!0,await _.post("wallet/config",{expire:l.expire,percent:l.percent}),m.success("تغییرات ثبت شد")}catch(a){m.error(((e=(i=a==null?void 0:a.response)==null?void 0:i.data)==null?void 0:e.message)??"خطا در ثبت تغییرات")}finally{p.value=!1}}async function y(){var i,e;if(Object.keys(d).forEach(a=>delete d[a]),(s.birthday_expire===void 0||s.birthday_expire===null)&&(d.birthday_expire=b),(s.birthday_credit===void 0||s.birthday_credit===null)&&(d.birthday_credit=b),!Object.keys(d).length)try{p.value=!0,await _.post("wallet/birthday/config",{birthday_expire:s.birthday_expire,birthday_credit:s.birthday_credit}),m.success("تغییرات ثبت شد")}catch(a){m.error(((e=(i=a==null?void 0:a.response)==null?void 0:i.data)==null?void 0:e.message)??"خطا در ثبت تغییرات")}finally{p.value=!1}}return S(async()=>{try{const[i,e]=await Promise.all([_.get("wallet/config"),_.get("wallet/birthday/config")]);Object.assign(l,i.data??{}),Object.assign(s,e.data??{})}catch(i){console.log(i)}}),(i,e)=>{const a=c("a-input-number"),u=c("a-form-item"),h=c("a-button"),x=c("a-form"),g=c("a-spin"),w=c("a-tab-pane"),E=c("a-tabs"),N=c("a-card");return k(),I("div",null,[B("config.wallet")?(k(),M(N,{key:0,title:"مدیریت کیف پول"},{default:r(()=>[t(E,{"default-active-key":"1"},{default:r(()=>[t(w,{key:"2",tab:"تاریخ تولد","force-render":""},{default:r(()=>[t(g,{spinning:p.value,tip:"لطفا کمی تامل کنید"},{default:r(()=>[t(x,{layout:"vertical",onSubmit:j(y,["prevent"])},{default:r(()=>[C("div",A,[t(u,{label:"انقضا (روز)","validate-status":d.birthday_expire?"error":"",help:d.birthday_expire},{default:r(()=>[t(a,{value:s.birthday_expire,"onUpdate:value":e[0]||(e[0]=n=>s.birthday_expire=n),class:"w-full",min:0},null,8,["value"])]),_:1},8,["validate-status","help"]),t(u,{label:"میزان (تومان)","validate-status":d.birthday_credit?"error":"",help:d.birthday_credit},{default:r(()=>[t(a,{value:s.birthday_credit,"onUpdate:value":e[1]||(e[1]=n=>s.birthday_credit=n),class:"w-full",min:0},null,8,["value"])]),_:1},8,["validate-status","help"])]),t(h,{type:"primary",class:"mb-4 mt-4 mr-4",onClick:y},{default:r(()=>[...e[4]||(e[4]=[O("ارسال",-1)])]),_:1})]),_:1})]),_:1},8,["spinning"])]),_:1}),t(w,{key:"1",tab:"پس از خرید","force-render":""},{default:r(()=>[t(g,{spinning:p.value,tip:"لطفا کمی تامل کنید"},{default:r(()=>[t(x,{layout:"vertical",onSubmit:j(v,["prevent"])},{default:r(()=>[C("div",D,[t(u,{label:"انقضا (روز)","validate-status":o.expire?"error":"",help:o.expire},{default:r(()=>[t(a,{value:l.expire,"onUpdate:value":e[2]||(e[2]=n=>l.expire=n),class:"w-full",min:0},null,8,["value"])]),_:1},8,["validate-status","help"]),t(u,{label:"درصد","validate-status":o.percent?"error":"",help:o.percent},{default:r(()=>[t(a,{value:l.percent,"onUpdate:value":e[3]||(e[3]=n=>l.percent=n),class:"w-full",min:0,max:100,formatter:n=>`${n}%`,parser:n=>n.replace("%","")},null,8,["value","formatter","parser"])]),_:1},8,["validate-status","help"])]),t(h,{type:"primary",class:"mb-4 mt-4 mr-4",onClick:v},{default:r(()=>[...e[5]||(e[5]=[O("ارسال",-1)])]),_:1})]),_:1})]),_:1},8,["spinning"])]),_:1})]),_:1})]),_:1})):R("",!0)])}}}),F=z(Q,[["__scopeId","data-v-89c1eb70"]]);export{F as default};