Files
Rasadyar_FrontEnd/build/assets/CityHatchingsArchiveOperations-C_2NZ-bu.js

2 lines
9.4 KiB
JavaScript
Raw Normal View History

2026-01-19 15:55:00 +03:30
import{j as u,ak as z,B as R,ai as E,b5 as L,T as V,i as P,ag as U,ah as Y,aj as N,I as Q,b0 as X,an as K,b4 as J,ap as Z,aq as uu}from"./mui-vendor-CkIVaoQP.js";import{r as d}from"./react-vendor-CmFgShSM.js";import{L as _,j as F,h,A as S,u as D,c as H,X as G,N as eu,fA as ru,M as T,cs as tu,G as A,C as W,r as ou,fj as au,O as w}from"./index-Vwb3Bce5.js";import{a as k,u as I,f as su}from"./redux-vendor-B7uoacJt.js";import{d as nu}from"./Tune-DzkdDfJZ.js";import{a as lu}from"./index.esm-Bu7XMDZU.js";import{F as iu}from"./FileUploader-C5K2edqw.js";import{d as cu}from"./Add-C-nZhvlM.js";import{d as du}from"./Sms-DJEGTBb8.js";const $=k("ARCHIVE_HATCHING_SERVICE",async(e,{dispatch:t})=>{t(_());try{const{data:o,status:s}=await F.put("poultry_hatching/0/",e);return t(h()),{data:o,status:s}}catch(o){return t(h()),{error:o.response.data.result}}}),Cu=H({name:T()}),Iu=({item:e,selectedAge1:t,selectedAge2:o,updateTable:s})=>{const[r]=d.useContext(S),c=I(),n=D({initialValues:{name:""},validationSchema:Cu,onSubmit:m=>{c($({key:e.key,archive_state:"",message:m.name,role:G()})).then(p=>{p.payload.error?r({vertical:"top",horizontal:"center",msg:p.payload.error,severity:"error"}):(c(eu({right:!1,bottom:!1,content:null})),t&&c(ru({selectedAge1:t,selectedAge2:o})),s(),r({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})}});return u.jsxs("form",{onSubmit:n.handleSubmit,children:[u.jsx(z,{id:"name",name:"name",label:"توضیحات",variant:"outlined",multiline:!0,rows:4,fullWidth:!0,margin:"normal",value:n.values.name,onChange:n.handleChange,onBlur:n.handleBlur,helperText:n.touched.name&&n.errors.name,error:n.touched.name&&!!n.errors.name}),u.jsx(R,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,children:"ثبت"})]})},hu=k("HATCHING_UNDO_ARCHIVE_SERVICE",async(e,{dispatch:t})=>{try{t(_());const{data:o,status:s}=await F.put("poultry_hatching/0/",e);return t(h()),{data:o,status:s}}catch(o){return t(h()),{error:o.response.data.result}}}),pu=({item:e,updateTable:t,isArchive:o})=>{const[s,r]=d.useState(e==null?void 0:e.violation),[c,n]=d.useState(!1),m=I(),p=i=>{r(i.target.checked)},x=i=>{n(i.target.checked)},[y]=d.useContext(S),[b,C]=d.useState([]),B=i=>{C(i)},l=D({initialValues:{reportText:e==null?void 0:e.violationReport,bar_image:""},validationSchema:H({reportText:T().required("این فیلد اجباری است!").typeError("لطفا گزارش خود را بیان کنید."),bar_image:tu()})});return d.useEffect(()=>{l.validateForm()},[]),u.jsxs(A,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(E,{control:u.jsx(L,{checked:s,onChange:p,color:"primary"}),label:s?"متخلف":"بدون تخلف",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),!o&&u.jsx(E,{control:u.jsx(L,{checked:c,onChange:x,color:"primary"}),label:"انتقال به بایگانی",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),u.jsx(z,{multiline:!0,rows:4,fullWidth:!0,id:"reportText",label:"متن گزارش",variant:"outlined",value:l.values.reportText,error:l.touched.reportText?!!l.errors.reportText:null,onChange:l.handleChange,onBlur:l.handleBlur,helperText:l.touched.reportText&&l.errors.reportText?l.errors.reportText:null}),u.jsx(V,{color:"error",children:"در صورت آپلود فایل جدید، سندهای پیشین حذف میشوند!"}),u.jsx(iu,{onChange:B}),u.jsx(R,{mt:2,disabled:!l.isValid||l.isSubmitting,fullWidth:!0,variant:"contained",onClick:async()=>{try{const i={key:e==null?void 0:e.key,violation_check:!0,violation:s,violation_report:l.values.reportText,archive:c},v=new FormData;Object.entries(i).forEach(([f,g])=>{v.append(f,g)}),b.forEach((f,g)=>{v.append(`violation_image_${g}`,f)});const j=await m($(b.length?v:i));if(j.error)throw new Error(j.error);t(1),m(W()),y({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})}catch(i){y({vertical:"top",horizontal:"center",msg:i.message||"خطا در ارسال اطلاعات",severity:"erro