Files
Rasadyar_FrontEnd/build/assets/SlaughterMorgue-C5DfynIX.js

2 lines
24 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{j as e,I as Su,b3 as r6,B as Y,an as V,ao as xu,aj as Xu,ak as Uu,al as Z,am as uu,ac as Du,T as o6,d as a6,a_ as n6,b5 as c6,b6 as u6,b as C6}from"./mui-vendor-D_SVL-Dx.js";import{r as a,j as s6,u as d6}from"./react-vendor-CmFgShSM.js";import{L as iu,j as eu,a0 as K,h as hu,A as wu,G as g,O as Fu,g2 as i6,c as h6,V as yu,b as Au,u as g6,v as J,$ as fu,C as ku,g4 as p6,p as x6,S as vu,dD as y6,g3 as A6,l1 as j6,l2 as F6}from"./index-D80MdVQn.js";import{R as ou}from"./ResponsiveTable-bUYl0qDM.js";import{a as l6,u as su,f as Q}from"./redux-vendor-CfkcHgWN.js";import{R as f6,a as k6}from"./index.esm-C1-dCPnj.js";import{d as t6}from"./Tune-BBzxV8DK.js";import{b as v6,s as S6,a as w6}from"./slaughter-allocate-steward-CCu9314u.js";import{S as _6,s as E6}from"./SlaughterAllocateToGuild-CeWc5BWf.js";import{N as ju}from"./NumberFormatCustom-BXcOcGV4.js";import{b as $6,a as b6}from"./slaughter-get-guilds-for-allocate-CQRKvxsV.js";import{I as T6,f as P6}from"./toBase64-UDzdrM-n.js";import{a as H6}from"./province-policy-upload-image-DZLwIF5K.js";import{c as G}from"./checkPathStartsWith-DedybDvj.js";import{B as B6}from"./BackButton-Dr-K0JXJ.js";import{d as L6}from"./Visibility-Cb7r65bM.js";import"./FilterAlt-DZsHj-WQ.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./MonthlyDataCalendar-_xfuL-Zd.js";import"./LabelField-BYhJrYEE.js";import"./PublishedWithChanges-Dz7dEVRv.js";import"./Delete-CIwpNviU.js";const G6=l6("SLAUGHTER_GET_MORGUE_DASHBOARD",async(p,{dispatch:l})=>{l(iu());const{data:w,status:d}=await eu.get("total-cold-house-dashboard-roles/",{params:{role:K(),...p}});return l(hu()),{data:w,status:d}}),R6=l6("SLAUGHTER_GET_MORGUES",async(p,{dispatch:l})=>{l(iu());const{data:w,status:d}=await eu.get("kill-house-cold-houses/",{params:{role:K()}});return l(hu()),{data:w,status:d}}),O6=({fetchApiData:p,item:l,fetchData:w,updateTable:d,priceInfo:$,remainWeight:h})=>{const[_,x]=a.useState(null),A=F=>{x(F.currentTarget)},t=()=>{x(null)},C=!!_,f=C?"popover":void 0,[i]=a.useContext(wu),k=su();return e.jsxs(g,{container:!0,children:[e.jsx(Su,{disabled:l==null?void 0:l.registrationCode,"aria-describedby":f,variant:"contained",color:"primary",onClick:A,children:e.jsx(t6,{})}),e.jsx(r6,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:f,open:C,anchorEl:_,onClose:t,children:e.jsx("div",{style:{padding:"20px",display:"flex",flexDirection:"column"},children:e.jsxs(g,{container:!0,direction:"column",gap:1,children:[e.jsx(Y,{variant:"outlined",onClick:()=>{t(),k(Fu({title:"ویرایش تخصیص",content:e.jsx(_6,{updateTable:w,fetchApiData:p,sellerType:"ColdHouse",sellType:"exclusive",coldHouseItemKey:l==null?void 0:l.key,priceInfo:$,editData:l,remainWeight:h})}))},children:"ویرایش"}),e.jsx(Y,{size:"small",disabled:l==null?void 0:l.registrationCode,variant:"outlined",color:"error",onClick:()=>{t(),k(v6({steward_allocation_key:l.key})).then(F=>{F.error?i({vertical:"top",horizontal:"center",msg:F.payload.error,severity:"error"}):(p(1),w(),d(),i({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"حذف"})]})})})]})},W6=({item:p,key:l,sellerType:w,fetchData:d,buyerType:$,allocationType:h,sellType:_,updateTable:x,fetchApiData:A,editData:t,priceInfo:C,coldHouseKey:f,coldHouseItemKey:i,remainWeight:k,killHouseAllocation:F})=>{var D;const v=su(),[y,R]=a.useState([]),[E,W]=a.useState([]),[T,m]=a.useState([]),[P,M]=a.useState(null),[j]=a.useContext(wu),[H,z]=a.useState(C!=null&&C.active?"true":"false"),[lu,gu]=a.useState(t!=null&&t.image?[{data_url:t.image}]:[]),[O,tu]=a.useState("own"),[pu,ru]=a.useState(1),[I,c]=a.useState(!1),u=Q(o=>o.userSlice.selectedSubUser),au=o=>{tu(o.target.value),q({key:"",item:"",buyerType:"",allocationType:""})},N=o=>{z(o.target.value),o.target.value==="false"&&s.setFieldValue("price","")},[n,q]=a.useState({key:l,item:p,buyerType:$,allocationType:h});a.useEffect(()=>{K()==="Steward"&&tu("free")},[]),a.useEffect(()=>{v(H6()).then(o=>{var r;(r=o.payload)!=null&&r.data&&ru(o.payload.data.killHouseAllocation)}),t||(v(i6({role_key:G("slaughter")&&(u==null?void 0:u.key)||""})).then(o=>{R(o.payload.data)}),p||(O==="cold"&&v($6({role_key:G("slaughter")&&(u==null?void 0:u.key)||""})).then(o=>{m(o.payload.data)}),v(b6({free:O==="free",role_key:G("slaughter")&&(u==null?void 0:u.key)||""})).then(o=>{W(o.payload.data)})))},[v,O,u==null?void 0:u.key]);const nu=h6({weight:Au().required("این فیلد اجباری است!").min(1,"یک مقدار مثبت وارد کنید!").max(t?k+(t==null?void 0:t.realWeightOfCarcasses):k,"وزن وارد شده بیش از موجودی انبار است!"),price:Au().required("این فیلد اجباری است!").min(1,"یک مقدار مثبت وارد کنید!"),wholePrice:Au().required("این فیلد اجباری است!").min(1,"یک مقدار مثبت وارد کنید!"),...F&&{image:yu().when([],{is:()=>(!t||I)&&pu>0,then:yu().required("عکس الزامی است"),otherwise:yu().notRequired()})}}),cu=o=>{var r;o[0]?(s.setFieldValue("image",P6((r=o[0])==null?void 0:r.data_url)),c(!0)):(s.setFieldValue("image",""),c(!0)),gu(o)},s=g6({initialValues:{weight:(t==null?void 0:t.realWeightOfCarcasses)||"",wholePrice:(t==null?void 0:t.totalAmount)||"",price:(t==null?void 0:t.amount)||"",image:(t==null?void 0:t.image)||""},validationSchema:nu});a.useEffect(()=>{s.validateForm()},[]),a.useEffect(()=>{H==="false"?s.values.weight&&s.values.price&&s.setFieldValue("wholePrice",s.values.price*s.values.weight):C!=null&&C.active&&s.values.weight&&s.setFieldValue("wholePrice",(C==null?void 0:C.killHousePrice)*s.values.weight)},[s.values.price,s.values.weight,H]),a.useEffect(()=>{C!=null&&C.active&&H==="true"&&s.setFieldValue("price",C==null?void 0:C.killHousePrice)},[H]);const X=()=>{v(ku()),j({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),v(p6({role_key:G("slaughter")&&(u==null?void 0:u.key)||""})),A&&A(1),x&&x(),d&&d(1)},[U,Cu]=a.useState(J(new Date).format("YYYY-MM-DD"));return e.jsxs(g,{container:!0,xs:12,direction:"column",justifyContent:"center",alignItems:"center",gap:1,children:[!t&&e.jsx(fu,{label:"تاریخ",id:"date",renderInput:o=>e.jsx(V,{fullWidth:!0,...o}),value:U,onChange:o=>{Cu(J(o).format("YYYY-MM-DD"))}}),!t&&!f&&e.jsx(g,{xs:12,container:!0,children:e.jsx(xu,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"hatching",options:y?y.map(o=>({data:o,label:`${o.name}`})):[],onChange:(o,r)=>{M(r.data)},renderInput:o=>e.jsx(V,{fullWidth:!0,...o,label:"انتخاب محصول"})})}),!t&&e.jsx(Xu,{children:e.jsxs(Uu,{row:!0,"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:O,onChange:au,children:[e.jsx(Z,{value:"own",control:e.jsx(uu,{}),label:"صنوف اختصاصی"}),e.jsx(Z,{value:"free",control:e.jsx(uu,{}),label:"صنوف آزاد"}),e.jsx(Z,{value:"cold",control:e.jsx(uu,{}),label:"انتقال به سردخانه"})]})}),!p&&!t&&O!=="cold"&&e.jsx(g,{xs:12,container:!0,children:e.jsx(xu,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"hatching",options:E?E.map(o=>{var r,S;return{data:o,label:`${o!=null&&o.steward?"مباشر":"صنف"} ${o==null?void 0:o.guildsName} ${(r=o==null?void 0:o.user)==null?void 0:r.fullname} (${(S=o==null?void 0:o.user)==null?void 0:S.mobile})`}}):[],onChange:(o,r)=>{var S,B,L;q({item:r==null?void 0:r.data,key:(S=r==null?void 0:r.data)==null?void 0:S.key,allocationType:(B=r==null?void 0:r.data)!=null&&B.steward?"killhouse_steward":"killhouse_guild",buyerType:(L=r==null?void 0:r.data)!=null&&L.steward?"Steward":"Guild"})},renderInput:o=>e.jsx(V,{fullWidth:!0,...o,label:"انتخاب مباشر / صنف"})})}),!p&&!t&&O==="cold"&&e.jsx(g,{xs:12,container:!0,children:e.jsx(xu,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"hatching",options:T?T.map(o=>{var r,S,B,L,b;return{data:o,label:`سردخانه ${o==null?void 0:o.name} (${((S=(r=o==null?void 0:o.steward)==null?void 0:r.user)==null?void 0:S.mobile)||((b=(L=(B=o==null?void 0:o.killHouse)==null?void 0:B.killHouseOperator)==null?void 0:L.user)==null?void 0:b.mobile)})`}}):[],onChange:(o,r)=>{var S;q({item:r==null?void 0:r.data,key:(S=r==null?void 0:r.data)==null?void 0:S.key,allocationType:"ColdHouse",buyerType:"ColdHouse"})},renderInput:o=>e.jsx(V,{fullWidth:!0,...o,label:"انتخاب سردخانه"})})}),e.jsx(ju,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"weight",label:"وزن لاشه",variant:"outlined",value:s.values.weight,error:s.touched.weight&&!!s.errors.weight||k<=0,helperText:k<=0?"موجودی انبار کافی نیست":s.touched.weight&&s.errors.weight,onChange:s.handleChange,onBlur:s.handleBlur,disabled:k<1,sx:{"& .MuiFormHelperText-root":{color:k&&s.values.weight>k?"error.main":void 0}}}),(C==null?void 0:C.active)&&e.jsx(Xu,{children:e.jsxs(Uu,{row:!0,"aria-labelledby":"demo-controlled-radio-buttons-group",name:"controlled-radio-buttons-group",value:H,onChange:N,children:[e.jsx(Z,{value:"true",control:e.jsx(uu,{}),label:"قیمت مصوب"}),e.jsx(Z,{value:"false",control:e.jsx(uu,{}),label:"قیمت آزاد"})]})}),e.jsx(ju,{disabled:(C==null?void 0:C.active)&&H==="true",allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"price",label:"قیمت هر کیلوگرم",variant:"outlined",InputProps:{endAdornment:e.jsx(Du,{position:"start",children:"ریال"})},value:s.values.price,error:s.touched.price?!!s.errors.price:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.price&&s.errors.price?s.errors.price:null}),e.jsx(ju,{disabled:!0,allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"wholePrice",label:"هزینه کل",variant:"outlined",InputProps:{endAdornment:e.jsx(Du,{position:"start",children:"ریال"})},value:s.values.wholePrice,error:s.touched.wholePrice?!!s.errors.wholePrice:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.wholePrice&&s.errors.wholePrice?s.errors.wholePrice:null}),(F||t&&t.image)&&e.jsxs(e.Fragment,{children:[e.jsx(T6,{onChange:cu,images:lu,maxNumber:1,title:"بارگزاری سند"}),s.touched.image&&!!s.errors.image&&e.jsx(o6,{color:"error",children:"ثبت تصویر الزامی است"})]}),e.jsx(Y,{variant:"contained",fullWidth:!0,disabled:t?!s.isValid:!s.isValid||(f?!1:!P)||!((D=n==null?void 0:n.item)!=null&&D.key),onClick:()=>{var r,S,B,L;let o={};i?o={allocation_key:i,number_of_carcasses:0,weight_of_carcasses:s.values.weight,amount:s.values.price,total_amount:s.values.wholePrice,...I&&{image:s.values.image}}:t?o={allocation_key:t==null?void 0:t.key,number_of_carcasses:0,weight_of_carcasses:s.values.weight,amount:s.values.price,total_amount:s.values.wholePrice,...I&&{image:s.values.image}}:(o={seller_type:w,buyer_type:n==null?void 0:n.buyerType,other_cold_house_key:(n==null?void 0:n.buyerType)==="ColdHouse"?(r=n==null?void 0:n.item)==null?void 0:r.key:null,guild_key:(n==null?void 0:n.buyerType)==="Guild"?(S=n==null?void 0:n.item)==null?void 0:S.key:null,steward_key:(n==null?void 0:n.buyerType)==="Steward"?(B=n==null?void 0:n.item)==null?void 0:B.key:null,kill_house_key:(n==null?void 0:n.buyerType)==="KillHouse"?(L=n==null?void 0:n.item)==null?void 0:L.key:null,cold_house_key:f||null,product_key:f?null:P.key,type:"manual",allocation_type:n==null?void 0:n.allocationType,number_of_carcasses:0,weight_of_carcasses:s.values.weight,sell_type:O==="cold"?"free":_,amount:s.values.price,total_amount:s.values.wholePrice,approved_price_status:H==="true",date:U,...lu.length>0&&{image:s.values.image}},o=Object.fromEntries(Object.entries(o).filter(([b,du])=>du!==null))),t?v(w6(o)).then(b=>{b.payload.error?j({vertical:"top",horizontal:"center",msg:b.payload.error,severity:"error"}):X()}):v(S6(o)).then(b=>{b.payload.error?j({vertical:"top",horizontal:"center",msg:b.payload.error,severity:"error"}):X()})},children:"ثبت"})]})},e6=({selectedDate1:p,selectedDate2:l,title:w,type:d,withDate:$,coldHouseKey:h,getDashboardsData:_,remainWeight:x})=>{const A=su(),t=Q(c=>c.userSlice.userProfile.key),[C]=a.useContext(wu),f=c=>{m(c.target.value)},i=Q(c=>c.userSlice.selectedSubUser),{priceInfo:k}=Q(c=>c.slaughterSlice),[F,v]=a.useState([]),[y,R]=a.useState(0),[E,W]=a.useState(10),[T,m]=a.useState(""),[P,M]=a.useState(1),[j,H]=a.useState([]),z=async c=>{A(iu());const u=await eu.get(`steward-allocation/?search=filter&value=${T}&role=${K()}${G("slaughter")?`&role_key=${i==null?void 0:i.key}`:""}${$?`&date1=${p}&date2=${l}`:""}&page=${c}&page_size=${E}&cold_house=true&type=${d}&cold_house_key=${h}`);A(y6({role_key:G("slaughter")&&(i==null?void 0:i.key)||""})),A(hu()),v(u.data.results),R(u.data.count)},lu=c=>{z(c),M(c)},gu=c=>{W(c),M(1)},O=()=>{z(P!==0?P:1)},tu=c=>c!=null&&c.systemRegistrationCode?[e.jsx(Su,{disabled:!0,"aria-label":"disabled-button",color:"primary",children:e.jsx(t6,{})},c)]:[e.jsx(O6,{fetchData:O,fetchApiData:_,item:c,priceInfo:k,remainWeight:x},c)],pu=()=>d==="output"?["عملیات"]:[],ru=w==="بارهای خارج شده";a.useEffect(()=>{const c=F==null?void 0:F.map((u,au)=>{var n,q,nu,cu,s,X,U,Cu,D,o,r,S,B,L,b,du,_u,Eu,$u,bu,Tu,Pu,Hu,Bu,Lu,Gu,Ru,Ou,Wu,Yu,Mu,zu,Nu,Vu,mu,Iu,qu,Zu,Ju,Ku,Qu;let N;switch(u==null?void 0:u.receiverState){case"pending":N="در انتظار تایید";break;case"accepted":N="تایید شده";break;case"rejected":N="رد شده";break;default:N="-"}return[P===1?au+1:au+E*(P-1)+1,x6(u==null?void 0:u.date),ru?u!=null&&u.toGuilds?"سردخانه به صنف":u!=null&&u.otherColdHouse?"سردخانه به سردخانه":u!=null&&u.toStewards?"سردخانه به مباشر":"-":`${u!=null&&u.killHouse?"کشتارگاه":"سردخانه"} به سردخانه`,ru?u!=null&&u.toGuilds?`${(n=u==null?void 0:u.toGuilds)==null?void 0:n.guildsName} ( ${(nu=(q=u==null?void 0:u.toGuilds)==null?void 0:q.user)==null?void 0:nu.fullname} ${(s=(cu=u==null?void 0:u.toGuilds)==null?void 0:cu.user)==null?void 0:s.mobile})`:u!=null&&u.otherColdHouse?(X=u==null?void 0:u.otherColdHouse)!=null&&X.steward?`${(D=(Cu=(U=u==null?void 0:u.otherColdHouse)==null?void 0:U.steward)==null?void 0:Cu.user)==null?void 0:D.fullname} (${(S=(r=(o=u==null?void 0:u.otherColdHouse)==null?void 0:o.steward)==null?void 0:r.user)==null?void 0:S.mobile})`:`${(L=(B=u==null?void 0:u.otherColdHouse)==null?void 0:B.killHouse)==null?void 0:L.name} (${(Eu=(_u=(du=(b=u==null?void 0:u.otherColdHouse)==null?void 0:b.killHouse)==null?void 0:du.killHouseOperator)==null?void 0:_u.user)==null?void 0:Eu.fullname} ${(Pu=(Tu=(bu=($u=u==null?void 0:u.otherColdHouse)==null?void 0:$u.killHouse)==null?void 0:bu.killHouseOperator)==null?void 0:Tu.user)==null?void 0:Pu.mobile})`:`${(Hu=u==null?void 0:u.toStewards)==null?void 0:Hu.name} (${(Lu=(Bu=u==null?void 0:u.toStewards)==null?void 0:Bu.user)==null?void 0:Lu.fullname}${(Ru=(Gu=u==null?void 0:u.toStewards)==null?void 0:Gu.user)==null?void 0:Ru.mobile})`:u!=null&&u.killHouse?`${(Ou=u.toColdHouse)==null?void 0:Ou.name} (${(zu=(Mu=(Yu=(Wu=u.toColdHouse)==null?void 0:Wu.killHouse)==null?void 0:Yu.killHouseOperator)==null?void 0:Mu.user)==null?void 0:zu.mobile})`:`${(Nu=u==null?void 0:u.otherColdHouse)==null?void 0:Nu.name} ${(qu=(Iu=(mu=(Vu=u==null?void 0:u.otherColdHouse)==null?void 0:Vu.killHouse)==null?void 0:mu.killHouseOperator)==null?void 0:Iu.user)==null?void 0:qu.mobile}`,(u==null?void 0:u.sellType)==="exclusive"?"اختصاصی":"آزاد",((Zu=u==null?void 0:u.amount)==null?void 0:Zu.toLocaleString())+" ریال",((Ju=u==null?void 0:u.totalAmount)==null?void 0:Ju.toLocaleString())+" ریال",(Ku=u==null?void 0:u.realWeightOfCarcasses)==null?void 0:Ku.toLocaleString(),(Qu=u==null?void 0:u.loggedRegistrationCode)==null?void 0:Qu.toLocaleString(),(u==null?void 0:u.systemRegistrationCode)===!0?"کد احراز ارسال شده":"در انتظار ارسال کد احراز",N,...tu(u)]});H(c)},[F]),a.useEffect(()=>{z(1)},[A,p,l,E,$,i==null?void 0:i.key]);const I=async c=>{c.preventDefault(),A(iu());try{const u=await eu.get(`steward-allocation/?role=${K()}${G("slaughter")?`&role_key=${i==null?void 0:i.key}`:""}&search=filter&value=${T}${$?`&date1=${p}&date2=${l}`:""}&page=1&page_size=${E}&cold_house=true&type=${d}&cold_house_key=${h}`);v(u.data.results),R(u.data.count),A(hu())}catch(u){console.error("Error fetching data:",u)}};return e.jsxs(g,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[e.jsxs(g,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[e.jsx(Y,{variant:"contained",onClick:()=>{A(Fu({title:"ثبت توزیع/ فروش سرد خانه",content:e.jsx(W6,{updateTable:_,sellerType:"ColdHouse",sellType:"exclusive",fetchApiData:z,coldHouseKey:h,remainWeight:x})}))},children:"ثبت توزیع/ فروش"}),d==="output"&&e.jsx(Y,{disabled:!j.length,variant:"outlined",onClick:()=>{A(Fu({title:"ثبت نهایی",content:e.jsxs(g,{container:!0,gap:vu.SMALL,children:[e.jsx(o6,{children:"در صورت ثبت نهایی انجام هیچگونه عملیاتی مانند حذف و ویرایش امکان پذیر نمی باشد."}),e.jsxs(g,{container:!0,direction:"column",gap:vu.TINY,width:"100%",children:[e.jsx(Y,{fullWidth:!0,variant:"contained",onClick:()=>{A(E6({steward_allocation_list:F.map(c=>c.key)})).then(c=>{A(ku()),c.payload.error?C({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(O(),z(1),C({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},children:"تایید"}),e.jsx(Y,{fullWidth:!0,color:"error",variant:"contained",onClick:()=>{A(ku())},children:"لغو"})]})]})}))},children:"تایید نهایی (یکجا)"}),e.jsx(g,{children:e.jsxs("form",{onSubmit:I,children:[e.jsx(V,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:f}),e.jsx(Y,{type:"submit",onClick:I,endIcon:e.jsx(f6,{}),children:"جستجو"})]})}),e.jsx(a6,{title:"خروجی اکسل",children:e.jsx(Y,{color:"success",onClick:()=>{C({vertical:"top",horizontal:"center",msg:"فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",severity:"success"});const c=`${eu.defaults.baseURL}cold_house_excel/?role=${K()}${G("slaughter")?`&role_key=${i==null?void 0:i.key}`:""}&key=${t}&type=${d}${$?`&date1=${p}&date2=${l}`:""}&cold_house_key=${h}&cold_house=true`;window.location.href=c},children:e.jsx(k6,{size:32})})})]}),e.jsx(ou,{data:j,columns:["ردیف","تاریخ ثبت","نوع تخصیص","مشخصات خریدار","نوع فروش","قیمت هر کیلو","قیمت کل","وزن تخصیصی","کد احراز","وضعیت کد احراز","وضعیت",...pu()],handlePageChange:lu,totalRows:y,page:P,perPage:E,handlePerRowsChange:gu,title:w})]})},Y6=()=>{var R,E,W,T,m,P,M;const p=su(),[l,w]=a.useState([]),[d,$]=a.useState([]),h=Q(j=>j.userSlice.selectedSubUser),{key:_}=s6(),[x,A]=a.useState(!1),[t,C]=a.useState(J(new Date).format("YYYY-MM-DD")),[f,i]=a.useState(J(new Date).format("YYYY-MM-DD")),k=()=>{p(A6({dashboard:!0,cold_house_key:_,role_key:G("slaughter")&&(h==null?void 0:h.key)||""})).then(j=>{w(j.payload.data)}),p(j6({date1:x?t:null,date2:x?f:null,cold_house_key:_,role_key:G("slaughter")&&(h==null?void 0:h.key)||""})).then(j=>{$(j.payload.data)})};a.useEffect(()=>{k()},[p,x,t,f,h==null?void 0:h.key]);const[F,v]=a.useState(0),y=(j,H)=>{v(H)};return e.jsx(e.Fragment,{children:e.jsxs(g,{container:!0,direction:"column",justifyContent:"center",xs:12,children:[e.jsxs(g,{container:!0,justifyContent:"space-between",gap:vu.SMALL,children:[e.jsx(ou,{noPagination:!0,columns:["وزن کل","وزن خارج شده","وزن باقیمانده"],data:[[(R=l==null?void 0:l.totalInputWeight)==null?void 0:R.toLocaleString(),(E=l==null?void 0:l.totalAllocatedWeight)==null?void 0:E.toLocaleString(),(W=l==null?void 0:l.totalRemainWeight)==null?void 0:W.toLocaleString()]],title:"موجودی سردخانه",isDashboard:!0}),e.jsx(ou,{noPagination:!0,columns:["تعداد کل بارهای وارد شده","وزن کل بارهای وارد شده","تعداد کل بارهای خارج شده","وزن کل بارهای خارج شده"],data:[[(T=d==null?void 0:d.totalInputBars)==null?void 0:T.toLocaleString(),(m=d==null?void 0:d.totalInputBarsWeight)==null?void 0:m.toLocaleString(),(P=d==null?void 0:d.totalOutputBars)==null?void 0:P.toLocaleString(),(M=d==null?void 0:d.totalOutputBarsWeight)==null?void 0:M.toLocaleString()]],title:"خلاصه اطلاعات",isDashboard:!0})]}),e.jsx(g,{container:!0,alignItems:"center",justifyContent:"space-between",gap:2,paddingTop:2,mb:1,width:"100%",children:e.jsxs(g,{container:!0,gap:1,style:{borderStyle:"solid",borderWidth:"1px",padding:"10px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},children:[e.jsx(g,{children:e.jsx(Z,{control:e.jsx(n6,{checked:x,onChange:()=>A(!x),color:"primary"})})}),e.jsx(g,{children:e.jsx(fu,{disabled:!x,label:"از تاریخ",id:"date",renderInput:j=>e.jsx(V,{size:"small",style:{width:"160px"},...j}),value:t,onChange:j=>{C(J(j).format("YYYY-MM-DD"))}})}),e.jsx(g,{children:e.jsx(fu,{disabled:!x,label:"تا تاریخ",id:"date",renderInput:j=>e.jsx(V,{size:"small",style:{width:"160px"},...j}),value:f,onChange:j=>{i(J(j).format("YYYY-MM-DD"))}})})]})}),e.jsxs(g,{container:!0,xs:12,justifyContent:"center",children:[e.jsxs(c6,{sx:{mb:2},value:F,onChange:y,"aria-label":"simple tabs example",children:[e.jsx(u6,{value:0,label:"بارهای خارج شده"}),e.jsx(u6,{value:1,label:"بارهای وارد شده"})]}),F===0&&e.jsx(e6,{selectedDate1:t,selectedDate2:f,title:"بارهای خارج شده",type:"output",withDate:x,coldHouseKey:_,getDashboardsData:k,remainWeight:l==null?void 0:l.totalRemainWeight}),F===1&&e.jsx(e6,{selectedDate1:t,selectedDate2:f,title:"بارهای وارد شده",type:"input",withDate:x,coldHouseKey:_,getDashboardsData:k})]})]})})},n0=()=>{var A,t,C,f;const p=su(),[l,w]=a.useState([]),[d,$]=a.useState([]),h=Q(i=>i.userSlice.selectedSubUser),_=d6(),{key:x}=s6();return a.useEffect(()=>{x||(p(G6({role_key:G("slaughter")&&(h==null?void 0:h.key)||""})).then(i=>{w(i.payload.data)}),p(R6()).then(i=>{var F,v;const k=(v=(F=i.payload.data)==null?void 0:F.coldHouses)==null?void 0:v.map((y,R)=>{var E,W,T;return[R+1,y==null?void 0:y.name,(E=y==null?void 0:y.totalInputWeight)==null?void 0:E.toLocaleString(),(W=y==null?void 0:y.totalAllocatedWeight)==null?void 0:W.toLocaleString(),(T=y==null?void 0:y.totalRemainWeight)==null?void 0:T.toLocaleString(),e.jsx(Su,{color:"success",onClick:()=>{_(F6+"/"+(y==null?void 0:y.key))},children:e.jsx(L6,{})},R)]});$(k)}))},[p,x,h==null?void 0:h.key]),e.jsx(e.Fragment,{children:e.jsx(C6,{display:"flex",justifyContent:"center",children:e.jsxs(g,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:[e.jsx(B6,{}),x?e.jsx(g,{container:!0,justifyContent:"start",alignItems:"center",xs:12,children:e.jsx(Y6,{})}):e.jsxs(g,{container:!0,justifyContent:"space-between",alignItems:"center",children:[e.jsx(g,{container:!0,mb:4,isDashboard:!0,xs:12,children:e.jsx(ou,{noPagination:!0,isDashboard:!0,columns:["تعداد سردخانه ها","وزن تخصیص داده شده","کل وزن وارد شده","وزن باقیمانده"],data:[[(A=l==null?void 0:l.totalColdHouses)==null?void 0:A.toLocaleString(),(t=l==null?void 0:l.totalAllocatedWeight)==null?void 0:t.toLocaleString(),(C=l==null?void 0:l.totalInputWeight)==null?void 0:C.toLocaleString(),(f=l==null?void 0:l.totalRemainWeight)==null?void 0:f.toLocaleString()]],title:"خلاصه اطلاعات"})}),e.jsx(g,{container:!0,xs:12,justifyContent:"center",alignItems:"cented",children:e.jsx(ou,{title:"سردخانه ها",paginated:!0,columns:["ردیف","نام سردخانه","وزن وارد شده","وزن خارج شده","وزن باقیمانده","نمایش"],data:d})})]})]})})})};export{n0 as default};