Files
tehran_taj/apps/admin-panel/dist/assets/create-vLvVGyyJ.js
T
mahmoodandCursor e51a068039 chore: include full admin-panel dist assets for Dokploy copy-only deploy
index.html was already in git pointing at hashed bundles, but the assets folder was missing from the image so nginx 404ed every JS/CSS request.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 12:10:55 +03:30

2 lines
10 KiB
JavaScript

import{G as ye,x as z,d as he,b as be,v as xe,f as N,g as i,j as Q,r as $,e as u,o as d,c as s,n as S,l as x,H as ke,i as k,k as B,F as C,h as P,J as we,t as w,E as Ie,K as Ce,A as qe,y as F,p as J,z as E,a as Ue}from"./index-uaIxISOz.js";import{X as Ne}from"./model-B7iFcNBm.js";import{b as Se}from"./productListModel-DfnhyLcX.js";import{u as Oe}from"./auth-CaNGzWpk.js";import{_ as Pe}from"./_plugin-vue_export-helper-DlAUqK2U.js";const X="admin_cart_items",ze=ye("cart",{state:()=>({items:[]}),actions:{addToCart(l){const v=this.items.findIndex(g=>g.pid==l.pid&&g.vid==l.vid),f=l.product.variants_all.filter(g=>g.id===l.vid)[0];f&&!(!f.is_pre_order&&f.qty===0)&&(v==-1?this.items.push(l):(this.items[v].product=l.product,this.items[v].qty=l.qty))},setItems(l){this.items=l,localStorage.setItem(X,JSON.stringify(l))},add(l){this.addToCart(l),this.setItems(this.items)},remove(l){const v=this.items.findIndex(f=>f.pid==l.pid&&f.vid==l.vid);v>-1&&this.items.splice(v,1),this.setItems(this.items)},updateItemQuantity(l){this.items[l.index].qty=l.quantity,this.setItems(this.items)},clear(){this.items=[],this.setItems(this.items)},async init(){try{const l=JSON.parse(localStorage.getItem(X)??"[]")||[],v=l.map(g=>g.product.id);if(v.length===0){this.setItems([]);return}const{data:f}=await z.post("product/variant",{products_id:v});if(f){const g=[];for(const y of l){const h=f.find(R=>R.id==y.product.id);h&&(!h.variants_all[0].is_pre_order&&h.variants_all[0].qty===0||g.push({vid:y.vid,pid:h.id,product:h,qty:y.qty,promotion_id:h.promotion&&h.promotion.id?h.promotion.id:null}))}this.setItems(g)}}catch(l){console.log("error in cart",l)}}}}),Ve=["src"],$e={key:1,class:"flex items-center"},Be=["src"],Ee={key:4,class:"flex"},Re={style:{width:"max-content"}},Te={class:"grid-5"},je={class:"totals"},H="/img/no-items.png",Le=he({__name:"create",setup(l){const v=Ue(),f=be(),g=Oe(),y=ze(),h=t=>!!f.hasPermission(t),R=Se(),Y=$(null),O=$(!1),M=$([]),A=$({}),Z={1:"ثبت سفارش",2:"تایید مدیر سیستم",3:"در حال تامین",4:"در حال آماده سازی",5:"ارسال",6:"تحویل مشتری"},n=F({customer_id:void 0,sts:void 0,type:void 0,note:"",shipping_address:{reciver_fname:"",reciver_lname:"",province:"",city:"",zipcode:"",reciver_phone:"",reciver_fixed_phone:"",address:""}}),c=F({}),ee=J(()=>{var t;return(t=g.user)==null?void 0:t.id}),b=J(()=>y.items),te=[{title:"حذف",dataIndex:"delete",width:60,align:"center"},{title:"کد محصول",dataIndex:"pid",align:"center",width:90},{title:"محصول",dataIndex:"product"},{title:"اجرت",dataIndex:"wage",align:"center"},{title:"تعداد",dataIndex:"qty",align:"center",width:140},{title:"وزن",dataIndex:"weight",align:"center",width:90},{title:"مجموع",dataIndex:"total",align:"center"}],m=F({});function I(t){return t.product.variants_all.find(e=>e.id===t.vid)??{}}function ae(t){var e,o,p;return((e=t==null?void 0:t.thumb)==null?void 0:e.full)??((p=(o=t==null?void 0:t.ProductImage)==null?void 0:o[0])==null?void 0:p.image)??H}const se=J(()=>{let t=0;for(const e of b.value)t+=Number(I(e).grams??0);return t});function ie(t){return Number(I(t).grams??0)*t.qty}function ne(t){const e=b.value[t];if(!e)return 1/0;const o=Number(I(e).qty??0);return o>0?o:1/0}function oe(t,e){y.updateItemQuantity({index:t,quantity:Number(e)})}function le(t,e){re(t,String(e.key))}function re(t,e){y.add({vid:e,pid:t.id,product:t,qty:1,promotion_id:t.promotion&&t.promotion.id?t.promotion.id:null}),E.info("اضافه شد")}function de(t){const e=I(t);m.id=e.id,m.grams=Number(e.grams??0)}async function ue(){var t,e;if(!(!m.id||!m.grams))try{O.value=!0;const o=b.value.find(p=>p.vid===m.id);await z.post("add/variant",{product_id:o==null?void 0:o.pid,title:`${m.grams} گرم`,grams:m.grams}),await y.init(),m.id=void 0,m.grams=void 0}catch(o){E.error(((e=(t=o==null?void 0:o.response)==null?void 0:t.data)==null?void 0:e.message)??"خطا در ثبت وزن")}finally{O.value=!1}}function pe(t,e){var o,p;return String(((p=(o=e==null?void 0:e.children)==null?void 0:o[0])==null?void 0:p.children)??"").toLowerCase().includes(t.toLowerCase())}function me(){return Object.keys(c).forEach(t=>delete c[t]),n.customer_id||(c.customer_id="مقدار را وارد نمایید"),n.sts===void 0&&(c.sts="مقدار را وارد نمایید"),n.type===void 0&&(c.type="مقدار را وارد نمایید"),Object.keys(c).length===0}async function D(){var t,e;if(me())try{O.value=!0;const o=b.value.map(p=>{const T=I(p);return{vid:p.vid,qty:p.qty,percent:T.percentage_pay,promotion_id:p.promotion_id}});await z.post("order",{...n,reagent_id:ee.value,app:"app",order_items:o}),E.info("عملیات با موفقیت انجام شد"),y.clear(),v.push("/order/list")}catch(o){console.log(o),E.error(((e=(t=o==null?void 0:o.response)==null?void 0:t.data)==null?void 0:e.message)??"خطا در ثبت اطلاعات.")}finally{O.value=!1}}return xe(async()=>{try{const[t,e]=await Promise.all([z.get("order/type"),z.post("single-customer",{page:1,limit:500})]);A.value=t.data,M.value=e.data.rows??[]}catch(t){console.log(t)}await y.init()}),(t,e)=>{const o=u("a-button"),p=u("a-menu-item"),T=u("a-menu"),ce=u("a-dropdown"),G=u("a-input-number"),_e=u("a-table"),j=u("a-select-option"),L=u("a-select"),_=u("a-form-item"),q=u("a-input"),K=u("a-textarea"),ve=u("a-tag"),fe=u("a-form"),W=u("a-card"),ge=u("a-spin");return h("order.create")?(d(),N(ge,{key:0,spinning:O.value},{default:i(()=>[s(W,{title:"لیست محصولات"},{default:i(()=>[s(Ne,{ref_key:"tblProducts",ref:Y,model:S(R)},{image:i(({record:a})=>[P("img",{width:"90px",height:"90px",style:{"object-fit":"scale-down"},src:a.thumb&&a.thumb.full?a.thumb.full:H},null,8,Ve)]),op:i(({record:a})=>[s(ce,null,{overlay:i(()=>[s(T,{onClick:r=>le(a,r)},{default:i(()=>[(d(!0),k(C,null,B(a.variants_all,r=>(d(),N(p,{key:r.id},{default:i(()=>[x(" افزودن تنوع "+w(r.title),1)]),_:2},1024))),128))]),_:2},1032,["onClick"])]),default:i(()=>[s(o,{style:{"margin-left":"8px"}},{default:i(()=>[e[13]||(e[13]=x(" افزودن ",-1)),s(S(ke))]),_:1})]),_:2},1024)]),_:1},8,["model"]),b.value.length>0?(d(),N(W,{key:0,title:"ثبت سفارش",class:"mt-5"},{default:i(()=>[s(_e,{columns:te,"data-source":b.value,bordered:"",pagination:!1,"row-key":"vid"},{bodyCell:i(({column:a,record:r,index:V})=>[a.dataIndex==="delete"?(d(),N(S(we),{key:0,class:"cursor-pointer",onClick:U=>S(y).remove(r)},null,8,["onClick"])):a.dataIndex==="product"?(d(),k("div",$e,[P("img",{src:ae(r.product),width:"50px"},null,8,Be),x(" "+w(r.product.title),1)])):a.dataIndex==="wage"?(d(),k(C,{key:2},[x(w(I(r).percentage_pay)+"٪ ",1)],64)):a.dataIndex==="qty"?(d(),N(G,{key:3,value:b.value[V].qty,"onUpdate:value":U=>b.value[V].qty=U,min:1,max:ne(V),onChange:U=>oe(V,U)},null,8,["value","onUpdate:value","max","onChange"])):a.dataIndex==="weight"?(d(),k("div",Ee,[!m.grams||m.id!==I(r).id?(d(),k(C,{key:0},[P("span",Re,w(I(r).title),1),s(S(Ie),{class:"cursor-pointer ml-2 text-primary",onClick:U=>de(r)},null,8,["onClick"])],64)):(d(),k(C,{key:1},[s(G,{value:m.grams,"onUpdate:value":e[0]||(e[0]=U=>m.grams=U)},null,8,["value"]),s(S(Ce),{class:"cursor-pointer ml-2 text-success",onClick:ue})],64))])):a.dataIndex==="total"?(d(),k(C,{key:5},[x(w(ie(r))+" گرم ",1)],64)):Q("",!0)]),_:1},8,["data-source"]),s(fe,{layout:"vertical",class:"mt-4",onSubmit:qe(D,["prevent"])},{default:i(()=>[P("div",Te,[s(_,{label:"مشتری","validate-status":c.customer_id?"error":"",help:c.customer_id},{default:i(()=>[s(L,{value:n.customer_id,"onUpdate:value":e[1]||(e[1]=a=>n.customer_id=a),"show-search":"","option-filter-prop":"children","filter-option":pe},{default:i(()=>[(d(!0),k(C,null,B(M.value,a=>(d(),N(j,{key:a.id,value:a.id},{default:i(()=>[x(w(`${a.id}-${a.fname} ${a.lname}`),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1},8,["validate-status","help"]),s(_,{label:"وضعیت تحویل","validate-status":c.sts?"error":"",help:c.sts},{default:i(()=>[s(L,{value:n.sts,"onUpdate:value":e[2]||(e[2]=a=>n.sts=a)},{default:i(()=>[(d(),k(C,null,B(Z,(a,r)=>s(j,{key:r,value:Number(r)},{default:i(()=>[x(w(a),1)]),_:2},1032,["value"])),64))]),_:1},8,["value"])]),_:1},8,["validate-status","help"]),s(_,{label:"نوع فروش","validate-status":c.type?"error":"",help:c.type},{default:i(()=>[s(L,{value:n.type,"onUpdate:value":e[3]||(e[3]=a=>n.type=a)},{default:i(()=>[(d(!0),k(C,null,B(A.value,(a,r)=>(d(),N(j,{key:r,value:Number(r)},{default:i(()=>[x(w(a),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value"])]),_:1},8,["validate-status","help"]),s(_,{label:"نام دریافت کننده"},{default:i(()=>[s(q,{value:n.shipping_address.reciver_fname,"onUpdate:value":e[4]||(e[4]=a=>n.shipping_address.reciver_fname=a)},null,8,["value"])]),_:1}),s(_,{label:"نام خانوادگی دریافت کننده"},{default:i(()=>[s(q,{value:n.shipping_address.reciver_lname,"onUpdate:value":e[5]||(e[5]=a=>n.shipping_address.reciver_lname=a)},null,8,["value"])]),_:1}),s(_,{label:"استان"},{default:i(()=>[s(q,{value:n.shipping_address.province,"onUpdate:value":e[6]||(e[6]=a=>n.shipping_address.province=a)},null,8,["value"])]),_:1}),s(_,{label:"شهر"},{default:i(()=>[s(q,{value:n.shipping_address.city,"onUpdate:value":e[7]||(e[7]=a=>n.shipping_address.city=a)},null,8,["value"])]),_:1}),s(_,{label:"کد پستی"},{default:i(()=>[s(q,{value:n.shipping_address.zipcode,"onUpdate:value":e[8]||(e[8]=a=>n.shipping_address.zipcode=a)},null,8,["value"])]),_:1}),s(_,{label:"تلفن همراه"},{default:i(()=>[s(q,{value:n.shipping_address.reciver_phone,"onUpdate:value":e[9]||(e[9]=a=>n.shipping_address.reciver_phone=a)},null,8,["value"])]),_:1}),s(_,{label:"تلفن ثابت"},{default:i(()=>[s(q,{value:n.shipping_address.reciver_fixed_phone,"onUpdate:value":e[10]||(e[10]=a=>n.shipping_address.reciver_fixed_phone=a)},null,8,["value"])]),_:1})]),s(_,{label:"توضیحات"},{default:i(()=>[s(K,{value:n.note,"onUpdate:value":e[11]||(e[11]=a=>n.note=a),"auto-size":{minRows:3,maxRows:5}},null,8,["value"])]),_:1}),s(_,{label:"آدرس"},{default:i(()=>[s(K,{value:n.shipping_address.address,"onUpdate:value":e[12]||(e[12]=a=>n.shipping_address.address=a),"auto-size":{minRows:3,maxRows:5}},null,8,["value"])]),_:1}),P("div",je,[s(ve,{color:"blue"},{default:i(()=>[x("مجموع وزن: "+w(se.value)+" گرم",1)]),_:1})]),s(o,{type:"primary",class:"mt-4",disabled:!b.value||b.value.length<1,onClick:D},{default:i(()=>[...e[14]||(e[14]=[x(" ثبت تغییرات ",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1})):Q("",!0)]),_:1})]),_:1},8,["spinning"])):Q("",!0)}}}),De=Pe(Le,[["__scopeId","data-v-cfb22e94"]]);export{De as default};