2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
import{j as u,T as P,ap as wu,al as J,a_ as ku,an as S,aj as Du,ak as Eu,am as cu,B as O,b5 as bu,b6 as Cu,b as Lu}from"./mui-vendor-D_SVL-Dx.js";import{G as C,S as g,mt as X,mu as Z,A as K,c as iu,V as Tu,u as du,b as Ou,a0 as T,mv as Ru,mw as U,kR as hu,mx as pu,C as Au,my as gu,mz as Nu,_ as Mu,p as yu,O as $u,$ as H,af as xu,L as uu,h as eu,v as Q,a3 as Yu,W as Wu,j as fu,mA as Bu,mB as Iu}from"./index-D80MdVQn.js";import{B as Pu}from"./BackButton-Dr-K0JXJ.js";import{V as Vu}from"./index.esm-DYumyMPq.js";import{L as Fu}from"./LinkItem-Din4toX7.js";import{N as ju}from"./NavLink-Uri4Pz8C.js";import{d as zu}from"./SlaughterShowProducts-C1xLq8AA.js";import{f as _u,r as l}from"./react-vendor-CmFgShSM.js";import{u as tu,f as au}from"./redux-vendor-CfkcHgWN.js";import{g as vu}from"./guild-allocated-stock-operation-BLvN06p9.js";import{c as A}from"./checkPathStartsWith-DedybDvj.js";import{R as I}from"./ResponsiveTable-bUYl0qDM.js";import{R as Su}from"./index.esm-C1-dCPnj.js";import{s as Gu,S as mu,a as qu}from"./StewardSegmentOperation-DdsyYFjL.js";import{s as Ku}from"./steward-get-dashboard-service-CAcZdhJs.js";import{S as Hu}from"./SlaughterStockWrapper-KWfSoKoo.js";import"./SystemUpdateAlt-QYMcO5S3.js";import"./FilterAlt-DZsHj-WQ.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./MonthlyDataCalendar-_xfuL-Zd.js";import"./LabelField-BYhJrYEE.js";import"./slaughter-get-guilds-for-allocate-CQRKvxsV.js";import"./Tune-BBzxV8DK.js";import"./EditOutlined-CdYoJAhn.js";import"./DeleteOutlineOutlined-BmausW-i.js";import"./province-policy-drop-limit-D3SVePgA.js";import"./Settings-Cboitw62.js";import"./vet-farm-get-out-province-dashboard-BLT-TxVO.js";import"./toBase64-UDzdrM-n.js";import"./PublishedWithChanges-Dz7dEVRv.js";import"./Delete-CIwpNviU.js";import"./slaughter-get-provinces-D6etA0Tf.js";import"./CarPelak-BUqZflo3.js";import"./ShowImage-DxnwAx1k.js";import"./Download-CJYPO5Fu.js";import"./Close-J1gH5PMD.js";import"./ToggleOffOutlined-C41wua6U.js";import"./ToggleOn-Cv1P2E48.js";import"./ChechClearanceCode-C2pygfym.js";import"./Pageview-CHY_bSEN.js";import"./AddCircleOutline-5cdNoXZy.js";const Ju=()=>{const{pathname:o}=_u();return u.jsxs(C,{container:!0,gap:g.SMALL,p:g.SMALL,direction:{xs:"column",md:"row"},justifyContent:"center",style:{placeContent:"baseline"},children:[u.jsx(ju,{to:X,active:o===X?"true":null,children:u.jsx(Fu,{icon:u.jsx(Vu,{size:30,color:"#244CCC"}),title:"ورود به انبار"})}),u.jsx(ju,{to:Z,active:o===Z?"true":null,children:u.jsx(Fu,{icon:u.jsx(zu,{sx:{fontSize:30,color:"#2444CC"}}),title:"قطعه بندی"})})]})},Qu=({item:o})=>{const i=tu(),[,,d]=l.useContext(K),[p]=l.useContext(K),[w,v]=l.useState("option1"),R=r=>{v(r.target.value)},f={authCode:""},_=iu({authCode:Tu().required("کداحراز اجباری است")}),c=du({initialValues:f,validationSchema:_}),[j,h]=l.useState(!1),x=()=>{h(!j)},t=du({initialValues:{number:"",weight:""},validationSchema:iu({weight:Ou().required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!")})});return l.useEffect(()=>{c.validateForm(),t.validateForm()},[]),u.jsxs(C,{container:!0,width:"100%",direction:"column",justifyContent:"space-between",gap:g.TINY,children:[u.jsxs(C,{container:!0,justifyContent:"space-around",children:[u.jsxs(P,{variant:"caption",children:["وزن تخصیصی: ",o.weightOfCarcasses.toLocaleString()," کیلوگرم"]}),u.jsxs(P,{variant:"caption",children:["تعداد تخصیصی: ",o.numberOfCarcasses.toLocaleString()," قطعه"]})]}),u.jsx(wu,{}),u.jsxs(C,{container:!0,spacing:1,alignItems:"center",children:[u.jsx(C,{item:!0,children:u.jsx(J,{control:u.jsx(ku,{size:"small",checked:j,onChange:x}),label:"ثبت تعداد واقعی تحویلی"})}),u.jsx(C,{container:!0,xs:12,spacing:1,children:u.jsx(C,{item:!0,xs:6,children:u.jsx(S,{id:"weight",size:"small",label:"وزن",variant:"outlined",fullWidth:!0,disabled:!j,onChange:t.handleChange,onBlur:t.handleBlur,value:t.values.weight,error:t.touched.weight&&!!t.errors.weight,helperText:t.touched.weight?t.errors.weight:""})})})]}),u.jsx(Du,{component:"fieldset",children:u.jsxs(Eu,{row:!0,"aria-label":"radio-buttons-group",name:"radio-buttons-group",value:w,onChange:R,style:{justifyContent:"space-between",flexDirection:"row"},children:[u.jsx(J,{value:"option1",control:u.jsx(cu,{}),label:"تحویل بار با کداحراز"}),u.jsx(J,{value:"option2",control:u.jsx(cu,{}),label:"تحویل بار بدون کداحراز"})]})}),w==="option1"&&u.jsx(S,{fullWidth:!0,id:"authCode",name:"authCode",label:"کداحراز",variant:"outlined",margin:"normal",onChange:c.handleChange,onBlur:c.handleBlur,value:c.values.authCode,error:c.touched.authCode&&!!c.errors.authCode,helperText:c.touched.authCode?c.errors.authCode:""}),u.jsx(O,{disabled:(w==="option1"?!c.isValid:!1)||(j?!t.isValid:!1),variant:"contained",onClick:()=>{let r={};c.values.authCode?T()==="senf"?r={guild_check_allocation:!0,receiver_real_number_of_carcasses:0,receiver_real_weight_of_carcasses:t.values.weight?t.values.weight:o.weightOfCarcasses,allocation_key:o.key,registration_code:Number(c.values.authCode),state:"accepted"}:r={steward_check_allocation:!0,allocation_key:o.key,receiver_real_number_of_carcasses:0,receiver_real_weight_of_carcasses:t.values.weight?t.values.weight:o.weightOfCarcasses,registration_code:Number(c.values.authCode),state:"accepted"}:T()==="senf"?r={guild_check_allocation:!0,allocation_key:o.key,receiver_real_number_of_carcasses:0,receiver_real_weight_of_carcasses:t.values.weight?t.values.weight:o.weightOfCarcasses,state:"accepted"}:r={steward_check_allocation:!0,allocation_key:o.key,receiver_real_number_of_carcasses:0,receiver_real_weight_of_carcasses:t.values.weight?t.values.weight:o.weightOfCarcasses,state:"accepted"},i(vu(r)).then(k=>{k.payload.error?p({vertical:"top",horizontal:"center",msg:k.payload.error,severity:"error"}):(T()==="senf"?(i(Ru({date:d})),i(U({date:d}))):(i(hu({date:d})),i(pu({date:d}))),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),i(Au()))})},children:"تحویل بار"}),u.jsx(O,{variant:"contained",color:"error",onClick:()=>{i(vu({steward_check_allocation:!0,allocation_key:o.key,state:"rejected"})).then(r=>{r.payload.error?p({vertical:"top",horizontal:"center",msg:r.payload.error,severity:"error"}):(i(hu({date:d})),i(pu({date:d})),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),i(Au()))})},children:"رد بار"})]})},Xu=()=>{const o=tu(),[i,d]=l.useState([]),[p,w]=l.useState("pending"),[v,R]=l.useState(""),[,,f,_,c,j]=l.useContext(K),{senfGetInventoryStock:h,senfGetInventoryAllocated:x,guildSalesInfoDashboard:t}=au(s=>s.generalSlice),r=au(s=>s.userSlice.selectedSubUser);l.useEffect(()=>{o(gu({date1:f,date2:c,role_key:A("senf")?r==null?void 0:r.key:"",search:v})),o(U({date1:f,date2:c,role_key:A("senf")?r==null?void 0:r.key:"",type:p,search:v})),o(Nu({role_key:A("senf")?r==null?void 0:r.key:""}))},[f,c,r==null?void 0:r.key,p,o]),l.useEffect(()=>{const s=(x==null?void 0:x.results)||[];if(s.length>0){const F=s.map((a,D)=>{var z,N,G,m,q,M,$,Y,n,e,L,W,B;let E="";(a==null?void 0:a.receiverState)==="accepted"?E="تحویل گرفته شده":(a==null?void 0:a.receiverState)==="rejected"?E="رد شده":E="در انتظار تحویل";const y=Mu(a==null?void 0:a.seller_type),V=((N=(z=a==null?void 0:a.stewards)==null?void 0:z.user)==null?void 0:N.fullname)||((G=a==null?void 0:a.stewards)==null?void 0:G.name)||((m=a==null?void 0:a.killHouse)==null?void 0:m.name)||((q=a==null?void 0:a.toKillHouse)==null?void 0:q.name)||"-",b=(($=(M=a==null?void 0:a.stewards)==null?void 0:M.user)==null?void 0:$.mobile)||((n=(Y=a==null?void 0:a.killHouse)==null?void 0:Y.user)==null?void 0:n.mobile)||((L=(e=a==null?void 0:a.toKillHouse)==null?void 0:e.user)==null?void 0:L.mobile)||"-";return[D+1,`${y} ${V} (${b})`,yu(a.date),((a==null?void 0:a.weightOfCarcasses)||0).toLocaleString()+" کیلوگرم",u.jsx(C,{container:!0,direction:"column",children:(a==null?void 0:a.receiverRealNumberOfCarcasses)&&u.jsxs(u.Fragment,{children:[u.jsx(P,{variant:"caption",children:((W=a==null?void 0:a.receiverRealNumberOfCarcasses)==null?void 0:W.toLocaleString())+" قطعه"}),u.jsx(P,{variant:"caption",children:((B=a==null?void 0:a.receiverRealWeightOfCarcasses)==null?void 0:B.toLocaleString())+" کیلوگرم"})]})},a.key),u.jsx(C,{container:!0,direction:"column",gap:g.SMALL,children:a.receiverState==="pending"?u.jsx(O,{onClick:()=>{o($u({title:"ثبت تحویل بار",content:u.jsx(Qu,{item:a})}))},children:"تحویل بار"}):E},a.key)]});d(F)}else d([])},[x,o]);const k=async s=>{s.preventDefault(),o(uu());try{o(gu({date1:f,date2:c,role_key:A("senf")?r==null?void 0:r.key:"",search:v})),o(U({date1:f,date2:c,role_key:A("senf")?r==null?void 0:r.key:"",type:p,search:v}))}catch(F){console.error("Error fetching data:",F)}finally{o(eu())}};return u.jsxs(C,{container:!0,gap:g.SMALL,pt:g.MEDIUM,children:[u.jsx(I,{title:"اطلاعات فروش",columns:["وزن دولتی (کیلوگرم)","وزن آزاد (کیلوگرم)","فروش دولتی (کیلوگرم)","فروش آزاد (کیلوگرم)","وزن قطعه بندی (کیلوگرم)","وزن انجماد (کیلوگرم)","مانده دولتی (کیلوگرم)","مانده آزاد (کیلوگرم)"],data:[[((t==null?void 0:t.totalGovernmentalInputWeight)||0).toLocaleString(),((t==null?void 0:t.totalFreeInputWeight)||0).toLocaleString(),((t==null?void 0:t.totalGovernmentalOutputWeight)||0).toLocaleString(),((t==null?void 0:t.totalFreeOutputWeight)||0).toLocaleString(),"0","0",((t==null?void 0:t.totalGovernmentalRemainWeight)||0).toLocaleString(),((t==null?void 0:t.totalFreeRemainWeight)||0).toLocaleString()]],noPagination:!0,isDashboard:!0}),u.jsx(C,{container:!0,gap:g.SMALL,alignItems:"center",justifyContent:"space-between",mb:2,mt:2,children:u.jsxs(C,{container:!0,gap:g.SMALL,alignItems:"center",children:[u.jsx(H,{label:"تاریخ شروع",id:"date1",renderInput:s=>u.jsx(S,{style:{width:"160px"},...s}),value:f,onChange:s=>{_(xu(s).format("YYYY-MM-DD"))}}),u.jsx(H,{label:"تاریخ پایان",id:"date2",renderInput:s=>u.jsx(S,{style:{width:"160px"},...s}),value:c,onChange:s=>{j(xu(s).format("YYYY-MM-DD"))}}),u.jsxs("form",{onSubmit:k,children:[u.jsx(S,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},value:v,onChange:s=>R(s.target.value)}),u.jsx(O,{type:"submit",onClick:k,endIcon:u.jsx(Su,{}),children:"جستجو"})]})]})}),u.jsx(I,{title:"ورودی به انبار",columns:["تعداد بار تخصیصی","وزن لاشه در انتظار تحویل","وزن لاشه تحویلی"],data:[[(h==null?void 0:h.allocationsCount)||0,(((h==null?void 0:h.notEnteredWeight)||0)+((h==null?void 0:h.enteredWeight)||0)).toLocaleString()+" کیلوگرم",((h==null?void 0:h.enteredWeight)||0).toLocaleString()+" کیلوگرم"]],noPagination:!0,isDashboard:!0}),u.jsx(C,{container:!0,justifyContent:"center",xs:12,mt:g.SMALL,children:u.jsxs(bu,{value:p,onChange:(s,F)=>w(F),sx:{borderBottom:1,borderColor:"divider",mb:1},children:[u.jsx(Cu,{label:"در انتظار تحویل",value:"pending"}),u.jsx(Cu,{label:"تحویل گرفته شده",value:"accepted"})]})}),u.jsx(I,{title:`بارهای اختصاصی ${p==="pending"?"در انتظار تحویل":"تحویل گرفته شده"}`,columns:p==="accepted"?["ردیف","فروشنده","تاریخ تخصیص","وزن تخصیص","تعداد/وزن واقعی تحویلی"]:["ردیف","فروشنده","تاریخ تخصیص","وزن تخصیص","تعداد/وزن واقعی تحویلی","عملیات"],data:p==="accepted"?i.map(s=>s.slice(0,-1)):i})]})},Zu=()=>{var M,$,Y;const[o,i]=l.useState([]),[d,p]=l.useState([]),[w,v]=l.useState([]),[R,f]=l.useState(0),[_,c]=l.useState(10),[j,h]=l.useState(""),[x,t]=l.useState(1),[r,k]=l.useState([]),s=au(n=>n.userSlice.selectedSubUser),[,,F,a,D,E]=l.useContext(K),y=tu(),V=()=>{y(Ku({value:j,date1:F,date2:D,role:T(),role_key:A("slaughter")||A("senf")?s==null?void 0:s.key:""})).then(n=>{k(n.payload.data)})};l.useEffect(()=>{const n=Q(new Date).format("YYYY-MM-DD");a(n),E(n)},[]);const b=async n=>{y(uu());const e=await fu.get(`app-segmentation/?search=filter&value=${j}&date1=${F}&date2=${D}&page=${n}&page_size=${_}&role=${T()}${A("slaughter")||A("senf")?`&role_key=${s==null?void 0:s.key}`:""}`);V(),y(eu()),i(e.data.results),f(e.data.count)},z=n=>{b(n),t(n)},N=()=>{b(x)},G=n=>{c(n),t(1)},m=n=>{h(n.target.value)};l.useEffect(()=>{b(1),y(Gu({role_key:(A("slaughter")||A("senf"))&&(s==null?void 0:s.key)||""})).then(n=>{p(n.payload.data)})},[]),l.useEffect(()=>{const n=o==null?void 0:o.map((e,L)=>{var W,B,ru,su,ou,nu,lu;return[x===1?L+1:L+_*(x-1)+1,e!=null&&e.productionDate?Yu(e==null?void 0:e.productionDate):"-",(e==null?void 0:e.distributionType)==="web"?"سایت":(e==null?void 0:e.distributionType)==="app"?"موبایل":(e==null?void 0:e.distributionType)==="pos"?"پوز":(e==null?void 0:e.distributionType)||"-",`${(W=e==null?void 0:e.buyer)==null?void 0:W.fullname}(${(B=e==null?void 0:e.buyer)==null?void 0:B.mobile})`,e!=null&&e.toGuild?`به قطعه بند - ${(su=(ru=e==null?void 0:e.toGuild)==null?void 0:ru.user)==null?void 0:su.fullname}(${(nu=(ou=e==null?void 0:e.toGuild)==null?void 0:ou.user)==null?void 0:nu.mobile})`:"قطعه بندی توسط کشتارگاه",e!=null&&e.date?yu(e==null?void 0:e.date):"-",e==null?void 0:e.weight,(e==null?void 0:e.quota)==="governmental"?"دولتی":(e==null?void 0:e.quota)==="free"?"آزاد":"-",(e==null?void 0:e.saleType)==="governmental"?"دولتی":(e==null?void 0:e.saleType)==="free"?"آزاد":"-",u.jsx(mu,{item:e,productKey:(lu=d==null?void 0:d[0])==null?void 0:lu.key,updateTable:N},L)]});v(n)},[o]),l.useEffect(()=>{b(1)},[F,D,_,s==null?void 0:s.key]);const q=async n=>{n.preventDefault(),y(uu());try{const e=await fu.get(`app-segmentation/?search=filter&value=${j}&date1=${F}&date2=${D}&page=${x}&role=${T()}${A("slaughter")||A("senf")?`&role_key=${s==null?void 0:s.key}`:""}`);i(e.data.results),f(e.data.count),V(),y(eu())}catch(e){console.error("Error fetching data:",e)}};return u.jsxs(C,{container:!0,children:[u.jsx(P,{variant:"h6",my:g.SMALL,children:"ثبت قطعه بندی"}),u.jsxs(C,{xs:12,container:!0,alignItems:"center",gap:g.SMALL,justifyContent:"flex-start",children:[u.jsx(C,{container:!0,mb:4,isDashboard:!0,xs:12,children:u.jsx(I,{noPagination:!0,isDashboard:!0,columns:["وزن کل (کیلوگرم)","وزن قطعه بندی","وزن تخصیصی به قطعه بندها"],data:[[((M=r==null?void 0:r.totalWeight)==null?void 0:M.toLocaleString())||"0",(($=r==null?void 0:r.totalSelfWeight)==null?void 0:$.toLocaleString())||"0",((Y=r==null?void 0:r.totalOtherWeight)==null?void 0:Y.toLocaleString())||"0"]],title:"خلاصه اطلاعات"})}),u.jsx("form",{children:u.jsxs(C,{container:!0,alignItems:"center",gap:g.SMALL,children:[u.jsx(O,{variant:"contained",onClick:()=>{var n;y(Wu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ثبت قطعه بندی",size:{xs:"100%",sm:"380px"},content:u.jsx(qu,{updateTable:N,productKey:(n=d==null?void 0:d[0])==null?void 0:n.key})}))},children:"ثبت قطعه بندی"}),u.jsx(S,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:m}),u.jsx(O,{type:"submit",onClick:q,endIcon:u.jsx(Su,{}),children:"جستجو"}),u.jsx(C,{children:u.jsx(H,{label:"از تاریخ",id:"date",renderInput:n=>u.jsx(S,{style:{width:"160px"},...n}),value:F,onChange:n=>a(Q(n).format("YYYY-MM-DD"))})}),u.jsx(C,{children:u.jsx(H,{label:"تا تاریخ",id:"date",renderInput:n=>u.jsx(S,{style:{width:"160px"},...n}),value:D,onChange:n=>E(Q(n).format("YYYY-MM-DD"))})})]})}),u.jsx(I,{data:w,columns:["ردیف","تاریخ تولید گوشت","ثبت شده","قطعه بند","تخصیص","تاریخ ","وزن (کیلوگرم)","سهمیه","نوع فروش","عملیات"],handlePageChange:z,totalRows:R,page:x,perPage:_,handlePerRowsChange:G,title:"قطعه بندی"})]})]})},Uu=()=>u.jsx(Hu,{}),P6=()=>{const{pathname:o}=_u();return u.jsx(Lu,{display:"flex",justifyContent:"center",children:u.jsxs(C,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:[u.jsx(Pu,{}),o===Bu&&u.jsx(C,{container:!0,direction:"column",justifyContent:"center",alignItems:"center",my:g.MEDIUM,children:u.jsx(Ju,{})}),o.includes(X)&&u.jsx(Xu,{}),o.includes(Z)&&u.jsx(Zu,{}),o.includes(Iu)&&u.jsx(Uu,{})]})})};export{P6 as default};
|