2 lines
29 KiB
JavaScript
2 lines
29 KiB
JavaScript
import{j as u,T as q,aj as Lu,ak as zu,al as fu,am as $u,an as B,B as R,d as Wu,I as Bu,a_ as Qu,ay as e6,az as a6,aA as wu,b3 as r6,b5 as Ju,b6 as bu}from"./mui-vendor-D_SVL-Dx.js";import{L as vu,j as J,h as m,A as Ru,u as Hu,c as qu,b as _u,G as C,S as L,C as Vu,g4 as Eu,O as Su,v as O,a0 as N,p as ku,$ as Z,W as Xu,fG as Zu,k$ as s6}from"./index-D80MdVQn.js";import{r as l}from"./react-vendor-CmFgShSM.js";import{S as t6}from"./SlaughterShowProducts-C1xLq8AA.js";import{a as l6,f as V,u as uu}from"./redux-vendor-CfkcHgWN.js";import{R as U}from"./ResponsiveTable-bUYl0qDM.js";import{p as n6}from"./province-policy-drop-limit-D3SVePgA.js";import{c as D}from"./checkPathStartsWith-DedybDvj.js";import{d as o6}from"./Settings-Cboitw62.js";import{R as Du,a as c6}from"./index.esm-C1-dCPnj.js";import{b as Uu,c as C6,s as d6,a as mu,S as i6,v as h6}from"./vet-farm-get-out-province-dashboard-BLT-TxVO.js";import{S as u6}from"./ShowImage-DxnwAx1k.js";import{d as g6}from"./ToggleOffOutlined-C41wua6U.js";import{d as p6}from"./ToggleOn-Cv1P2E48.js";import{d as x6}from"./SystemUpdateAlt-QYMcO5S3.js";import{C as F6}from"./ChechClearanceCode-C2pygfym.js";import{d as y6}from"./Tune-BBzxV8DK.js";const A6=l6("SLAUGHTER_SUBMIT_REAL_INVENTORY",async(a,{dispatch:F})=>{F(vu());try{const{data:s,status:k}=await J.put("ware-house-accept-kill-house-request/0/",a);return F(m()),{data:s,status:k}}catch(s){return F(m()),{error:s.response.data.result}}}),j6=({item:a,updateTable:F})=>{var z,$,P;const[s,k]=l.useState("weight"),[t,A]=l.useState("0"),[g,f]=l.useState({min:0,max:100}),S=V(y=>y.userSlice.selectedSubUser),d=y=>{k(y.target.value)},[v,E]=l.useState(a!=null&&a.killer?"killer":"self"),W=y=>{E(y.target.value)},[w]=l.useContext(Ru),x=uu();l.useEffect(()=>{x(n6()).then(y=>{var j;(j=y.payload)!=null&&j.data&&f({min:parseFloat(y.payload.data.killHouseLimitPercentDown),max:parseFloat(y.payload.data.killHouseLimitPercentUp)})})},[]);const p=Hu({initialValues:{realNumber:a!=null&&a.acceptedRealQuantity?a==null?void 0:a.acceptedRealQuantity:"",realWeight:a!=null&&a.wareHouseAcceptedRealWeight?a==null?void 0:a.wareHouseAcceptedRealWeight:0},validationSchema:qu({realNumber:_u().typeError("لطفا فیلد را به درستی وارد کنید.!").required("این فیلد اجباری است!").min(0,"مقدار نمیتواند منفی باشد"),realWeight:_u().typeError("لطفا فیلد را به درستی وارد کنید.!").required("این فیلد اجباری است!").min(0,"مقدار نمیتواند منفی باشد")})}),h=Hu({initialValues:{lossWeight:""},validationSchema:qu({lossWeight:_u().typeError("لطفا فیلد را به درستی وارد کنید.!").required("این فیلد اجباری است!").min(g.min,`درصد افت باید بین ${g.min} تا ${g.max} درصد باشد!`).max(g.max,`درصد افت باید بین ${g.min} تا ${g.max} درصد باشد!`)})});l.useEffect(()=>{if(s==="weight")if(a!=null&&a.acceptedRealWeight&&p.values.realWeight){const j=(a.acceptedRealWeight-p.values.realWeight)/a.acceptedRealWeight*100;A(j.toFixed(2))}else A(0);else if(a!=null&&a.acceptedRealWeight&&h.values.lossWeight){const y=a.acceptedRealWeight/100*h.values.lossWeight;A((a.acceptedRealWeight-y).toFixed(2))}else A(0)},[p.values.realWeight,h.values.lossWeight,s,a]);const _=()=>s==="weight"?t>=g.min&&t<=g.max:h.isValid,b=()=>s==="weight"?p.isValid&&_():h.isValid,T=()=>{if(!b())return;const y=s==="weight"?{input_type:"input_weight",ware_house_accepted_real_quantity:parseInt(p.values.realNumber),ware_house_accepted_real_weight:parseInt(p.values.realWeight),kill_house_request_key:a==null?void 0:a.key,loss_percent:parseFloat(t)}:{input_type:"loss_weight",loss_percent:parseInt(h.values.lossWeight),kill_house_request_key:a==null?void 0:a.key};x(A6({...y,...a!=null&&a.killer?{input_warehouse:v}:{}})).then(j=>{j.payload.error?w({vertical:"top",horizontal:"center",msg:j.payload.error,severity:"error"}):(x(Vu()),F(),x(Eu({role_key:D("slaughter")?S==null?void 0:S.key:""})),Y())})},Y=()=>{x(Su({title:"عملیات با موفقیت انجام شد",content:u.jsx(u.Fragment,{children:u.jsxs(C,{container:!0,gap:L.SMALL,justifyContent:"center",children:[u.jsx(q,{variant:"body2",color:"secondary",children:"جهت ویرایش میتوانید حداکثر تا پایان امروز یا قبل از اولین تخصیص اقدام کنید."}),u.jsx(R,{variant:"outlined",onClick:()=>{x(Vu())},children:"متوجه شدم"})]})})}))};return u.jsx(u.Fragment,{children:u.jsxs(C,{xs:12,container:!0,spacing:L.SMALL,alignItems:"center",justifyContent:"center",children:[u.jsxs(C,{container:!0,xs:12,gap:L.TINY,children:[u.jsxs(C,{container:!0,xs:12,gap:L.SMALL,justifyContent:"center",children:[(a==null?void 0:a.killer)&&u.jsxs(q,{color:"primary",variant:"body2",children:["کشتارکن: ",(z=a==null?void 0:a.killer)==null?void 0:z.name]}),u.jsxs(q,{color:"primary",variant:"body2",children:["کد بار: ",a.barCode]}),u.jsxs(q,{color:"primary",variant:"body2",children:["حجم بار: ",($=a==null?void 0:a.acceptedRealQuantity)==null?void 0:$.toLocaleString()]}),u.jsxs(q,{color:"primary",variant:"body2",children:["وزن بار: ",(P=a==null?void 0:a.acceptedRealWeight)==null?void 0:P.toLocaleString()]})]}),u.jsx(Lu,{children:u.jsxs(zu,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:"بر اساس وزن ورودی",name:"radio-buttons-group",value:s,onChange:d,row:!0,children:[u.jsx(fu,{value:"weight",control:u.jsx($u,{}),label:"بر اساس وزن ورودی"}),u.jsx(fu,{value:"loss",control:u.jsx($u,{}),label:"بر اساس درصد افت"})]})}),s==="weight"?u.jsxs(u.Fragment,{children:[u.jsx(B,{fullWidth:!0,id:"realWeight",size:"small",label:"وزن لاشه",variant:"outlined",value:p.values.realWeight,error:p.touched.realWeight?!!p.errors.realWeight:null,onChange:p.handleChange,onBlur:p.handleBlur,helperText:p.touched.realWeight&&p.errors.realWeight?p.errors.realWeight:null}),u.jsx(B,{fullWidth:!0,id:"realNumber",size:"small",label:"حجم لاشه",variant:"outlined",value:p.values.realNumber,error:p.touched.realNumber?!!p.errors.realNumber:null,onChange:p.handleChange,onBlur:p.handleBlur,helperText:p.touched.realNumber&&p.errors.realNumber?p.errors.realNumber:null})]}):u.jsx(B,{fullWidth:!0,id:"lossWeight",size:"small",label:"درصد افت",variant:"outlined",value:h.values.lossWeight,error:h.touched.lossWeight?!!h.errors.lossWeight:null,onChange:h.handleChange,onBlur:h.handleBlur,helperText:h.touched.lossWeight&&h.errors.lossWeight?h.errors.lossWeight:null})]}),(a==null?void 0:a.killer)&&u.jsx(C,{mt:2,xs:12,container:!0,justifyContent:"start",p:1,sx:{borderStyle:"solid",borderWidth:"1px",borderColor:"red",borderRadius:"15px"},children:u.jsx(Lu,{children:u.jsxs(zu,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:v,name:"radio-buttons-group",value:v,onChange:W,row:!0,children:[u.jsx(fu,{value:"self",control:u.jsx($u,{color:"error"}),label:"ورود به انبار کشتارگاه"}),u.jsx(fu,{value:"killer",control:u.jsx($u,{color:"error"}),label:"ورود به انبار کشتارکن"})]})})}),u.jsxs(C,{container:!0,xs:12,gap:4,alignItems:"center",mt:2,justifyContent:"space-between",children:[u.jsx(C,{children:s==="weight"?u.jsxs(C,{container:!0,gap:2,alignItems:"center",children:[u.jsxs(q,{variant:"body1",color:"primary",children:["افت: ",t>0?t:0,"%"]}),!_()&&u.jsxs(q,{variant:"body2",color:"error",children:["درصد افت باید بین ",g.min," تا ",g.max," درصد باشد!"]})]}):u.jsxs(q,{variant:"body1",color:"primary",children:["وزن: ",t]})}),u.jsx(C,{children:u.jsx(R,{disabled:!b(),size:"small",variant:"outlined",onClick:T,children:"ثبت"})})]})]})})},Ku=({type:a})=>{const[F,s]=l.useState(O(new Date).format("YYYY-MM-DD")),k=V(i=>i.userSlice.selectedSubUser),[t,A]=l.useState(O(new Date).format("YYYY-MM-DD")),g=uu(),f=i=>{_(i.target.value)},[S,d]=l.useState(a==="entered"),[v,E]=l.useState([]),[W,w]=l.useState(0),[x,p]=l.useState(10),[h,_]=l.useState(""),[b,T]=l.useState(1),[Y,z]=l.useState([]),[$,P]=l.useState("all"),y=l.useCallback(async i=>{g(vu());const e=await J.get(`bars_for_kill_house/?search=filter&value=${h}&role=${N()}${S?`&date1=${F}${D("slaughter")?`&role_key=${k==null?void 0:k.key}`:""}&date2=${t}`:""}&page=${i}&page_size=${x}&type=${a}"a=${$}`);g(m()),E(e.data.results),w(e.data.count)},[h,S,F,t,x,a,$,g,E,k==null?void 0:k.key,w]),j=i=>{y(i),T(i)},r=i=>{p(i),T(1)},M=()=>{y(b!==0?b:1)};l.useEffect(()=>{const i=v==null?void 0:v.map((e,I)=>{var G,n,Q,H,eu,au,ru,su,tu,lu,nu,ou,cu,Cu,du,iu,c,o,X,hu,gu,pu,xu,Fu,yu,Au,ju,Iu,Tu,Mu,Yu,Pu,Ou,Nu;return[b===1?I+1:I+x*(b-1)+1,e==null?void 0:e.barCode,ku((G=e==null?void 0:e.poultryRequest)==null?void 0:G.date),`${(n=e==null?void 0:e.poultryRequest)==null?void 0:n.poultryName} (${(Q=e==null?void 0:e.poultryRequest)==null?void 0:Q.poultryMobile}) - ${(H=e==null?void 0:e.poultryRequest)==null?void 0:H.poultryUserName}`,(eu=e==null?void 0:e.poultryRequest)==null?void 0:eu.poultryCity,`${(au=e==null?void 0:e.killhouseUser)!=null&&au.killer?"کشتارکن":"کشتارگاه"} ${(ru=e==null?void 0:e.killhouseUser)==null?void 0:ru.name} (${(lu=(tu=(su=e==null?void 0:e.killhouseUser)==null?void 0:su.killHouseOperator)==null?void 0:tu.user)==null?void 0:lu.mobile})`,(nu=e==null?void 0:e.poultryRequest)==null?void 0:nu.poultryReqOrderCode,e!=null&&e.freezing?"انجماد":e!=null&&e.export?"صادرات":"عادی",e!=null&&e.killer?`${(ou=e==null?void 0:e.killer)==null?void 0:ou.name} (${(du=(Cu=(cu=e==null?void 0:e.killer)==null?void 0:cu.killHouseOperator)==null?void 0:Cu.user)==null?void 0:du.mobile})`:"-",(iu=e==null?void 0:e.poultryRequest)!=null&&iu.freeSaleInProvince?"آزاد":"دولتی",(c=e==null?void 0:e.poultryRequest)==null?void 0:c.chickenBreed,`${(X=(o=e==null?void 0:e.addCar)==null?void 0:o.driver)==null?void 0:X.driverName}/${(gu=(hu=e==null?void 0:e.addCar)==null?void 0:hu.driver)==null?void 0:gu.typeCar}`,(xu=(pu=e==null?void 0:e.addCar)==null?void 0:pu.driver)!=null&&xu.healthCode?(yu=(Fu=e==null?void 0:e.addCar)==null?void 0:Fu.driver)==null?void 0:yu.healthCode:"-",e!=null&&e.clearanceCode?e==null?void 0:e.clearanceCode:"-",(Au=e==null?void 0:e.acceptedRealQuantity)==null?void 0:Au.toLocaleString(),(ju=e==null?void 0:e.acceptedRealWeight)==null?void 0:ju.toLocaleString(),(Iu=e==null?void 0:e.weightInfo)==null?void 0:Iu.state,e==null?void 0:e.wareHouseAcceptedRealQuantity.toLocaleString(),e==null?void 0:e.wareHouseAcceptedRealWeight.toLocaleString(),(Tu=e==null?void 0:e.weightInfo)!=null&&Tu.weightLoss?((Yu=(Mu=e==null?void 0:e.weightInfo)==null?void 0:Mu.weightLoss)==null?void 0:Yu.toFixed(2))+"%":"0%",(Pu=e==null?void 0:e.weightInfo)!=null&&Pu.inputLoss?((Nu=(Ou=e==null?void 0:e.weightInfo)==null?void 0:Ou.inputLoss)==null?void 0:Nu.toFixed(2))+"%":"0%",e!=null&&e.dateOfWareHouse?ku(e==null?void 0:e.dateOfWareHouse):"-",u.jsx(Wu,{title:"ورود بار به انبار",children:u.jsx(Bu,{size:"small",color:"primary",onClick:()=>{g(Su({title:"ثبت موجودی واقعی",content:u.jsx(j6,{updateTable:M,item:e})}))},children:u.jsx(o6,{fontSize:"small"})})},I)]});z(i)},[v]),l.useEffect(()=>{y(1)},[y]);const K=async i=>{i.preventDefault(),g(vu());try{const e=await J.get(`bars_for_kill_house/?role=${N()}${D("slaughter")?`&role_key=${k==null?void 0:k.key}`:""}&search=filter&value=${h}${S?`&date1=${F}&date2=${t}`:""}&page=1&page_size=${x}&type=${a}"a=${$}`);E(e.data.results),w(e.data.count),g(m())}catch(e){console.error("Error fetching data:",e)}};return u.jsxs(C,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(C,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsxs(C,{container:!0,style:{borderStyle:"solid",borderWidth:"1px",padding:"10px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},children:[a==="notentered"&&u.jsx(C,{children:u.jsx(fu,{control:u.jsx(Qu,{checked:S,onChange:()=>d(!S),color:"primary"})})}),u.jsx(C,{children:u.jsx(Z,{disabled:!S,label:"از تاریخ",id:"date",renderInput:i=>u.jsx(B,{size:"small",style:{width:"160px"},...i}),value:F,onChange:i=>{s(O(i).format("YYYY-MM-DD"))}})}),u.jsx(C,{children:u.jsx(Z,{disabled:!S,label:"تا تاریخ",id:"date",renderInput:i=>u.jsx(B,{size:"small",style:{width:"160px"},...i}),value:t,onChange:i=>{A(O(i).format("YYYY-MM-DD"))}})})]}),u.jsx(C,{children:u.jsxs(Lu,{size:"small",style:{minWidth:150},children:[u.jsx(e6,{children:"نوع فروش"}),u.jsxs(a6,{value:$,onChange:i=>P(i.target.value),label:"نوع فروش",children:[u.jsx(wu,{value:"all",children:"همه"}),u.jsx(wu,{value:"governmental",children:"دولتی"}),u.jsx(wu,{value:"free",children:"آزاد"})]})]})}),u.jsx(C,{children:u.jsxs("form",{onSubmit:K,children:[u.jsx(B,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:f}),u.jsx(R,{type:"submit",onClick:K,endIcon:u.jsx(Du,{}),children:"جستجو"})]})})]}),u.jsx(U,{data:Y,columns:["ردیف","کدبار","تاریخ کشتار","مرغدار","شهر مرغدار","خریدار","کدسفارش","کشتار","کشتارکن","فروش","نژاد","راننده/نوع خودرو","کدبهداشتی حمل و نقل","کدرهگیری سامانه قرنطینه","حجم بار (قطعه)","وزن بار (کیلوگرم)","وضعیت","حجم لاشه","وزن لاشه","درصد افت در لحظه","درصد افت ورود به انبار","تاریخ ورود به انبار","عملیات"],handlePageChange:j,totalRows:W,page:b,perPage:x,handlePerRowsChange:r,title:a==="entered"?"وارد شده به انبار (کشتار داخل استان)":"در انتظار ورود به انبار (کشتار داخل استان)"})]})},f6=({item:a,updateTable:F,barState:s,type:k})=>{const t=uu(),A=V(x=>x.userSlice.selectedSubUser),[g,f]=l.useState(null),S=x=>{f(x.currentTarget)},d=()=>{f(null)},v=!!g,E=v?"popover":void 0,W=()=>k==="carcass"||(a==null?void 0:a.buyType)!=="live"?!0:!s&&!a.weightOfCarcasses,w=(a==null?void 0:a.registerType)==="automatic"?!1:a.weightOfCarcasses&&!s&&(a==null?void 0:a.buyType)==="live";return u.jsxs("div",{children:[u.jsx(Bu,{disabled:w,"aria-describedby":E,variant:"contained",color:"primary",onClick:S,children:u.jsx(y6,{})}),u.jsx(r6,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:E,open:v,anchorEl:g,onClose:d,children:u.jsx("div",{style:{padding:"20px"},children:u.jsxs(C,{container:!0,direction:"column",children:[s==="entered"&&(a==null?void 0:a.registerType)==="automatic"&&u.jsx(R,{onClick:()=>{d(),t(Xu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ویرایش بار آزاد",content:u.jsx(Uu,{item:a,updateTable:F})}))},children:"ویرایش"}),(s==="entered"?(a==null?void 0:a.registerType)!=="automatic":!0)&&u.jsx(R,{onClick:()=>{d(),t(Su({title:"ثبت اطلاعات لاشه ورودی به انبار",content:u.jsx(C6,{item:a,updateTable:F,IsEdit:s==="entered"})}))},children:s==="entered"?"ویرایش":"ورود به انبار"}),W()&&(a==null?void 0:a.registerType)!=="automatic"&&u.jsx(R,{color:"error",onClick:()=>{d(),t(d6(a.key)).then(()=>{F(),t(Eu({role_key:(A==null?void 0:A.key)||""}))})},children:"حذف"})]})})})]})},Gu=({title:a,barState:F,handleUpdate:s,withDate:k,selectedDate1:t,selectedDate2:A,searchValue:g})=>{const f=uu(),[S]=l.useContext(Ru),d=V(j=>j.userSlice.selectedSubUser);l.useEffect(()=>{f(Zu({role_key:D("slaughter")&&(d==null?void 0:d.key)||""}))},[d==null?void 0:d.key]);const[v,E]=l.useState([]),[W,w]=l.useState(0),[x,p]=l.useState(10),[h,_]=l.useState(1),[b,T]=l.useState([]),Y=async j=>{let r;f(vu());try{r=await J.get(`kill_house_free_bar/?type=live&role=${N()}${D("slaughter")?`&role_key=${d==null?void 0:d.key}`:""}&page=${j}&page_size=${x}&bar_state=${F}&date_type=input${k?`&date1=${t}&date2=${A}`:""}${g?`&search=filter&value=${g}`:""}`),E(r.data.results),w(r.data.count)}catch(M){console.error("Error fetching data:",M)}finally{f(m())}},z=j=>{Y(j),_(j)},$=j=>{p(j),_(1)},P=()=>{Y(h!==0?h:1),s(),f(Eu({role_key:D("slaughter")&&(d==null?void 0:d.key)||""}))};l.useEffect(()=>{Y(1)},[x,k,t,A,g,d==null?void 0:d.key]),l.useEffect(()=>{const j=v==null?void 0:v.map((r,M)=>{var K,i,e,I,G,n,Q,H;return[h===1?M+1:M+x*(h-1)+1,(r==null?void 0:r.barCode)||"-",(r==null?void 0:r.registerType)==="automatic"?"سیستمی":"دستی",ku(r.createDate),`${(K=r==null?void 0:r.killHouse)==null?void 0:K.name} (${(I=(e=(i=r==null?void 0:r.killHouse)==null?void 0:i.killHouseOperator)==null?void 0:e.user)==null?void 0:I.mobile})`,r!=null&&r.exclusiveKiller?`${(G=r==null?void 0:r.exclusiveKiller)==null?void 0:G.name} (${(H=(Q=(n=r==null?void 0:r.exclusiveKiller)==null?void 0:n.killHouseOperator)==null?void 0:Q.user)==null?void 0:H.mobile})`:"-",r.buyType==="live"?"مرغ زنده":"لاشه",r.poultryName,`${r.province}/${r.city}`,u.jsx(F6,{clearanceCode:r.barClearanceCode},M),r.quantity.toLocaleString(),r.liveWeight.toLocaleString(),ku(r.date),r.numberOfCarcasses.toLocaleString(),r.weightOfCarcasses.toLocaleString(),r!=null&&r.weightLoss?(r==null?void 0:r.weightLoss)+"%":"-",u.jsx(u6,{src:r.barImage},M),u.jsx(u.Fragment,{children:N()==="KillHouse"?u.jsx(f6,{item:r,inventoryKey:r==null?void 0:r.key,updateTable:P,barState:F},r.key):u.jsx(R,{variant:"outlined",disabled:(r==null?void 0:r.killHouseVetState)!=="pending",size:"small",onClick:()=>{f(Su({title:"تایید / رد",content:u.jsx(mu,{item:r,updateTable:P})}))},children:"تایید / رد"})})]});T(j)},[v,h,x]);const y=V(j=>j.userSlice.userProfile.key);return u.jsx(C,{container:!0,justifyContent:"flex-end",mt:2,mb:2,children:u.jsx(C,{container:!0,mt:L.MEDIUM,alignItems:"end",gap:2,justifyContent:"flex-end",children:u.jsx(U,{operation:u.jsx(C,{children:u.jsx(Wu,{title:"خروجی اکسل",placement:"top",children:u.jsx(Bu,{color:"primary",onClick:()=>{S({vertical:"top",horizontal:"center",msg:"فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",severity:"success"});const j=`${J.defaults.baseURL}kill_house_free_bar_excel/?role=${N()}${D("slaughter")?`&role_key=${d==null?void 0:d.key}`:""}&key=${y}&type=live&bar_state=${F}${k?`&date1=${t}&date2=${A}`:""}`;window.location.href=j},children:u.jsx(x6,{})})})}),data:b,columns:["ردیف","کد بار","نوع بار","تاریخ خرید","خریدار","کشتارکن","محصول","فروشنده","استان/شهر","کدقرنطینه","حجم زنده","وزن زنده (کیلوگرم)","تاریخ ورود به انبار","حجم لاشه","وزن لاشه (کیلوگرم)","درصد افت","بارنامه","عملیات"],handlePageChange:z,totalRows:W,page:h,perPage:x,handlePerRowsChange:$,title:a})})})},v6=()=>{var H,eu,au,ru,su,tu,lu,nu,ou,cu,Cu,du,iu;const a=uu(),[F,s]=l.useState(0),k=(c,o)=>{s(o)},t=V(c=>c.userSlice.selectedSubUser),[,,A,g,f,S]=l.useContext(Ru);l.useEffect(()=>{const c=O(new Date).format("YYYY-MM-DD");g(c),S(c)},[]);const d=c=>{_(c.target.value)};l.useEffect(()=>{a(Zu({role_key:D("slaughter")&&(t==null?void 0:t.key)||""}))},[t==null?void 0:t.key,a]);const[v,E]=l.useState([]),[W,w]=l.useState(0),[x,p]=l.useState(10),[h,_]=l.useState(""),[b,T]=l.useState(1),[Y,z]=l.useState([]),[$,P]=l.useState(!1),[y,j]=l.useState(""),r=async c=>{a(vu());const o=await J.get(`kill_house_free_bar/?type=${F===0?"live":"carcass"}&dashboard=true&search=filter&value=${y}&role=${N()}${D("slaughter")?`&role_key=${t==null?void 0:t.key}`:""}${$?`&date1=${A}&date2=${f}`:""}&page=${c}&page_size=${x}&date_type=input`);a(m()),E(o.data.results),w(o.data.count)},M=c=>{r(c),T(c)},K=c=>{p(c),T(1)},i=()=>{T(1),r(1),e(),a(Eu({role_key:D("slaughter")&&(t==null?void 0:t.key)||""}))},e=()=>{a(h6({search:"filter",role:N(),role_key:D("slaughter")&&(t==null?void 0:t.key)||"",value:y,type:F===0?"live":"carcass",...$&&{date1:A,date2:f}})).then(c=>{Q(c.payload.data)})};l.useEffect(()=>{r(b!==0?b:1),e()},[$,A,f,x,F,y,t==null?void 0:t.key]),l.useEffect(()=>{const c=v==null?void 0:v.map((o,X)=>{var hu,gu,pu,xu,Fu,yu,Au,ju;return[b===1?X+1:X+x*(b-1)+1,(o==null?void 0:o.barCode)||"-",ku(o.createDate),`${(hu=o==null?void 0:o.killHouse)==null?void 0:hu.name} (${(xu=(pu=(gu=o==null?void 0:o.killHouse)==null?void 0:gu.killHouseOperator)==null?void 0:pu.user)==null?void 0:xu.mobile})`,o!=null&&o.exclusiveKiller?`${(Fu=o==null?void 0:o.exclusiveKiller)==null?void 0:Fu.name} (${(ju=(Au=(yu=o==null?void 0:o.exclusiveKiller)==null?void 0:yu.killHouseOperator)==null?void 0:Au.user)==null?void 0:ju.mobile})`:"-",o.buyType==="live"?"مرغ زنده":"لاشه",o.poultryName,`${o.province}/${o.city}`,o.barClearanceCode,o.numberOfCarcasses.toLocaleString(),o.weightOfCarcasses.toLocaleString(),u.jsx(u6,{src:o.barImage},X),u.jsx(u.Fragment,{children:N()==="KillHouse"?u.jsx(i6,{item:o,inventoryKey:o==null?void 0:o.key,updateTable:i,type:"carcass"},o.key):u.jsx(R,{variant:"outlined",disabled:(o==null?void 0:o.killHouseVetState)!=="pending",size:"small",onClick:()=>{a(Su({title:"تایید / رد",content:u.jsx(mu,{item:o,updateTable:i})}))},children:"تایید / رد"})})]});z(c)},[v]);const I=async c=>{c.preventDefault(),j(h)},G=V(c=>c.userSlice.userProfile.key),[n,Q]=l.useState([]);return u.jsxs(C,{container:!0,direction:"column",flexWrap:"nowrap",children:[u.jsx(C,{container:!0,justifyContent:"center",alignItems:"center",children:u.jsxs(Ju,{scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,value:F,onChange:k,children:[u.jsx(bu,{label:"زنده"}),u.jsx(bu,{label:"لاشه"})]})}),F===0&&u.jsx(C,{mt:2,container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:u.jsxs(C,{container:!0,gap:1,style:{borderStyle:"solid",borderWidth:"1px",padding:"5px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},alignItems:"center",children:[u.jsx(Qu,{icon:u.jsx(g6,{}),checkedIcon:u.jsx(p6,{}),checked:$,onChange:()=>{P(!$),r(1)},color:"primary",size:"large"}),u.jsx(C,{children:u.jsx(Z,{disabled:!$,label:"از تاریخ",id:"date",renderInput:c=>u.jsx(B,{size:"small",style:{width:"160px"},...c}),value:A,onChange:c=>{g(O(c).format("YYYY-MM-DD"))}})}),u.jsx(C,{children:u.jsx(Z,{disabled:!$,label:"تا تاریخ",id:"date",renderInput:c=>u.jsx(B,{size:"small",style:{width:"160px"},...c}),value:f,onChange:c=>{S(O(c).format("YYYY-MM-DD"))}})}),u.jsx(C,{children:u.jsxs("form",{onSubmit:I,children:[u.jsx(B,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},value:h,onChange:d}),u.jsx(R,{type:"submit",onClick:I,endIcon:u.jsx(Du,{}),children:"جستجو"})]})})]})}),u.jsxs(C,{container:!0,mt:L.MEDIUM,alignItems:"center",justifyContent:"center",gap:2,children:[u.jsx(C,{container:!0,alignItems:"center",gap:L.SMALL,justifyContent:"start",xs:12,children:u.jsx(R,{variant:"contained",onClick:()=>{a(Xu({right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,title:"ثبت اطلاعات خرید",content:u.jsx(Uu,{inventoryKey:"slaughterGetInventoryStockData?.key",selectedDate:A,updateTable:i})}))},children:"ثبت اطلاعات خرید"})}),u.jsx(C,{container:!0,mb:4,isDashboard:!0,xs:12,children:F===0?u.jsx(U,{noPagination:!0,columns:["تعداد کل بارهای زنده","حجم کل بارهای زنده","وزن کل بارهای زنده","تعداد کل بارها وارد شده به انبار","حجم کل بارهای زنده وارد شده به انبار","وزن کل بارهای زنده وارد شده به انبار","وزن لاشه بارهای وارد شده به انبار","تعداد کل بارها وارد نشده به انبار","حجم کل بارهای زنده وارد نشده به انبار","وزن کل بارهای زنده وارد نشده به انبار"],data:[[(H=n==null?void 0:n.totalBars)==null?void 0:H.toLocaleString(),(eu=n==null?void 0:n.totalBarsQuantity)==null?void 0:eu.toLocaleString(),(au=n==null?void 0:n.totalBarsLiveWeight)==null?void 0:au.toLocaleString(),(ru=n==null?void 0:n.enteredTotalBars)==null?void 0:ru.toLocaleString(),(su=n==null?void 0:n.enteredTotalBarsQuantity)==null?void 0:su.toLocaleString(),(tu=n==null?void 0:n.enteredTotalBarsLiveWeight)==null?void 0:tu.toLocaleString(),(lu=n==null?void 0:n.enteredTotalBarsWeightOfCarcasses)==null?void 0:lu.toLocaleString(),(nu=n==null?void 0:n.notEnteredTotalBars)==null?void 0:nu.toLocaleString(),(ou=n==null?void 0:n.notEnteredTotalBarsQuantity)==null?void 0:ou.toLocaleString(),(cu=n==null?void 0:n.notEnteredTotalBarsLiveWeight)==null?void 0:cu.toLocaleString()]],customColors:[{name:"وزن لاشه بارهای وارد شده به انبار",color:"green"}],title:"خلاصه اطلاعات"}):u.jsx(U,{noPagination:!0,isDashboard:!0,columns:["تعداد کل بارها","حجم لاشه","وزن لاشه"],data:[[(Cu=n==null?void 0:n.totalBars)==null?void 0:Cu.toLocaleString(),(du=n==null?void 0:n.totalBarsNumberOfCarcasses)==null?void 0:du.toLocaleString(),(iu=n==null?void 0:n.totalBarsWeightOfCarcasses)==null?void 0:iu.toLocaleString()]],title:"خلاصه اطلاعات"})}),F===0?u.jsxs(u.Fragment,{children:[u.jsx(Gu,{title:"بار زنده در انتظار ورود به انبار (خارج استان)",barState:"notentered",handleUpdate:i,searchValue:y,withDate:$,selectedDate1:A,selectedDate2:f}),u.jsx(Gu,{title:"بار زنده وارد شده به انبار (خارج استان)",barState:"entered",handleUpdate:i,searchValue:y,withDate:$,selectedDate1:A,selectedDate2:f})]}):u.jsxs(u.Fragment,{children:[u.jsx("form",{onSubmit:I,children:u.jsxs(C,{container:!0,alignItems:"center",gap:L.SMALL,children:[u.jsx(B,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},value:h,onChange:d}),u.jsx(R,{type:"submit",onClick:I,endIcon:u.jsx(Du,{}),children:"جستجو"}),u.jsx(C,{children:u.jsx(Z,{label:"از تاریخ",id:"date",renderInput:c=>u.jsx(B,{style:{width:"160px"},...c}),value:A,onChange:c=>{g(O(c).format("YYYY-MM-DD"))},disabled:!$})}),u.jsx(C,{children:u.jsx(Z,{label:"تا تاریخ",id:"date",renderInput:c=>u.jsx(B,{style:{width:"160px"},...c}),value:f,onChange:c=>{S(O(c).format("YYYY-MM-DD"))},disabled:!$})}),u.jsx(Wu,{title:"خروجی اکسل",children:u.jsx(R,{color:"success",onClick:()=>{const c=`${J.defaults.baseURL}kill_house_free_bar_excel/?role=${N()}${D("slaughter")?`&role_key=${t==null?void 0:t.key}`:""}&key=${G}${$?`&date1=${A}&date2=${f}`:""}&type=${F===0?"live":"carcass"}&search=filter&value=${y}&date_type=input`;window.location.href=c},children:u.jsx(c6,{size:32})})})]})}),u.jsx(U,{data:Y,columns:["ردیف","کد بار","تاریخ خرید","خریدار","کشتارکن","محصول","فروشنده","استان/شهر","کدقرنطینه","حجم لاشه","وزن لاشه (کیلوگرم)","بارنامه","عملیات"],handlePageChange:M,totalRows:W,page:b,perPage:x,handlePerRowsChange:K,title:"بار لاشه خرید خارج استان"})]})]})]})},k6=()=>{var f,S,d,v,E,W,w,x,p,h;const[a,F]=l.useState("0"),[s,k]=l.useState([]),t=V(_=>_.userSlice.selectedSubUser),A=(_,b)=>{F(b)},g=uu();return l.useEffect(()=>{g(s6({role_key:D("slaughter")&&(t==null?void 0:t.key)||""})).then(_=>{k(_.payload.data)})},[g,t==null?void 0:t.key]),u.jsxs(C,{container:!0,xs:12,justifyContent:"end",alignItems:"center",children:[u.jsx(C,{container:!0,width:"100%",isDashboard:!0,children:u.jsx(t6,{})}),u.jsx(C,{container:!0,xs:12,justifyContent:"center",alignItems:"center",mt:2,children:u.jsxs(Ju,{value:a,onChange:A,textColor:"secondary",indicatorColor:"secondary","aria-label":"secondary tabs example",children:[u.jsx(bu,{value:"0",label:"بارهای داخل استان"}),u.jsx(bu,{value:"1",label:"خریدهای خارج استان"})]})}),a==="0"&&u.jsx(C,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:u.jsxs(C,{container:!0,justifyContent:"start",alignItems:"center",xs:12,children:[u.jsx(U,{title:"اطلاعات کلی بارها",noPagination:!0,data:[[(f=s==null?void 0:s.totalBars)==null?void 0:f.toLocaleString(),(S=s==null?void 0:s.totalBarsQuantity)==null?void 0:S.toLocaleString(),(d=s==null?void 0:s.totalBarsWeight)==null?void 0:d.toLocaleString(),(v=s==null?void 0:s.totalEnteredBars)==null?void 0:v.toLocaleString(),(E=s==null?void 0:s.totalEnteredBarsWeight)==null?void 0:E.toLocaleString(),(W=s==null?void 0:s.totalEnteredBarsCarcasses)==null?void 0:W.toLocaleString(),(w=s==null?void 0:s.totalEnteredBarsCarcassesWeight)==null?void 0:w.toLocaleString(),(x=s==null?void 0:s.totalNotEnteredBars)==null?void 0:x.toLocaleString(),(p=s==null?void 0:s.totalNotEnteredBarsQuantity)==null?void 0:p.toLocaleString(),(h=s==null?void 0:s.totalNotEnteredKillHouseRequestsWeight)==null?void 0:h.toLocaleString()]],columns:["تعداد کل بارها","حجم کل بارها (قطعه)","وزن کل بارها (کیلوگرم)","تعداد کل بارهای وارد شده","وزن کل بارهای وارد شده","حجم کل لاشه وارد شده (قطعه)","وزن کل لاشه وارد شده (کیلوگرم)","تعداد کل بارهای وارد نشده","حجم کل بار وارد نشده (قطعه)","وزن کل بار وارد نشده (کیلوگرم)"],allColors:{color:"#f3bda3",text:"#332a3d"}}),u.jsx(C,{container:!0,mt:L.MEDIUM,mb:L.MEDIUM,children:u.jsx(Ku,{type:"notentered"})}),u.jsx(C,{container:!0,mt:L.MEDIUM,mb:L.MEDIUM,children:u.jsx(Ku,{type:"entered"})})]})}),a==="1"&&u.jsx(C,{container:!0,mt:L.MEDIUM,mb:L.MEDIUM,children:u.jsx(v6,{})})]})},N6=()=>u.jsx(C,{container:!0,alignItems:"center",justifyContent:"center",direction:"column",xs:12,children:u.jsx(k6,{})});export{N6 as S};
|