Files
machartaa_admin_dist/dist/assets/index-8c53c704.js
T

2 lines
19 KiB
JavaScript
Raw Normal View History

2026-06-04 15:16:36 +03:30
import{_ as xe}from"./BasicMainCard-870e6a2f.js";import{_ as ge}from"./BasicModal.vue_vue_type_style_index_0_lang-726d71cc.js";import{_ as be}from"./BasicTextArea.vue_vue_type_style_index_0_lang-65d10079.js";import{a as ee,_ as ye,u as G}from"./useBaseTable-54b44400.js";import{_ as te}from"./BasicInput.vue_vue_type_style_index_0_lang-d9dc6382.js";import{_ as ae}from"./button.vue_vue_type_style_index_0_lang-25794594.js";import{_ as he,I as R,d as ne,g as I,h as $,x as we,D as f,o as P,c as S,F as Ie,a as t,b as o,t as D,q as ke,w as b,e as Z,j as h,G as V,k as X,H as Ae}from"./index-4139499d.js";import{t as F}from"./useDataTime-6fbd057f.js";import{I as B}from"./Icon-b81ad543.js";import{g as Le}from"./index-ed0c2ba9.js";import{e as Y,g as J}from"./convert-67c23be8.js";import{T as W}from"./index-32f1bdce.js";import{M as Re}from"./index-3fee3d89.js";import{S as Ce}from"./index-975727f6.js";import{T as q}from"./shallowequal-26ff1c74.js";import{U as Pe}from"./index-ef8c1567.js";import"./_plugin-vue_export-helper-c6b863a5.js";import"./index-1f06eb35.js";import"./Col-8e46ddda.js";import"./vnode-b177b857.js";import"./isPlainObject-ae5f6084.js";import"./index-23976fcd.js";import"./FormItemContext-dfbd6afd.js";import"./index-862849ae.js";import"./toArray-92f12fb1.js";import"./pickAttrs-782832e8.js";import"./useState-ec2259f2.js";import"./index-9520c8d4.js";import"./usePrice-7afab779.js";import"./useRefs-5fd4ee0f.js";import"./index-13d6d167.js";function se(e,i){return Math.max(0,Math.round(e*(1-(i||0)/100)))}async function Se(e){const{TableEngineRequest:i}=await he(()=>import("./buildSupabaseQuery-db3c9bb7.js"),["assets/buildSupabaseQuery-db3c9bb7.js","assets/index-4139499d.js","assets/index-2e613fc8.css"]),l={...e};!l.sort&&!l.order&&(l.order="-sort_order");const a=await i(l,"subscription_plans");if(Array.isArray(a==null?void 0:a.rows)){const p=a.rows.map((g,m)=>({...g,index:m,final_price:se(Number(g.price),Number(g.discount_percent||0))}));return{...a,rows:p}}return a}async function Ne(e){const{limit:i=20,page:l=1,search:a}=e,{data:p,error:g}=await R.from("subscription_purchases").select("*, users(name, phone, first_name, last_name)",{count:"exact"}).order("created_at",{ascending:!1});if(g)throw g;let m=(p||[]).map((u,_)=>{const c=Array.isArray(u.users)?u.users[0]:u.users;let k="نامشخص";return c!=null&&c.name?k=c.name:c!=null&&c.first_name||c!=null&&c.last_name?k=`${c.first_name||""} ${c.last_name||""}`.trim():c!=null&&c.phone&&(k=c.phone),{...u,index:_,user_name:k,user_phone:(c==null?void 0:c.phone)||""}});if(a){const u=String(a).toLowerCase();m=m.filter(_=>(_.plan_title||"").toLowerCase().includes(u)||(_.user_name||"").toLowerCase().includes(u)||(_.user_phone||"").toLowerCase().includes(u)||(_.payment_status||"").toLowerCase().includes(u))}const w=(l-1)*i;return{rows:m.slice(w,w+i).map((u,_)=>({...u,index:w+_})),total:m.length,query:{...e,total:m.length,page:l,limit:i}}}async function Te(e){const{data:i,error:l}=await R.from("subscription_plans").insert([{title:e.title,description:e.description||null,image_url:e.image_url,price:e.price,discount_percent:e.discount_percent??0,duration_days:e.duration_days,is_active:e.is_active??!0,sort_order:e.sort_order??0}]).select().single();if(l)throw l;return i}async function ze(e,i){const{data:l,error:a}=await R.from("subscription_plans").update({title:i.title,description:i.description||null,image_url:i.image_url,price:i.price,discount_percent:i.discount_percent??0,duration_days:i.duration_days,is_active:i.is_active??!0,sort_order:i.sort_order??0,updated_at:new Date().toISOString()}).eq("id",e).select();if(a)throw a;return l}async function Be(e){const{error:i}=await R.from("subscription_plans").delete().eq("id",e);if(i)throw i}async function Ue(e,i){const{data:l,error:a}=await R.from("subscription_plans").update({is_active:i,updated_at:new Date().toISOString()}).eq("id",e).select();if(a)throw a;return l}function Q(e){return Number(e||0).toLocaleString("fa-IR")}const $e=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:e=>(e.record.index??0)+