Files
tehran_taj/apps/admin-panel/dist/assets/create-Cnio7TTC.js
T
mahmoodandClaude Sonnet 5.5 5ddb225813 fix(ui): act-as strip no longer covers headers; customer type and slider permission
- apps: the fixed «در حال مشاهده به‌عنوان» strip (38px) sat over the fixed page
  headers, which still sat at top: 0 (the old 30px body padding was shorter than
  the strip too). The strip's height is now one variable, --aab-h, that the
  fixed headers (PageBar, home, dashboard, toasts) use as their top.
- admin: the customer form offers only «مغازه دار اپلیکیشن» to anyone but the
  super admin; bankers and walk-in shopkeepers are listed by super-admin-only
  endpoints, so ordinary admins lost the customers they created under them.
- admin: the mobile slider rid (custom.config.statics.slider) was only under the
  «سفارشی» branch, which the permission screen hides outside level 104. Same rid,
  now listed under «مدیریت ثابت ها». Display only: the slider routes are still
  gated by config.statics.

Rebuilds admin-panel, user-app and user-app-v2 dist.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 11:16:23 +03:30

2 lines
11 KiB
JavaScript

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