2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
import{j as r,T as Qu,an as I,B as xu,d as P,I as yu,bs as Xu,b5 as Ju,b6 as D,b as Zu}from"./mui-vendor-D_SVL-Dx.js";import{L as ku,j as S,a0 as o,h as Su,A as Uu,af as T,G as c,S as f,$ as Au,X as O,O as vu}from"./index-D80MdVQn.js";import{r as s}from"./react-vendor-CmFgShSM.js";import{a as mu,f as Fu,u as ue}from"./redux-vendor-CfkcHgWN.js";import{d as ju}from"./Delete-CIwpNviU.js";import{R as ee,a as re}from"./index.esm-C1-dCPnj.js";import{P as te}from"./PageTable-B0hPU2Kw.js";import{S as ae}from"./SimpleTable-tm4uaKUf.js";import{V as bu,S as le}from"./SlaughterEnterNoneReciept-By4AAznT.js";import{V as oe}from"./VetFarmEditTrafficCode-C5Hod_My.js";import{V as ne}from"./VetFarmDeletedBars-D6uptIlB.js";import{P as se}from"./ProvinceBarDifference-BXZCyzMP.js";import{C as ce}from"./ChechClearanceCode-C2pygfym.js";import{R as Ce}from"./ResponsiveTable-bUYl0qDM.js";import{c as x}from"./checkPathStartsWith-DedybDvj.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./index-Eu1ghc4Y.js";import"./Close-J1gH5PMD.js";import"./Search-TgPAjvS8.js";import"./Tune-BBzxV8DK.js";import"./ReceiptLong-BODgrrI9.js";import"./ShowImage-DxnwAx1k.js";import"./Download-CJYPO5Fu.js";import"./aviculture-get-hatching-data-BHS_PijM.js";import"./toBase64-UDzdrM-n.js";import"./PublishedWithChanges-Dz7dEVRv.js";import"./resizeImage-Csf2MO3w.js";import"./Pageview-CHY_bSEN.js";import"./AddCircleOutline-5cdNoXZy.js";import"./FilterAlt-DZsHj-WQ.js";const $u=mu("SLAUGHTER_BAR_DASHBOARD_SERVICE",async(C,{dispatch:y})=>{y(ku());const{data:p,status:R}=await S.get("dashboarad_bar_for_kill_house",{params:{role:o(),date1:C.selectedDate1,date2:C.selectedDate2,filter:"search",value:C.textValue,role_key:C.role_key||""}});return y(Su()),{data:p,status:R}}),de=()=>{var W,G,K,z,Q,X,J,Z,U,m;const[,,C,y,p,R]=s.useContext(Uu);s.useEffect(()=>{const u=T(new Date).format("YYYY-MM-DD");y(u),R(u)},[]);const Ru=Fu(u=>u.userSlice.userProfile.key),[A,Du]=s.useState(0),Ou=(u,e)=>{Du(e)},h=ue(),[Eu,Mu]=s.useState([]),[i,E]=s.useState([]),[_u,w]=s.useState(!1),[q,M]=s.useState(0),[_,Lu]=s.useState(10),[a,V]=s.useState([]),l=Fu(u=>u.userSlice.selectedSubUser),g=async u=>{w(!0);const e=await S.get(`kill_house_request_bar_management/?check&search=filter&value=${v}&role=${o()}${x("slaughter")?`&role_key=${l==null?void 0:l.key}`:""}&date1=${C}&date2=${p}&page=${u}&page_size=${_}`);E(e.data.results),M(e.data.count),w(!1),h(Su())},[Iu,Pu]=s.useState(0),Tu=(u,e)=>{h(ku()),Pu(e),g(e+1)},qu=u=>{g(u)},Vu=async(u,e)=>{w(!0);const t=await S.get(`kill_house_request_bar_management/?check&search=filter&value=${v}&role=${o()}${x("slaughter")?`&role_key=${l==null?void 0:l.key}`:""}&date1=${C}&date2=${p}&page=${e}&page_size=${u}`);E(t.data.results),M(t.data.count),Lu(u),w(!1)};s.useEffect(()=>{g(1)},[]);const B=!(o()==="ProvinceOperator"||o()==="CityVet"),Y=[{name:"کدبار",selector:u=>u.barCode,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"100px"},{name:"خریدار",selector:u=>{var e,t,n,d;return`${(e=u.killhouseUser)==null?void 0:e.name} (${(d=(n=(t=u.killhouseUser)==null?void 0:t.killHouseOperator)==null?void 0:n.user)==null?void 0:d.mobile})`},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"کشتارکن اختصاصی",selector:u=>{var e,t,n,d;return u!=null&&u.killer?`${(e=u==null?void 0:u.killer)==null?void 0:e.name} (${(d=(n=(t=u==null?void 0:u.killer)==null?void 0:t.killHouseOperator)==null?void 0:n.user)==null?void 0:d.mobile})`:"-"},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"ماشین",selector:u=>`${u.addCar.driver.typeCar} ${u.addCar.driver.pelak}`,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"100px"},{name:"راننده",selector:u=>`${u.addCar.driver.driverName} (${u.addCar.driver.driverMobile})`,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"کد بهداشتی حمل و نقل",selector:u=>u==null?void 0:u.trafficCode,sortable:!1,wrap:!0,allowOverflow:!0,center:!0},{name:"قیمت مرغ زندهی بار",selector:u=>{var e;return((e=u==null?void 0:u.amount)==null?void 0:e.toLocaleString())+" ﷼"},sortable:!1,wrap:!0,allowOverflow:!0,center:!0},{name:"نژاد",selector:u=>u.poultryRequest.chickenBreed,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"50px"},{name:"تعداد اولیه",selector:u=>{var e;return(e=u.quantity)==null?void 0:e.toLocaleString()},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"50px"},{name:"وزن اولیه بار (کیلوگرم)",selector:u=>{var e,t;return(t=(e=u==null?void 0:u.weightInfo)==null?void 0:e.weight)==null?void 0:t.toLocaleString()},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"70px"},{name:"میانگین وزن اولیه (کیلوگرم)",selector:u=>{var e,t;return(t=(e=u==null?void 0:u.weightInfo)==null?void 0:e.indexWeight)==null?void 0:t.toLocaleString()},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"70px"},{name:"قیمت مرغدار",selector:u=>{var e,t;return((t=(e=u==null?void 0:u.poultryRequest)==null?void 0:e.amount)==null?void 0:t.toLocaleString())+" ﷼"},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"قیمت کشتارگاه",selector:u=>{var e,t;return((t=(e=u==null?void 0:u.weightInfo)==null?void 0:e.killHousePrice)==null?void 0:t.toLocaleString())+" ﷼"},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"مرغدار",selector:u=>{var e,t,n,d;return`${(t=(e=u.poultryRequest)==null?void 0:e.poultry)==null?void 0:t.unitName} (${(d=(n=u.poultryRequest.poultry)==null?void 0:n.user)==null?void 0:d.mobile})`},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"دامپزشک فارم",selector:u=>{var e,t,n,d,F,j,b,$,k;return(n=(t=(e=u==null?void 0:u.vetFarm)==null?void 0:e.vet)==null?void 0:t.user)!=null&&n.fullname?((j=(F=(d=u==null?void 0:u.vetFarm)==null?void 0:d.vet)==null?void 0:F.user)==null?void 0:j.fullname)+`(${(k=($=(b=u==null?void 0:u.vetFarm)==null?void 0:b.vet)==null?void 0:$.user)==null?void 0:k.mobile})`:"فاقد دامپزشک"},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"100px"},{name:"کدرهگیری سامانه قرنطینه",selector:u=>{var e,t,n;return r.jsx(r.Fragment,{children:o()==="VetFarm"||o()==="ProvinceOperator"||o()==="CityVet"||o()==="VetSupervisor"?r.jsx(r.Fragment,{children:(e=u==null?void 0:u.registerar)!=null&&e.date?`${O(new Date((t=u==null?void 0:u.registerar)==null?void 0:t.date),"yyyy/MM/dd")} ${(n=u==null?void 0:u.registerar)==null?void 0:n.name}`:""}):u!=null&&u.clearanceCode?(u==null?void 0:u.clearanceCode)&&r.jsx(ce,{clearanceCode:u==null?void 0:u.clearanceCode}):"-"})},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"200px"},{name:"محل کشتار",selector:u=>`${u.killPlace}`,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"شهر",selector:u=>u.poultryRequest.poultry.address.city.name,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"تاریخ کشتار",selector:u=>u!=null&&u.poultryRequest.sendDate?O(new Date(u==null?void 0:u.poultryRequest.sendDate),"yyyy/MM/dd"):"-",sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"کدسفارش کشتار",selector:u=>u==null?void 0:u.poultryRequest.orderCode,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"70px"},{name:"تعداد نهایی",selector:u=>{var e;return(e=u.acceptedRealQuantity)==null?void 0:e.toLocaleString()},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"50px"},{name:"وزن نهایی بار (کیلوگرم)",selector:u=>{var e;return(e=u==null?void 0:u.acceptedRealWeight)==null?void 0:e.toLocaleString()},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"70px"},{name:"میانگین وزن نهایی (کیلوگرم)",selector:u=>{var e,t;return(t=(e=u==null?void 0:u.weightInfo)==null?void 0:e.finalIndexWeight)==null?void 0:t.toLocaleString()},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"70px"},{name:"وضعیت",selector:u=>{let e="";return u.vetState==="accepted"?e="تایید تخلیه":u.vetState==="pending"&&(e="در انتظار تخلیه"),e},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"90px"},{name:"عملیات",selector:u=>r.jsx(c,{children:r.jsx(P,{title:"لغو بار",children:r.jsx(yu,{disabled:B,color:"error",onClick:()=>{h(vu({title:"لغو بار",content:r.jsx(bu,{updateTable:L,killHouseRequestKey:u.key})}))},children:r.jsx(ju,{})})})},u.barCode),sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"70px"}],Bu=u=>{y(u)},Yu=u=>{R(u)};s.useEffect(()=>{g(1)},[C,p,_,l==null?void 0:l.key]);const[v,Hu]=s.useState(""),Nu=u=>{Hu(u.target.value)};s.useEffect(()=>{g(1),h($u({selectedDate1:C,selectedDate2:p,textValue:v,role_key:x("slaughter")&&(l==null?void 0:l.key)||""})).then(u=>{V(u.payload.data)})},[h,C,p,l==null?void 0:l.key]);const H=async u=>{u.preventDefault(),w(!0);try{const e=await S.get(`kill_house_request_bar_management/?check&role=${o()}${x("slaughter")?`&role_key=${l==null?void 0:l.key}`:""}&search=filter&value=${v}&date1=${C}&date2=${p}&page=1&page_size=${_}`);E(e.data.results),M(e.data.count),h($u({selectedDate1:C,selectedDate2:p,textValue:v,role_key:x("slaughter")&&(l==null?void 0:l.key)||""})).then(t=>{V(t.payload.data)})}catch(e){console.error("Error fetching data:",e)}finally{w(!1)}},L=()=>{g(1)},N=r.jsx(c,{container:!0,alignItems:"start",justifyContent:"space-between",gap:2,paddingTop:2,mb:1,children:r.jsxs(c,{container:!0,alignItems:"center",gap:f.SMALL,children:[r.jsx(Qu,{children:"مدیریت بارها"}),r.jsx(c,{style:{width:"150px"},children:r.jsx(Au,{label:"از تاریخ",id:"date",renderInput:u=>r.jsx(I,{...u}),value:C,onChange:u=>{Bu(T(u).format("YYYY-MM-DD"))}})}),r.jsx(c,{style:{width:"150px"},children:r.jsx(Au,{label:"تا تاریخ",id:"date",renderInput:u=>r.jsx(I,{...u}),value:p,onChange:u=>{Yu(T(u).format("YYYY-MM-DD"))}})}),r.jsxs("form",{onSubmit:H,children:[r.jsx(I,{autoComplete:"off",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:Nu}),r.jsx(xu,{type:"submit",onClick:H,endIcon:r.jsx(ee,{}),children:"جستجو"})]}),r.jsx(P,{title:"خروجی اکسل",children:r.jsx("a",{href:`${S.defaults.baseURL}bar_excel/?start=${C}&end=${p}&key=${Ru}&role=${o()}${x("slaughter")?`&role_key=${l==null?void 0:l.key}`:""}`,rel:"noreferrer",children:r.jsx(xu,{disabled:!((G=(W=i[0])==null?void 0:W.killhouseUser)!=null&&G.key),color:"success",children:r.jsx(re,{size:32})})})})]})}),Wu=u=>{let e="";return u.vetState==="accepted"?e="تایید تخلیه":u.vetState==="pending"&&(e="در انتظار تخلیه"),e},Gu=Y.map(u=>u.name),Ku=window.innerWidth<=600;s.useEffect(()=>{const u=i==null?void 0:i.map((e,t)=>{var n,d,F,j,b,$,k,uu,eu,ru,tu,au,lu,ou,nu,su,cu,Cu,du,pu,fu,hu,iu,wu,gu;return[e.barCode,`${(n=e.killhouseUser)==null?void 0:n.name} (${(j=(F=(d=e.killhouseUser)==null?void 0:d.killHouseOperator)==null?void 0:F.user)==null?void 0:j.mobile})`,`${e.addCar.driver.typeCar} ${e.addCar.driver.pelak}`,`${e.addCar.driver.driverName} (${e.addCar.driver.driverMobile})`,r.jsx(oe,{updateTable:L,killHouseRequestKey:e.key,trafficCode:e==null?void 0:e.trafficCode,isEditable:o()==="VetFarm"||o()==="ProvinceOperator"||o()==="KillHouseVet"||o()==="KillHouse"||o()==="CityVet"||o()==="VetSupervisor"},t),e.poultryRequest.chickenBreed,(b=e.quantity)==null?void 0:b.toLocaleString(),(k=($=e==null?void 0:e.weightInfo)==null?void 0:$.weight)==null?void 0:k.toLocaleString(),(eu=(uu=e==null?void 0:e.weightInfo)==null?void 0:uu.indexWeight)==null?void 0:eu.toLocaleString(),`${(tu=(ru=e.poultryRequest)==null?void 0:ru.poultry)==null?void 0:tu.unitName} (${(lu=(au=e.poultryRequest.poultry)==null?void 0:au.user)==null?void 0:lu.mobile})`,(su=(nu=(ou=e==null?void 0:e.vetFarm)==null?void 0:ou.vet)==null?void 0:nu.user)!=null&&su.fullname?((du=(Cu=(cu=e==null?void 0:e.vetFarm)==null?void 0:cu.vet)==null?void 0:Cu.user)==null?void 0:du.fullname)+`(${(hu=(fu=(pu=e==null?void 0:e.vetFarm)==null?void 0:pu.vet)==null?void 0:fu.user)==null?void 0:hu.mobile})`:"فاقد دامپزشک",r.jsx(r.Fragment,{children:o()==="VetFarm"||o()==="ProvinceOperator"||o()==="CityVet"||o()==="VetSupervisor"?r.jsx(r.Fragment,{children:(iu=e==null?void 0:e.registerar)!=null&&iu.date?`${O(new Date((wu=e==null?void 0:e.registerar)==null?void 0:wu.date),"yyyy/MM/dd")} ${(gu=e==null?void 0:e.registerar)==null?void 0:gu.name}`:""}):e!=null&&e.clearanceCode?e==null?void 0:e.clearanceCode:"-"}),`${e.killPlace}`,e.poultryRequest.poultry.address.city.name,e!=null&&e.poultryRequest.sendDate?O(new Date(e==null?void 0:e.poultryRequest.sendDate),"yyyy/MM/dd"):"-",e==null?void 0:e.poultryRequest.orderCode,Wu(e),r.jsx(c,{children:r.jsx(P,{title:"لغو بار",children:r.jsx(yu,{disabled:B,color:"error",onClick:()=>{h(vu({title:"لغو بار",content:r.jsx(bu,{updateTable:L,killHouseRequestKey:e.key})}))},children:r.jsx(ju,{})})})},e.barCode)]});Mu(u)},[i]);const zu=r.jsxs(Ju,{scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,value:A,onChange:Ou,children:[r.jsx(D,{label:"اطلاعات بارها",value:0}),r.jsx(D,{label:"بارهای حذف شده",value:1}),r.jsx(D,{label:"اختلاف کشتار",value:2}),r.jsx(D,{label:"عدم وصول",value:3})]});return r.jsxs(c,{container:!0,direction:"column",flexWrap:"nowrap",mt:f.SMALL,children:[r.jsx(c,{container:!0,justifyContent:"center",mb:f.MEDIUM,children:zu}),A===0&&r.jsxs(c,{container:!0,mt:f.MEDIUM,alignItems:"center",justifyContent:"center",children:[r.jsx(c,{container:!0,mt:2,mb:4,isDashboard:!0,xs:12,children:r.jsx(Ce,{noPagination:!0,isDashboard:!0,columns:["تعداد بار","تعداداولیه بار","وزن اولیه بار","میانگین وزن اولیه","تعداد بار های دارای کد قرنطینه","تعداد نهایی بار","وزن نهایی بار","میانگین وزن نهایی "],data:[[(K=a==null?void 0:a.count)==null?void 0:K.toLocaleString(),(z=a==null?void 0:a.firstQuantity)==null?void 0:z.toLocaleString(),(Q=a==null?void 0:a.firstWeight)==null?void 0:Q.toLocaleString(),(X=a==null?void 0:a.firstIndexWeight)==null?void 0:X.toLocaleString(),(J=a==null?void 0:a.clearanceCodeCount)==null?void 0:J.toLocaleString(),(Z=a==null?void 0:a.acceptedRealQuantity)==null?void 0:Z.toLocaleString(),(U=a==null?void 0:a.acceptedRealWeight)==null?void 0:U.toLocaleString(),(m=a==null?void 0:a.finalIndexWeight)==null?void 0:m.toLocaleString()]],title:"خلاصه اطلاعات"})}),Ku?r.jsxs(c,{container:!0,justifyContent:"center",gap:f.SMALL,children:[N,r.jsx(ae,{columns:Gu,data:Eu}),r.jsx(Xu,{count:Math.ceil(q/10),page:Iu+1,variant:"outlined",onChange:(u,e)=>{Tu(u,e-1)}})]}):r.jsx(te,{title:N,columns:Y,data:i,progressPending:_u,pagination:!0,paginationServer:!0,paginationTotalRows:q,onChangeRowsPerPage:Vu,onChangePage:qu})]}),A===1&&r.jsx(c,{mt:f.MEDIUM,children:r.jsx(ne,{})}),A===2&&r.jsx(c,{mt:f.MEDIUM,children:r.jsx(se,{})}),A===3&&r.jsx(c,{mt:f.MEDIUM,children:r.jsx(le,{})})]})},He=()=>r.jsx(r.Fragment,{children:r.jsx(Zu,{display:"flex",justifyContent:"center",children:r.jsx(c,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:r.jsx(de,{})})})});export{He as default};
|