2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{j as e,b as L,aL as _,aM as O,T as V,aN as G,ak as o,ag as R,av as Y,aw as P,ax as d,aU as $,am as U,B as f}from"./mui-vendor-CkIVaoQP.js";import{j as W,A as H,u as y,c as D,b as t,M as i,Q as q,G as r,S as m,k as Q,W as T,v as E,L as J,h as K}from"./index-N50kY0pn.js";import{r as C}from"./react-vendor-CmFgShSM.js";import{a as X,u as Z}from"./redux-vendor-B7uoacJt.js";import{d as uu}from"./Add-CXfAQ_ni.js";import{b as eu}from"./index-Cyn2oTqg.js";import{d as ru}from"./Search-DJS_LN_I.js";import{A as au}from"./AdvancedTable-DMW4hUQ0.js";import"./Close-Cnq7tLoz.js";import"./Delete-CiVJBR3T.js";const lu=X("INSPECTOR_GET_REPORTING",async h=>{const{data:p,status:F}=await W.get("reporting-all-poultry/?type=filter&value="+h);return{data:p,status:F}}),pu=()=>{const[h,p]=C.useState(),[F,N]=C.useState(),x=Z(),[I]=C.useContext(H),u=y({initialValues:{mobile:"",fname:"",lname:"",nationalCode:"",nationalId:"",address:"",unitName:"",gisCode:"",operationNumber:"",halls:"",economicCode:"",systemCode:"",epidemiologicalCode:"",capacity:"",licenseNumber:"",healthCode:"",orderCode:"",race:""},validationSchema:D({mobile:t().typeError("لطفا عدد وارد کنید!"),fname:i().typeError("فیلد را به درستی وارد کنید!"),lname:i().typeError("فیلد را به درستی وارد کنید!"),nationalCode:t().typeError("لطفا عدد وارد کنید!"),nationalId:t().typeError("لطفا عدد وارد کنید!"),address:i().typeError("فیلد را به درستی وارد کنید!"),unitName:i().typeError("فیلد را به درستی وارد کنید!"),race:i().typeError("فیلد را به درستی وارد کنید!"),gisCode:t().typeError("لطفا عدد وارد کنید!"),operationNumber:t().typeError("لطفا عدد وارد کنید!"),halls:t().typeError("لطفا عدد وارد کنید!"),economicCode:t().typeError("لطفا عدد وارد کنید!"),systemCode:t().typeError("لطفا عدد وارد کنید!"),epidemiologicalCode:t().typeError("لطفا عدد وارد کنید!"),capacity:t().typeError("لطفا عدد وارد کنید!"),licenseNumber:t().typeError("لطفا عدد وارد کنید!"),healthCode:t().typeError("لطفا عدد وارد کنید!"),orderCode:t().typeError("لطفا عدد وارد کنید!")})}),l=y({initialValues:{hatchingDateFrom:"",hatchingDateTo:""},validationSchema:D({hatchingDateFrom:i().typeError("فیلد را به درستی وارد کنید!"),hatchingDateTo:i().typeError("فیلد را به درستی وارد کنید!")})});C.useEffect(()=>{u.validateForm(),l.validateForm()},[]);const z=()=>u.isValid&&l.isValid?Object.values(u.values).filter(n=>n.length>0).length===0&&Object.values(l.values).filter(n=>n.length>0).length!==2:!0,[g,w]=C.useState(!0),S=()=>{w(!g)},M=()=>{let n=Object.values(u.values).filter(s=>s.length>0),a="";for(let s=0;s<n.length;s++)a=a+n[s]+",";a=a.substring(0,a.length-1),l.values.hatchingDateFrom&&(a=a+"&double_hatching_date="+l.values.hatchingDateFrom+","+l.values.hatchingDateTo),u.values&&x(J()),x(lu(a)).then(s=>{x(K()),s.error?I({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):p(s==null?void 0:s.payload.data)})};C.useEffect(()=>{if(h){const n=h.map((a,s)=>{var A,v,j,B,b;return[s+1,a.unitName,(A=a.userprofile)==null?void 0:A.fullName,a.breedingUniqueId,a.numberOfHalls,a.totalCapacity,(v=a.userprofile)==null?void 0:v.mobile,(j=a.userprofile)==null?void 0:j.province,(B=a.userprofile)==null?void 0:B.city,(b=a.hatching)==null?void 0:b.length,a.numberOfParty,q(new Date(a==null?void 0:a.lastPartyDate),"yyyy/MM/dd"),a.gisCode,a.economicCode,a.samasatUserCode,a.unitStatus]});N(n)}},[h]);const[c,k]=C.useState(!1);return e.jsx(e.Fragment,{children:e.jsx(L,{display:"flex",justifyContent:"center",children:e.jsxs(r,{container:!0,direction:"column",xs:12,sm:12,md:10,lg:10,mt:m.MEDIUM,children:[e.jsxs(_,{xs:12,expanded:g,onChange:S,children:[e.jsx(O,{expandIcon:e.jsx(Q,{}),"aria-controls":"panel1a-content",id:"panel1a-header",children:e.jsx(V,{children:"جستجو"})}),e.jsx(G,{children:e.jsxs(r,{container:!0,justifyContent:"center",gap:m.SMALL,children:[e.jsxs(r,{justifyContent:"start",container:!0,gap:m.SMALL,children:[e.jsx(r,{children:e.jsx(o,{size:"small",id:"mobile",label:"موبایل",value:u.values.mobile,error:u.touched.mobile?!!u.errors.mobile:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.mobile&&u.errors.mobile?u.errors.mobile:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"fname",label:"نام",value:u.values.fname,error:u.touched.fname?!!u.errors.fname:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.fname&&u.errors.fname?u.errors.fname:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"lname",label:"نام خانوادگی",value:u.values.lname,error:u.touched.lname?!!u.errors.lname:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.lname&&u.errors.lname?u.errors.lname:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"nationalCode",label:"کد ملی",value:u.values.nationalCode,error:u.touched.nationalCode?!!u.errors.nationalCode:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.nationalCode&&u.errors.nationalCode?u.errors.nationalCode:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"nationalId",label:"شماره شناسنامه",value:u.values.nationalId,error:u.touched.nationalId?!!u.errors.nationalId:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.nationalId&&u.errors.nationalId?u.errors.nationalId:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"address",label:"آدرس",value:u.values.address,error:u.touched.address?!!u.errors.address:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.address&&u.errors.address?u.errors.address:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"unitName",label:"نام واحد",value:u.values.unitName,error:u.touched.unitName?!!u.errors.unitName:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.unitName&&u.errors.unitName?u.errors.unitName:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{minWidth:230,children:e.jsxs(R,{size:"small",children:[e.jsx(Y,{id:"demo-simple-select-label",children:"نژاد مرغ"}),e.jsxs(P,{labelId:"demo-simple-select-label",id:"race",label:"نژاد مرغ",value:u.values.race,error:u.touched.race?!!u.errors.race:null,onChange:n=>{u.setFieldValue("race",n.target.value)},onBlur:u.handleBlur,children:[e.jsx(d,{value:"",children:"همه"}),e.jsx(d,{value:"آرین",children:"آرین"}),e.jsx(d,{value:"راس",children:"راس"}),e.jsx(d,{value:"آربراکرز (آپلاس)",children:"آربراکرز (آپلاس)"}),e.jsx(d,{value:"کاب",children:"کاب"}),e.jsx(d,{value:"هوبارد",children:"هوبارد"}),e.jsx(d,{value:"ترکیبی",children:"ترکیبی"}),e.jsx(d,{value:"وارداتی",children:"وارداتی"})]}),e.jsx($,{children:u.touched.race&&u.errors.race?u.errors.race:null})]})}),c&&e.jsxs(e.Fragment,{children:[e.jsx(r,{children:e.jsx(o,{size:"small",id:"gisCode",label:"کد gis",value:u.values.gisCode,error:u.touched.gisCode?!!u.errors.gisCode:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.gisCode&&u.errors.gisCode?u.errors.gisCode:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"operationNumber",label:"شماره گواهی عملیاتی",value:u.values.operationNumber,error:u.touched.operationNumber?!!u.errors.operationNumber:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.operationNumber&&u.errors.operationNumber?u.errors.operationNumber:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"halls",label:"تعداد سالن",value:u.values.halls,error:u.touched.halls?!!u.errors.halls:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.halls&&u.errors.halls?u.errors.halls:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"economicCode",label:"کد اکونومی",value:u.values.economicCode,error:u.touched.economicCode?!!u.errors.economicCode:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.economicCode&&u.errors.economicCode?u.errors.economicCode:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"systemCode",label:"کد سیستمی",value:u.values.systemCode,error:u.touched.systemCode?!!u.errors.systemCode:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.systemCode&&u.errors.systemCode?u.errors.systemCode:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"epidemiologicalCode",label:"کد اپیدمیولوژیک",value:u.values.epidemiologicalCode,error:u.touched.epidemiologicalCode?!!u.errors.epidemiologicalCode:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.epidemiologicalCode&&u.errors.epidemiologicalCode?u.errors.epidemiologicalCode:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"capacity",label:"ظرفیت کل",value:u.values.capacity,error:u.touched.capacity?!!u.errors.capacity:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.capacity&&u.errors.capacity?u.errors.capacity:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"licenseNumber",label:"شماره مجوز",value:u.values.licenseNumber,error:u.touched.licenseNumber?!!u.errors.licenseNumber:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.licenseNumber&&u.errors.licenseNumber?u.errors.licenseNumber:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"healthCode",label:"کد بهداشتی",value:u.values.healthCode,error:u.touched.healthCode?!!u.errors.healthCode:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.healthCode&&u.errors.healthCode?u.errors.healthCode:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{children:e.jsx(o,{size:"small",id:"orderCode",label:"کد سفارش",value:u.values.orderCode,error:u.touched.orderCode?!!u.errors.orderCode:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.orderCode&&u.errors.orderCode?u.errors.orderCode:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(r,{maxWidth:230,children:e.jsx(T,{label:"جوجه ریزی از",id:"hatchingDateFrom",renderInput:n=>e.jsx(o,{size:"small",...n,error:!1}),value:l.values.hatchingDateFrom,error:l.touched.hatchingDateFrom?!!l.errors.hatchingDateFrom:null,onChange:n=>{l.setFieldValue("hatchingDateFrom",E(n).format("YYYY-MM-DD"))},onBlur:l.handleBlur,helperText:l.touched.hatchingDateFrom&&l.errors.hatchingDateFrom?l.errors.hatchingDateFrom:null})}),e.jsx(r,{maxWidth:230,children:e.jsx(T,{label:"تا",id:"hatchingDateTo",renderInput:n=>e.jsx(o,{size:"small",...n,error:!1}),value:l.values.hatchingDateTo,error:l.touched.hatchingDateTo?!!l.errors.hatchingDateTo:null,onChange:n=>{l.setFieldValue("hatchingDateTo",E(n).format("YYYY-MM-DD"))},onBlur:l.handleBlur,helperText:l.touched.hatchingDateTo&&l.errors.hatchingDateTo?l.errors.hatchingDateTo:null})})]})]}),e.jsx(U,{sx:{width:"100%"}}),e.jsx(r,{children:e.jsx(f,{size:"small",endIcon:e.jsx(ru,{}),variant:"contained",disabled:z(),onClick:M,children:"جستجو"})}),e.jsx(r,{children:e.jsx(f,{variant:"contained",endIcon:c?e.jsx(eu,{}):e.jsx(uu,{}),onClick:()=>{k(!c)},size:"small",children:c?e.jsx(e.Fragment,{children:"کاهش فیلتر"}):e.jsx(e.Fragment,{children:"افزودن فیلتر"})})})]})})]}),e.jsx(r,{container:!0,justifyContent:"space-between",gap:m.SMALL,children:e.jsx(r,{xs:12,children:e.jsx(au,{name:"گزارشات",columns:["ردیف","نام واحد","نام مرغدار","شناسه یکتا","تعداد سالن","ظرفیت","موبایل","استان","شهرستان","تعداد جوجه ریزی","تعداد پارتی","تاریخ آخرین پارتی","کد gis","کد اکونومی","کد سماصط","وضعیت واحد"],data:F})})})]})})})};export{pu as default};
|