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