2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{j as t,T as x,ak as W,B as w,d as S,ag as _,av as L,aw as E,ax as R,b as G}from"./mui-vendor-CkIVaoQP.js";import{r as s,f as V}from"./react-vendor-CmFgShSM.js";import{A as Y,j as a,X as c,G as l,S as f,_ as A,V as P,lm as X,ln as J}from"./index-Cr86_nOs.js";import{f as Z}from"./redux-vendor-B7uoacJt.js";import{R as uu,a as T}from"./index.esm-Bu7XMDZU.js";import{P as eu}from"./PageTable-whKVbv5q.js";import{a as tu}from"./ChainBarManagement-BrSz4Hwe.js";import"./iconBase-BEJYyZsk.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./ResponsiveTable-Dua7tTwQ.js";import"./FilterAlt-RwhTl5ac.js";import"./Edit-DVocKJob.js";import"./Settings-BSDlStEO.js";import"./Tune-m0V6JHJm.js";import"./Delete-CTUmuli-.js";import"./CarPelak-Ddy5J5I5.js";import"./Pageview-Dg_y1yOR.js";import"./AddCircleOutline-CCVNHzAe.js";const ru=()=>{const[o,v]=s.useState(0),[C,F]=s.useState(0),[k,p]=s.useState([]),[M,n]=s.useState(!1),[N,h]=s.useState(0),[g,m]=s.useState(10),[d,z]=s.useState(""),I=Z(u=>u.userSlice.userProfile.key),K=u=>{z(u.target.value)};s.useEffect(()=>{$(1)},[]);const[b]=s.useContext(Y),y=u=>{let e="";return e=u.quantity-u.losses-u.leftOver,e},$=async(u,e)=>{n(!0);let r;e?r=await a.get(`poultry_hatching?search=filter&value=${e}&role=${c()}&page=${u}&page_size=${g}&chain=true`):o&&C?r=await a.get(`poultry_hatching?role=${c()}&age1=${o}&age2=${C}&page=${u}&page_size=${g}&chain=true`):r=await a.get(`poultry_hatching/?role=${c()}&page=${u}&page_size=${g}&chain=true`),p(r.data.results),h(r.data.count),n(!1)},D=u=>{$(u,d)},H=async(u,e)=>{n(!0);let r;d?r=await a.get(`poultry_hatching?search=filter&value=${d}&page=${e}&page_size=${u}&search=filter&value=${d}&chain=true`):o&&C?r=await a.get(`poultry_hatching?role=${c()}&age1=${o}&age2=${C}&page=${e}&page_size=${g}&chain=true`):r=await a.get(`poultry_hatching/?role=${c()}&page=${e}&page_size=${u}&chain=true`),p(r.data.results),h(r.data.count),m(u),n(!1)},j=async u=>{u.preventDefault(),n(!0);try{const e=await a.get(`poultry_hatching/?role=${c()}&search=filter&value=${d}&chain=true`);p(e.data.results),h(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{n(!1)}},B=async u=>{u.preventDefault(),v(null),F(null),n(!0);try{const e=await a.get(`poultry_hatching/?role=${c()}&chain=true&search=filter&value=`);p(e.data.results),h(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{n(!1)}},Q=async u=>{u.preventDefault(),n(!0);try{const e=await a.get(`poultry_hatching?role=${c()}&age1=${o}&age2=${C}&chain=true`);p(e.data.results),h(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{n(!1)}};let U=[{name:"ردیف",selector:(u,e)=>e+1,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"30px"},{name:"شرکت زنجیره",selector:(u,e)=>{var r,i;return`${(r=u==null?void 0:u.chainCompany)==null?void 0:r.name} (${(i=u==null?void 0:u.chainCompany)==null?void 0:i.user.mobile})`},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وضعیت",selector:(u,e)=>t.jsx(x,{variant:"body2",color:u.violation?"error":"black",children:u.violation?"متخلف":"عادی"}),sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"60px"},{name:"نام فارم",selector:u=>u.poultry.unitName,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"90px"},{name:"مرغدار",selector:u=>`${u.poultry.userprofile.fullName} (${u.poultry.userprofile.mobile})`,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"شهر/تعاونی",selector:u=>{var e,r,i;return`${(e=u==null?void 0:u.poultry)==null?void 0:e.address.city.name}/${(r=u==null?void 0:u.poultry)!=null&&r.cityOperator?(i=u==null?void 0:u.poultry)==null?void 0:i.cityOperator:"بدون تعاونی"}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"دامپزشک فارم",selector:u=>{var e,r,i;return(e=u==null?void 0:u.vetFarm)!=null&&e.vetFarmMobile?`${(r=u==null?void 0:u.vetFarm)==null?void 0:r.vetFarmFullName} (${(i=u==null?void 0:u.vetFarm)==null?void 0:i.vetFarmMobile})`:"-"},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"سالن",selector:u=>u.hall,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"60px"},{name:"دوره جوجه ریزی",selector:u=>u.period,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"تاریخ ثبت جوجه ریزی",selector:u=>A(u==null?void 0:u.createDate),sortable:!1,wrap:!1,allowOverflow:!0,center:!0,width:"100px"},{name:"تاریخ جوجه ریزی",selector:u=>A(u==null?void 0:u.date),sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"100px"},{name:"نژاد",selector:u=>u.chickenBreed,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"سن",selector:u=>u.age,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"60px"},{name:"تعداد جوجه ریزی",selector:u=>{var e;return(e=u==null?void 0:u.quantity)==null?void 0:e.toLocaleString()},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"تلفات دوره (قطعه)",selector:u=>`${u.losses} (%${(u.losses*100/u.quantity).toFixed(0)})`,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"تعداد کل تعهد دولتی (قطعه)",selector:u=>{var e;return`${(e=u==null?void 0:u.totalCommitmentQuantity)==null?void 0:e.toLocaleString()}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"تعداد کشتار شده دولتی (قطعه)",selector:u=>{var e;return`${(e=u==null?void 0:u.governmentalQuantity)==null?void 0:e.toLocaleString()}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وزن کشتار شده دولتی",selector:u=>{var e;return`${(e=u==null?void 0:u.governmentalKilledQuantity)==null?void 0:e.toLocaleString()}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"تعداد کشتار شده آزاد (قطعه)",selector:u=>{var e;return`${(e=u==null?void 0:u.freeQuantity)==null?void 0:e.toLocaleString()}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وزن کشتار شده آزاد ",selector:u=>{var e;return`${(e=u==null?void 0:u.freeKilledQuantity)==null?void 0:e.toLocaleString()}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"حجم خارج از استان",selector:u=>{var e;return`${(e=u==null?void 0:u.outProvinceKilledQuantity)==null?void 0:e.toLocaleString()}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وزن خارج از استان",selector:u=>{var e;return`${(e=u==null?void 0:u.outProvinceKilledWeight)==null?void 0:e.toLocaleString()}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"کشتار شده (قطعه)",selector:u=>{var e;return((e=y(u))==null?void 0:e.toLocaleString())+` (%${(y(u)*100/u.quantity).toFixed(0)})`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"90px"},{name:"مانده در سالن (قطعه)",selector:u=>{var e;return`${(e=u==null?void 0:u.leftOver)==null?void 0:e.toLocaleString()} (%${(u.leftOver*100/u.quantity).toFixed(0)})`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"90px"},{name:"وزن تعهد دولتی",selector:u=>{var e;return((e=u==null?void 0:u.totalCommitment)==null?void 0:e.toLocaleString())+" کیلوگرم "},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وزن کشتار دولتی",selector:u=>{var e;return((e=u==null?void 0:u.governmentalKilledQuantity)==null?void 0:e.toLocaleString())+" کیلوگرم "},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وزن کشتار آزاد",selector:u=>{var e;return((e=u==null?void 0:u.freeKilledQuantity)==null?void 0:e.toLocaleString())+" کیلوگرم "},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"میانگین وزن کشتار",selector:u=>{var e;return((e=u==null?void 0:u.totalAverageKilledWeight)==null?void 0:e.toLocaleString())+" کیلوگرم "},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وزن کل کشتار شده",selector:u=>{var e;return((e=u==null?void 0:u.totalKilledWeight)==null?void 0:e.toLocaleString())+" کیلوگرم "},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"کشتار فعال",selector:u=>{var e;return(e=u==null?void 0:u.activeKill)!=null&&e.activeKill?"دارد":"ندارد"},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"تعداد درخواست کشتار",selector:u=>{var e;return(e=u==null?void 0:u.activeKill)!=null&&e.countOfRequest?u.activeKill.countOfRequest:"-"},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"آخرین تغییر",selector:u=>{const e=u.lastChange&&u.lastChange.date&&`${u.lastChange.fullName} (${P(u.lastChange.role)}) در تاریخ ${A(u.lastChange.date)}`;return u.lastChange?e:"-"},sortable:!0,wrap:!0,allowOverflow:!0,center:!0},{name:"سازنده جوجه ریزی",selector:u=>{const e=u.latestHatchingChange&&u.latestHatchingChange.date&&`${u.latestHatchingChange.fullName} (${P(u.latestHatchingChange.role)}) در تاریخ ${A(u.latestHatchingChange.date)}`;return u.latestHatchingChange?e:"-"},sortable:!0,wrap:!0,allowOverflow:!0,center:!0}];const O=Array.from({length:75},(u,e)=>e+1),q=t.jsxs(l,{container:!0,alignItems:"center",justifyContent:"space-between",gap:2,paddingTop:2,mb:1,width:"100%",mt:2,children:[t.jsxs(l,{container:!0,alignItems:"center",gap:f.SMALL,style:{padding:"10px",border:"1px solid #bbb",borderRadius:"10px"},children:[t.jsx(x,{children:"زنجیره های زیرمجموعه"}),t.jsxs("form",{onSubmit:j,children:[t.jsx(W,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:K}),t.jsx(w,{type:"submit",onClick:j,endIcon:t.jsx(uu,{}),children:"جستجو"}),t.jsx(S,{title:"خروجی اکسل",children:t.jsx(w,{color:"success",onClick:()=>{b({vertical:"top",horizontal:"center",msg:"فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",severity:"success"});const u=`${a.defaults.baseURL}0/hatching_excel/?role=${c()}&key=${I}&chain=true`;window.location.href=u},children:t.jsx(T,{size:32})})})]})]}),t.jsxs(l,{container:!0,alignItems:"center",gap:f.SMALL,style:{padding:"10px",border:"1px solid #bbb",borderRadius:"10px"},children:[t.jsx(l,{children:t.jsx(x,{variant:"caption",children:"جستجو براساس سن:"})}),t.jsx(l,{style:{width:"80px"},children:t.jsxs(_,{fullWidth:!0,children:[t.jsx(L,{id:"demo-simple-select-label",children:"از سن"}),t.jsx(E,{MenuProps:{PaperProps:{style:{maxHeight:200,width:80}}},labelId:"demo-simple-select-label",id:"demo-simple-select",value:o,label:"از سن",size:"small",onChange:u=>v(u.target.value),children:O.map(u=>t.jsx(R,{value:u,children:u},u))})]})}),t.jsx(l,{style:{width:"80px"},children:t.jsxs(_,{fullWidth:!0,children:[t.jsx(L,{id:"demo-simple-select-label",children:"تا سن"}),t.jsx(E,{MenuProps:{PaperProps:{style:{maxHeight:200,width:80}}},labelId:"demo-simple-select-label",id:"demo-simple-select",value:C,label:"تا سن",size:"small",onChange:u=>F(u.target.value),children:O.map(u=>t.jsx(R,{value:u,children:u},u))})]})}),t.jsx(w,{onClick:Q,children:"جستجو"}),t.jsx(S,{title:"خروجی اکسل",children:t.jsx(w,{color:"success",onClick:()=>{b({vertical:"top",horizontal:"center",msg:"فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.",severity:"success"});const u=`${a.defaults.baseURL}hatching_report_from_age_excel/?age1=${o}&age2=${C}&chain=true`;window.location.href=u},children:t.jsx(T,{size:32})})})]}),t.jsx(w,{onClick:B,color:"error",children:"حذف فیلتر"})]});return t.jsx(l,{container:!0,xs:12,children:t.jsx(l,{container:!0,xs:12,justifyContent:"center",mt:2,children:t.jsx(eu,{title:q,columns:U,data:k,progressPending:M,pagination:!0,paginationServer:!0,paginationTotalRows:N,onChangeRowsPerPage:H,onChangePage:D})})})},bu=()=>{const{pathname:o}=V();return t.jsx(t.Fragment,{children:t.jsx(G,{display:"flex",justifyContent:"center",children:t.jsx(l,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,my:f.MEDIUM,children:t.jsx(l,{container:!0,justifyContent:"space-between",gap:f.SMALL,children:t.jsxs(l,{xs:12,children:[o===X&&t.jsx(ru,{}),o===J&&t.jsx(tu,{})]})})})})})};export{bu as default};
|