2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{j as e,B as h,ao as z,an as _,aj as eu,ay as tu,az as ru,aA as j,aX as au,d as su,I as nu,b as ou,aM as lu}from"./mui-vendor-D_SVL-Dx.js";import{G as s,S as c,mc as B,md as M,me as m,mf as q,mg as w,mh as L,j as Q,A as J,u as K,c as X,af as P,b as O,L as k,h as U,W as H,$ as Cu,jR as Y,p as D,v as cu,a6 as iu,mi as du}from"./index-D80MdVQn.js";import{A as hu}from"./AvicultureNewRequest-CaXMyPWQ.js";import{T as Au,A as pu,a as xu}from"./reactour.esm-Cls5e3_6.js";import{a as Z,u as G,f as ju}from"./redux-vendor-CfkcHgWN.js";import{f as uu,r as o}from"./react-vendor-CmFgShSM.js";import{A as Fu}from"./AvicultureArchivedRequests-Dfl8V9Dw.js";import{R as fu,a as vu}from"./RequestsAwaitingInspections-BVdLAhwd.js";import{N as F}from"./NavLink-Uri4Pz8C.js";import{d as gu}from"./Delete-CIwpNviU.js";import{a as Eu}from"./CityNewKillRequest-N5kvrMlL.js";import{N as yu}from"./NumberFormatCustom-BXcOcGV4.js";import{A as V}from"./AdvancedTable-DF_gMS-x.js";import"./aviculture-get-hatching-data-BHS_PijM.js";import"./Add-CiyqkOpq.js";import"./DialogAlert-CML4Ua46.js";import"./Done-CKhyNcU8.js";import"./aviculture-get-unions-C7MHhZje.js";import"./SelectCheck-DMZOQn3F.js";import"./ResponsiveTable-bUYl0qDM.js";import"./FilterAlt-DZsHj-WQ.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./Plagiarism-BibpZV6P.js";import"./chart-vendor-sE2SUVPW.js";import"./Search-TgPAjvS8.js";import"./SimpleTable-tm4uaKUf.js";import"./index-Eu1ghc4Y.js";import"./Close-J1gH5PMD.js";import"./province-get-sell-for-freezing-status-q8iW-gS-.js";import"./province-policy-market-daily-limitation---nGjnVx.js";import"./isValidIndexWeight-C_ik-uYa.js";import"./LabelField-BYhJrYEE.js";const Du=()=>{const{pathname:t}=uu();return e.jsxs(s,{container:!0,gap:c.SMALL,p:c.SMALL,direction:{xs:"column",md:"row"},children:[e.jsx(F,{to:B,active:t===B?"true":null,children:e.jsx(h,{variant:"text",color:"inherit",children:"ثبت اطلاعات جوجه ریزی"})}),e.jsx(F,{to:M,active:t===M?"true":null,children:e.jsx(h,{variant:"text",color:"inherit",children:"ثبت درخواست کشتار"})}),e.jsx(F,{to:m,active:t===m?"true":null,children:e.jsx(h,{variant:"text",color:"inherit",children:"در انتظار پرداخت"})}),e.jsx(F,{to:q,active:t===q?"true":null,children:e.jsx(h,{variant:"text",color:"inherit",children:"در انتظار بازرسی"})}),e.jsx(F,{to:w,active:t===w?"true":null,children:e.jsx(h,{variant:"text",color:"inherit",children:"سفارشات رد شده"})}),e.jsx(F,{to:L,active:t===L?"true":null,children:e.jsx(h,{variant:"text",color:"inherit",children:"سفارشات بایگانی شده"})})]})},bu=Z("VET_FARM_NEW_FARM",async t=>{const{data:l,status:n}=await Q.post("poultry_hatching/",t);return{data:l,status:n}}),Tu=()=>{const t=G(),[l]=o.useContext(J),[n,b]=o.useState(""),[E,T]=o.useState(""),[S,N]=o.useState(!0),[y,R]=o.useState(1),[C,f]=o.useState(null),r=K({initialValues:{quantity:"",hatchingDate:P(Date()).format("YYYY-MM-DD hh:mm:ss"),race:"آرین"},validationSchema:X({quantity:O().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});return o.useEffect(()=>{r.validateForm(),t(k()),t(Eu()).then(a=>{T(a.payload.data),t(U())})},[]),o.useEffect(()=>{n&&(y===0?(l({vertical:"top",horizontal:"center",msg:"ابتدا برای این مرغداری جوجه ریزی ثبت کنید.",severity:"error"}),t(H({right:!1,bottom:!1,content:null}))):N(!1))},[n]),e.jsxs(s,{container:!0,gap:c.SMALL,direction:"column",flex:"1",height:"100%",justifyContent:"space-between",children:[e.jsxs(s,{container:!0,direction:"column",gap:c.SMALL,children:[e.jsx(s,{children:e.jsx(z,{disablePortal:!0,id:"hatching",options:E?E.map(a=>({id:a.key,label:a.unitName,halls:a.numberOfHalls})):[],onChange:(a,u)=>{b(u.id),R(u.halls)},renderInput:a=>e.jsx(_,{...a,label:"محل پرورش"})})}),e.jsx(s,{children:e.jsx(z,{disabled:S,disablePortal:!0,options:[...Array(y)].map((a,u)=>({label:"سالن شماره "+(u+1),id:u})),onChange:(a,u)=>{f(u.id+1)},renderInput:a=>e.jsx(_,{...a,label:"سالن را انتخاب کنید"})})}),e.jsx(yu,{allowLeadingZeros:!0,thousandSeparator:",",id:"quantity",value:r.values.quantity,error:r.touched.quantity?!!r.errors.quantity:null,onChange:r.handleChange,onBlur:r.handleBlur,helperText:r.touched.quantity&&r.errors.quantity?r.errors.quantity:null,label:"تعداد",variant:"outlined"}),e.jsx(Cu,{label:"تاریخ جوجه ریزی",id:"hatchingDate",renderInput:a=>e.jsx(_,{...a}),value:r.values.hatchingDate,error:r.touched.hatchingDate?!!r.errors.hatchingDate:null,onChange:a=>{r.setFieldValue("hatchingDate",P(a).format("YYYY-MM-DD hh:mm:ss"))},onBlur:r.handleBlur,helperText:r.touched.hatchingDate&&r.errors.hatchingDate?r.errors.hatchingDate:null}),e.jsxs(eu,{fullWidth:!0,children:[e.jsx(tu,{id:"demo-simple-select-label",children:"نژاد مرغ"}),e.jsxs(ru,{labelId:"demo-simple-select-label",id:"race",label:"نژاد مرغ",value:r.values.race,error:r.touched.race?!!r.errors.race:null,onChange:a=>{r.setFieldValue("race",a.target.value)},onBlur:r.handleBlur,children:[e.jsx(j,{value:"آرین",children:"آرین"}),e.jsx(j,{value:"راس",children:"راس"}),e.jsx(j,{value:"آربراکرز (آپلاس)",children:"آربراکرز (آپلاس)"}),e.jsx(j,{value:"کاب",children:"کاب"}),e.jsx(j,{value:"هوبارد",children:"هوبارد"}),e.jsx(j,{value:"ترکیبی",children:"ترکیبی"}),e.jsx(j,{value:"وارداتی",children:"وارداتی"})]}),e.jsx(au,{children:r.touched.race&&r.errors.race?r.errors.race:null})]})]}),e.jsx(s,{children:e.jsx(h,{disabled:!(r.isValid&&n.length&&C),fullWidth:!0,variant:"contained",onClick:()=>{t(k()),t(bu({key:n,quantity:r.values.quantity,date:r.values.hatchingDate,chicken_breed:r.values.race,hall:C})).then(a=>{a.error?a.error.message.includes("403")?l({vertical:"top",horizontal:"center",msg:"قبلا برای این تاریخ یا این سالن جوجه ریزی ثبت شده است.",severity:"error"}):l({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(t(Y()),t(H({right:!1,bottom:!1,content:null})),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})),t(U())})},children:"ثبت اطلاعات"})})]})},Su=Z("AVICULTURE_DELETE_HATCHING",async t=>{const{data:l,status:n}=await Q.delete("poultry_hatching/0/?key="+t);return{data:l,status:n}}),Nu=[{selector:".first-step",content:()=>e.jsx("div",{children:"برای ثبت جوجه ریزی اینجا کلیک کنید!"})},{selector:".second",content:()=>e.jsx("div",{children:"در این قسمت جوجه ریزی های ثبت شده توسط شما نمایش داده می شود."})}],Ru=()=>{const t=G(),[l]=o.useContext(J),{avicultureHatchings:n}=ju(C=>C.avicultureSlice),[b,E]=o.useState(!1),[T,S]=o.useState([]),[N,y]=o.useState([]);o.useEffect(()=>{t(Y())},[]),o.useEffect(()=>{const C=n==null?void 0:n.filter(u=>u.allowHatching==="pending"),f=n==null?void 0:n.filter(u=>u.allowHatching==="True"),r=C==null?void 0:C.map((u,I)=>{var g;const i=(u==null?void 0:u.quantity)||0,A=(u==null?void 0:u.losses)||0,p=(u==null?void 0:u.leftOver)||0,v=i-A-p,x=i>0?d=>(d*100/i).toFixed(0):()=>"0";return[I+1,((g=u==null?void 0:u.poultry)==null?void 0:g.unitName)||"",(u==null?void 0:u.hall)||"",(u==null?void 0:u.period)||"",D(u==null?void 0:u.createDate),D(u==null?void 0:u.date),(u==null?void 0:u.chickenBreed)||"",(u==null?void 0:u.age)||"",i,`${A} (%${x(A)})`,v+` (%${x(v)})`,`${p} (%${x(p)})`,e.jsx(su,{title:"حذف جوجه ریزی",placement:"left-start",children:e.jsx(nu,{"aria-label":"delete",color:"error",onClick:()=>{t(k()),t(Su(u==null?void 0:u.key)).then(d=>{var $;if(t(U()),d!=null&&d.error){const W=(($=d.error)==null?void 0:$.message)||"";W.includes("403")?l({vertical:"top",horizontal:"center",msg:"برای این جوجه ریزی درخواست کشتار ثبت شده است!",severity:"error"}):W.includes("400")?l({vertical:"top",horizontal:"center",msg:"برای این جوجه ریزی بازرسی ثبت شده است!",severity:"error"}):l({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"})}else t(Y()),l({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})},children:e.jsx(gu,{})})},u==null?void 0:u.key)]});S(r);const a=f==null?void 0:f.map((u,I)=>{var g;const i=(u==null?void 0:u.quantity)||0,A=(u==null?void 0:u.losses)||0,p=(u==null?void 0:u.leftOver)||0,v=i-A-p,x=i>0?d=>(d*100/i).toFixed(0):()=>"0";return[I+1,((g=u==null?void 0:u.poultry)==null?void 0:g.unitName)||"",(u==null?void 0:u.hall)||"",(u==null?void 0:u.period)||"",D(u==null?void 0:u.createDate),D(u==null?void 0:u.date),(u==null?void 0:u.chickenBreed)||"",(u==null?void 0:u.age)||"",i,`${A} (%${x(A)})`,v+` (%${x(v)})`,`${p} (%${x(p)})`]});y(a)},[n]);const R=K({initialValues:{noChicken:"",slaughterDate:cu(Date()).format("YYYY-MM-DD hh:mm:ss"),race:"آرین",weight:""},validationSchema:X({noChicken:O().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!"),weight:O().required("این فیلد اجباری است!").typeError("لطفا وزن را وارد کنید!")})});return o.useEffect(()=>{R.validateForm()},[]),e.jsx(s,{container:!0,gap:c.MEDIUM,direction:"column",xs:12,children:e.jsx(s,{container:!0,gap:c.SMALL,justifyContent:{xs:"center",lg:"space-between"},alignSelf:"center",alignItems:"center",xs:12,direction:{xs:"column",lg:"row"},children:e.jsxs(s,{container:!0,xs:12,alignItems:"start",gap:c.SMALL,direction:"column",children:[e.jsxs(s,{width:"100%",container:!0,alignItems:"center",justifyContent:"space-between",children:[e.jsx(s,{children:e.jsx(h,{className:"first-step",variant:"contained",disabled:!0,onClick:()=>{t(H({title:"ثبت اطلاعات جوجه ریزی",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:e.jsx(Tu,{})}))},children:"ثبت جوجه ریزی جدید"})}),e.jsx(s,{})]}),e.jsx(Au,{steps:Nu,isOpen:b,onRequestClose:()=>E(!1),styles:{popover:C=>({...C,borderRadius:"10px","--reactor-accent":"red"})}}),e.jsx(s,{width:"100%",className:"second",children:e.jsx(V,{name:"دوره های فعال جوجه ریزی",data:T,columns:["ردیف","نام فارم","سالن","دوره جوجه ریزی","تاریخ ثبت جوجه ریزی","تاریخ جوجه ریزی","نژاد","سن","تعداد جوجه ریزی","تلفات دوره","کشتار شده","مانده برای کشتار","اقدام"]})}),e.jsx(s,{mt:c.SMALL,width:"100%",className:"second",children:e.jsx(V,{name:"بایگانی جوجه ریزی",data:N,columns:["ردیف","نام فارم","سالن","دوره جوجه ریزی","تاریخ ثبت جوجه ریزی","تاریخ جوجه ریزی","نژاد","سن","تعداد جوجه ریزی","تلفات دوره","کشتار شده","مانده در سالن"]})})]})})})},l6=()=>{const{pathname:t}=uu(),l=G();return o.useEffect(()=>{l(iu())},[]),e.jsx(ou,{display:"flex",justifyContent:"center",children:e.jsxs(s,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:[e.jsx(s,{justifyContent:"center",my:c.MEDIUM,children:e.jsx(lu,{children:e.jsx(Du,{})})}),e.jsx(s,{container:!0,justifyContent:"space-between",gap:c.SMALL,children:e.jsxs(s,{xs:12,children:[t===du&&e.jsx(hu,{}),t===B&&e.jsx(Ru,{}),t===M&&e.jsx(pu,{}),t===w&&e.jsx(xu,{}),t===L&&e.jsx(Fu,{}),t===m&&e.jsx(fu,{}),t===q&&e.jsx(vu,{})]})})]})})};export{l6 as default};
|